Following on from the previous project, I have been asked to look at updating this project to drive two 7 seven segment displays instead of one seven segment display. So, instead of taking av4 bit binary input (0000 to 1111) and driving a single 7 Segment LED display with values from 0 to 9 and A to F; the plan is now to read 8 bit of binary data (00000000 to 11111111) and output corresponding hex value (00 to FF).
This is now makes this project and ideal tool that can be used on the retro computer build. As one of these circuits could be used to read the data bus while two could be used to read the address bus.
It does mean that we need to change the way the existing project is wired. The PIC controller only has 16 inputs/output pins. If we are to read the 8 bit binary data this leaves only 8 pins for driving the output and reading the control lines. As the 7 segment LED displays need 7 lines (8 if we include the decimal point) we need to look at an alternative way to drive the LED displays.
If we use a serial to parallel shift register we could drive 8 lines from just a clock and data line, by using a third pin we can enable/disable the shift register. This will let us drive all seven segments plus the decimal point. This solves the first issue of driving more lines from less pins on the PIC micro controller.
The next issue, is how do we drive two 7 segment displays. This can be achieved by multiplexing the display. By this I mean we light up one display with the segments required, then we switch on the other display and light up the segments on that display. By switching on the segments on the two LED alternating, we can give the appearance that both displays are on at the same time.
In the above circuit we can see we added a busy line to the circuit to let external circuits know when the decoder is busy updating the display.
The external circuit only needs to place the 8 bit data on the data bus, bring the enable pin low and then bring the write line low. The resistors on port A provide pull up logic, to ensure the data lines are not floating and are in a known state. The PIC micro controller has internal weak pull up resistors, so the resistor network RN1 may not be required, we will only know when we start testing.
Lets look at how this is going to work…
As this circuit will be used to drive LED displays which tend to be consume power, we don’t need to worry too much about power consumption, but lets not just ignore it, we still want to be as efficient as possible. With this in mind, the PIC micro controller will be using its internal oscillator of 4MHz. We could use an external 20MHz crystal / resonator, to allow for faster speeds. As we want to keep the costs down, there is no need to add parts that are not required. As the LED displays are used to display the result to us humans, we don’t need a fast refresh rate for the HEX display. So if the refresh rate is set to 100Hz it should provide a good display results. When the display is not getting updated the PIC should power down into standby more.
First we need to read the input and the control lines, when both the WR (Write) and EN (Enable) go LOW, the micro controller will set the BUSY pin active (LOW) and then read the 8 bit input. When the controller had saved the value to displayed, it will then set the BUSY pin inactive (HIGH).
A timer interrupt will activate every 10ms, the BUSY pin will go active (LOW) to indicate to any external circuit that the controller is refreshing the displays. Once the controller has finished refreshing the display it will the BUSY pin as inactive (HIGH).
When the PIC has the 8 bit data word, it will be broken into two 4 bit nibbles. Each 4 bit nibble will then be converted to a hex value. As the conversion for each nibble is the same, we can simplify the process by converting the first 4 bits from the right to our HEX value, then we shift right the word by 4 bits and cover the first 4 bits from the right to our HEX value. This means we can keep the routine from the previous project for converting our input to HEX.
Once we have the HEX output we can send it one bit at a time into the serial to parallel shift register. The 74HC164 IC the devices that we are using in this circuit, as it is low cost and simple to use. The A & B inputs will be tied together to ensure that we are sending the same data to the into the shift register.
The active low clear pin will be used to reset the IC while the CLK pin will be used to clock data into the shift register. Once we have clocked the data in, we then switch on the relevant 7 Segment LED display, to show the result.
The above table shows what segments of the LED display should be switch on to display the various values from 0 to F.