RTC Battery Back-Up

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

Post Reply
gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

RTC Battery Back-Up

Post by gavo4 »

Hi Leigh,

Just a quick question with regards to the RTC Battery Back-up.

I have inserted a 2032 Lithium battery in the Miac and I assume we can't keep calling a RTC Set-up Macro as it will keep defaulting the RTC Clock to the time we have set in the Macro. How can we call the RTC set-up once and not again so we don't overwrite the time each time the MIAC Switches off?

Regards,

Gavin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: RTC Battery Back-Up

Post by LeighM »

Hi Gavin,
The RTC setting is usually done via a setup menu selected via the keypad.
Leigh

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Thanks Leigh!,

I have written the Time part of the RTC keypad working nicely, just the date side and I will run some tests..;-)

Regards,

Gavin

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Thanks Leigh!,

Working nicely now - thanks again for the help!

Regards,

Gavin

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Hi Leigh,

I have the time working nicely, the date is an issue, I can't seem to get the last digit for the Year on my routine, somehow I have tried it a Million ways and still nothing. Any help would be greatly appreciated.

The routine is not very polished just playing about but somehow If I enter 10/01/19 in the key pad I can only get 10/01/1

Many Thanks...;-)

Regards,

Gavin
Attachments
RTC_2.fcfx
(100.95 KiB) Downloaded 259 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: RTC Battery Back-Up

Post by LeighM »

Hi Gavin,
You are getting on well :D
The simulation debugger is very useful for helping with these kind of problems.
If you set a breakpoint in your GET_DATE, run the simulation, when it stops on the breakpoint add DATE to the variable watch.
You can then edit the value of DATE to help see what is happening ...
breakpoint.jpg
breakpoint.jpg (80.96 KiB) Viewed 8661 times
Then Step to the next icon and see how the DATE changes ...
step.jpg
step.jpg (48.85 KiB) Viewed 8661 times
So this is the fix ...
correction.jpg
correction.jpg (17.04 KiB) Viewed 8661 times
Hope that helps
Leigh

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Thanks Leigh,

The Simulation really, really helps!,

I still can't seem to see the 2?

I used the calculation in Date Set as:

DATE[5] = '5'
DATE[4] = '4'
DATE[3] = '3'
DATE[2] = '2'
DATE[1] = '1'
DATE[0] = '0'

I used the Calculation as

DATE[8] = 0
DATE[7] = DATE[5]
DATE[6] = DATE[4]
DATE[5] = '/'
DATE[4] = DATE[3]
DATE[3] = DATE[2]
DATE[2] = '/'
DATE[1] = DATE[1]
DATE[0] = DATE[0]


And attached is what I get
Clipboard03.jpg
Clipboard03.jpg (108.58 KiB) Viewed 8654 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: RTC Battery Back-Up

Post by LeighM »

The RTC:SetDate string should only be 6 characters and without the '/'

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Hi Leigh,

I did do that?, perhaps I have miss-understood you?
Clipboard05.jpg
Clipboard05.jpg (108.62 KiB) Viewed 8650 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: RTC Battery Back-Up

Post by LeighM »

Could you try it on the hardware now?
It could be that the RTC component does not simulate.
If hardware does not work, could you post your latest project file?

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

on the Display I get when I run the code:

01/03/45

Regards,
'
Gavin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: RTC Battery Back-Up

Post by LeighM »

Ah, I think that might just be the RTC component doing some checking,
i.e. there is no month 23 :wink:

gavo4
Posts: 92
Joined: Sat Aug 25, 2018 7:58 pm
Been thanked: 8 times
Contact:

Re: RTC Battery Back-Up

Post by gavo4 »

Oops how embarrassing as I should've seen that...

thanks Leigh - all working!

Post Reply