TIme Based Events with the Spinneret RTC question
I have done several project that have logged data with time. This would involve waiting for a condition on a pin to change states and then capturing the state change and time and logging it to an SD card.
What i have not ever done is Time based such as a sprinkler timer.
I know that i can use the RTC object that has been posted to get the time. If i were to have an ON time of 0600 and an OFF time of 1900.
Would i create an object that just constantly compares the RTC time to the desired set times and change the state of my output?
What i have not ever done is Time based such as a sprinkler timer.
I know that i can use the RTC object that has been posted to get the time. If i were to have an ON time of 0600 and an OFF time of 1900.
Would i create an object that just constantly compares the RTC time to the desired set times and change the state of my output?
Comments
I'm using Kye's RTC object. The code snippet below sets the alarm on INT1 to fire when the minutes matches 46. INT1AlarmCheck returns true if the alarm has fired.
INT1Alarm(week, hour, minute)
There is also user defined output on pins INT1/INT2 which I have not tried. I suppose the output could drive external logic.
S35390A Manual
I would roll the alarm logic into a COG using the cognew command right in the object that processes the alarm.
I am actually making it more complicated than this in that i have 6 zones that could potentially each have their own start and stop times as well as a condition per zone, where ,when the zone is on an off state, and a condition is met on a pin, the zone will turn back on for 1 hour from that moment.
This is why it looks like i will not be able to us the internal alarms and will need to create a 'parser' to handle this. We will see how it goes.
I am pulling my hair out right now.
I am using the SNTP demo code where the time get set by an SNTP server.
It sets the RTC time. All of this is working correctly and i see the correct time in my debug window. (parallax terminal)
then i try to do some comparisons.
I have created a DAT section that has the on and off times. I have put them in the following format The objects from the RTC are as follows.
I am trying to compare the one against the other to create some logic. This is not working as i had planned. I have tried many different ways. I changed the DAT to longs because that is what is being sent back from the RTC object. But still no joy.
What am i doing wrong??
By the way, I built a count down timer a while back. You're welcome to it not sure if it fits your needs though. It runs in a COG and can handle 4 timers with a 1/512 resolution and 2330 hour max. A pin goes high when the timer starts then low when the timer reaches zero.
This is what i currently have working. and here is the code that is working. Now i need to gust include state changes on the conditions
I changed the way i store the day and times.