Three counters are used to create a 24-hour clock: counter C000 counts seconds and resets every 60 seconds to track minutes; counter C001 counts the number of times C000 resets to track minutes; and counter C002 counts resets of C001 to track hours, with its set value determining a 12-hour or 24-hour display. The clock operates continuously by having C000 reset itself after each 60 second cycle.
Three counters are used to create a 24-hour clock: counter C000 counts seconds and resets every 60 seconds to track minutes; counter C001 counts the number of times C000 resets to track minutes; and counter C002 counts resets of C001 to track hours, with its set value determining a 12-hour or 24-hour display. The clock operates continuously by having C000 reset itself after each 60 second cycle.
Three counters are used to create a 24-hour clock: counter C000 counts seconds and resets every 60 seconds to track minutes; counter C001 counts the number of times C000 resets to track minutes; and counter C002 counts resets of C001 to track hours, with its set value determining a 12-hour or 24-hour display. The clock operates continuously by having C000 reset itself after each 60 second cycle.
There are three counters used in the following application to count the time.
24Hour Clock Using Counters
24Hour Clock Using Counters
This small program starts working the instant the PC is put into run. The key to its operation is based on the special auxiliary device M8013. This device provides an oscillating 1 sec pulse. By associating the counter C000 with this clock pulse, the number of elapsed seconds can be counted. If this count is reset at 60 events then the position within the current minute will be known. To enable this cycle to operate continuously the counter C000 actually resets itself on completion of its 60 counts. If the number of times C000 resets is counted by a second counter the number of elapsed minutes will be known. Therefore following the same logic as before but using C001 to count the minutes and one step further using C002 to count the hours completes a full independent clock. The time is simply read directly from the 3 counters. A 24 hour clock can be made by making the set value of C002 equal to 24 or a standard 12 hour clock can be operated when the set value is made equal to 12.