Interface Arduino to a common anode 7 segment display


#1

I’m trying to interface an Arduino to a 7 segment display with 6 digits all configured as common anode.
This means that positive 5 volts needs to be on the column and ground on the segment.
The board has built in resistors and works on 5 volts fine.

My current idea is to use a 74LS138 3 to 8 decoder from the Arduino for the columns.
It is inverting outputs meaning that it would need to be inverted before it would work.

So, could I just put a 74LS04 Hex Inverter on the output of the decoder and then attach some mosfet based circuit to give the 160mA or so required to power the 8 leds that might be on at once?

Then I could just sink the segments into GPIO pins to select which segments are on. LOW = ON (Max one led)

Is there a better way?

Tagging @artg_dms but I welcome anyones input


#2

I don’t have specific answers but it sounds like you will be awesomely prepared to teach a class on the subject when you finish.


#3

You will need a transistor for each of the digits because the 74LS138 cannot source enough current for seven segments or eight if you include a decimal point. Using a PNP transistor or P-channel MOSFET automatically inverts the logic.

You can sink the segments directly if only one digit is lit at a time.


#4

If you just want to display numbers on the 7 seg? Oh yes, a far better way. Look at a 7447 or a 7446 (can’t remember which is a CA and which is CC).

If you need to display hex as well then there are some parts that do it, but I don’t know the part numbers off the top of my head.


#5

If I remember our discussion and understand your circuit, the following should work - at least in theory :wink:
P channel fet high side switch.
Some theory:


A possible part (note Supertex is now part of Microchip):

Some important circuit notes:
For the 74138, use the 74HC138. This is the CMOS version of the part. CMOS output swings rail to rail whereas TTL has an offset. The inverted / active low output of the 74HC138 will be inverted by the P channel fet. A logic low (ie gnd) on the fet’s gate will turn on the fet on. A logic high (ie +5v) on the fet’s gate will turn the fet off. This assumes that everything is running off a single pwr rail of +5 volts.


#6

Consider getting one of these:

It may be less expensive and is more compact than rolling your own.


#7

Note that since you are using a microcontroller, you can implement the 74LS138 as a function in the arduino. And you would have flexibility to add hex and octal, etc.

The 138 let’s you get away with 3 external pins to control the 7-segment display. If one implements the 138 in the microcontroller, 8 external pins will be needed.


#8

Yes, or in this case, 6, because their are only 6 columns. I’m still researching the board that @Bill posted to see if it can do what I want


#9

Good idea but I don’t think it will work. It looks like it expects common cathode displays and expects them not to have a resistor built in. Also, I would like to PWM in some manner individual segments and this seems to only dim the entire panel row.


#10

Would this work instead of an inverting decoder? Looks like this is non-inverting but CMOS and only $0.51 for 1.
I just need to figure out the P-Channel and N-Channel MOSFet parts now for the in and out.

https://www.arrow.com/en/products/cd74hc238ee4/texas-instruments


#11

From

http://www.ti.com/product/CD74HC238

The 238 is a 138 with inverted outputs.

A P-channel MOSFET conducts when the gate is low while an N-channel one when the gate is high.

Edit: corrected


#12

What about http://www.ti.com/lit/ds/symlink/cd4543b.pdf?


#13

I thought about using this and it might be a good choice if you just want to display numbers.
I’m wanting to do effects as well and be able to dim each segment independently.
This will need to be done inside the Arduino in the code but each segment needs to be addressable.


#14

I would avoid these part numbers as they can be difficult to find these days.


#15

'238 has active hi outputs ie noninverted
'138 has active lo outputs ie inverted.
HCT/ACT family is CMOS w/ TTL compatible inputs.
Generally good design practice says don’t mix TTL and CMOS parts.
Pick a family and use throughout the dsign.
Here’s a TI design guide. Includes a table on which families can drive what.
http://www.ti.com/lit/sg/sdyu001ab/sdyu001ab.pdf
This may be of interest to those designing w/ different voltages in their system:: Voltage translation guide:
http://www.ti.com/lit/ml/scyb018h/scyb018h.pdf

Got your P and N backwards. See pg 1 of app note


#16

You have a good idea there, but it will require plenty of pins, and constant refreshing within your code.
Here’s a chip that can be used to drive 8 7-segment displays or an 8x8 matrix LED display. Max7219
Here’s a module from Ebay with an 8x8 led matrix and the chip: https://www.ebay.com/itm/222709799381
I ordered a couple to play with.
Searching Ebay with “MAX7219” will return plenty of example modules…
https://www.ebay.com/itm/113552174776


#17

Oops! You are so right.


#18

Well, the Arduino Uno uses the ATmega328P which is a CMOS part. So, best to stick with CMOS.


#19

I really like that chip, except it is targeted to just numbers (& a few letters) and is for common cathode panels.