Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« on: February 05, 2013, 05:37:21 pm » |
Hello, After finishing my 3x3x3 LED cube I decided to go a little bigger (5x5x5). Now the arduino doesn't have enough pins to control the LEDs, so I decided to use (5)shift registers to expand my number of outputs. So I was searching on the internet and found this tutorial( http://arduino.cc/en/Tutorial/ShiftOut). So I ordered a few LEDs and the 74hc595N shift register (datasheet:http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf). After wired everything (only 2 LEDs hooked up) up as the tutorial shows, everything worked perfectly fine  . Because i'm gonna use 5 transistors to control the LED's layers, I pulled out the ground (pin 8 on the shift register). I expected to see the LEDs go off though they didn't. So now I pulled out the 5v aswell and still the LEDs are on (less bright though). Now I think the shift register is provided by current through the I/O pins 8, 11, 12. Now I don't why this happening so if someone can explain it to me (why and how??) it would be very helpful! this code i'm using: //Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11;
void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); }
void loop() { // count from 0 to 4 and display the number // on the LEDs for (int numberToDisplay = 0; numberToDisplay < 4; numberToDisplay++) { // take the latchPin low so // the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(500); } } this is what is happening:
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13898
Lua rocks!
|
 |
« Reply #1 on: February 05, 2013, 06:08:54 pm » |
ICs can power themselves parasitically by drawing current from the data lines. However that is not the recommended way to use them and may damage them. They aren't designed for it.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 73
Posts: 6638
Arduino rocks
|
 |
« Reply #2 on: February 05, 2013, 06:18:15 pm » |
Don't do that! You risk frying the chip!
CMOS logic (these days that's everything pretty-much) is extremely sensitive to static electricity and ESD (electro-static discharge) - so almost every chip has input-protection diodes on all the inputs (and outputs usually), whose purpose is to reduce the risk of stray electrostatics destroying the FETs on the chip.
The gate of a FET is a few atoms thick layer of silicon dioxide and a static discharge if even a few dozen volts can easily blow holes through it and destroy the FET.
The protection diodes connect the input and output pins to Vdd and GND such that the gate voltage is prevented from exceeding safe limits (for small discharges, upto a few thousand volts from a human finger...). But of course they allow the power rails to be directly powered by any input, which is the behaviour you see.
However the continuous current carrying ability of these diodes is usually quite small - think mA or less - so this is usually a bad state of affairs - the input diodes overheat and degrade and perhaps melt.
Furthermore if you pass large currents through these diodes even for very short times this can trigger "CMOS latch-up" - wikipedia will explain this.
So in short never disconnect GND or Vdd from the chips
What you want to do is use a group of transistors to handle the layers of the LED cube, and power the bases of these transistors from the shift register outputs via resistors - disconnect the LEDs anodes from GND, don't disconnect the shift register from GND!!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #3 on: February 05, 2013, 06:45:44 pm » |
Yes I discovered I made a bad mistake what mark mentioned. Instead of pulling out the ground from the arduino I should have pulled out the ground from the LED(so stupid). Mark, thanks for the info by the way now I know even more about shift register(I am still very new with electronics so it is a kind of learning experience for me), thanks  !
|
|
|
|
« Last Edit: February 05, 2013, 06:50:24 pm by WonderTiger »
|
Logged
|
|
|
|
|
Cumming, Ga
Offline
Edison Member
Karma: 12
Posts: 1389
Ultimate DIY: Arduino
|
 |
« Reply #4 on: February 06, 2013, 09:37:19 am » |
Well, there is also the mindset that says... "You learn more from failure than success" So while your experimentation is somewhat beneficial, (you now know more than you did before) you also need to be prepared to replace damaged parts.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #5 on: February 06, 2013, 03:51:51 pm » |
Yes I agree with you, failures are there to learn from as we say in Holland  . Luckily the chip still works fine, I just keep it for experimenting and use new shift registers for my cube;).
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #6 on: February 07, 2013, 12:38:41 pm » |
I still have a small 'problem'. The shift registers are hooked up to the arduino (3 digital pins, GND and 5V), when I put my USB cable in my laptop all the LEDS light up for a second and then just run the code I what was uploaded to the arduino. Is there any way to let the LEDs not light up whenever I connect my arduino to my laptop? Vid:
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, England
Offline
Full Member
Karma: 6
Posts: 188
Quick, chuck it in the bin before the boss finds out...
|
 |
« Reply #7 on: February 07, 2013, 01:59:39 pm » |
Try a 10k resistor between latch and ground.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #8 on: February 07, 2013, 02:39:45 pm » |
Thanks for the tip! Now the LEDs won't light up when i connect the USB to my laptop!
Btw: Does every latch pin from each shift register need a resistor to ground? *I tie all the latches from each shift register (6 in total) together*
I don't think every latch need a resistor though
|
|
|
|
« Last Edit: February 07, 2013, 03:00:21 pm by WonderTiger »
|
Logged
|
|
|
|
|
Leeds, England
Offline
Full Member
Karma: 6
Posts: 188
Quick, chuck it in the bin before the boss finds out...
|
 |
« Reply #9 on: February 07, 2013, 03:00:41 pm » |
Sorry, I think I got that the wrong way round - try to +5v! It won't have done any harm. It holds the line high while the processor is sorting itself out. However if the processor drags it low then it could shift out data to the registers. It's a suggestion from Nick Gammon: http://gammon.com.au/forum/?id=11518
|
|
|
|
« Last Edit: February 07, 2013, 03:12:30 pm by dannable »
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #10 on: February 07, 2013, 03:18:06 pm » |
No you was right! The latch pin should be low so no data will be send to the outputs. If i put the resistor on 5v and the latch then the latch will be high, if i tie it to GND then it is low(atleast it's working if i put the resistor between latch and ground). However i'm not sure if I need to place a resistor on every latch pin or only 1 resistor from latch to ground will be good enough (notice that all the latches from the 6 registers are tied together).
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, England
Offline
Full Member
Karma: 6
Posts: 188
Quick, chuck it in the bin before the boss finds out...
|
 |
« Reply #11 on: February 07, 2013, 03:28:13 pm » |
One resistor should suffice for all the registers.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #12 on: February 07, 2013, 03:31:32 pm » |
Ok thank you very much  ! Then i put around a 10k resistor between the latch and gnd on my 5x5x5 cube.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 1
Posts: 55
|
 |
« Reply #13 on: February 08, 2013, 01:05:32 pm » |
Did some testing with 2 different codes today(changed the code in something easier for the forum): 1: void loop(){ shiftOut(dataPin, clockPin, MSBFIRST, B00001); digitalWrite(latchPin, HIGH); delay(500); digitalWrite(latchPin, LOW); }
2: void loop(){ shiftOut(dataPin, clockPin, MSBFIRST, B00001); digitalWrite(latchPin, HIGH); digitalWrite(latchPin, LOW); delay(500); }
As you can see the difference is the place of the delay(). I uploaded both codes, and both looks exactly the same, so i can assume it does not care where i place the delay? ]
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, England
Offline
Full Member
Karma: 6
Posts: 188
Quick, chuck it in the bin before the boss finds out...
|
 |
« Reply #14 on: February 08, 2013, 01:29:03 pm » |
That's a rather strange way of ordering the events!
The sequence is:
Latch low Data out Latch high.
If you want to add a delay it should ideally be outside this sequence.
|
|
|
|
« Last Edit: February 08, 2013, 01:33:29 pm by dannable »
|
Logged
|
|
|
|
|
|