This display comes in very handy if you work with the ADC function of micro controllers.
It only needs two pins to control the display (three if you would like to control latch too). With two seven segments it can display up to 0xFF as hex. That is the whole 8bit range, what is the most used variable-width for small uCs.
I built it because the final application doesn't have a display and I wanted to know what's happening before I finished it.
You need two 74HC959 shift registers, two seven-segment displays and 14 (16) resistors You need 16 if you want to use the dots, which are not implemented in the software. But using the dots would expand the displayable values to 10bit or 0-1027. I leave it up to you to figure this out.
Step 1: The Schematic
We use two 74HC595 shift-registers to interface the seven segment displays. Whether you use common anode or common cathode 7-segments you have to adjust the circuit. I used common cathodes. What means that each segment is one green LED and the cathodes of all LEDs are connected together. (Pins 3 and 8 of the 7-seg. display)
The shift registers work this way:
Each time you apply a pulse at the shift input, the current state of the serial input pin is shifted in the memory of the 74HC595. Each time a pulse at the latch input arrives the state of the internal memory is used to drive the outputs.
After 8 shift cycles the first input is shifted out at pin9 again and could be used as an input to another 74HC595. This is also called a daisy chain.
The 74HC595 can drive up to 70mA in total, so we have to adjust the resistors in a way that the current through each LED-segment stays below 9mA, which is about 470 Ohm for 5V and the used displays.
Step 2: The Shift Register 75HC595
A look to the picture tells you which pins you need to connect.
The pins are counted anti clock wise starting from the mark on the IC if you look at it from the top.
Connect pin 1 - 7 and pin 15 to the pins of the 7-segment.
Pin 8 and 13 must be connected to ground (GND or negativ terminal of battery)
Pin 9 is connected to pin 14 of the next IC.
Pin 10 and pin 16 must be connected to the supply voltage (VCC or positive terminal of battery)
Pin 11, 12 and 14 are the interface to be driven by the microcontroller, connect these to the three pin pinheader for external interfacing.
Step 3: Built the Display
Although it would have been possible to etch a custom circuit board, I chose to built the whole thing on breadboard with thin copper wire.
This copper wire is coated, but the coating could be burned down with a bit of molten tin. It is very easy to make connections with it. Just tin one end, solder it to the pin and then stretch it to the other pin and burn the isolation where you want to solder it. Then solder it to the pin and cut the rest. A 30W soldering iron like this from Craftsman is more than enough for the job.
I used small 1206 SMD resistors, because these fit nicely beneath the seven segment displays.
But after all, you need to make up the board by yourself and you can of course also take any resistor you like.
Step 4: Find the Order of Segments
Finally we have to write the functions to display something meaningful.
The main problem is now to find the right segment - control sequence. At first try to push a single 1 through the whole shift register.
Apply a high to the serial input and pulse the shift one time. Now pulse the latch one time and see which segments lights up.
If you then hit the shift and latch button again, the next segment will light up and so on.
Finally you have the order of all the segments and you can transfer them into binary numbers.
Step 5: Write the Code
If you wired up the board differently, you might have to adjust the segmentcontrol array.
To use it, you need to adjust the pin-defines in the file debug.h (first 12 lines).
In the main application you need to add the following lines:
initdebug(); // This initialises the Output ports specified in debug.h
Then you can display any 8bit variable by just calling the debug function with it. say the variable is called counter, then the current value of counter is displayed by:
- Add some delay time after the call of debug() to have time to read the value.
- When you connected shift and latch together, just define the two ports for the same pin. Each time the shift is triggered it also latched out the current state, that means the display flickers while the shiftregisters are loaded. If you do this fast compared to the time that you let the display stay it's o.k.
- To display a 16bit value either divide it by 256 and display the result or separate the high byte and the low byte and display them one after another with a small brake in between.
Step 6: Test It
The program of the embedded video just counts from 0 to 0xFF and back again.