Simple PIC18 Projects:Two-Digit Multiplexed 7-Segment LED

PROJECT 6.6—Two-Digit Multiplexed 7-Segment LED

Project Description

This project is similar to Project 6.5, but here multiplexed two digits are used instead of just one digit and a fixed number. In this project the number 25 is displayed. In multiplexed LED applications (see Figure 6.29) the LED segments of all the digits are tied together and the common pins of each digit are turned ON separately by the microcontroller. When each digit is displayed only for several milliseconds, the eye cannot tell that the digits are not ON all the time. This way we can multiplex any number of 7-segment displays together. For example, to display the number 53, we have to send 5 to the first digit and enable its common pin. After a few milliseconds, number 3 is sent to the second digit and the common point of the second digit is enabled. When this process is repeated continuously, it appears to the user that both displays are ON continuously.

Some manufacturers provide multiplexed multidigit displays, such as 2-, 4-, or 8-digit multiplexed displays, in single packages. The display used in this project is the DC56- 11EWA, which is a red 0.56-inch common-cathode two-digit display having 18 pins and the pin configuration as shown in Table 6.9. This display can be controlled from the microcontroller as follows:

• Send the segment bit pattern for digit 1 to segments a to g

• Enable digit 1

Simple PIC18 Projects-0040

Simple PIC18 Projects-0041

• Wait for a few milliseconds

• Disable digit 1

• Send the segment bit pattern for digit 2 to segments a to g

• Enable digit 2

• Wait for a few milliseconds

• Disable digit 2

• Repeat these steps continuously

The segment configuration of the DC56-11EWA display is shown in Figure 6.30. In a multiplexed display application the segment pins of corresponding segments are connected together. For example, pins 11 and 16 are connected as the common a segment, pins 15 and 10 are connected as the common b segment, and so on.

Simple PIC18 Projects-0042

Project Hardware

The block diagram of this project is shown in Figure 6.31. The circuit diagram is given in Figure 6.32. The segments of the display are connected to PORTC of a PIC18F452- type microcontroller, operated with a 4MHz resonator. Current limiting resistors are used on each segment of the display. Each digit is enabled using a BC108-type transistor switch connected to port pins RB0 and RB1 of the microcontroller. A segment is turned on when a logic 1 is applied to the base of the corresponding segment transistor.

Simple PIC18 Projects-0043

Project PDL

At the beginning of the program PORTB and PORTC pins are configured as outputs. The program then enters an endless loop where first of all the Most Significant Digit (MSD) of the number is calculated, function Display is called to find the bit pattern and then sent to the display, and digit 1 is enabled. Then, after a small delay, digit 1 is disabled, the Least Significant Digit (LSD) of the number is calculated, function Display is called to find the bit pattern and then sent to the display, and digit 2 is enabled. Then again after a small delay, digit 2 is disabled, and this process repeats indefinitely. Figure 6.33 shows the PDL of the project.

Simple PIC18 Projects-0044

The program is named SEVEN3.C, and the listing is shown in Figure 6.34. DIGIT1 and DIGIT2 are defined as equal to bit 0 and bit 1 of PORTB respectively. The value to be displayed (the number 25) is stored in variable Cnt. An endless loop is formed using a for statement. Inside the loop, the MSD of the number is calculated by dividing the number by 10. Function Display is then called to find the bit pattern to send to PORTC. Then digit 1 is enabled by setting DIGIT1 ¼ 1 and the program waits for 10ms. After this, digit 1 is disabled and the LSD of the number is calculated using the mod operator (“%”) and sent to PORTC. At the same time, digit 2 is enabled by setting DIGIT2 ¼ 1 and the program waits for 10ms. After this time digit 2 is disabled, and the program repeats forever.

Simple PIC18 Projects-0045

Simple PIC18 Projects-0046

Leave a comment

Your email address will not be published. Required fields are marked *