[info] real time clock

Hardware inside and outside of the ECU
Post Reply
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

real time clock

Post by AndreyB »

We need a real time clock module. The module should be cheap :) But it should also survive short-term power disconnects.

We will probably start by one of the existing modules, but eventually we would need our KiCad files :)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
acab
provoker
provoker
Posts: 263
Joined: Wed Dec 18, 2013 7:27 pm
Location: Minsk, BY

Re: real time clock

Post by acab »

You sure that RTC not build in STM32F407? You need it for logging to SDCard?

Or you need it with external power source? On sparkfun.com you can buy RTC module with DS1307 chip.

Image

Schematic
Eagle Files
GIT
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

STM32F407 (the chip) does not have build-in RTC - it requires external oscillator. STM32F4discovery does not have the RTC oscillator soldered on it, there is a manual how to add it - but the other problem is power consumption, and that's too much programming for my small brain.

I like everything about this BOB-00099 but I do not like the price, why is it so damn expensive? I will order one of the DS1307 modules from eBay. Does anyone know why it looks like two chips on these DS1307 eBay modules?

Anyway I think we will still need KiCad files so that we can put all this on our own module?

I guess just soldering these module to our board is also an option, but there is the risk that they will stop making them. Maybe we need to draw a KiCad schematics of a HOLE in our PCB to which we will solder one of these Chinese modules?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

I have ordered two of the eBay modules.

Artem, is there any chance you can order the same DS1307 module from China and write all the needed code?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
acab
provoker
provoker
Posts: 263
Joined: Wed Dec 18, 2013 7:27 pm
Location: Minsk, BY

Re: real time clock

Post by acab »

russian wrote:I have ordered two of the eBay modules.

Artem, is there any chance you can order the same DS1307 module from China and write all the needed code?
I havent money yet ;(
And i say about problem of payment from Belarus via Visa\PayPal. Our cards didnt trusted ;(

I can try make code for that. I think its not hard...

UPDATE: you sure that your board didnt have oscillator for RTC? My board have it...
User avatar
rus084
contributor
contributor
Posts: 678
Joined: Sun Dec 01, 2013 1:40 pm
Location: Russia , Stavropol

Re: real time clock

Post by rus084 »

why RTC can't have in programm of stm32f4?
quartz oscillator in microcontroller have little error in frenqarity . else how profit from RTOS?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

rus084 wrote:why RTC can't have in programm of stm32f4?
quartz oscillator in microcontroller have little error in frenqarity . else how profit from RTOS?
First of all, there is no oscillator inside the chip itself. Secondly, I have no idea why - but for RTC you need a separate oscillator. Also you are forgetting ABOUT POWER CONSUMPTION.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
acab
provoker
provoker
Posts: 263
Joined: Wed Dec 18, 2013 7:27 pm
Location: Minsk, BY

Re: real time clock

Post by acab »

How to add RTC support for Discovery:
Without parts at X3, C16, C27, and removing SB15 and SB16, the LSE is not going to tick or come ready
Image
Image

Better idea to use integrated RTC in STM32F4, becouse there are complete librarys and all stuff for work with RTC.

About consumption, read please datasheet paragraf 2.2.20 VBAT operation.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

Code: Select all

2.2.20 VBAT operation
The VBAT pin allows to power the device VBAT domain from an external battery, an external
supercapacitor, or from VDD when no external battery and an external supercapacitor are
present.
VBAT operation is activated when VDD is not present.
The VBAT pin supplies the RTC, the backup registers and the backup SRAM.
Note: When the microcontroller is supplied from VBAT, external interrupts and RTC alarm/events
do not exit it from VBAT operation.
When PDR_ON pin is not connected to VDD (internal reset OFF), the VBAT functionality is no
more available and VBAT pin should be connected to VDD.
It looks like we do not need external RTC chip. What we need would be to 'upgrade' discovery to RTC configuration and figure out power supply. So, we still need a KiCad module for with proper battery or battery housing, but things are look up :)
Thank you Artem! Why did not you explain this before I have wasted $4 on these RTC modules? :)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
acab
provoker
provoker
Posts: 263
Joined: Wed Dec 18, 2013 7:27 pm
Location: Minsk, BY

Re: real time clock

Post by acab »

russian wrote:

Code: Select all

2.2.20 VBAT operation
The VBAT pin allows to power the device VBAT domain from an external battery, an external
supercapacitor, or from VDD when no external battery and an external supercapacitor are
present.
VBAT operation is activated when VDD is not present.
The VBAT pin supplies the RTC, the backup registers and the backup SRAM.
Note: When the microcontroller is supplied from VBAT, external interrupts and RTC alarm/events
do not exit it from VBAT operation.
When PDR_ON pin is not connected to VDD (internal reset OFF), the VBAT functionality is no
more available and VBAT pin should be connected to VDD.
It looks like we do not need external RTC chip. What we need would be to 'upgrade' discovery to RTC configuration and figure out power supply. So, we still need a KiCad module for with proper battery or battery housing, but things are look up :)
Thank you Artem! Why did not you explain this before I have wasted $4 on these RTC modules? :)
You wasted 4$ becouse you hate me)))
Its revenge)!
jedediah_frey
contributor
contributor
Posts: 51
Joined: Tue Nov 05, 2013 1:43 pm

Re: real time clock

Post by jedediah_frey »

russian wrote: I have no idea why - but for RTC you need a separate oscillator. Also you are forgetting ABOUT POWER CONSUMPTION.
I did the math on power consumption here: http://rusefi.com/forum/viewtopic.php?f=4&t=236&hilit=+RTC A C2032 battery should power the RTC for 12 years a 60 AH car battery for 3422 years.

While it may not work on the STM32F4 Discovery board when you get your own board designed the ideal solution is to use the RTC on the 407VG. (And f or your own board I think you may as well look at th 427/437 since it has double the flash. and it's the latest and fastest. (Another 12 MHz over the 407).
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

Until yesterday I did not realize that stm32 has the VBAT pin with a special RTC mode. I was wrongly assuming that the whole unit would need to stay up.

180MHz is a different story altogether :) We will do this eventually but right now it's not worth the time to figure our the differences.

So, we are going with the 407 rtc. We now need a KiCad module for the battery as an add-on to the stm32f4discovery and we need someone with the hardware to implement the needed code.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: real time clock

Post by AndreyB »

Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply