Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Decimal counter 00-99 with pic 16f877A

Status
Not open for further replies.

jean12

Advanced Member level 2
Joined
Aug 27, 2013
Messages
529
Helped
5
Reputation
12
Reaction score
6
Trophy points
18
Activity points
5,497
Hello there,I would like to make a counter counting from 00-99 and then go to start (go to 0),the added push button when pressed it reset the PIC;I am using ccs c compiler.

can you please help,here are the complete project,proteus simulation and the codes I tried to run;it is working but jumping some digits (0,6,8 and 9).

See the codes below,they are the same with the ones which are in the zipped folder.

PHP:
#include "16F877A.h"
#USE DELAY(CLOCK=4000000 ) 
#FUSES XT,NOWDT,NOPROTECT,NOPUT,NOLVP,NODEBUG,NOBROWNOUT 
byte const digit[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
int right,cnt;
char  digit1[2];
void main()
{


set_tris_b(0x00); 
set_tris_a(0x00);
set_tris_d(0xff);
output_b(0x00); 
output_a(0x00);

for( ;; )

{

for(cnt=0;cnt<=99;cnt++)
{
       digit1[0]=cnt/10;
        digit1[1]=cnt%10;
        
        
       
       delay_ms(200);
       output_high(PIN_A0);
       output_b(digit[digit1[0]]);
       output_low(PIN_A1);
       delay_ms(200);
       output_high(PIN_A1);
       output_b(digit[digit1[1]]);
       output_low(PIN_A0);
       delay_ms(200);      
       

              }
while(input(PIN_D0)==0)
{
cnt=0;
}
 
 
 
 
 
          }
      }
Thanks.
 

Attachments

  • Counter.zip
    19.4 KB · Views: 95

Hello Sir,consider the ccs c project here and proteus simulation circuit.

Thanks.
 

Attachments

  • Counter.zip
    50.4 KB · Views: 68

Thanks you very much,problem solved.

Thanks again.
 
Last edited:

Hello jayanth.devarayanadurga,can you help me to create a conveniable delay which allow all SSD to display and make a simple delay before incrementation to the next number see the codes and simulation in Proteus.
 

Attachments

  • CNTT.zip
    63.7 KB · Views: 54

There is some problem with the 7 Segment Proteus model you used. It flickers, I don't know why. Maybe some timing issue with the model. I have fixed the code. It uses 12 MHz Fosc. If you change Fosc to 4 MHz then you should also change the Timer1 interrupt reload value accordingly. I am attaching the working CCS C Code and Proteus file which I modified. You need to use PNP transistors to drive the Anodes of SSDs. You were using NPN transistors.

96181d1379209822-dc.png
 

Attachments

  • Decimal Counter.rar
    95.7 KB · Views: 111
  • dc.png
    dc.png
    28.3 KB · Views: 122

Not only in proteus ,but also on the board there are the flickering .
 

Why using interrupts in this program?if I change the delay on line 71 I put 500ms what will happen?
Can you please help me to understand the interrupts in normal applications?

Thanks.
 

Tiner interrupt is used for refreshing (Multiplexing) SSDs. If you use longer delays like 0.5 sec then each SSD will turn on every 0.5 sec and so you see flickering. My code works fine if you use it. Why do you want to change the timer interrupt? Don't change it. If you use 4 MHz Fosc then change timer reload value such that you get 200 us timer interrupt.

Working project attached for 4 MHz Fosc.
 

Attachments

  • Decimal Counter 4MHz.rar
    97.3 KB · Views: 112
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top