Devo12: enabling builtin real time clock

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
04 Mar 2013 20:25 - 14 Mar 2013 15:41 #7354 by rbe2012
Someone here in the forum had the idea of showing the actual time on the screen (sorry whoever it was, can't call back which thread). Looking at the datasheets brought me to the idea to make use of the RTC which is integrated in the MCU.
Looking at the boards I have seen that the Devo12 has a complete functional clock (battery backed up) while the Devo8 lacks some components (crystal and battery). I decided to give it a try and here it is.
The parts for my Devo8 are ordered so I will later post a checklist to make it complete. But the RTC can be used also with the internal crystal and works as long as the tx is powered on.
I implemented a page for setting time and date. The RTC can be shown (only the time) in one of the boxes simply by selecting RTC as a timer type.
On the USB page I have added two boxes for time and date.
Internally the value is stored in the format "deviation epoch" (seconds since 01.01.2012, 0:00) and is saved in the tx.ini file to check if the clock was reset when the tx was powered off or stayed running.

I have no Devo12 to check if it works correctly. So I am looking for someone who is willing to test my work. You can get it at bitbucket ( deviation-rbe-rtc) ). I synched it regularly with PBs repo so it should contain the actual developement state including the additional work Hexperience and I have done for using the bigger screen.







Attachments:
Last edit: 14 Mar 2013 15:41 by FDR.

Please Log in or Create an account to join the conversation.

More
04 Mar 2013 20:56 - 04 Mar 2013 21:47 #7355 by Hexperience
Replied by Hexperience on topic Devo8/12: enabling builtin real time clock
It works in the emu_devo12 I built, but not in the radio. I may have done something incorrectly...

Do you think I might need to do a make devo8 first? I've seen that fix filesystem problems...

---edit---
Turned on: #define ADDON_HAS_RTC 1
Now it's showing the pages...

I'll test the clock now...

---edit---
Wow... other than the year being 2025.. my clock was already set! It was about 1 minute off real time, and I don't ever recall setting it when I had the walkera software on there.

I set the correct year, and turned it off.. letting it sit for a few minutes...

---edit---

Powers up and the clock is correct...


There are 10 types of people in this world. Those that understand binary and those that don't.
Attachments:
Last edit: 04 Mar 2013 21:47 by Hexperience.

Please Log in or Create an account to join the conversation.

More
04 Mar 2013 22:06 #7359 by Hexperience
Replied by Hexperience on topic Devo8/12: enabling builtin real time clock
Do you think it will be too small if we put the time in the top bar?

There are 10 types of people in this world. Those that understand binary and those that don't.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
05 Mar 2013 06:17 - 05 Mar 2013 06:18 #7372 by rbe2012
Replied by rbe2012 on topic Devo8/12: enabling builtin real time clock
Thanks for testing, Hexperience.
I will look why it did not compile. I built all with "make release", devo8 comes first so I did not mention this.
The #define is added to my repo now.
I put it in the boxes as a timer because it was "easy" to do and the user has a way to show it or not and even to stop running (the screen update). On the Devo12 screen there is enough space in the top line to put the time there, but not in Devo8.
Last edit: 05 Mar 2013 06:18 by rbe2012.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
05 Mar 2013 08:00 - 05 Mar 2013 09:00 #7378 by rbe2012
Replied by rbe2012 on topic Devo8/12: enabling builtin real time clock

Hexperience wrote: other than the year being 2025.. my clock was already set! It was about 1 minute off real time, and I don't ever recall setting it when I had the walkera software on there.[/attachment]


This is obviously because Walkera uses 2000 as base while I decided to use 2012. The RTC is a counter who does only know the relative time, not absolute.
Last edit: 05 Mar 2013 09:00 by rbe2012.

Please Log in or Create an account to join the conversation.

More
13 Mar 2013 21:26 #7712 by RCadik
Replied by RCadik on topic Devo8/12: enabling builtin real time clock
Set the year. Turn off 12S and back on and the year changes to 2026.
All other values are correct.

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 01:07 - 14 Mar 2013 01:10 #7727 by clearprop88
Replied by clearprop88 on topic Devo8/12: enabling builtin real time clock
I like this feature very much since I don't wear a watch.
Will it be incorporated into the next V3.0 release for my Devo 8?

Will it be possible to re-order the date to MON/DAY/YEAR, and 12 hr format?
I don't think am, and pm would be necessary.

Thanks for the effort on this.
Last edit: 14 Mar 2013 01:10 by clearprop88. Reason: add

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 04:42 #7732 by Hexperience
Replied by Hexperience on topic Devo8/12: enabling builtin real time clock
The 8s has no crystal or battery backup. So without adding those the 12 is the only one working at the moment.

None of this will be in 3.0. 3.0 will introduce the 12s for the first time in an official release. Up to now, the 12s has only been in the nightly builds.

There are 10 types of people in this world. Those that understand binary and those that don't.

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 05:09 #7733 by clearprop88
Replied by clearprop88 on topic Devo8/12: enabling builtin real time clock
I guess I misread the statement about the internal crystal that could be used for the RTC, but I see now that it only works while the TX is powered on.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
14 Mar 2013 06:24 #7736 by rbe2012
Replied by rbe2012 on topic Devo8/12: enabling builtin real time clock
As Hexperience stated only the Devo12 has the battery and crystal built in. When the time was set with the original firmware, it is counted up in the background independently of the firmware. Because Walkera and I have chosen different start values (2000 / 2012) the year must be set once correctly and it will run. Maybe I change the base to 2000 to get rid of this.

For my Devo8 I built in a battery and I can see that the value is stored when the tx is off. I also soldered a crystal and capacitors at the corresponding pins but I did not get it running until now (every time I choose LSE as clock source the MCU waits endlessly for the clock to be stable - the watchdog resets the tx after short time). So I'll work on but for now I must admit it does not work...
When the tx.ini is saved when powering off (e.g. when you changed some setting) the actual clock value is stored inside and read after waking up. So it looks like the clock does not count but preserves the value but in reality the value is lost and set after powering up.

I thought about 12/24 hour format but did not implement this because (1) I would also have to code a way to choose between 12 and 24 and (2) I used the existing code for showing the time which is originally for a counter which counts until 99:59:59. But it will not be too much work so I could do this.
I also thought about different date formats. The easiest way to achieve this would be a string like "M/D/Y" which would be translated in the different languages like "D.M.Y" for German. But this needs some more effort. The other way would be to make it configurable somehow (with gui or with editing the tx.ini).

Nothing of this gets into 3.0. I can provide a build based on 3.0 when it's official released where the rtc is integrated.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
14 Mar 2013 15:23 - 14 Mar 2013 15:24 #7753 by rbe2012
Replied by rbe2012 on topic Devo12: enabling builtin real time clock
[changed the headline; deleted Devo8 for not misleading]

EDIT: seems to be shown only here, not in the "Recent Topics" page...
Last edit: 14 Mar 2013 15:24 by rbe2012.

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 15:36 - 14 Mar 2013 15:42 #7754 by FDR
You have to change the subject of the first post for that...

EDIT: done...
Last edit: 14 Mar 2013 15:42 by FDR.

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 16:01 #7755 by RCadik
Replied by RCadik on topic Devo8/12: enabling builtin real time clock
I loaded a new model on my 12S to set up a DSMX 3D ship for range testing etc..
During the process of configuring, I changed the Date amongst many things. Today turned on the radio & the date was correct. Going back to my previous model, the Date is now correct there also.
Should I look at a ini. file for the cause of this saved change?

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
14 Mar 2013 16:59 #7756 by rbe2012
Replied by rbe2012 on topic Devo12: enabling builtin real time clock
FDR: thank you.

RCadik: The value is read always when the tx.ini is read, but it is only applied when it is greater than the value read from the clock. So if the clock is running while the tx is shut down the value must be higher (at least until 2079) than the last saved value and will be kept.
The question is: why was it set to 2026 as you mentioned in your first post? I assume you did not set the date after installing my / Hexperiences build before shutting down the first time. Then the value from the clock (seconds since 1/1/2000 as Walkera has defined it, about 423036000) will be saved in the tx.ini. When you set the date later to the correct value (will be about 36806400 and therefor less than Walkera's value because my base is 1/1/2012) and this value is not written to the tx.ini (this does not happen every time when the tx is shut down, only if something in the config has changed!! A mistake, I know, but was simply for a tx whose clock stops when shutting off so I have a better start point...), after the next start the value is set to Walkera's and this will be interpreted as 3/13/2013+(2012-2000) and should result in a date in 2025.
So I have no clue why it should have been 2026.
I will take the saving out of the code (makes no sense yet) and provide a new build (in the build section) later / at the weekend.

Please Log in or Create an account to join the conversation.

More
14 Mar 2013 20:15 #7759 by RCadik
Replied by RCadik on topic Devo12: enabling builtin real time clock
rbe2012: Thanks for your explanation & your contribution to the widescreen of Deviation firmware.
Part of the problem might be that I did not do a format of the drive before installing the file system. I will go through the procedure properly and see if I get the same or similar results.

Please Log in or Create an account to join the conversation.

More
17 Mar 2013 05:14 #7844 by RCadik
Replied by RCadik on topic Devo12: enabling builtin real time clock
Re-installed and everything is working as described after making changes to the config file as stated.
A nice addition to the Widescreen 12S display.
Thanks for your abilities and contributions to Deviation.

Please Log in or Create an account to join the conversation.

Time to create page: 0.159 seconds
Powered by Kunena Forum