Go Down

Topic: 4 Digit 7 segment LED Display Question (Read 8975 times)previous topic - next topic

Chris7777

Apr 04, 2012, 11:49 am
I was at my local electronics store today and I was going to buy a 1 digit 7 segment display but I spotted the 4 digit one for only a bit more so I went for it. I have a question about displaying different numbers on different digits.  Turns out it's a Common Cathode version if that matters. It took me a while(read lots of googling) to get it wired up right and kinda working. I didn't want to just grab some code or a library; I wanted to play around with it myself to better understand it. Right now I have it wired up to just use two digits with one digit displaying a bar at the top and one a bar at the bottom. This is working but I can see just a faint bit of bleed over, for example the digit with the bottom bar on has its top bar on ever so faintly. What I wanted to know is, is this par for the course when powering a display this way or is my code not the best?

My Code is following some sudo code I found here http://forums.adafruit.com/viewtopic.php?f=25&t=20305
In loop():
(1) All four cathodes high
(2) Desired anodes for the first digit high
(3) Cathode for first digit low
(4) Delay
Repeat for digit 2

Code: [Select]
`void setup() {                  pinMode(7, OUTPUT);    pinMode(2, OUTPUT);  pinMode(10, OUTPUT);    pinMode(12, OUTPUT);  }void loop() {  // pins 10 and 12 turn on the whole digit: HIGH is on  // pins 2 and 7 turn on the top and bottom bars: HIGH is off     // Turn the Digits on  digitalWrite(10, HIGH);     digitalWrite(12, HIGH);     // first digit, turn top bar on  digitalWrite(7, LOW);      digitalWrite(2, HIGH);        // Turn off the Digit  digitalWrite(10, LOW);    // sleep  delayMicroseconds(10000);      // repeat for digit 2   digitalWrite(10, HIGH);     digitalWrite(12, HIGH);     // second digit turn bottom bar on  digitalWrite(7, HIGH);      digitalWrite(2, LOW);        digitalWrite(12, LOW);  delayMicroseconds(10000);}`

Thanks
Chris

dean8020

#1
Apr 04, 2012, 01:15 pm
Hello,
Quote
it's a Common Cathode version if that matters.

Yes that does matter as it changes how you control the digits.

Quote
Code: [Select]
`// pins 10 and 12 turn on the whole digit: HIGH is on`

From this I assume pins 10 and 11 are connected directly to the common cathode of each digit?
If that is the case, as the cathode connects to ground, LOW would be on not HIGH.

And the same is true for the Anodes, they connect to positive supply, so HIGH is on and LOW is OFF.
Although having said that, the code seem's to be in the correct order, just your comments are wrong.

Code: [Select]
`// Turn the Digits off  digitalWrite(10, HIGH);     digitalWrite(12, HIGH);     // first digit, turn top bar on  digitalWrite(7, LOW);      digitalWrite(2, HIGH);        // Turn on the Digit  digitalWrite(10, LOW);    // sleep  delayMicroseconds(10000);`

I'm not sure about the leakage, but if the digital output for the segment that is off, is still turning off when the digit is turned on, it may appear feint.

I would try adding a very small delay between setting the segments and switching the digit on.
Or of course wait for a more conclusive answer from an expert

Just what I would try while waiting

Dean

Grumpy_Mike

#2
Apr 04, 2012, 01:20 pm
You need to post the schematic of how you have wired it up.
It sounds like you have no current limiting resistors and you are trying to drive too much current through the arduino pins, thus damaging it.

Chris7777

#3
Apr 05, 2012, 01:30 am

Thanks for the input Dean

I think I am wrong, I think the display is a Common Anoid, the part number on the display is AECE-5461AHO(O might be Zero tho)
I found this datasheet http://www.datasheetarchive.com/indexdl/Scans-004/Scans-0081690.pdf
which from the datasheet shows the A on the end of the part means it should be a Common Cathode however it seems to behave more like a Common Anoid,
I provide HIGH/Voltage to turn on the digit and then LOW/Ground the pins for each segment of that digit I want to light up. Or do I have that backwords?

I have included a schematic of how I have it hooked up.

Another question from that pseudo code I was using is why do I have to turn on all Digits to HIGH( ie "(1) All four cathodes high"), why cant I just send power to the one digit I want to light up, ground the pins/segments I want to make the number and move on to the next digit or change the current digit again? I messed around with that code trying different settings and I just cant make it work, any ideas?

Thanks
Chris

dean8020

#4
Apr 05, 2012, 02:06 am
Hi,

A quick test to see if it is common cathode or anode, as the pin out is the same for both models on the data sheet,  Connect 5v, through your resistor, to pin 1 of the package and gnd to pin 12, if a segment lights up it is common cathode, if not swap the connections (5v to 12 ground to 1) and the segment should then light up and it is common anode.

I am confused as to how you have wired it up though,
Either it is wired differently to your diagram or it is not the correct datasheet or the pins are numbered in a very unconventional way.

You say you have the top bar and bottom bar active, using pins 2 and 7 of the arduino.

The top bar is segment 'A' and the bottom segment 'D' on pins 11 and 2 of the display, the package in the data sheet is 12 pins (1 row of 6 each side) so pin 11 and 2 should be on opposite sides to each other...

dean8020

#5
Apr 05, 2012, 02:16 am
Also:

Quote
Another question from that pseudo code I was using is why do I have to turn on all Digits to HIGH( ie "(1) All four cathodes high"), why cant I just send power to the one digit I want to light up, ground the pins/segments I want to make the number and move on to the next digit or change the current digit again?

The pseudo code was written for a common cathode device.

Digits are controlled by the cathode, segments by the anodes.

Setting "(1)All four cathodes high" turns off all of the digits. As a cathode needs to be LOW to be on.
You then select your segments for the digit you want to make your number on.
Then set that one digit LOW or 'on' to display the number.

Then you move on to the next digit and start by ensuring all the digits are turned off before you set segments, if you left a digit turned on (Cathode LOW) and set up the number, the digit that was left on would be displaying it rather than the one you wanted.

So essentially you are
Quote
sending power to the one digit I want to light up, ground the pins/segments I want to make the number and move on to the next digit

Just in a slightly different order. And grounding segments is done to common Anode devices.
I think the confusion will lift slightly once we establish for certain which type of device you have.

Is pin 1 marked on your package? as it is not on the data sheet, and it is important to know that before doing the check.

Chris7777

#6
Apr 05, 2012, 02:36 am
Hi Dean

I did the test, and a segment lights up on the first(far left digit) with 5v to pin 12 and ground to pin 1( 5v to pin 1 and ground to pin 12 does nothing). So I guess it is a Common anode, very strange why the datasheet is wrong, who knows maybe its old.

You are right in that I did change up the wiring, to make it a bit simpler for me to wire up to the bread board I changed it to light up the bottom bar and the middle bar. Which is pin 2 and 5 respectably.

I am still working on getting different numbers to show up. Then I wanted to use a 595 shift chip to control it, tho from what I understand it cant handle the amps to power that many LEDs. So I will need to wire up a different transistor(TIP-122 or 2n2222) for each digit to switch the power on and use the 595 to control the ground or will that will pull too much current?

Thanks
Chris

Grumpy_Mike

#7
Apr 05, 2012, 09:54 am
You need a resistor not in the common connector but in each of the other side. I am not sure what you have got but if it is a common anode you need resistors in each of the seven cathodes.
Are you going to multiplex them? I think you need to in order to get diffrent numbers to be shown on the four diffrent displays.

dean8020

#8
Apr 05, 2012, 04:36 pm
Hi,

The code you were using was for common cathode, as you have common anode firstly:
Quote
you need resistors in each of the seven cathodes

And secondly the code needs altering to:

Code: [Select]
`void setup() {                  pinMode(7, OUTPUT);    pinMode(2, OUTPUT);  pinMode(10, OUTPUT);    pinMode(12, OUTPUT);  }void loop() {  // pins 10 and 12 turn on the whole digit: HIGH is on  // pins 2 and 7 turn on the top and bottom bars: HIGH is off     // Turn the Digits off  digitalWrite(10, LOW);     digitalWrite(12, LOW);     // first digit, turn top bar on  digitalWrite(7, LOW);      digitalWrite(2, HIGH);        // Turn on the Digit  digitalWrite(10, HIGH);    // sleep  delayMicroseconds(10000);      // repeat for digit 2   digitalWrite(10, LOW);     digitalWrite(12, LOW);     // second digit turn bottom bar on  digitalWrite(7, HIGH);      digitalWrite(2, LOW);        digitalWrite(12, HIGH);  delayMicroseconds(10000);}`

Using the code you were with a common anode display means, you were indeed switching all digits on, setting the bars then turning off the one you actually wanted to display it on.
So the bars were probably displaying on the opposite digits than you intended.

With the code above, everything should make sense?

(1)Turn off all digits
(2)Set up segments to display
(3)Turn on digit to display number

And I imagine the feint bar should now disappear, before you were turning the bar on just before you switched the digit off every time (hence it coming on for a tiny amount of time and appearing dim).

In terms of the 595, I am only just exploring this myself so I can't really offer any advice on that yet, but with that display (4 Anodes, 7 Cathodes) you can control the entire display from the Arduino to get the multiplexing sorted before adding the extra complexity of a shift register?

#9
Apr 05, 2012, 04:50 pm
"In terms of the 595, I am only just exploring this myself so I can't really offer any advice on that yet, but with that display (4 Anodes, 7 Cathodes) you can control the entire display from the Arduino to get the multiplexing sorted before adding the extra complexity of a shift register?"

No. You can use the arduino to source current to segments (with a current limit resistor per segment) but you need a ULN2003/2803 type part, or 4 transistors, to sink the combined 140mA that could go thru each segment. The Arduino cannot sink that much current.

Or, limit the current sourced to each segment to 20/7mA, ~3 to 4mA, then an Arduino pin can sink the common cathode current.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Chris7777

#10
Apr 06, 2012, 01:56 am
Thanks for the help with the code dean, I think the faint bleed over went away, it looks like it but I will know for sure tonight when its darker. I was also able to reduce the huge delay timing from 10000 to delayMicroseconds(500) and it works just fine.

As for the 595 I was thinking of using 4 TIP122 or 2n2222 transistors to provide the power to the digits and a special high power 595 to ground/sink the current too. You can buy it here from adafruit http://www.adafruit.com/products/457
Has anyone tried that chip before or is there a better way to go about powering all 4 digits?

Also CrossRoads you said I would need "4 transistors, to sink the combined 140mA" I am still new to this but if the transistor is turned on and switches current from say a 5volt source/collector would that transistor be sourcing the current to the display digit?

Thanks
Chris

#11
Apr 06, 2012, 03:40 am
Here's what I am describing:
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Grumpy_Mike

#12
Apr 06, 2012, 03:39 pm
Quote
if the transistor is turned on and switches current from say a 5volt source/collector would that transistor be sourcing the current to the display digit?

Yes that is the correct way of saying it.

rilesjenkins

#13
Feb 09, 2013, 06:12 am
I just worked this one out for myself. I was working on a timer and you could see the least significant digit of the seconds changing faintly on the display for the most significant digit. I'm not certain how your circuit is designed but I wired each segment in series, so that each segment is driven by 1 output for all displays (ie the decimal segment on every display is controlled by one output). The common annode for each display is then connected to its own output. My strategy was to activate the segments one at a time and output the given segment values for the corresponding display. In your case, I would activate the first display, turn on the top segment, then change to the second display, turn on bottom segment, and repeat. Something like this:

seg1 active
seg2 inactive

top on
bot off

seg1 inactive
seg2 active

top off
bot on

This caused bleeding for me, and I eventually realized it needs to look more like this:

seg1 active
seg2 inactive

top on
bot off

top off
bot off
seg1 inactive
seg2 active

top off
bot on
top off
bot off

So basically, you activate one display, display the required value, clear the display, then switch to the next one. Looping fast enough makes the displays look constant and the clearing of the display with every iteration prevents bleeding. Sorry this post is too late, hope it helps anyone else working on the same issue.

Jay98

#14
May 06, 2015, 07:09 pmLast Edit: May 06, 2015, 07:48 pm by Jay98
disregard this found it was my mistake, and sorry about the necro post

Go Up