Introduction: 7 Segment Up/Down Counter
The method I use to make PC Boards, is called the "Heat Transfer" method, using Press-n-Peel transfer paper. After applying the Press-n-Peel to a blank PC Board, I use a standard A4 laminator to transfer the toner from the Press-n-Peel to the PC Board. With the laminator set to the 125ug temperature setting, passing the PC Board trough 10 times gives me the best results.
Why the Counter?
A simple task of counting the number of passes through the laminator proved to be confusing at times. Especially when I am "multi-tasking" (boiling the kettle for hot water, prepare the acid bowl, etc).
To ensure that I no longer miss a count, I decided to build a simple counter to keep track of the number of passes :) :) :)
- The counter had to be build with components I had at hand.
- Must be self-powered.
- Self-contained PC Board design. I did not want to put the project inside an enclosure.
- No loose wiring.
- The 7 Segment displays were salvaged from an old abandoned project. They are common cathode types.
- I decided to make use of surface mount components as much as possible. This was more for the practice of working with SMD components.
- Chip selection was the ATMEGA8 or ATMEGA328p. I decided on the ATMEGA8 as I have several of these due to an incorrect order on eBay (my mistake). Code is compatible with both.
- Buttons selected was 2 x 12mm tactile switches. Due to their larger size, they are easier to use.
! ! ! NOTE ! ! !
The 7 Segment displays looks quite dim in the picture. This is due to the multiplexing of the display. The display is in fact very visible.
Step 1: Power Supply
Because the project uses 7 Segment displays, alkaline batteries will work the best to power the project. The only PC Board mountable battery holder I had, was for a 9V battery. Thus I opted for this as the power source.
The power supply consist of an on-board battery, On/Off switch, followed by a reverse polarity protection diode. Smoothing capacitors on the input side of the regulator is not crucial, but must be rated for at least 16V.
I used a ASM1117 5V SMD regulator, but it can be replaced with a 7805 1A regulator.
Smoothing capacitors on the output of the regulator reduces high frequency noise (0.1uf), and the 100uf reduces voltage ripples caused by the 7 Segment displays switching on and off.
Step 2: 7 Segment Display
The displays are connected in parallel with each other, except their common cathode connections. Thus, segments A .. F are common to both displays.
Display data will be placed on the A .. F lines, one display at a time. The common cathodes are used to select on which display the data will be displayed. This is done via the two NPN transistors and CC_L and CC_R lines. This is called multiplexing, and switching between the two displays are called strobing.
The decimal points does not serve any purpose, but I decided to make them available through DP_L and DP_R lines. They are not connected together as the A .. F segments.
Refer to the attached datasheet for the display connections.
Step 3: The Processor
The processor part consist of four parts:
The circuit board and software is compatible with the following processors:
7 Segment lines
The micro is set up to have 11 outputs for the display:
- 7 for the A .. F segments
- 2 for the strobe lines (CC_L and CC_R).
- 2 for each display's decimal point (DP_L and DP_R).
Two buttons are used to count up or down:
- Pressing the left button will increase the counter.
- Pressing the right counter will decrease the counter.
- Pressing any button for more than 2 seconds, will reset the counter to zero.
- Note that there are no pull-up resistors connected to the buttons. In software, I have enabled the internal weak pull-ups for the two button inputs.
For both chip options, the oscillator consist of the same parts:
- 16MHz low-profile crystal
- 2 x 22pf loading capacitors.
Step 4: Designing the PC Board
The PC Board was designed using the freeware version of Cadsoft Eagle.
- PC Board is a single sided design.
- All components are mounted onto the PC board, including the 9V battery and holder. No external components or connections are required.
- To make the top of the PCB as clean as possible, all surface mount components are placed on the solder side (bottom) of the PC Board.
- Wire jumpers are hidden beneath components for a cleaner look.
I use the following method to make PC Boards:
- The PC Board image is printed on Press-n-Peel using a laser printer.
- The Press-n-Peel is then placed on top of a clean piece of PC Board, and secured with some tape.
- The PC Board image is then transferred from the Press-n-Peel to the blank PC Board by passing the board through a laminator. For me, 10 passes works best.
- After the PC Board cooled down to room temperature, the Press-n-Peel is slowly lifted from the board.
- The PC Board is then etched using Ammonium Persulphate crystals dissolved in hot water.
- After etching, the blue Press-n-Peel and black toner is removed by cleaning the etched PC Board with some acetone.
- The board is then cut to size with a Dremel
- Holes for all the through-hole components are drilled using a 1mm drill bit.
- The On/Off switch and tactile buttons are drilled larger, using a 1.2mm drill bit.
- The battery wire connections are drilled using a 1.5mm drill bit.
- The battery holder is placed in position, and two 3mm holes drilled for the mounting screws.
Step 5: Placing Components - Solder Side
Start by soldering all the SMD components to the bottom of the PC Board first. This will ensure a flat and stable top surface while placing the SMD components.
- Apply solder paste to each component pad. I use a Magnum MD100 applicator.
- Using tweezers, place each component on top of the solder paste.
- Ensure correct polarity of the 1N4007 diode.
- Using a fine-tipped soldering iron, solder each component to the PC Board.
Step 6: Placing PC Board Jumpers
Solder the six jumper wires into place before the rest of the components..
- For a cleaner PC Board look, all the jumpers have been placed underneath components.
- There are four jumpers underneath the 7 Segment displays.
- There are two jumpers underneath the ATMEGA IC socket.
- Jumpers can be insulated or non-insulated wires.
- These MUST be soldered in place BEFORE the components are soldered into place.
Step 7: Placing Components - Component Side
Start by soldering components by height Start with lowest components first..
- Solder crystal into place first.
- Add the two tactile switches.
- Add the IC socket.
- Add the programming header.
- Add the On/Off slide switch.
- Add the 100uf capacitors.
- Before soldering the 7 Segment displays, test fit them, and see if they fit flush on to of the jumpers. If not, file down their edges for a nice fit.
- Cut the battery holder leads shorted, and solder them into place, making sure of the correct polarity.
- Lastly, secure the battery holder into place with two screws.
Step 8: Testing the Circuit
Before inserting the ATMEGA chip, test the completed PC Board.
- Insert the 9V battery into the battery holder.
- Switch the power on with the slide switch.
- Measure and confirm 9V to be present on the input of the voltage regulator. If the 9V is not present, ensure correct polarity of the 1N4007 diode.
- Measure and conform 5V on the IC socket. (Pin 6 positive, pin 7 negative).
- If measurements are correct, turn off the switch, and inset your ATMEGA chip.
Step 9: Programming the Counter
The chip can now be programmed using your own favorite method.
I am using an Arduino with a programming shield. See my Arduino UNO as AtMega328P Programmer on how to make one, and use it.
Programming the Chip
- When programming the ATMEGA 'in-circuit', power the board from the 9V battery, and NOT the programmer.
- In the Arduino IDE, select your desired chip (ATMEGA8 or Arduino Uno for the ATMEGA328p).
- Next, burn the bootloader onto the chip. This will ensure that the ATMEGA cofiguration fuses are set correct for use as a stand-alone circuit.
- Lastly, upload the sketch using your Aduino Uno as programmer.
If all went well, your counter will restart after programming, with zero on the display.
Step 10: Final Steps
After testing the counter, prepare your counter PC Board to be used safely as a stand-alone unit.
- Remove the 9V battery from the battery holder.
- Clean the PC Board using PCB and Flux remover. Use an old toothbrush to get rid of stubborn flux.
- Clean the PC Board thoroughly under running water.
- Use compressed air, or a hair drier, to dry the PC Board and components thoroughly.
- Spray 2 - 3 coats of clear lacquer on the bottom of the PC Board, allowing the lacquer to dry completely between applications. This will protect the copper tracks and solder points from short circuits during use.
- After the lacquer has dried completely, add four rubber feet to the PC Board. Space has been provided for screw mounted feet. Or just stick on some self-adhesive rubber feet.
- Reinstall the battery.
The Up/Down counter is now ready for long term use.