In the past I posted a counter and timer circuit and it is used two seven segment displays to display number and it can only count 0-99. you can see it from here. This circuit was developed version of it.
This project shows cheap and accurate up counter and it can count up to 9999 and then it will start from 0.
For this circuit i used PIC16F628A micro-controller and four common cathode seven segment displays. Any 7-Segment displays will work in this circuit. You need to identify
the pin-out of any display you use. In Proteus schematic i used NOT gate for reduce CPU usage while simulating and you need to replace that NOT gate with NPN transistors such as BC547 and do not connect transistor's base directly with PORTA (A0-A3). Put a 1k-10k resistor for base of each transistor.
Schematic diagram of 4 digit up counter |
Operation of Circuit
- To start counting simply press the 'Count' button and every time you pressed that button the number will increase one by one and displayed on the seven segment displays. if you need to automatic counting, it is also possible to connect this pin with pulse generator.
- Pressed 'Clear' button to clear the display and start from zero.
- 'Reset' button is optional and you can omitted it. but you must add pull-up resistor. otherwise device will reset continuously. 'Reset' button is useful when the circuit was stuck or not responded.
The main problem of counter circuit was contact bounce. The contact bounce is a common problem with mechanical switches. When the contacts strike together, their momentum and elasticity act together to cause bounce. The result is a rapidly pulsed electrical current instead of a clean transition from zero to full current. It mostly occurs due to vibrations, slight rough spots and dirt between contacts. This effect is usually unnoticeable when using these components in everyday life because the bounce happens too fast to affect most equipment. However, it causes problems in some analog and logic circuits that respond fast enough to misinterpret on/off pulses as a data stream. Anyway, the whole process doesn’t last long (a few micro or milliseconds), but long enough to be registered by the microcontroller. When only a push-button is used as a counter signal source, errors occur in almost 100% of cases!
To prevent contact bounce I added some extra code. so we can get error less counting from this circuit. When you pressed and hold the Count button this circuit wont count.
PIC16F628A Datasheet |
Where can i download the code?
ReplyDeleteRegister and click the Download button.
Deletehello sir would it be possible to put a button for a desired preset value let say 100 each press and stop when the count value reach...
ReplyDeletethnks.. mike
You have to modify the code.
Deletewould it be possible to have the code..sir
Deleteyou can able to download the code from given link
DeleteDo you done this code. If so please share with me
DeleteWhere is the link..I am not able to doenload from Dowbload button
ReplyDeletehttp://tiny.cc/4ssd-up
DeleteIt is not having code file....I need code
ReplyDeleteCan you provide code for preset counter with power failure memory.
ReplyDeleteIf you can edit I can send source code
DeletePlease sir the would be nice. Tnx
ReplyDeleteI will post it here soon
Deleteang also sir could you add the features With power-off memory counting
ReplyDeletetnx.
Thank you sir for posting this diagram. Can you modify the code to count up and down. May be, changing the clear button to count down button.
ReplyDelete