I am trying to create an 8 digit, 7 segment display using an Arduino, 2 4-digit displays and an 74HC138 demux. The 4 displays each have 12 pins: 4 common cathodes, 7 segments and one dot. I thought I would use 8 of the Arduino's digital pins and wire them to the segment and dot pins on the displays, and then use the of the Arduino's digital outputs to control the 74HC138 demux and use that to select the subdisplay. The IC outputs a LOW on the output pin, and so I need to wire a transistor so that it connects the common cathode to ground only when the base current is LOW. Is that correct? How would I wire the components to do that and what transistor do you recommend for this? Should I add any resistors between Arduino's +5V and the LED displays or the IC output and the base terminal of the transistor?
Build an 8-digit display using Seven-segment Display and 74HC138
arduinoled
Related Solutions
I do not believe you can reasonably run your display (or any multi-digit common anode display) using this chip. You may be able to finagle it to drive a single digit display through some creativity by hard-wiring the common anode to VCC and not connecting any of the DIG pins of the chip.
The way the chip works is that the SEG* pins "source current to the display" and the DIG* pins "sink current from the display common cathode". The way it's meant to be wired is that the common cathode of each digit on the 7SD is wired to a corresponding DIG pin and the SEG pins are wired to the corresponding anode segment pins of the 7SD. You serially load up "what should be displayed" into the memory of the chip and some configuration settings and it takes it from there.
The chip "scans" the 7-segment display for you and does this by, for each digit N:
- switching the DIG N pin to GND (and all other DIG pins to high-impedance).
- setting all the SEG pins to what is stored in its memory (optionally decoding the stored value as BCD first)
- then moving on to digit N+1 modulo the number of digits its scanning...
There's just no way you are going to be able to take advantage of the chip's multiplexing algorithm because it relies on the DIG pins driving the common cathode to GND to "enable" each digit in turn.
You could insert an inverting buffer between all the SEG and DIG pins of the chip and the display and then you would communicate with the chip and wire it up "normally" as though it was a common cathode display. Not worth it if you ask me...
I think you are making your problem a bit too complicated. You do not need the 4-16 decoder at all.
Simply deliver four output lines from the MCU board to all three of the BCD-Seven segment decoders digit input pins in common. Then wire three more signals from the MCU with one going to the enable pin on each of the BCD-Seven segment decoders. The software that you need to create with this type of display hookup will sequentially output the four bit code for each display digit in turn while activating just one of the three decoder enable signals corresponding to the digit being displayed just now.
If the display decoders that you have selected are the type without any data latch in them then you need to run this this display algorithm in a fast repeating loop. The resulting display will only have each digit actually ON 33% of the time but if you run the update fast enough the three digits will all appear to be on steady.
If the display decoders that you are using are the type that have an internal latch to hold the digit data then those three lines that go to each decoder want to be connected to the pins that cause the digit input data to be captured into the latch. Any additional enable pins on the display decoder chips can be simply pulled op or down as appropriate to keep the decoder active all the time. With this scheme the software would just do its output process three times at the time it was necessary to change the display content.
Using these schemes you have consumed a total of 4 + 3 for a total of 7 I/O lines to run your display. The use of the 4-16 decoder chip could come into play if you were to try to build a display with more digits. Say you made a 16 digit display, the same four digit data pins would be used to all 16 display decoders but unstead of 16 separate decoder enable signals from the MCU the decoder could be used to accept a separate 4-bit code that selects one of the 16 digits to update at a particular time. You could actually use this scheme for your three digit display too and only use three outputs of the 4-16 decoder. If done this way two of the 4 inputs to the 4-16 decoder would be connected to GND and then the other two inputs would come from the MCU. This would reduce your total I/O usage from the MCU to 4 + 2 = 6 lines. Above I suggested not doing this because it is probably simpler to just use the one additional I/O signal rather than wiring up a whole extra chip.
If the decode output from the 4-16 decoder is the wrong polarity to properly connect into the enable or latch control inputs of the BCD decoders then it would be necessary to wire up inverters between the 4-16 decoders and the BCD decoders. The possible need for inverters is another reason that I suggested not even using the 4-16 decoders for your three digit display. Your software can take care of the correct enable / latch polarity for the BCD decoders without having to add additional chips.
Related Topic
- Electronic – arduino – Working with a cathode-based LED seven-segment display
- Using a LS248 7-segment driver, but segments are dim. Can’t figure out why
- Problem with 7-segment display: dimly lit when off
- Electrical – 7 Segment Common Cathode LED Digit Display Circuit for Arduino
- Electronic – Charlieplexing 7-segment display segments vs segment
- Electronic – Driving 16-segment displays with MAX7219
Best Answer
Using an external decoder for digit selection is a good idea, since it will save on Arduino pins (but you'll still need 3 address pins). And you are correct that you'll need boost transistors. Connecting a decoder with active-low outputs, like a 74HC138 to transistors to provide active-low display drive is not exactly simple for beginners, since you'll need 2 transistors per channel. You can do it like this
simulate this circuit – Schematic created using CircuitLab You'll notice that it takes 2 layers of function. Since you're already buying a decoder, you can save some circuitry if you instead use the 74HC238. This is identical to the 138 except that the outputs are active high, and you can do this
simulate this circuit instead. Using the components shown, you'll have no trouble drawing 50 mA per cathode, and 100 mA is entirely reasonable.