Go Down

Topic: 7-Segment Display Wiring and Programming (Read 66 times) previous topic - next topic

guitarboy667

Hey everyone, I was wondering if someone could help me figure out how to wire and eventually program two 7-segment displays of 4 digits each. I'd like to learn about it as I go.

Here is the data sheet for the 7-segment displays:
http://www.us.kingbright.com/images/catalog/SPEC/SA18-11EWA.pdf

I'll be using an Arduino Mega, but I assume I'll need bit registers or something like that? Thanks for your help!

BKnight760

7 Segment displays are fairly easy.

You'll need 7 I/O pins for each digit if you do it without an additional components.

Otherwise, pick up a shift register from Sparkfun.  You can then drop the I/O requirements significantly.

The datasheet shows that each of the seven segments on the display are labeled as a,b,c,d,e,f,g and dp (decimal point).  Apply a voltage to pin 1 or 5, and the apply a voltage to the pin for the segment which you want to turn on.  Pretty easy.

The trickier part will be wiring up your shift registers correctly, as you'll have a mess of wires for 8 digits (8x7 = 56 wires minimum).

You'll likely need to write some code that extracts a single decimal digit from an integer and figures out which display it goes on.

Si

Hi, there is 2 digit 7-segment display example in my book.

http://www.arduinoevilgenius.com
--
My New Arduino Book: http://www.arduinobook.com

guitarboy667

So apply a voltage to the segment I want to light up and have it all connected to a common ground? Does the Arduino even have enough power/current for this?

How would I wire it with a shift register and which should I use?

Si

The mega has lots of pins for this, you can use a pin per segment.

It can also provide up to 40mA per output, so thats fine too as you should probably aim for about 10mA per segment.

You will need a series resistor for each segment.
--
My New Arduino Book: http://www.arduinobook.com

BKnight760

#5
Dec 08, 2010, 11:25 pm Last Edit: Dec 08, 2010, 11:26 pm by BKnight760 Reason: 1
Quote
How would I wire it with a shift register and which should I use?


Here's a shift register from Sparkfun... costs about $1.50
http://www.sparkfun.com/products/733

Read the datasheet on it and it will explain how to use it.

Basically, you connect it to the serial connection on your board, and then supply it with power and ground.  Each time you send a byte on the serial connection, it shifts it into the register (1 byte = 8 bits).  Until you send it another byte, those 8 bits will remain set.  So, you just send a byte representing the digital outputs you want to turn on/off.

Code: [Select]

Hex       Binary
0xFF = 11111111       This turns all 8 outputs of the shift register on.
0x00 = 00000000       This turns all 8 outputs of the shift register off.
0xAA = 10101010       This turns every-other output on.


So, now, all you have to do is connect each of the 8 shift register outputs to one of the segments on your display.  (Remember to connect the display to ground as well.)

CrossRoads

#6
Dec 09, 2010, 07:02 am Last Edit: Dec 09, 2010, 07:03 am by CrossRoads Reason: 1
The datasheet you submitted is for a common anode part.
If this was a typical 7-segment display, the way it is usually used is that the commone anode, pins 1&5, are connected to 3.3V or to 5v.
Then a current limiting resister of say 330 ohm is connected from each of the segment leads to an output pin on the arduino (or, to a shift register output pin). When the pin is low, the segmet will turn on. When the output is high, it will turn off (as both sides of the LED are now high).

However, your part has 3 LEDs per segment, so it will need a higher voltage, the spec sheet shows 6-7.5.
For that you will need a part that can withstand a higher off voltage and not be damaged, such as
a tpic6b595 open drain shift register, which can take 50V.  Or, put an NPN transistor at the bottom of each cathode, which is basically what the output of the tpic6b595 has.

There are some other open collector/open drain parts as well.


Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

guitarboy667

I'm sorry, but that last explanation went a bit over my head. I think I understand how the shift register works. I'd still have to figure out how to convert the numbers that have been calculated into signals to be sent to the shift register though.

So I won't be able to power the 7-segment displays with the Arduino no matter what? That's fine, but the diagram confused me. Is there 2 shift registers per digit or are those the digits themselves? I think I see transistors there, so that would make them seem like the digits, right? Can all 8 be hooked up off that 18 volt power supply? Idk what the D arrow things are and I'm still working on calculating the resistance there. Sorry for all the questions. I'm trying to get it.

Also I believe the Arduino mega has only 4 (or is it 3) transmitting serial pins. Is there a way around this? I know that Sparkfun has a 4 digit display hooked up to a single serial output, but I wanted larger digits.

MarkT

Quote


Here is the data sheet for the 7-segment displays:
http://www.us.kingbright.com/images/catalog/SPEC/SA18-11EWA.pdf

Those LEDs take over 7.5V to drive - do you realise this?  The common anodes will require a driver circuit each that takes logic levels up to the appropriate supply voltage (9V would be an obvious choice).  LED displays compatible with 5V are much simpler to drive.
[ I won't respond to messages, use the forum please ]

CrossRoads

Okay, I may have two posts mixed up. But not totally. I had 6 LEDs strings & 18V supply on the mind from something else.

Did you look at the internal schematic for your part? The segments all have 3 LEDs in series. 5V from an arduino will not be enough to turn them on.  You will need to apply a voltage of >6V to  pins 1&5 for all the digits, then individually apply a logic low (close to 0V) to turn an individual segment on.


When a segment is not on, the bottom of the last LED will go up to whatever voltage you are suppying them with and blow up the output of the arduino or standard shift register if that is above 5V.

To turn the segments on, you will use the shiftout command with 1s & 0s.
The shiftout command looks like this
shiftOut(shiftdataout, serialclock, MSBFIRST, outdata);
where shiftdataout is the pin that data is coming from on the arduino.
serialclock is the clock line from the arduino,
MSBFIRST indidatces bit 7 goes first,
and outdata is the 8 bits you want sent out.

If for example your shift register bits were wired like this:
Output 0 = segment A
O1 = B
O2 = C
O3 = D
O4 = E
O5 = F
O6 = G
O7 = decimal point

Thus to send out a "1" character, you set outdata to
(bit # / segment -on/off)
0/a-off
1/b-on
2/c-on
3/d-off
4/e-off
5/f-off
6/g-off
7/dp-off

outdata would be set to 0b11111001 if you had a shift register that could handle >5V on its outputs,  such as the tpic6b595. The 2 zero bits would result in low outputs for O2 & O3 to turn on segments B & C.
On the other hand, if you used a standard shift register and added transistors to its outputs to control the LEDs instead, such as the last schematic I posted (where I showed 6 LEDs instead of 3 by accident), then you would shift in 1's to turn on the transistors; outdata would be set to 0b00000110.  The two 1 bits would turn on the 2 transistors for segments B & C and turn them on.

You will need 1 shift register per digit. The >6V supply will go to pins 1&5 on all the digits.

Another option is to put a part like an 74LS47 in there, which can work with up to 15V.
A shift register could supply 4 bits to each of two 74LS47s.  The '47s will decode the 4 bits into 15 characters (plus a blank state), so you coud just shift out a "1" and it will show up as 1, "2" for a 2, etc. and hex "f" to blank the display. However, you are stuck with the decode that is built in.  If you wanted characters that looked like some letters (E, h, P, n, L, A, J, C or c, etc.) you're better off with the shift register so you have more control.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

guitarboy667

But I'd need to use the serial outputs one per digit if I used shift registers right?

CrossRoads

1. You could shift out to each shift register individually (have  the data line and the clock line common to all parts, with unique load or enable lines).  Takes 10 arduino output lines.
2. You could have the data shift thru all the parts (output becomes the input to the next) and then shift out the 64 bits of data for all of them every time. Uses less pins that way. Takes 3 output arduino lines.
3. Another option is to use a MAX7221, which combines both these approaches - it has additional logic so that you are only shifting out to 1 part (uses the SPI format, ties up 4 specific output pins, D10-11-12-13).  The registers are individually addressable (you shift out an address and then the data for that address). However, it won't do 6-7.5v outputs.
You would have to add two sets of transistors - one set to switch on the 7.5V to each digit's common anode, and one set to switch the common segments lines to ground.
See Figures 1 & 4 in this application note:
http://www.maxim-ic.com/app-notes/index.mvp/id/1196
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

guitarboy667

So an output line would be a pin? If I don't need to use the serial pins for this then I don't mind taking a lot of output pins since I'm using an Arduino Mega. 10 pins would be fine, but if you need to use a serial pin to send data to the shift register then I don't believe there is enough on the Arduino Mega.

guitarboy667


CrossRoads

You will not be using the Serial Rx/Tx lines, just regular I/O lines.
Define a pin as the common data output line.
Define a pins as the common shift clock line.
Define 8 pins as the unique Strobe, or Load, or whatever it is called for the 595 variant that you are using.

Glad to help. Talking others thru these helps me get things clear in my mind for my designs as well. I don't have any shift registers handy, so I am wiring up a 74F374 as shift registers, which also comes in handy for driving (single) LEDS per output (with current limit resister) directly.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up