|
|
View previous topic :: View next topic |
Author |
Message |
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
7 segment LED Problem |
Posted: Wed Sep 21, 2011 3:00 am |
|
|
Hi,
I am interfacing the pic16f877a with two 7 segment displays. I am using Proteus for testing my code. LED flickering is appearing in my code. How to eliminate the flickering? And also tell me that, whether this flicker will appear in real time? because I don't have 7 segment display now.
I used common anode 7 segment displays and bc547 transistor for switching between the displays. (no drivers)
My code,
Code: |
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
unsigned char display[]={0x40,0xF9,0x24,0xB0,0x99,0x92,0x82,0x78,0x00,0x90};
long count = 0,i = 0,j = 0;
int temp1,temp2;
#int_RTCC
RTCC_isr()
{
count++;
if(count >= 90)
{
count=0;
if(i==0)
{
output_low(pin_d1);
output_b(display[temp1]);
output_D(0xFE);
}
else if(i==1)
{
output_low(pin_d0);
output_b(display[temp2]);
output_D(0xFD);
}
i++;
if(i==2)
{
i=0;
count=0;
}
}
}
void main()
{
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while(1)
{
for(j=0;j<=99;j++)
{
temp1 = j % 10;
temp2 = j / 10;
delay_ms(1000);
}
}
}
|
Note: in future I am planning to add 2 more led displays. Please suggest me how to eliminate the flicker. I am using pcm3.185 and Proteus 7.0
Thanks in advance |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Wed Sep 21, 2011 4:59 am |
|
|
To eliminate the flickering you must update(strobe) the LEDS faster than 50Hz. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Sep 21, 2011 3:13 pm |
|
|
and to know whats really going on -
junk Proteus then
build and test with real hardware ;-)) |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
changed code |
Posted: Wed Sep 21, 2011 8:10 pm |
|
|
Hi,
Thanks for your replies. I have updated my code with less than 50Hz refreshing rate. But still i have the flicker. Please see my changed code and suggest me to eliminate the flicker.
Code: |
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
unsigned char display[]={0x40,0xF9,0x24,0xB0,0x99,0x92,0x82,0x78,0x00,0x90};
long count = 0,i = 0,j = 0;
int temp1,temp2;
#int_TIMER0
RTCC_isr()
{
count++;
if(count >= 20) // less than 50HZ refresh rate
{
count=0;
if(i==0)
{
output_low(pin_d1);
output_b(display[temp1]);
output_high(pin_d0);
}
else if(i==1)
{
output_low(pin_d0);
output_b(display[temp2]);
output_high(pin_d1);
}
i++;
if(i==2)
{
i=0;
count=0;
}
}
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while(1)
{
for(j=0;j<=99;j++)
{
temp1 = j % 10;
temp2 = j / 10;
delay_ms(1000);
}
}
} |
_________________
embedding innovation in engineers |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Thu Sep 22, 2011 6:30 am |
|
|
what are your resistor values to the segments?? you can try reducing to 480E or so!
but before that try working on a real hardware! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Sep 22, 2011 8:24 am |
|
|
let me say it with more clarity:
Quote: |
YOU CAN NOT TRUST ANY SUBTLE TIMING ASPECT OF PROTEUS SIMULATION.
|
|
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
Thanks |
Posted: Thu Sep 22, 2011 5:15 pm |
|
|
I will try in real hardware and get back to you .. thanks for your valuable suggestions |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|