Advertisement

7-Segment display. PIC

, Posted by ADMIN at 10:08 AM

7-Segment display.

 

7-segment LED displays are used in front panel to indicate numbers in many applications such as pocket calculators, microwave ovens, frequency counters. A 7-segment LED display contains 7 separate LEDs arranged in a pattern to form posible number from 0 - 9. It can be catagorized as either common cathode or common anode. Fig 1 shown the segment identification and equivalent circuit, with decimal point.

In operation for common cathode, the individual segment anodes are each connected to separate current limiting resistors or LED drivers while common cathode is grounded.

The figure above shown connection between MCU and 7-segment display. To display number '1' is to set b and c segments or 0x06. Table below is shown display code for common cathode LED display.If more than one display is needed, scaning technique program code is used.

dp
g
f
e
d
c
b
a
number
CC hex code
0
0
1
1
1
1
1
1
0
0x3F
0
0
0
0
0
1
1
0
1
0x06
0
1
0
1
1
0
1
1
2
0x5B
0
1
0
0
1
1
1
1
3
0x4F
0
0
1
1
0
1
1
0
4
0x66
0
1
1
0
1
1
0
1
5
0x6D
0
1
1
1
1
1
0
1
6
0x7D
0
0
0
0
0
1
1
1
7
0x07
0
1
1
1
1
1
1
1
8
0x7F
0
1
1
0
1
1
1
1
9
0x6F

 

/*
* Project name:
7-segment LED display sample
* Copyright:
Nicholas Sirirak
* Description:
Display number from 0 - 9; and then loop, increase every 1 second
* Test configuration:
MCU: PIC16F886
Dev.Board: -
Oscillator: HS, 20.0000 MHz
Ext. Modules: -
SW: mikroC v8.1.0.0
* NOTES:

*/

char DSP_code[10]= {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void main(){
char i;
ANSELH = 0;
TRISB = 0;
PORTB = 0;

while(1){
for(i=0; i<10; i++){
PORTB = DSP_code[i];
delay_ms(1000);
}
}
} // end main

MC14489 display driver.

 

MC14489 is a 7-segment display driver chip. One chip can drive 5-digit display of common cathode LEDs. It compatible with Motorola SPI and National MICROWIRE serial data ports. Established serial comunication with MCU, send one byte to change configulation or 3 bytes to display with no address. The bit stream starts with the MSB and it shifted in on the low-to-high of Clock signal. The DATA IN is the input pin. The low-to-high on CLOCK pin shift bit available at DATA IN.To transfer data to MC14489 Enable pin must be held to low state (normally it's high). With MC14489 7-segment driver, we can reduce sevral pins of MCU to 3 pins -- Data, Clock and Enable, to control up to 5 7-segment display LEDs.

 

Figure (a) shown the timing diagram of configuration register.

Figure (b) shown the timing diagram of display register

Example.

 

 

/*
* Project name:
4 digit 7-segment LED display sample with MC14489 driver
* Copyright:
Nicholas Sirirak
* Description:
Display number from 0000 to 9999, number increase every 200 ms
Using PIC16F886 SPI module
* Test configuration:
MCU: PIC16F886
Dev.Board: -
Oscillator: HS, 20.0000 MHz
Ext. Modules: -
SW: mikroC v8.1.0.0
* NOTES:
Pin connected
MCU MC14489
------------------------
RC0 <--> Enable
RC3 <--> Clock
RC5 <--> DATA IN

*/

#define Mc_Enable PORTC.F0

void main(){
char i,j;
TRISC = 0;
PORTB = 0;

Spi_Init();
delay_ms(100);
// initial MC14489
Mc_Enable = 0;
Spi_Write(0b00000001); // config code
Mc_Enable = 1;
delay_ms(100);
// end initial MC14489

while(1){

for(j=0; j<=0x99; j++){
if( (j&0x0A) == 0x0A) j += 6;
for(i=0; i<=0x99; i++){
if( (i&0x0A) == 0x0A) i += 6;
Mc_Enable = 0;
Spi_Write(0x80);
Spi_Write(j);
Spi_Write(i);
Mc_Enable = 1;
delay_ms(200);
}
}
}
}// end main


--
With Regards,

s.m.sethupathy,
sms communication,
Tanjore -1.


mobile :9944 186 173           
      www.questionpaperlink.co.cc
      www.sethu-panguvarthagam.blogspot.com






Currently have 0 comments: