View previous topic :: View next topic |
Author |
Message |
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
multiplexing 7 segment display |
Posted: Tue Oct 19, 2010 10:29 pm |
|
|
Hi,
I am using PIC 16f877a for displaying the counter which is of 0 to 9999. I am using 4 seven segment leds.
There I am having flickering problem. I have changed the delay to many numbers in milliseconds, but I can't eliminate the flickering problem.
Here I have given the code, please correct my mistake.
I am using common cathode 7 segment led and I am giving ground to the 7 segment led by means of switching the transistor(BC548).
I am using Port C0, C1, C2, C3 pins for switching transistors and port B for displaying the digits.
Code: |
b = 0xFC;
output_B(digit[b]);
output_c(0x01);
delay_ms(5);
output_c(0x00);
output_B(digit[b]);
output_c(0x02);
delay_ms(5);
output_c(0x00);
output_B(digit[b]);
output_c(0x04);
delay_ms(5);
output_c(0x00);
output_B(digit[b]);
output_c(0x08);
delay_ms(5);
output_c(0x00);
|
I am displaying '0' in all 4 digits. But i am having flickering effect. The 0 is coming properly in all digits.
Thanks in advance,
Regards,
Varadharaj E _________________ embedding innovation in engineers |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Wed Oct 20, 2010 6:16 am |
|
|
Well the eye can begin to see flickering at around 1/80th of a second or about 12.5 ms. You have 4 digits each with a 5ms on time so every digit gets action every 20 ms so flickering is not unexpected. Leds switch very fast so try delay values in the high us range. |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Wed Oct 20, 2010 6:35 am |
|
|
I'm not sure that the problem is the 5msec delays, though that's an awful technique. How often is this routine executed? If there's a delay in the rest of the progam, it could cause the interval between operations of the LED digits to be long enough to be visible.
I would set up a repetitive timer interrupt to run at (let's say) 400 Hz. Then every time the interrupt executes, send out the data for one digit and increment a counter that cycles through the 4 digits. That way, you will know that each digit will be illuminated for 2.5msec, 100 times a second. You aren't wasting time with the delay routine, so your processor will have more time to do other things. |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
|
Posted: Thu Oct 21, 2010 10:11 pm |
|
|
Thanks John and Kennedy for your valuable comments. For incrementing the counter I am planning to use the timer 0 interrupt.
Please tell me, can I use the in built function delay_ms() for delay between the digits shifting and timer interrupt for incrementing the count?
Thanks and Regards,
Varadharaj E _________________ embedding innovation in engineers |
|
|
|