Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

7 segment drive function

Status
Not open for further replies.

sahu

Member
hi every one pl guide me
how drive 3 seven(7) segment as per below sch. here i use common anode type segments
A RC0
B RC1
C RC2
D RC3
E RC4
F RC5
G RA2

unit_display RA4 // when RA4 on
ten_display RA5 // when RA5 on
hundred_display // when RA4 & RA5 both are off
 

Attachments

  • proteus.PDF
    39.1 KB · Views: 397
Last edited:
You have to put a driver transistor on the common line of the displays - - one for each display.
It is best to have 3 outputs for this.
 
I suggest that you configure timer 0 to increment the digit counter about every 5 mS for multiplexing the display. You can see an example of this in a tachometer design here on my website. If you click on "Source and Hex files" and unzip the .zip file you can see the source code. The first item in the interrupt routine is timer dealing with timer 0 . You will need to modify this so that your counter only counts 0 to 2 (As you only have three digits and my tachometer has 4 digits. You could also leave it counting to 4 and not use the last time slot.) This sets a flag bit to inform the main program that it needs to load the 7 segment pattern for the next digit. You will see this if you look at the code starting at location "Display_Next_Dig" The numbers are converted into the 7 segment patterns at location "HEX2SEGMENTS" You will need to modify this code as you use a bit in a different port for the "G" segment.

Les.
 
You have to put a driver transistor on the common line of the displays - - one for each display.
It is best to have 3 outputs for this.
Yes I know, the simple technic is use 3 output for each segment.
But my need here I can use only 2 output for 3 segment
 
I suggest that you configure timer 0 to increment the digit counter about every 5 mS for multiplexing the display. You can see an example of this in a tachometer design here on my website. If you click on "Source and Hex files" and unzip the .zip file you can see the source code. The first item in the interrupt routine is timer dealing with timer 0 . You will need to modify this so that your counter only counts 0 to 2 (As you only have three digits and my tachometer has 4 digits. You could also leave it counting to 4 and not use the last time slot.) This sets a flag bit to inform the main program that it needs to load the 7 segment pattern for the next digit. You will see this if you look at the code starting at location "Display_Next_Dig" The numbers are converted into the 7 segment patterns at location "HEX2SEGMENTS" You will need to modify this code as you use a bit in a different port for the "G" segment.

Les.
Asm file is taf for me, as compresion c
 
why not bit bang then? create 2 function, one called SelectLed(); other called DisplayDigit(); there are lots of examples on web of how to use timer0 that you can wrap them into.
......you cant use other ppls code unless you use their hardware config as well, with your own config you will need to resolve own code, you can only snip code if its a part you share in common, ie...how to call the timer0 routine, since the application of timer0 is different so will be the things inside the call...


just an example, but:
void SelectLed(unsigned char cathode){
switch (cathode){
case(1): RA5 = 0;RA4 =1;break;
case(2): RA4 = 0;RA5 = 1;break;
case(3): RA5 = 0;RA4 =0;break;
case else:RA5 = 1;RA4 =1;break;
}}

void DisplayDigit(unsigned char anode){
all_pins_off();
switch (anode){
case(1): pin4 = 1;pin5=1;break;
case(2): pin6 = 1;pin7 = 1;pin4 = 1;pin8 = 1;pin9 = 1;break;
//.....ect....10 cases for 0-9
}}
 
why not bit bang then? create 2 function, one called SelectLed(); other called DisplayDigit(); there are lots of examples on web of how to use timer0 that you can wrap them into.
......you cant use other ppls code unless you use their hardware config as well, with your own config you will need to resolve own code, you can only snip code if its a part you share in common, ie...how to call the timer0 routine, since the application of timer0 is different so will be the things inside the call...


just an example, but:
void SelectLed(unsigned char cathode){
switch (cathode){
case(1): RA5 = 0;RA4 =1;break;
case(2): RA4 = 0;RA5 = 1;break;
case(3): RA5 = 0;RA4 =0;break;
case else:RA5 = 1;RA4 =1;break;
}}

void DisplayDigit(unsigned char anode){
all_pins_off();
switch (anode){
case(1): pin4 = 1;pin5=1;break;
case(2): pin6 = 1;pin7 = 1;pin4 = 1;pin8 = 1;pin9 = 1;break;
//.....ect....10 cases for 0-9
}}
U are under stand my problem.
But I cont fully understand ur short example.
I have need read ADC value for RA0 & RA1 .
Then I confused how can read ADC in ur example.
Pl give me completed example as per sch
 
You'd get more done if you learn yourself. Take this in steps get each part to work.
then it's simple.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top