kolyur
Lifetime Supporting Member + Moderator
I'm using the RTC in a MicroLogix 1400 and I want the operator to be able to set the date and time via an HMI (brand irrelevant). The HMI can't access RTC registers directly so I copy values to N7 registers first. When values are changed by HMI, I verify that they are within valid ranges, then copy back to RTC with CPW instruction. So far, so good.
Attempting to set a RTC value outside of the valid ranges will cause a CPU fault. The user manual claims that the RTC day-of-month value has a range of 1-31. In actuality, the range is equal to the number of days in the current month. This necessitated some extra logic to determine whether the valid date range is 28, 30, or 31 days. In addition, I have to do a leap year calculation in case February happens to have 29 days.
Everything works correctly but it wasn't near as simple as I had hoped. This PLC is part of a critical process and I can't afford the possibility of a CPU fault when someone's setting the clock. Am I missing something or is all of this necessary to allow the clock to be set externally?
Attempting to set a RTC value outside of the valid ranges will cause a CPU fault. The user manual claims that the RTC day-of-month value has a range of 1-31. In actuality, the range is equal to the number of days in the current month. This necessitated some extra logic to determine whether the valid date range is 28, 30, or 31 days. In addition, I have to do a leap year calculation in case February happens to have 29 days.
Everything works correctly but it wasn't near as simple as I had hoped. This PLC is part of a critical process and I can't afford the possibility of a CPU fault when someone's setting the clock. Am I missing something or is all of this necessary to allow the clock to be set externally?