Seven segment simulation for digital clock program with hours-minutes-seconds display
Seven Segment is one of the most common components used primarily to display data in the form of numbers. For that, Microcontroller Project also provides a simulation for seven segment, namely SSLED.exe.
Seven segment simulation provided by the SSLED.exe has eight-digit in multiplex manner. Multiplex technique is the most commonly used because of its compact wiring and requires only a few ports to control it. How to control the seven segment arranged in multiplex is by dividing two kinds of line, i.e. the data line and digits control line. Data line is used to determine which LED are lit, while the digits controller line is used to set which digits are lit.
Data line and digits control line of SSLED.exe received using window message as WM_USER. If lParam is 1, then the received signal will be considered as a signal for digits control line. Whereas if the lParam value is 2, then the received signal will be considered as a signal for the data line.
On the data line, bit 0 will be used for LED a, bit 1 to turn on the LED b, and so on until bit 6 to turn on the LED g. While the bit 7 is used to lit the decimal point LED. If a bit is 1, then the corresponding LED will lit. This would fit with the common cathode type. However, we can also reverse the data so that if the data sent value is FF, then the data would be considered 00. This capability is useful for adjustment with seven segment types to be used.
SSLED.exe provides two ways of controlling the digits, i.e. the parallel way and the counter way. In the parallel way, each digit can be individually activated depending on the bit of the line controller. Bit 0 in the line controller will control the rightmost digit and bit 7 will control the leftmost digit. If a bit is 1, then the corresponding digits will be active. And just as in the data line, the line controller digits can also be reversed.
In counter mode, only bit 0 and bit 1 in the line controller digit is used. Bit 0 is used to reset the counter, so the active digit will be the rightmost digit. While the bit 1 is used to shift the active digit to be the next left digit, or name it as raising the counter count. There are two kinds of how to raise the counter count, i.e. L to H transition or H to L transition. If we use the L to H transition, then the counter will be increased if bit 1 state changed from 0 to 1. Conversely, if the transition used are H to L, then counter would be raised if the bit condition changed from 1 to 0.
If the current digit is the leftmost digit and count raised, the active digit will return to the rightmost digit.
The picture above is an example of how simulation if operated for seven segment display digital clock program. Above program is actually a modification of the program on Interrupts chapter of the Easy and Fun Learning Microcontroller book, ie on Timer.A51 program. But in the book we will try to program the actual seven segment, so we need to save money just by using four digits only. While in this simulation, we have simulated seven segment that provides eight digits. Therefore, we can show not only hours and minutes but also seconds. In fact we still have the remaining two digits. The remaining digits are used to separate hours to minutes and minutes to seconds, i.e. by displaying a (-) sign. Therefore, we need a little modification of the Timer.A51 program in order to display the seconds and the separation mark.
The source code is written with the format of M51 and c where the data signal transmitted using P0, and the digit control signal using P1. Thus, we must set P0 to link by the Link Message with a WM_USER message, and lParam value is 2 and fill the Handle with the Handle of running SSLED.exe using Capture Handle button. Do this to P1 too. But in P1, lParam value is 1. And remember, remove the check mark on the Update Display menu on the simulator.
But keep in mind that the program is written to run on a microcontroller with a 11.592 MHz crystal. So the second change speed during the simulation may be is not correct. And its speed depends on the speed of the computer you use.
Well, interesting isn’t it? Happy trying ❗
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.Please notice that comment or question submitted should match the topic.