Introduction
A micro-controller port output could interface to many digital peripheral devices using the advantage of multiplexing. Display multiplexing commonly found is a dot matrix display, graphical display, 7-Segments display, etc.
Three-Digits multiplexing 7-Segments Display. |
A 16×32 high red single color dot matrix display |
In previous example, I showed a programming and interfacing example of ATMega16 and a single common anode 7-Segments display. A single digit display requires one single port of a microcontroller. However, software is able to output up to eight digits 7-Segments display using a single share digital port and eight additional common control pins.
Multiplexing a display save a lot of microcontroller digital pins but it requires an additional coding technique.
Multiplexed 7-Segments Display
Device
A multiplexed 7-Segments display made from a number of digits, a two-digits, a four-digits, and up to eight-digits. All digits are fabricated in a single display module.
A pair of two-digits multiplexed 7-Segments display in green color with the digit size of 0.36″ |
As a sample picture shown above, it’s a three-digits multiplexed display. It’s a common cathode type, green, with its 0.36″ digit size.
Specification
Since this type of display made from LED in rectangle shape, the major concern is about the technical data of each LED and device pins out.
Package and dimension of a three-digits common cathode type display as shown in the picture above |
Electrical specification of this multiplexed display |
I got this device for taydaelectronics a few years ago. Recently I putted this display on my development board I designed.
Each segment forward voltage is between 3.2V. So it vitals to tune its input voltage to each segment to this voltage level. Typically, a microcontroller digital I/O pin outputs a 5V voltage level. Hence from a microcontroller digital output pin to the segment, a low Watt resistor is in used to divide the voltage for the segment.
ATMega16 AVR Microcontroller Interface
Each digit of a multiplexed display shares the same port, but each digit’s common pin is enable/display by its own control pin.
Atmega16 interfaces to a two-digits seven-segments display in multiplexing mode |
The schematic above I use only a two-digits seven-segments display. Without any electrical calculation I use a 680 Ohm resistor to drop the voltage, making the segment work in its nominal state.
Programming And Interfacing
Within this section I will show some programming example of multi-digits multiplexing display.
Interfacing to a three-digits display
On my own development board I putted a multiplexed seven-segments display made up to six digits. Each digit is 0.36″ in size as shown in the picture above. The display type used here is common cathode.
For an introductory example, I use only three digit to a getting-started section more simple.
Schematic diagram I took from my development board. |
Using the schematic diagram above, port B output LED pattern to seven-segments display. Port C controls each digit. Each digit is activated for 1 ms in convenience.
AVR GCC source code compiled in Atmel Studio 7 lists below.
/* * twoDigitMuxCc.c * * Created: 11/26/2020 7:16:36 PM * Author : admin */ #include <avr/io.h> #define F_CPU 16000000UL #include <util/delay.h> #define onTime 1 int main(void) { unsigned char cCathode[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; /*Port B drive the segments*/ DDRB=0xFF; /*Port C drive the digits*/ DDRC=0xFF; while (1) { PORTC=0x00; PORTB=cCathode[1]; PORTC=(1<<2); _delay_ms(1); PORTC=0x00; PORTB=cCathode[2]; PORTC=(1<<3); _delay_ms(1); PORTC=0x00; PORTB=cCathode[3]; PORTC=(1<<4); _delay_ms(1); } }
I tested this example code on my development board.
The program is written to display “123” on multiplexed display. |
Click here to download zip file of this example coding. This video shows more details.
Interfacing to a six-digits display
As mentioned earlier, the on board seven-segments display module made up to six digits. Here, I program to make these six digits work together.
/* * sixDigitMuxCc.c * * Created: 11/26/2020 10:02:59 PM * Author : admin */ #include <avr/io.h> #define F_CPU 16000000UL #include <util/delay.h> #define onTime 1 int main(void) { unsigned char cCathode[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; /*Port B drive the segments*/ DDRB=0xFF; /*Port C drive the digits*/ DDRC=0xFF; while (1) { PORTC=0x00; PORTB=cCathode[0]; PORTC=(1<<5); _delay_ms(onTime); PORTC=0x00; PORTB=cCathode[1]; PORTC=(1<<6); _delay_ms(onTime); PORTC=0x00; PORTB=cCathode[2]; PORTC=(1<<7); _delay_ms(onTime); PORTC=0x00; PORTB=cCathode[5]; PORTC=(1<<4); _delay_ms(onTime); PORTC=0x00; PORTB=cCathode[4]; PORTC=(1<<3); _delay_ms(onTime); PORTC=0x00; PORTB=cCathode[3]; PORTC=(1<<2); _delay_ms(onTime); } }
The experiment on board is shown below.
The program uses all these six digits showing the number “012345”. |
Click here to download the zip file of this example. Let watch this embedded video.
No comments:
Post a Comment