CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

7 segment LED Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
evaradharaj



Joined: 15 Jan 2009
Posts: 60

View user's profile Send private message Visit poster's website

7 segment LED Problem
PostPosted: Wed Sep 21, 2011 3:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 21, 2011 4:59 am     Reply with quote

To eliminate the flickering you must update(strobe) the LEDS faster than 50Hz.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Sep 21, 2011 3:13 pm     Reply with quote

and to know whats really going on -
junk Proteus then
build and test with real hardware ;-))
evaradharaj



Joined: 15 Jan 2009
Posts: 60

View user's profile Send private message Visit poster's website

changed code
PostPosted: Wed Sep 21, 2011 8:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 6:30 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Sep 22, 2011 8:24 am     Reply with quote

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

View user's profile Send private message Visit poster's website

Thanks
PostPosted: Thu Sep 22, 2011 5:15 pm     Reply with quote

I will try in real hardware and get back to you .. thanks for your valuable suggestions
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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