Go Down

Topic: Shift Register only works when hand is close (Read 3117 times) previous topic - next topic

shiznatix

Feb 25, 2013, 10:19 pm Last Edit: Feb 25, 2013, 10:26 pm by shiznatix Reason: 1
I am trying to learn to use the TPIC6B595N shift register http://www.adafruit.com/datasheets/tpic6b595.pdf but I am having a strange problem. The register only works every now and then and very often it works only when my hand is nearby.

I don't have to touch anything actually, just put my hand close to the register. I have tested this extensively and it doesn't always happen but about 80% of the time I just have to put my hand in a specific way and it works.

I have read of this problem before here: http://flashgamer.com/arduino/comments/arduino-controlling-24-leds-with-shift-registers but it just says that when the SRCLR pin (clockPin) is low, the register would clear. It didn't give a real fix though that I can see.

Hopefully someone can give me some guidance on this.

I have attached my basic sketch and my code is here:
Code: [Select]
void setup() {
 //set pins to output because they are addressed in the main loop
 pinMode(clearPin, OUTPUT);
 pinMode(latchPin, OUTPUT);
 pinMode(dataPin, OUTPUT);  
 pinMode(clockPin, OUTPUT);
 Serial.begin(9600);
 Serial.println("*");
 
 // delay a little and then set
 delay(100);
 // Always start by sentting SRCLR high
 digitalWrite( clearPin, HIGH);
}

void loop() {
 // write to the shift register with the correct bit set high:
 Serial.print("counter: ");
 Serial.println(0);
 registerWrite();
 delay( 1000 );
}

// This method sends bits to the shift register:

void registerWrite() {
 // the bits you want to send
 byte bitsToSend0 = 0;
 // write number as bits
 
 bitWrite(bitsToSend0, 0, HIGH);
 //bitWrite(bitsToSend0, 1, LOW);
 //bitWrite(bitsToSend0, 2, HIGH);

 // turn off the output so the pins don't light up
 // while you're shifting bits:
 digitalWrite(latchPin, LOW);
 
 // shift the bits out
 shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend0);

 // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
}

majenko


scswift

You're missing a bunch of connections.

Connect each GND pin to GND.  You've only got one attached right now.

Also you don't have a pulldown on the G pin.  That pin decides if the LEDs are all on or off so you don't want to leave it floating.  Pulling it down with a 10K resistor to ground will make the LEDs that you've set to be on, stay on.

Also, keep in mind those breadboard power rails often have a break in the middle of them.  Putting a couple jumpers across the center at the top and bottom of the board to make sure the power is getting where it needs to be is a good idea, but if your chip is powering up at all, that's probably not an issue with your breadboard.

And as majenko sugested, a 0.1uf decoupling cap between the VCC pin and GND might help.  That helps remove noise in the circuit that could lead to erratic behavior.

shiznatix


Where's the decoupling capacitors?


I didn't know I needed one. I am quite new to electronics and am trying to control an LED matrix. What would I use a decoupling capacitor for in this situation?

Grumpy_Mike

Use a 0.1ceramic capacitor on the power pins of each external chip.

majenko


Use a 0.1ceramic capacitor on the power pins of each external chip.

Plus a larger electrolytic (say 100µF) on the power lines of the breadboard where the power connections arrive from the Arduino.

scswift


What would I use a decoupling capacitor for in this situation?


When a chip turns on and off it creates noise on your power rails.  The voltage in the parts of the circuit near the chip fluctuate.  This is noise.  If the noise is too great, then when a pin should read low it might read high instead, or vice versa. 

The decoupling caps charge up when you place them in the circuit.  Then when a dip in power starts to occur, they discharge a bit which raises the voltage back to where it should be.

Typically you put one or two small capacitors, say, 10uf and 0.1uF between an IC's VCC and GND pins as close to the IC as possible to prevent any noise from getting to it, or being generated by it.


shiznatix

Thanks, I will grab these extra parts today and put some stuff together, hopefully all will go well.

@scswift:
What though, is an IC?

Shpaget

#8
Feb 26, 2013, 11:48 am Last Edit: Feb 26, 2013, 11:51 am by Shpaget Reason: 1
Integrated Circuit.
A whole bunch of individual components crammed into something smaller.

Grumpy, just to clarify,  0.1 what?

majenko


Integrated Circuit.
A whole bunch of individual components crammed into something smaller.

Grumpy, just to clarify,  0.1 what?


0.1µF, aka 100nF aka "104" aka "Magic Bullet"...

scswift


Thanks, I will grab these extra parts today and put some stuff together, hopefully all will go well.

@scswift:
What though, is an IC?


An IC is a chip.  Like your shift register.  As someone else mentioned, it stands for "integrated circuit". 

Btw for your decoupling capacitors, get little ceramic ones.  You don't need to worry about polarity with those.

shiznatix


Btw for your decoupling capacitors, get little ceramic ones.  You don't need to worry about polarity with those.


In regards to this, can you give me an example? My local "electronics shop" is really terrible and the staff know less about electronics than your standard pizza delivery driver. So, when I go there, I need to know exactly what it is that I need.

majenko



A 100nF ceramic capacitor is a 100nF ceramic capacitor.  If it doesn't say 100nF ceramic capacitor, or 0.1µF ceramic capacitor on the packet, then don't buy it.  It may have the numbers "104" printed on the actual capacitor surface itself.

Shpaget

I found out that my local electronics shop works best if I go to them with their own inventory numbers and not component name, so take a look at their web site, if they have one, and see if they have their own code listed next to the part name.

MarkT



Where's the decoupling capacitors?


I didn't know I needed one. I am quite new to electronics and am trying to control an LED matrix. What would I use a decoupling capacitor for in this situation?


The rule is simple, _all_ digital logic chips should have a decoupling capacitor to ground on every supply right next to the
chip.  (most chips have only one supply, here 5V).  Typical symptoms of inadequate decoupling is random,
occasional misbehaviour.  Unless you enjoy circuits that sometimes go wrong for no obvious reason don't
forget to decouple!

Without further information 0.1uF is a good default value that should work in most
circumstances, but the datasheet for the chip will have chapter-and-verse on decoupling requirements.
Buy decoupling capacitors in bulk, its much more economic!
[ I won't respond to messages, use the forum please ]

Go Up