Quote Originally Posted by Scampy View Post
My current project is not performing very well. It relies on matching the values in two variables to the converted BDC format from a battery backed up 1307 RTC. My idea is to use a variable to store the current time in minutes from midnight, so in theory it should have a value between 0 and 1439. The idea then is to convert the time the LEDs come on into a numerical value and the use the "if then " statement to determine if the LEDs should be on in the event of a power cut. For example if the on time was from 14:00 to 18:00 hrs then the values would be => then 840 but =< 1080, so if there was a power cut and power was resumed at say 15:00 hrs then as the time would be converted to 900 and the logic would then check the value against the programmed value and thus turn the LEDs on. This is my proposed code (with some of the RTC variables not included for simplicity)

Would welcome comments
I thought to take another look benefited by the large screen, as I did not understand well your explanation of what was to happen here. Perhaps I still do not... curiosity begs to ask: What is the purpose of this?

Typically I refrain from asking, but in this case I try only to understand for my own satisfaction whether I am slow to comprehend the text... or the purpose. If the clock is battery-backed, the time will be always correct then yes? Should it not then be correct to calculate the LED's status from the current time always? Why then to store the minutes from midnight (rather than calculate)? And, if the clock is not correct, then how can the minutes from midnight be the right number and the LED's status correctly resolved?

Also, if the "start" of the counter is always midnight, could you not avoid any calculation at all by maintaining a count as the minutes pass similar to:

If OldMinute <> NewMinute then
MinituesSinceMidnight = MinutesSinceMidnight +1
OldMinute = NewMinute
Endif

starting at midnight?