1
\$\begingroup\$

I've wired up two 74HC595s to a Photon from Particle. I followed this guide here for Arduino in how I wired it. The only place I deviated is to not put a capacitor on the latch pin.

It all appears to work. I can shift in two bytes in a row and they show up on my leds. My problem is one or two LEDS don't go as high as the others. Most of them measure at about 2.8 volts, but the few dim ones are at 1.8 volts. When I make all the pins low then the voltage is basically zero. So it seems like its trying to work but for some reason not giving full voltage.

I googled the 74HC595 and low voltage on pin and wasn't really seeing anything. This is happening on four different chips that I've tried so it must be some thing I'm doing wrong.

Below is a sample of the code I'm using:

#define bitSet(value, bit) ((value) |= (1UL << (bit)))

int dataPin = D6;
int clockPin = D4;
int latchPin = D5;

byte leds = 0;
byte leds2 = 0;

void setup() 
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
}

void loop() 
{

    leds = 0;
    leds2 = 255;
    updateShiftRegister();
}

void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds2);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}
\$\endgroup\$
  • \$\begingroup\$ Are all your LEDs and resistors identical? \$\endgroup\$ – uint128_t Mar 7 '16 at 3:30
  • \$\begingroup\$ Yes, they are. If I directly provide power to the pin right after the shift register and before the resistor then the LED will light up properly. \$\endgroup\$ – Simon The Cat Mar 7 '16 at 3:32
  • \$\begingroup\$ You know, with this code, the LEDs shouldnt light up at all (assuming they are active HIGH) since you only latch the last byte shifted out. Can you provide your schematic? \$\endgroup\$ – TisteAndii Mar 7 '16 at 3:38
  • 1
    \$\begingroup\$ What happens if you swap a brigh LED and a dim LED? (In other words, is the difference pin-related or LED-related?) \$\endgroup\$ – Wouter van Ooijen Mar 7 '16 at 7:20
7
\$\begingroup\$

@SimonTheCat,

for some reason not giving full voltage

The classic reason for that behaviour (and the Arduino tutorial you are using is at risk of causing this issue), is that you are drawing too much current from the 74HC595 outputs, when multiple LEDs are lit. Once the total current drawn exceeds the specified limit for the IC, the voltage droop at the different output pins can vary, as you measured (hence some bright LEDs and some dim LEDs) - I have seen exactly that situation when exceeding the maximum current for an IC.

The big clue is the lower-than-expected voltage which you mentioned of 2.8V on even the IC pins driving the "bright" LEDs. Assuming this is a 74HC595 (i.e. CMOS compatible outputs) as you say, then any V\$_{OH}\$ value less than approx 0.6 x V\$_{CC}\$ (typical minimum V\$_{OH}\$) indicates a likely output over-current situation (0.6 x 5V = 3V so your 2.8V outputs are already below that, never mind the 1.8V outputs). (It would be worth measuring the voltage at each 74HC595 V\$_{CC}\$ pin 16 when you are seeing the "dim LED problem", to ensure that you are not also suffering from reduced voltage there too e.g. due to long, thin power supply wires.)

TL;DR - Based on the voltage measurements you supplied, and assuming all LEDs and resistors are the same type, then the short answer is either to add external drivers for the LEDs, or to reduce the current per LED (i.e. increase the external resistors from the 220\$\small\Omega\$ value listed in that tutorial - I suggest 560\$\small\Omega\$ minimum), to reduce the total output current for the IC.

Your linked Arduino tutorial links to a very old (1998) Philips datasheet for the 74HC595 which, unfortunately, is incomplete as it refers to another datasheet for vital information, on the maximum output current values. A different (and complete) 74HC595 datasheet from NXP shows that:

Absolute maximum current for any one Q0-Q7 pin is 35mA but the maximum total current for the whole IC is 70mA - see:

Section 8, Limiting Values: http://cache.nxp.com/documents/data_sheet/74HC_HCT595.pdf?pspll=1

Part of section 8 from NXP 74HC595 datasheet

So as soon as you have 8 LEDs drawing (for example) even 10mA each, you have exceeded the maximum allowable current for the IC (i.e. 8 LEDs x 10mA per LED > 70mA).

But that is an Absolute Maximum rating shown in Section 8 of the datasheet, and shouldn't be used for normal operation. Instead look at the Section 10, Static Characteristics, and you see that at V\$_{CC}\$=4.5V, for a current of 6mA per pin, the output voltage will typically be 4.32V (likely a little higher for V\$_{CC}\$=5V - say around 4.8V).

Part of section 10 from NXP 74HC595 datasheet

FYI that I\$_O\$ (output current) value of 6mA in section 10 of the datasheet is not chosen at random - the Q0-Q7 pins of a 74HC595 are "bus driver" type HC outputs and those were originally specified as a 6mA-capable output (normal HC output driver was 4mA, as you can see in the specification of the Q7S output, which is a normal HC output driver).

Aiming for 6mA per LED, then 6mA per pin x 8pins = 48mA total - so well within the total 70mA current limit for the IC. Assuming you have red LEDs and guessing a minimum V\$_F\$ of 1.8V (look in your LED datasheet for your actual value), we can calculate the necessary resistor as (4.8V - 1.8V)/6mA = 500\$\small\Omega\$ minimum resistor.

Hence I suggest that you use no lower than the next higher standard value i.e. 560\$\small\Omega\$ for all the LED series resistors and try again. I expect you will see a consistent light (but likely dimmer than your current bright LEDs) from all the LEDs (assuming the LEDs are all the same type). If you need the LEDs to be brighter even with a larger series resistor, either use high-brightness LEDs (which give more light for a given current than "standard" LEDs) or use external drivers and adjust the LED current to stay within the limits of whatever drivers (IC, BJT or MOSFET) you choose.

[Also the circuit in that Arduino tutorial needs to include small decoupling capacitors across the 74HC595 ICs, physically close to each IC, and preferably a larger capacitor too per breadboard - otherwise the current spikes, especially at each clock transition, could cause further problems.]

Edit:

@SimonTheCat,

Although you linked to an Arduino tutorial, since you are actually using a Photon, I realised there is a slight wrinkle to this. Assuming that you power your Photon via USB and then power the 74HC595 and LEDs from its VIN (V\$\small_{IN}\$) pin [please confirm your exact connections - even better, supply a schematic!], the voltage on that VIN pin is already dropped to around 4.8V due to its built-in Schottky diode (assuming your USB power source is supplying 5V). That slightly affects my previously listed calculations, although the main point is unchanged. When you have some actual voltage readings, the necessary resistance calculations can be updated if needed - 470\$\small\Omega\$ might then be a suitable series LED resistor value.

\$\endgroup\$
  • \$\begingroup\$ Would connecting the LEDs to 5V and driving them with complementary outputs help? Like in the last picture on this page: allaboutcircuits.com/textbook/digital/chpt-12/… . In that case the current would be supplied by the power supply directly. \$\endgroup\$ – Sredni Vashtar Mar 7 '16 at 12:22
  • 1
    \$\begingroup\$ @SredniVashtar, No. that type of connection (where the HC595 is sinking the current instead of sourcing it) does not change the overall problem. Although 74 series TTL had greater current sinking capability than sourcing, the HC series has symmetric sinking & sourcing capability. Look in the datasheet which I linked, Section 10, Table 6, where VOL is specified at 6mA sinking, just as VOH is specified at 6mA sourcing. But that page which you linked is using 470 Ohm resistors and so it is much less likely to show the problem, compared to using 220 Ohm resistors mentioned by the OP! \$\endgroup\$ – SamGibson Mar 7 '16 at 12:44
  • 1
    \$\begingroup\$ Thanks. This is a reminder to always check the logic family. As you surmised, I was thinking in TTL logic. I guess that shows my age ;-) \$\endgroup\$ – Sredni Vashtar Mar 7 '16 at 13:09
  • \$\begingroup\$ I know what you mean - I grew up with TTL too ;-) Some young engineers who have only ever used CMOS, will not have seen that particular quirk of TTL! \$\endgroup\$ – SamGibson Mar 7 '16 at 13:19
  • \$\begingroup\$ Very good answer and very nice going into the math it helped me understand some of what was going on. I replaced the resistors with higher value ones. As you said I now see a more consistent, but lower light. I still have three LEDs being weird though. Two of them it seems after passing through the resistor (I tried 1 ohm, 510 ohm, 2k ohm) drop down way low to around 0.3 v If I briefly wire it directly they will light though. I'm also seeing small amounts of voltage between my common ground and the ground on the LED. Its perplexing lol. \$\endgroup\$ – Simon The Cat Mar 11 '16 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.