Correct 7 segment connection

Would someone be kind enough to tell me, [ I can sense GM close by :D ] if using a 7 segment common cathode display, where you are multiplexing the display, is it necessary to have a resistor on each anode, or is it sufficient to have just two resistors on the two cathode pins. Some people suggest that if you do not have resistors on all eight anodes you will damage the controlling ic and also you will get different brightness levels depending on how many segments are turned on for any given number display. I realise that technically the brightness levels should vary but have found that in practise there is negligible difference. Thanks Pedro.

If you are only turning on one segment at a time, then you can use one resistor in the cathode. If you turn on the whole numeric digit one at once (multiple segments), then I think you will notice a dimming issue unless you put a resistor for each segment (anode).

Thanks for that answer afremont. So just to clarify if I may, if I am using this code to control the attached circuit, am I only turning on one segment at a time. Thanks for your time Pedro.

// LED Segment allocation within byte = {ABCDEFG DP}

int latchPin = 8;    // connect to pin 12 on the shift register

int dataPin  = 11;   // connect to pin 14 on the shift register

int clockPin = 12;   // connect to pin 11 on the shift register

int i = 0;

byte digit[] = {B11111100,B01100000,B11011010,B11110010,B01100110,B10110110,B10111110,B11100000,B11111110,B11110110};

void setup()

{

pinMode(dataPin, OUTPUT);       // Configure dataPin  as OUTPUT

pinMode(latchPin, OUTPUT);      // Configure latchPin as OUTPUT

pinMode(clockPin, OUTPUT);      // Configure clockPin as OUTPUT

}

void loop()

{

for (i = 0; i < 10; i++)

{

digitalWrite(latchPin, LOW);                            // Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, LSBFIRST,digit[i]);         // Send the data

digitalWrite(latchPin, HIGH);                           // Pull latch HIGH to stop sending data

delay(1000);

}

}

You have up to seven segments lit at any one time so yes, you need one resistor per segment. Also keep an eye on the current draw. The typical '595 is only good for around 70mA, that's three segments simultaneously, so either use a transistor to control each segment or use a led driver chip (I can't remember the model number!)

No, you are turning the whole number on at once. You will need a resistor on each segment anode.

Thanks for your help gents I'll fit more resistors and investigate using shift registers that can sink or source more current. Am I right in assuming that if i want to use 595 in conjunction with with ULN2803 (which sink current?) that I would have to use common anode 7 segment displays. I realise that using LED drivers is simpler than combining a 595 and ULN2803, but I am looking at this as learning how to combine different components to more fully understand how they can all work together to achieve the desired outcome. So much to learn :D

Yes, use common anode display with TPIC6B595, combines HC595 & ULN2803 into one chip.

Just a few more questions if I may. So my shift register example from reply #2 is not multiplexing because all the segments for any given number to be displayed are all on at the same time, so therefore I need to use a 595 / 2803 combination to control high current flow with a resistor on each segment of a common anode 7 seg or use a TPIC6B595 also with eight resistors (if using decimal point). The other ways that I have driven these displays is by direct port manipulation with this code and the attached 7seg_dpm circuit. I assume that this is also not multiplexed and would also require a 595 / 2803 / resistors combination or TPIC6B595 / resistors. The two circuits that I have attached have not yet been revised to include the additional resistors required.

// Because Direct Port Manipulation uses pins 0 and 1, which are the RX and TX  // pins respectively, you have to disconnect these pins when uploading the code

// LED Segment allocation within byte = {DP ABCDEFG }

int i = 0;

void setup()

{

DDRD = B11111111; // set PORTD (digital 7~0) to outputs

}

byte digit[10] = {B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011 };

void count()

{

for(i = 0; i <10; i++)

{

PORTD = digit[i];

delay(1000);

PORTD = 0;

}

}

void loop()

{

count();

}

The other method that I have used is directly from the Arduino with this code and the attached 7seg_direct_drive circuit. I am assuming that this is also not multiplexed and would also require a 595 / 2803 / resistors combination or TPIC6B595.

// Thanks to Grumpy Mike  http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

// LED Segment allocation within byte = {DP ABCDEFG }

int pins [] = {2, 3, 4, 5, 6, 7, 8, 9 };     // pin 9 allocated to DP but not used (first element of binary array in char tenCode)

int digit[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

int counter = 0;                              // initialise counter as zero

int timer = 1000;                             // delay timer interval

char tenCode[] = {B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011 };

void setup()

{

for(int i = 0; i < 8; i++)                  // set digital pins as OUTPUTS

pinMode(pins[i], OUTPUT);

}

void loop()

{

for(int j = 0; j < 10; j++)

{

displayEleven(digit[j]);

delay(timer);

}

}

void displayEleven(int num)

{

int mask = 1;

for(int i = 0; i < 8; i++)

{

if((mask & tenCode[num]) == 0)

digitalWrite(pins[i], LOW);

else digitalWrite(pins[i], HIGH);

mask = mask << 1;

}

}

I know that I am doing a lot of assuming here but how am I going, or should I just take up basket weaving XD
Thanks again Pedro

7seg_direct_drive.jpg

Both code listings do not appear to be multiplexing, and would benefit from a resistor per segment and with the CCs connected direct to Gnd. Select your resistors so the current per PORT does not exceed the port limitations of section 29 of the '328P datasheet.

Thanks Crossroads 8)

Lately I have been concerned that I have been drawing too much current from the output pins, due to my insufficient knowledge regarding maximum current limitations and general bad design on my part. From looking at Nick’s info at

http://www.gammon.com.au/forum/?id=11473

I see that as well as a max of 40, but preferable 20 mA per pin, there are also a maximum 100mA for different groups of pins, and a max 200 mA for the whole board.

I realise that you connect a multimeter in series to check the current draw but is there a specific thread on the forum or good external link that discusses this.

For example, if I wish to check the current draw in my badly designed circuit in reply # 2
[ which I realise does not have enough resistors 8) ] as per the ammeter placement in the attached Current draw 1 file, is this the correct checking procedure. Is Meter 1 showing 63 mA indicating the total current being drawn from the board by both the shift register and the 7 Seg and is the 12 Ma showing at meter 2 indicating the current draw of the Seg A of the 7 Seg. Also is the Meter 1 reading showing the total current flowing through the shift register which I believe typically has a max current allowance of 70 mA .

Also in the attached Current draw 2 circuit, where the power is being solely supplied by the digital pins, is the meter placement correct where Meter 3 showing 9 mA is indicating the current being drawn from the connected digital pin and does the Meter 4 reading of 20 mA indicate the total current being drawn from the whole board. I apologise for so many questions but I prefer to understand this correctly and thanks for reading Pedro.

For what it's worth: I think that there's not much more intensity to be had from an LED drawing 20mA than when it's drawing 10mA.

Yes Runaway or do you prefer Mr Pancake 8) sorry warped SOH, I have seen people say this and I suppose the less current you draw in any given situation is good but I am just trying to get a handle on how to check current flow in varying circuits so I am not labouring under any misconceptions.

Actually, it's Doctor Pancake, But anyway... (: Your understanding of ammeter (milliammeter) placement is sound.

Thanks Doc, glad I'm on the right track and that there are people here with a GSOH