Saturday, August 21, 2021

ATMega16 Interfaces To Multiplexed Display

 

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. 

 

ATMega16 Interfaces To Multiplexed Display
Three-Digits multiplexing 7-Segments Display.

ATMega16 Interfaces To Multiplexed 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.

ATMega16 Interfaces To Multiplexed Display
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.

ATMega16 Interfaces To Multiplexed Display
Package and dimension of a three-digits common cathode type display as shown in the picture above
A 20mA flowing current is a nominal forward current per segment of this display. The forward voltage is between 3 and 3.5V per segment.

ATMega16 Interfaces To Multiplexed Display
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 Multiplexed Display
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.

ATMega16 Interfaces To Multiplexed Display
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.

  1. /*
  2.  * twoDigitMuxCc.c
  3.  *
  4.  * Created: 11/26/2020 7:16:36 PM
  5.  * Author : admin
  6.  */
  7.  
  8. #include <avr/io.h>
  9.  
  10. #define F_CPU 16000000UL
  11. #include <util/delay.h>
  12.  
  13. #define onTime 1
  14.  
  15. int main(void)
  16. {
  17. unsigned char cCathode[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
  18. /*Port B drive the segments*/
  19. DDRB=0xFF;
  20. /*Port C drive the digits*/
  21. DDRC=0xFF;
  22. while (1)
  23. {
  24. PORTC=0x00;
  25. PORTB=cCathode[1];
  26. PORTC=(1<<2);
  27. _delay_ms(1);
  28.  
  29. PORTC=0x00;
  30. PORTB=cCathode[2];
  31. PORTC=(1<<3);
  32. _delay_ms(1);
  33.  
  34. PORTC=0x00;
  35. PORTB=cCathode[3];
  36. PORTC=(1<<4);
  37. _delay_ms(1);
  38. }
  39. }

 

I tested this example code on my development board.

ATMega16 Interfaces To Multiplexed Display
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.

  1. /*
  2.  * sixDigitMuxCc.c
  3.  *
  4.  * Created: 11/26/2020 10:02:59 PM
  5.  * Author : admin
  6.  */
  7.  
  8. #include <avr/io.h>
  9.  
  10. #define F_CPU 16000000UL
  11. #include <util/delay.h>
  12.  
  13. #define onTime 1
  14.  
  15. int main(void)
  16. {
  17. unsigned char cCathode[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
  18. /*Port B drive the segments*/
  19. DDRB=0xFF;
  20. /*Port C drive the digits*/
  21. DDRC=0xFF;
  22. while (1)
  23. {
  24. PORTC=0x00;
  25. PORTB=cCathode[0];
  26. PORTC=(1<<5);
  27. _delay_ms(onTime);
  28.  
  29. PORTC=0x00;
  30. PORTB=cCathode[1];
  31. PORTC=(1<<6);
  32. _delay_ms(onTime);
  33.  
  34. PORTC=0x00;
  35. PORTB=cCathode[2];
  36. PORTC=(1<<7);
  37. _delay_ms(onTime);
  38.  
  39. PORTC=0x00;
  40. PORTB=cCathode[5];
  41. PORTC=(1<<4);
  42. _delay_ms(onTime);
  43.  
  44. PORTC=0x00;
  45. PORTB=cCathode[4];
  46. PORTC=(1<<3);
  47. _delay_ms(onTime);
  48.  
  49. PORTC=0x00;
  50. PORTB=cCathode[3];
  51. PORTC=(1<<2);
  52. _delay_ms(onTime);
  53. }
  54. }

The experiment on board is shown below.

ATMega16 Interfaces To Multiplexed Display
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

Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)