Shift Register only works when hand is close

scswift:
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.

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.

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.

shiznatix:

majenko:
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!

How I buy decoupling capacitors:

I wasn't able to go to the shop myself today and my girlfriend may have gotten the wrong part. I have put all ground pings to ground and put a resistor between G pin and ground. These things seam to have really helped out but it hasn't totally fixed the problem. It still only works when a hand is near, but it is quite consistent and doesn't require much precision, just a human body nearby.

The capacitors I was able to get are 50V 0.1uF and 25V 10uF. I am not sure what the voltage here means, if it is a limit or what it should be run at.

Not sure if it matters, but I daisy chained another shift register on another breadboard and it seams like the closer the breadboards are to eachother, the more pronounced this problem is.

I have tried both capacitors across both shift registers but alas, nothing.

Should I just go myself to the store and ensure that I get the correct capacitors?

Edit: I also bought a few transistors to play around with but there is of course an issue here too. If I hold the wire that goes from the shift register to the base pin of the transistor between two fingers everything works perfectly with the transistor. But if I am not holding the wire, the current to the LED is super low, hardly any light up at all. I am not sure what would cause that but I can say that my wires are quite basic (my cables are just untwisted ethernet cables...).

Last Edit: The only company around me is called Elfa and on their website I can't find any 100 nf ceramic decoupling capacitors. My search leads me to https://www.elfaelektroonika.ee/elfa3~ee_en/elfa/init.do?cat=0&sq=ceramic+decoupling+capacitor+100+nf&sel=1&solrRows=10&selectedCategory=&fq=|inStock%3Atrue|priceRangeMin%3A0|priceRangeMax%3A1&sortBy=&sortOrder=&priceRangeMin=0&priceRangeMax=1&searchFilterInStock=inStock

We have become so bogged down in decoupling capacitors that we have failed to look at anything else.

I see that you are using pin D1 in your wiring diagram. You are also using the Serial port.

You can't do both. Try moving D1 to D2 instead.

Also, you haven't posted your complete code. You know how I can tell? You're not defining your pin variables anywhere. Please post your full code.

Ok, my package finally arrived with bunches of jumper wires and another arduino (micro this time)! I was also able to get the proper decoupling capacitors. After using proper jumper wires to wire everything up, it all seams to work properly.

So, thank you everyone for your help. I learned quite.

My last question is - on the datasheet for the shift registers that I am using (http://www.adafruit.com/datasheets/tpic6b595.pdf), there are 3 ground pins per register. Do I need to put each of these pins to ground or can I just put 1 to ground and call it a day? I just want to make sure I don't fry my registers.

Follow the data sheet's recommendation... Always unless you KNOW SPECIFICALLY OTHERWISE...From the symptoms you quote you have a 'floating' input to the S.R.
Go over your wiring carefully and If you don't find it... POST YOUR CODE AND AN ACCURATE DRAWING OF THE DEVICE. An Accurate Schematic would be great but good pictures of your wiring are better than nothing. Without your code and drawings/pictures anything returned is at best a guess...

Bob

Connect all ground pins to ground.
There is also G pin (pin 9) that should also be grounded for the outputs to output.

When output enable (G) is held high, all data in the output buffers is held low and all drain outputs are off.
When G is held low, data from the storage register is transparent to the output buffers.

Docedison:
From the symptoms you quote you have a 'floating' input to the S.R.

Sorry, what is the S.R.?

As for the drawings and exact code - I will post these as soon as I get home after work with the remaining issues that I have.

As promised, here is my wiring diagram and the exact code I am using. The Arduino that I am using is actually an Arduino Micro but I couldn't find that in the Fritzing program. All pins are correct though.

Right now, the shift registers are working properly, yay! I have not gotten any interference since I changed the wires to proper jumper wires.

The problem though that I am having now is that my transistor is not working. If I screw around and plug things in and hold some wires, it will sometimes work. The transistor datasheet is here: https://www1.elfa.se/data1/wwwroot/assets/datasheets/cgON-BC546-548_en.pdf

My exact code is as follows:

//Pin to clear the register
const int clearPin = 7;
const int latchPin = 8;
const int clockPin = 12;
const int dataPin = 11;

int i = 0;

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:
  if (i == 2) {
    i = 0;
  }
  
  registerWrite();
  delay(1000);
  
  i++;
}

// This method sends bits to the shift register:

void registerWrite() {
  // the bits you want to send
  byte bitsToSend0 = 0;
  byte bitsToSend1 = 0;
  // write number as bits
  
  bitWrite(bitsToSend0, i, HIGH);
  bitWrite(bitsToSend1, i, 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, bitsToSend1);
  shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend0);

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

transistor.fzz (10.8 KB)

transistor_bb.png

From what I can make out from that tangled mess, you have your transistor wired up like:

That is wrong. Firstly your current limit resistor is in the wrong place (it is offsetting the transistor, which is bad), plus you don't have a current limit resistor on the base, which is bad, as it could kill your shift register.

It should be like this:

bad.png

good.png

I am not sure exactly how to read those diagrams but I gave it a shot. Alas, it doesn't work.

Attached is how i have wired up the LED with the transistor. Right now I only get some current through the LED when I am holding wire 2 between my fingers - but not much as the LED only lights up a little.

Am I doing this wrong?

tmp.png

That looks right, and the fact that touching wire 2 turns it on (probably flickering at 50/60Hz) means it's wired fine. It sounds like the output you are connecting it to though isn't actually running as an output, and the connection is floating.

majenko:
That looks right, and the fact that touching wire 2 turns it on (probably flickering at 50/60Hz) means it's wired fine. It sounds like the output you are connecting it to though isn't actually running as an output, and the connection is floating.

Ok, but how could that be? If I take the transistor out and just have the LED connected like: 5V - resistor - LED - shift register pin - it all works just fine. I can I get it to work properly?

Datasheet:
Outputs are low-side, open-drain DMOS transistors with output ratings of 50 V and 150-mA continuous sink-
current capability.

Add a 10K pull-up resistor between the shift register output and +5V.

Note that the output operation (HIGH/LOW) will be reversed.

majenko:
Add a 10K pull-up resistor between the shift register output and +5V.

Note that the output operation (HIGH/LOW) will be reversed.

So I should put this pull-up resistor connecting wire 2 and 3?

Yes. The "outputs" of the shift register act just like your transistor - they are "off" so then are high impedance (open circuit), or "on" and connected to ground. You need power from the 5V rail to turn your transistor on, and when you turn on the output to the shift register it connects the base of your transistor to ground, turning it off.

majenko:
Yes. The "outputs" of the shift register act just like your transistor - they are "off" so then are high impedance (open circuit), or "on" and connected to ground. You need power from the 5V rail to turn your transistor on, and when you turn on the output to the shift register it connects the base of your transistor to ground, turning it off.

Wouldn't this just connect the collector to the base of the transistor? How would this allow the power to flow to the emitter in of the transistor?