DS1307 Real Time clock chip¶
The DS1307 device contains a battery backed real time clock which can be read over I2C by the IO_DS1307 driver. The usual I2C address is 0x68 and the clock is defined as follows with a suitable VPIN number of your choice.
HAL(DS1307,444,0x68)
The clock must be manually set when first used, on a time-zone change or when it had drifted (They are not as accurate as a quartz watch). You may also prefer to change the clock to suit the time of day you are modelling rather then the real time.
The clock is set with a serial command <z vpin hh mm ss>
to write to the chosen VPIN using the 24hour clock.
For example:
<z 444 13 25 15>
The driver will monitor the clock and will invoke EXRAIL time events every minute (synchronized with the 0 seconds of the clock)
-
ONTIME(minute_in_day) Start task here when clock matches the minute_in_day value (0..1439)
-
ONCLOCKTIME(hours,mins) Starts task at given time
-
ONCLOCKMINS(mins) Start task here hourly when clock minutes matches.
You can stack the ON* handlers in EXRAIL so the example below will trigger every 15 minutes.
ONCLOCKMINS(0)
ONCLOCKMINS(15)
ONCLOCKMINS(30)
ONCLOCKMINS(45)
PRINT("something happened")
... do something clever
DONE
An analog read in EXRAIL IFGTE(vpin, value) etc will check against the hh*60+mm time.