Overview
A 7-Segments display commonly found in a typical digital electronics equipment, a temperature controlled switch, a sign board, etc.
It made of segment-shaped of LED with seven light emitting diodes to creates a pattern of numbers, sign, or any characters with an optional dotting point (dp).
Some common anode 7-segments display type with the size of one inch. I use these stuffs for my serial display board. |
Technical Data
A 7-Segments display varies in its display size, color and its common configurations. I have seen some available sizes of this type of display, 0.36″, 0.40″, 0.56″, 1″, 2.3″, 3″, 4″ and 5″.
Some Parameters
The size refers to the effective display size. Red in output color is a preferred one’s for most hobbyists. The common configuration are the Common Anode (CA) and the Common Cathode (CC). The designer may select between this two kind of configuration to work with the output of any digital IC or embedded controller.
The mechanical diagram and the internal circuit arrangement of a single one inch 7-Segments display. |
Some hobbyists make this display by connecting multiple LED to make the segments and dotting point.
Each segment of this one inch size display typically supplied at 3.4V for the 20mA forward current. Some large display size above 2.3 inches have a typical forward current of 25mA with the nominal forward voltage of 9.25V.
Display Representation
A parallel output port of a digital IC or a microcontroller output data to this display. It’s 8-bit including the dotting point. However the dotting point is optional, and it usually bit-wise ORed within the output port.
Typically the programmer maps the segments to a corresponding value in a table. For the common anode display, we have a table below.
Display | g | f | e | d | c | b | a | HEX |
---|---|---|---|---|---|---|---|---|
0 | OFF | ON | ON | ON | ON | ON | ON | 0xC0 |
1 | OFF | OFF | OFF | OFF | ON | ON | OFF | 0xF9 |
2 | ON | OFF | ON | ON | OFF | ON | ON | 0xA4 |
3 | ON | OFF | OFF | ON | ON | ON | ON | 0xB0 |
4 | ON | ON | OFF | OFF | ON | ON | OFF | 0x99 |
5 | ON | ON | OFF | ON | ON | OFF | ON | 0x92 |
6 | ON | ON | ON | ON | ON | OFF | ON | 0x82 |
7 | OFF | OFF | OFF | OFF | ON | ON | ON | 0xF8 |
8 | ON | ON | ON | ON | ON | ON | ON | 0x80 |
9 | ON | ON | OFF | ON | ON | ON | ON | 0x90 |
For a common cathode type display, the 7-Segments data table lists below.
Display | g | f | e | d | c | b | a | HEX |
---|---|---|---|---|---|---|---|---|
0 | OFF | ON | ON | ON | ON | ON | ON | 0x3F |
1 | OFF | OFF | OFF | OFF | ON | ON | OFF | 0x06 |
2 | ON | OFF | ON | ON | OFF | ON | ON | 0x5B |
3 | ON | OFF | OFF | ON | ON | ON | ON | 0x4F |
4 | ON | ON | OFF | OFF | ON | ON | OFF | 0x66 |
5 | ON | ON | OFF | ON | ON | OFF | ON | 0x6D |
6 | ON | ON | ON | ON | ON | OFF | ON | 0x7D |
7 | OFF | OFF | OFF | OFF | ON | ON | ON | 0x07 |
8 | ON | ON | ON | ON | ON | ON | ON | 0x7F |
9 | ON | ON | OFF | ON | ON | ON | ON | 0x6F |
It’s not only decimal numbers, we can create some ASCII characters to show on this display – for example A, B, L, etc. Due to a limited content I don’t list them all here. We will see them in the programming section.
Interfacing And Programming
A parallel port output of a digital IC or a microcontroller/microprocessor connects to this display via current limiting resistors. These resistors divide the voltage between the LED segment to around 3.4V (1 inches size display), to get a nominal forward current 20mA.
Here I preferred a one inch common anode red display, I stock in my warehouse.
A single red common anode 7-Segments display – 7SR10012BS I stock. |
Microcontroller To 7-Segments Interface
Port C of ATMega16 outputs 7-Segments data to this display via current limiting resistors. With a nominal forward current of 20mA, the voltage drop at each segment is 3.7V. We need to find the an appropriate value of resistor. The onboard devices including the ATMega16 supplies at 5V. So Port C digital output high to external devices must be 5V. Using the voltage divider rule, current limiting resistor is 63 Ohm. However, I only have a 68 Ohm one’s in my stock.
Schematic Diagram Of This Example |
Atmel Studio 7 C Programming
Using C in Atmel Studio, we don’t need any hardware library to code within this simple example. It’s nothing more than a digital I/O programming. One important note is creating a 7-Segments data table that have shown in the table above.
Here we use a common anode type display. The display will show a decimal number from 0 to 9 and a character from A to F. The program just display the counting value from 0 to 15, then roll back to 0 and vice versa.
/* * discreteSsdCa.c * * Created: 11/14/2020 6:46:30 PM * Author : Admin */ #include <avr/io.h> #define F_CPU 16000000UL #include <util/delay.h> int main(void) { //7-Segment data table unsigned char cAnode[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88, 0x83,0xC6,0xA1,0x86,0x8E}; //counting parameter unsigned char cnt=0; //Port C As Output DDRC=0xFF; while (1) { //Display the 7-Segments Data PORTC=cAnode[cnt]; //Increase the counter cnt++; //Reset when it reaches 16 if(cnt>15) cnt=0; _delay_ms(1000); } }
On my development board I externally add a one inch 7-Segments display inserted on a bread board.
A program test using development board with some external add-on components. |
Click here to download a zip file of this programming example. Let see this video on YouTube.
No comments:
Post a Comment