Search This Blog

Sunday, 22 April 2012

Object Counter using PIC16F877

Hey,
This blog is about the circuit that I've designed for my college project.
I've designed Object counter using PIC16F877 and used Op-Amp as comparator-LM324.
The circuit diagram and simulation is as under:


1).Sensor Circuit.

 Working of Sensor:


  • Resistance of LDR when light falls on it=7.8k
  • Resistance of LDR when light is blocked=19k
  •  Voltage drop across R2 when light falls on LDR=1.42V
  • Voltage drop across R2 when light is blocked by an object=0.7V
  • Voltage given to comparator by potentiometer=1.38V
  • Output Voltage from Comparator=2.17V
          As you can see from the circuit that when light is blocked by an object the resistance of the LDR increases hence voltage drop across R2 is decrease. We've given this decreased voltage to the negative terminal of Op-Amp. Hence difference between reference voltage and sensor output will be amplified.


 2).Microcontroller Programming and Proteus Simulation:


I've done simulation in proteus. I couldn't find a way to give input from sensor to microcontroller for simulation. So, I've skipped that part and simulate only initialization of 16x2 LCD.
Programming is done in MPLAB using HI-Tech C Compiler. I've made my own library to use 16x2 LCD.I've made a simple mistake while programming that skips the counts of 10,20,30....etc.
So, whenever count reaches to 8,18,28..... it skips 9,19,29,..... and shows 10,20,30....etc.

The recording was done before I can edit my program.I made some modification after that and now the circuit works fine. So, hope you'll bear me for this video that was recorded before I can find my mistake.

Bill Of Materials

U1            PIC16F877                                                           
U2            LM324                                                               
X1            4MHz Quartz Crystal                                       
2              15pF Capacitor
1              16x2 JHD162A LCD
2              150 resistors
2              1k  resistors
2              IC Sockets
1              Yello LED in white
2              10k POT
1              LDR
1              9V Battery

 Some Photos







PS: To get proteus file or MPLAB coding file mail me or write your e-mail address in comment.