2 Digit Counter using PIC12F629 Microcontroller

Summary of 2 Digit Counter using PIC12F629 Microcontroller


This article details a 2-Digit Counter project using the Microchip PIC12F629 microcontroller. It demonstrates how to drive two 7-segment displays with only five output lines by utilizing tri-state outputs (HIGH, LOW, FLOATING) and multiplexing. The circuit employs nine transistors and voltage dividers to manage segment illumination efficiently, allowing higher current pulses for brightness while saving power.

Parts used in the 2-Digit Counter:

  • Microchip PIC12F629
  • Two 7-segment displays
  • Nine transistors
  • Voltage divider components

This article describes a 2-Digit Counter using a Microchip PIC12F629.
It shows what can be done with an 8-pin chip having just 5 output lines and one input line.
The chip drives two7-segment displays and this would normally require 7 lines to drive the segments plus another one or two lines to select the displays.
We have shown how a single line can be used to drive two different segments by using the tri-state of an output.

2 Digit Counter

Each output of the chip has three states: HIGH, LOW and FLOATING (high impedance). The high impedance state occurs when the line is in the input state and any line can be changed from output to input at any time during the running of the program.
The circuit is more complex than shown in the diagram. The interface circuit between the chip and the displays is duplicated two more times for the other 4 lines to the displays. This means we have used 9 transistors to drive 6 lines, whereas it would have normally taken 6 transistors.
The other secret behind driving the displays is multiplexing.
Since we can only show 3 or 4 segments of a display at any time, we need to alternately show up to 3 segments for a short period of time and then the other 4 segments.
We can then repeat the procedure for the other display.
This means any segment will only be illuminated for a maximum of 25% of the time and if we deliver a higher current for this short period of time, we can achieve a very good brightness.
This is one of the features of a LED. It can be pulsed with a higher current for a short period of time and the brightness will be equivalent to a lower constant current.
In fact the overall current will be less in pulse-mode and this represents a saving in power.
To deliver this higher current we need driver transistors as the chip is only able to deliver 25mA from each drive line and we need about 30mA.
The other secret to the operation of the circuit is the voltage divider. It is designed to  put 0.5v between the base and emitter of the two transistors when the output of the chip is floating.
This means neither of the transistors is turned on and no segment will be illuminated.
When the output of the chip is HIGH, the lower transistor is turned on and this turns on the middle transistor to illuminate a segment.
When the output of the chip is LOW, the upper transistor is turned on.

The multiplexing and driving the segments involves a lot more programming and setting the lines to input and then output, but this will not inhibit the running of the program as the displays must be illuminated for long periods of time compared with the time taken for carrying out the instructions.
The whole purpose of this project is to show what can be done with a small micro

For more detail: 2 Digit Counter using PIC12F629 Microcontroller

Quick Solutions to Questions related to 2-Digit Counter:

  • How many output lines does the chip use?
    The chip uses just five output lines.
  • Can a single line drive two different segments?
    Yes, a single line can drive two different segments by using the tri-state of an output.
  • What are the three states of each output?
    The three states are HIGH, LOW, and FLOATING.
  • Why is multiplexing necessary for this project?
    Multiplexing is needed because only three or four segments can be shown at any time, requiring alternating display updates.
  • How much current does the chip deliver compared to what is needed?
    The chip delivers 25mA per drive line, but about 30mA is needed.
  • Does pulsing the LED reduce overall power consumption?
    Yes, the overall current will be less in pulse-mode, representing a saving in power.
  • What is the purpose of the voltage divider in the circuit?
    The voltage divider puts 0.5v between the base and emitter when the output is floating to ensure no segment is illuminated.
  • How often is a segment illuminated during operation?
    Any segment will only be illuminated for a maximum of 25% of the time.
  • Does the complex programming inhibit program running?
    No, the displays must be illuminated for long periods compared with the time taken for carrying out instructions.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter