Pages: [1]   Go Down
Author Topic: Extending LED's with their own power using the 74HC595  (Read 691 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Arduino,

I have a question: Is it possible to feed the led's with their own power with the 74HC595 or do i need relais to do that? I have the following wiring that seems to work now. But i dont know if that is good.


I am using the following code:
Code:
const int pinLatch = 8;
const int pinClock = 12;
const int pinData = 11;
unsigned long registerState     = 0;

void setup()
{
// Shiftregister Pin's
pinMode(pinLatch, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinData, OUTPUT);

// Initiate the Serial (COM)
Serial.begin(9600);

writeRegister(0, HIGH);
writeRegister(1, HIGH);
writeRegister(2, HIGH);
}

void loop()
{
writeRegister(0, HIGH);
writeRegister(1, LOW);
writeRegister(2, LOW);
delay(250);
writeRegister(0, LOW);
writeRegister(1, HIGH);
writeRegister(2, LOW);
delay(250);
writeRegister(0, LOW);
writeRegister(1, LOW);
writeRegister(2, HIGH);
delay(250);
}

void writeRegister(byte pin, byte value)
{
bitWrite(registerState, pin, value);
digitalWrite(pinLatch, LOW);
byte shiftRegisters[3];
shiftRegisters[0] = registerState >> 0;
shiftRegisters[1] = registerState >> 8;
shiftRegisters[2] = registerState >> 16;
//shiftOut(pinData, pinClock, MSBFIRST, shiftRegisters[2]);
//shiftOut(pinData, pinClock, MSBFIRST, shiftRegisters[1]);
shiftOut(pinData, pinClock, MSBFIRST, shiftRegisters[0]);
digitalWrite(pinLatch, HIGH);
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes that is fine so long as the resistors such that the current from each pin does not exceed what it is rated at. Also note that there is a limit on the total ammount of current drawn from all the pins. This is less than the maximum current for any one pin.
Time to look at the data sheet of your device.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You've commoner up on the positive rail there, but you take the positive for your IC from the +5v of the UNO and the Gnd from your batteries. The Gnd will be different between the two. E.g if your batteries are 3 x AA giving 4.5v then your UNO Gnd and battery Gnd has a PD of 0.5v.

This means that you may not be putting 5v onto that Ic as you expect. You also have the !OE pin from the UNO Gnd so there might be a PD existing internal to the IC. If you did this with two pins connected internally to Gnd (such as a uC that has two or more Vcc and Gnd pins) then you'd effectively be putting a 0.5v 'short' between the two power supplies and have current flowing that would only be dependent on the resistances in that path.

The same thing goes for your signals. You think you're providing 5v signals from the output pins, but they are actually at a lower level. If you were using a 3v supply for Red LEDs then your signals would be at 3v because of the way you've effectively wired your IC across the battery and not the UNO. You haven't got the UNO Gnd connected to the Gnd of your 595.

My choice would be to common up the Gnds and use the 595 as a current sink to switch the Cathodes of the LEDs. Obviously it will mean that setting the 595 bit low will turn the LED on, but you can easily code this inverting in.

Failing that, you need to remember that the positive is your common rail here, so your Gnd needs to be taken from the same rail when connecting a single device, and being mindful of the PD you actually want, and which levels you are making common throughout your circuit.
« Last Edit: January 13, 2013, 08:43:16 am by tack » Logged

Sweden
Offline Offline
Full Member
***
Karma: 1
Posts: 185
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a look at the following thread regarding maximum current for 74HC595.
http://arduino.cc/forum/index.php/topic,15620.0.html

6mA per output.
The "typical" 20mA current for a LED is often unnecessary high. 6mA may be enough.

70mA maximum current for the chip.

/Olof
Logged

Pages: [1]   Go Up
Jump to: