PIC Timer

Equipment

Description

Power Supply

 

single power supply

Vmax

5V

 

Vmin

0

O Scope

100 MHz oscilloscope

Components

16F84A , 74LS47 

Computer & Software PC & PIC - Lite 

Pic Programmer 

USB PIC Programmer

 

Here is the open source code for the Pic Timer.. It is a short program because I included a 47LS47 decoder. If you to wanted to cut down parts (74LS47), just include the decoding in the 16F84A. I used PIC-Lite program to compile the C code into Hex code. You need to load  the Hex code into PIC. 

 

  #include <pic.h>
#include <sys.h>

/*
  *  PIC 16F84A
  *
  */

#define DELAY_TIME 200          // oscillator freq - about 2MHz (RC)
#define DELAY_TIME_TRAN 100

static unsigned FIRST;
static unsigned SECOND;
static unsigned Refresh;
static unsigned del;

    void delay()
       {
           for (del=0;del<DELAY_TIME_TRAN;del++);
        }

main ()
{
// -------- initalports()------------
      TRISA = 0x00 ; // ALL  4 OUTPUT
      TRISB = 0xC0 ; // LAST TWO INPUT    0000 0011
      PORTA = 0x00 ; // right now the out put is 0x00h
      PORTB = 0x00 ;


for (SECOND=0;SECOND<10;SECOND++)
    { 
            for (FIRST=0;FIRST<10;FIRST++)
           { 
                    for (Refresh=0;Refresh<DELAY_TIME;Refresh++)
                   {
                   PORTA=FIRST;
                            PORTB=0x02;
                                                            delay();
                           PORTA=SECOND;
                   PORTB=0x04;
                                                            delay();
                  }
          }
    }

};
 

 

for (SECOND=0;SECOND<10;SECOND++)

     for (FIRST=0;FIRST<10;FIRST++)
     { 
          for (Refresh=0;Refresh<DELAY_TIME;Refresh++) // refreshes  200 times
          {

    PORTA=FIRST;    Port A consists of RA0 to RA3 and there outputs range are  from 0 to 9. Port A sends out the FIRST number to both LED display
                  PORTB=0x02; Port B sends a high voltage to RB1 and turns on the first transistor so the first LED can turn on.
                       delay(); Calls up the delay function to reduce the displayed numbers from over lapping
         PORTA=SECOND; Port A sends out the SECOND number to both LED display
                  PORTB=0x04;         Port B sends a high voltage to RB2 and turns on the first transistor

                        delay();
                  }
      }
 }

 

 

1