Case——24-hour clock

This case uses three counters to count time, it uses 24-hour clock as an example.

2. I/O list

Device Register Description
Second C0 For seconds
Minute C1 For minutes
Hour C2 For hours
M8013 Oscillates once per second

3. Project


The program uses M8013 (oscillation once per second) to provide pulses for the seconds counter C0. When C0 counts up to 60, i.e., for one minute, C0 automatically reset, and triggers C1 to count 1.
When C1 counts up to 60, i.e., for one hour, C1 automatically reset, and triggers C2 to count 1.
When the C2 counts up to 24, C2 automatically reset, 24-hour count is completed. If the user needs a 12-hour clock, just change 24 to 12.