Following on from my previous threads, the current code for my aquarium controller has been running without issue for the past three days, and has been keeping time very well considering it uses a timer overflow rather than a dedicated time chip like the DS1307 (which the previous version used and kept issuing 10:10:10:10 as the time etc). My new code uses a variable to store a value based on minutes since midnight, and then logic statements are used to determine the phase of the lights (ramp up, on ramp down). This works really well, but as the code is using the internal timers to overflow, the main program loop must be less than the overflow timing, otherwise the clock looses time.
The alternative is to use a DS1307, and but still do the conversion into minutes since midnight as that has proven to be more reliable than doing direct comparison to matching time in Hrs and Min format. However I only really need the HH:MM segment of the time, and I know that the DS1307 has a long string of info stored that includes month, day, year etc. What would be the best way to write / read the DS1307 so that it only gives the hours and minutes and nothing else.
This way if I add features which would otherwise delay the cycle and cause the clock to loose time, with the reading of the DS1307 the counter would still be correct.
The idea is
Code:
Counter1 variable word
Read DS1307 to get hours and minutes
Counter1 = (Hours * 60) + minutes
Do logic of if on time >= counter1 then do something etc
Bookmarks