Introduction of counter Project:-
This is a simple microcontroller project build for a Up and Down Counter with Reset of counts facility.
In this project PIC18f452 is used for processing and this device is the heart of the project. A 2 line 20 character General purose LCD is used as basic display of the counter.
In this project three push button are used as inputs of counter, but any TTL signal provider ciruit cn be interfaced which uses IR,LDR,phototransistor or optocoupler as input. Because this counter can be used any where, to counts any object passing through a certain location. This counter project counts up to 1000000 counts.
Thus this counter project is suitable where we have to counts any large number of objects.
Parts of the Counter Project:-
This counter project is based on a very few components which are listed as follows:-
1. The heart of the counter project is PIC18f452 (1Nos)
2. Liquid Crystal Display LCD ( 2 line 20 Characters 1Nos)
3. crystal 4MHz (1Nos)
4. Capacitor 20pF (2Nos)
5. Push Buttons (4 Nos)
6. Resistors (10K ohm 4Nos)
7. variable resistor (10K ohm 1 Nos)
A regulated power supply of +5V DC is required to make this project operational.
Circuit Diagram of Counter Project:-
Below is the circuit diagram of counter using PIC18f452 PIC Microcontroller and LCD.
Main Features of Up and Down Counter:-
The object counter based on PIC Microcontroller have following three basic inputs.
- Up button for increment the nuber of counts
- Down Button for decrement the number of counts
- Reset Button for reset the counted value to zero.
Code of counter:-
The code of this project is written in basic language and compiled using proton basic compiler from Crownhill. Proton IDE is a professional and powerful visual Integrated Development Environment (IDE) designed specifically for the Proton Plus compiler.
'* Name : LCD_pic18f452.BAS *
'* Author : [Dr.Rana] *
'* Notice : www.picinf.blogspot.com All Rights Reserved *
'* Date : 9/18/2011 *
'* Version : 1.0 *
'* Notes : Students can use this program for learning *
'* : *
Device = 18F452
TRISB = %11100000 ' only last three pin are inputs
Declare LCD_Interface 4
Declare LCD_Lines 2
Declare LCD_DTPin PORTD.0 ' first four lines Used for 4-line interface.
Declare LCD_ENPin PORTD.4 ' Enable PIN of LCD
Declare LCD_RSPin PORTD.5 ' RS PIN of LCD
Symbol up_counter = PORTB.7
Symbol down_counter = PORTB.6
Symbol reset_counter = PORTB.5
Dim old_b1 As Bit
Dim old_b2 As Bit
Dim old_b3 As Bit
Dim my_counts As Dword
Dim old_counts As Dword
Print At 1 , 5 , "HELLO WORLD"
Print At 2 , 1 , "Counts = "
old_counts = 0
my_counts = 0
old_b1 = 1
old_b2 = 1
old_b3 = 1
PORTB = 255
If up_counter = 0 And old_b1 = 1 Then GoSub increment_counts
If down_counter = 0 And old_b2 = 1 Then GoSub decrement_counts
If reset_counter = 0 And old_b3 = 1 Then GoSub reset_counts
If old_counts < > my_counts Then GoSub print_counts
old_counts = my_counts
old_b1 = up_counter
old_b2 = down_counter
old_b3 = reset_counter
If my_counts > = 1000000 Then my_counts = 0
If my_counts > 0 Then Dec my_counts
my_counts = 0
Print At 2 , 10 , Dec my_counts
proton basic example project pic18f452 up and down counter with lcd