Pages: [1] 2 3   Go Down
Author Topic: Shift Register only works when hand is close  (Read 2756 times)
0 Members and 1 Guest are viewing this topic.
Estonia
Offline Offline
Full Member
***
Karma: 1
Posts: 188
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
}


* tmp.png (183.32 KB, 702x491 - viewed 60 times.)
« Last Edit: February 25, 2013, 04:26:06 pm by shiznatix » Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where's the decoupling capacitors?
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Manchester, New Hampshire
Offline Offline
Edison Member
*
Karma: 4
Posts: 1363
Propmaker
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Estonia
Offline Offline
Full Member
***
Karma: 1
Posts: 188
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

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

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Manchester, New Hampshire
Offline Offline
Edison Member
*
Karma: 4
Posts: 1363
Propmaker
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Estonia
Offline Offline
Full Member
***
Karma: 1
Posts: 188
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

@scswift:
What though, is an IC?
Logged

Croatia
Offline Offline
God Member
*****
Karma: 13
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Grumpy, just to clarify,  0.1 what?
« Last Edit: February 26, 2013, 05:51:05 am by Shpaget » Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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"...
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Manchester, New Hampshire
Offline Offline
Edison Member
*
Karma: 4
Posts: 1363
Propmaker
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Estonia
Offline Offline
Full Member
***
Karma: 1
Posts: 188
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset



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.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Croatia
Offline Offline
God Member
*****
Karma: 13
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12467
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1] 2 3   Go Up
Jump to: