Offline
Newbie
Karma: 0
Posts: 49
|
 |
« on: February 25, 2013, 04:19:25 pm » |
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: 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); }
|
|
|
|
« Last Edit: February 25, 2013, 04:26:06 pm by shiznatix »
|
Logged
|
|
|
|
|
UK
Offline
Edison Member
Karma: 41
Posts: 2170
What a host of balls she had seen: gaity, the brass buttons...
|
 |
« Reply #1 on: February 25, 2013, 05:06:02 pm » |
Where's the decoupling capacitors?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester, New Hampshire
Offline
Edison Member
Karma: 0
Posts: 1114
Propmaker
|
 |
« Reply #2 on: February 25, 2013, 05:11:32 pm » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #3 on: February 25, 2013, 05:16:05 pm » |
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
Brattain Member
Karma: 269
Posts: 25381
Solder is electric glue
|
 |
« Reply #4 on: February 25, 2013, 05:18:24 pm » |
Use a 0.1ceramic capacitor on the power pins of each external chip.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Edison Member
Karma: 41
Posts: 2170
What a host of balls she had seen: gaity, the brass buttons...
|
 |
« Reply #5 on: February 25, 2013, 05:19:59 pm » |
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
|
|
|
|
|
Manchester, New Hampshire
Offline
Edison Member
Karma: 0
Posts: 1114
Propmaker
|
 |
« Reply #6 on: February 25, 2013, 10:55:02 pm » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #7 on: February 26, 2013, 05:38:31 am » |
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
Full Member
Karma: 9
Posts: 240
|
 |
« Reply #8 on: February 26, 2013, 05:48:34 am » |
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
Edison Member
Karma: 41
Posts: 2170
What a host of balls she had seen: gaity, the brass buttons...
|
 |
« Reply #9 on: February 26, 2013, 05:55:43 am » |
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
|
|
|
|
|
Manchester, New Hampshire
Offline
Edison Member
Karma: 0
Posts: 1114
Propmaker
|
 |
« Reply #10 on: February 26, 2013, 08:11:34 am » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #11 on: February 26, 2013, 08:48:45 am » |
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
Edison Member
Karma: 41
Posts: 2170
What a host of balls she had seen: gaity, the brass buttons...
|
 |
« Reply #12 on: February 26, 2013, 08:58:23 am » |
 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
|
|
|
|
|
Croatia
Offline
Full Member
Karma: 9
Posts: 240
|
 |
« Reply #13 on: February 26, 2013, 09:06:40 am » |
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
Tesla Member
Karma: 71
Posts: 6596
Arduino rocks
|
 |
« Reply #14 on: February 26, 2013, 12:14:28 pm » |
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
|
|
|
|
|
|