Here is a sample of to write an RTC and trap the contract hour. Contract hour is a time in a day where production number are consolidated for reporting.
The logic is designed to trigger end day (contract hour) at 0800hrs using Modbus register 1001. I am also trapping a trigger at 2 seconds past 0800hrs as Modbus register 1002
Note that you will have to assign SCADAPack Real Time Clock And Alarm module to this project. See image below.
The first register is assigned on “AO Start Register” textbox and the rest of the registers are automatically assigned. The table below is from Telepace Studio help file which outlines what each of the AO# registers denote.
Register Assignment |
Assignment to Module Hardware |
|
AO1 | Real time clock hour | 0 to 23 |
AO2 | Real time clock minute | 0 to 59 |
AO3 | Real time clock second | 0 to 59 |
AO4 | Real time clock year | 00 to 99 |
AO5 | Real time clock month | 1 to 12 |
AO6 | Real time clock day | 1 to 31 |
AO7 | Real time clock day of week | 1 to 7 1 = Sunday 2 = Monday 7 = Saturday |
AO8 | Alarm hour | 0 to 23 |
AO9 | Alarm minute | 0 to 59 |
AO10 | Alarm second | 0 to 59 |
AO11 | Alarm control |
0 = no alarm 1 = absolute time 2 = elapsed time alarm (relative from now)1 |
The Alarm Control register (AO11) enables or disables the alarm. A value of 0 in this register disables the alarm. A value of 1 sets an alarm to be triggered in absolute time, based on the values in the preceding three registers. A value of 2 sets the alarm to be triggered at a latter time, starting now.
Additional Information
- The alarm settings above and those in the Sleep (SLP) ladder element will trigger the same interrupt. Using both alarm settings, therefore, in the same program is not recommended.
- SCADAPack Controllers have a hardware based real-time clock that independently maintains the time and date for the operating system. The time and date remain accurate during power-off. The calendar automatically handles leap years.
- Set the 7 registers for the real time clock to valid values for the clock to operate properly.
- Eleven holding registers are assigned to the I/O database when you use this module.