The ghost in the machine: Shift Register weirdness

Hi,

I'm having loads of small problems and also loads of small successes with this newbie project I'm trying to do.

My plan is to use two shift registers to eventually drive relays to hit things to make chords. (12 things, 12 tones=every possible chord.) As an intermediate step, I'm just turning on and off a bunch of LEDs connected to the shift reg. Once those are working properly, I'll switch to relays.

The most frustrating thing right now: My shift register will turn off randomly from time to time. I can make it work again by unplugging the Vcc 5V, but then it quits sooner and sooner until I give it a rest. Plugging in the 5V somewhere else on the rail seems to help. The chip's cool to the touch, so no overheating, but maybe there's some capacitance weirdness happening somewhere?

I'm new to this and don't know enough about circuits to do this by the book, but I put in a bunch of tiny tiny capacitors .1uF and that seems to have helped some. I still get all sorts of weird behavior, though, the pinnacle of which is: If I pick up the breadboard in my hands, the shift register comes on and the LEDs start working. (I'm running count-to-255 code now, and it starts wherever the Arduino is in the sequence... so the Arduino seems to be fine.) Then, after I set it down, it works for 7-10 seconds more, and then quits.

Could this be some weird capacitance thing? My body acting as a decoupler?

I'll work on a diagram. But this seems like the kind of thing that one of the "God Members" could read and just say "Oh yes, grasshopper. You're forgetting ______."

Perhaps?

Thanks,
Charlie

Oh yes. And when I tried to run it off external 12V DC to the Arduino, it would only work if I touched part of the DC connector.

Ghosts? Electrons?

Sounds like you're missing some grounds somewhere :X

Some pictures and/or code, might help us decipher your mysterious problem:D

how do you have the LEDs wired to the shift register? You may be drawing too much current, and overheating it.

Ran

Oh yes, grasshopper. You're forgetting that solder less bread board is not always very good at making connections. Lifting it up disturbs the connections and makes it work. When you put it down the mechanical springiness with the wires is causing something to be disconnected.

So try changing the holes you are using, say shift the circuit down to one end. Make sure you are using solid core wire to connect things up.

:wink:

"output enable" --> GND ?
"master reset" --> +5V ?

If these 2 are allowed to float, you can have all sorts of weird "I wave my hand over it and it suddenly works" behaviour. I did, and what fun I had with it.

Thanks for the wisdom, folks. I'm using a high-voltage shift register so I should run into power-overage problems, at least not until I start hooking up loads of solenoids. Good to know about the breadboard, though. These are surplus and may very well be shady. I'll try my fancy new one.

Here's a photoshop-wonderful diagram of how I've got things hooked up, and as a bonus, how I'd like to hook them up once I solve the "ghost" problem.

And, here's my code. The commented bit at the end is what's eventually going to happen, I'm using the "hello world, 1, 2, 3" code just to give the shift register a predictable behavior while I wire it up. Oh, and please forgive my crazy obscene shouting-at-self comments. I was a bit frustrated when I put those in. Probably should clean that up:

// 5ths clock
// simple

//Pin connected to ST_CP of 74HC595 = Storage Register Clock Pin = RCK
// f that. Ard-pin 8 connects to RCK, pin 12 of HiV B595. Which is the register clock.
int latchPin = 8; //green
//Pin connected to SH_CP of 74HC595 = Shift Reg Clock Pin = SRCK
// f that. Ard-pin 12 connects to SRCK, pin 13 of HiV B595. Which is the Shift clock.
int clockPin = 12; //blue
////Pin connected to DS of 74HC595 = Serial Data Input
// serial always works. pin 3 in HiV 595.
int dataPin = 11; //yellow

// Had to set the SRCLR pin, shift-register-clear, to HIGH in order to get data
// from the inputs to the outputs. When stuff wasn't working, this pin was unconnected
// and drifting. In LA it must have just drifted HIGH somehow?

int resetPin = 2; //red
int chord = 255;
//int outputPin = 3;

void setup() {
Serial.begin(9600);
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(resetPin, OUTPUT);
digitalWrite(resetPin, HIGH);
}

void loop() {
//count up routine
for (int j = 0; j < 256; j++) {
Serial.println(j);
//ground latchPin and hold low for as long as you are transmitting
digitalWrite(latchPin, LOW);
// digitalWrite(13, HIGH);

shiftOut(dataPin, clockPin, MSBFIRST, j);
//return the latch pin high to signal chip that it
//no longer needs to listen for information
digitalWrite(latchPin, HIGH);
delay(250);
// digitalWrite(13, LOW);
// delay(100);
}
}

//void loop() {
// if (Serial.available( > 0)) {
// chord = Serial.read();
// digitalWrite(latchPin, LOW);
// shiftOut(dataPin, clockPin, MSBFIRST, chord);
// digitalWrite(latchPin, HIGH);
// delay(250);
// }
//}

Just had to point this out.. I'm sure you've already got it figured out, but when you're setting up your relays, or at least your external supply, the ground of that external 12v supply needs to be connected to the Arduino as well, or you'll probably run into the same problems. (or even more problems, like not working at all)

But you could just use Transistors with some regular shift registers, rather than going with the High Voltage, or even use a Darlington Array transistor chip, line up and save alot of space.. But I'm not sure what amperage you'll be needing for your solenoids so that's up to you!:smiley:

Anyways, good luck with your project and do keep us informed, sounds like a fun project.

tsk squared :slight_smile:

so you're using something like TPIC6B595 aren't you ?
and what did I say about the "G-bar" line ?

if you look at the datasheet and the internal logic, you'll see that "G-bar" is connected via an inverter to all output FETs by and gates. So the output can only be "on" if the data-bit says "on" and if the "G-bar" pin is set to GND (active low).

In your case you'll always get ERRATIC behaviour if you leave "G-bar" unconnected. Been there done that.

You can use the "G-bar" pin to turn all outputs on/off instantly without disturbing the data you've sent into the chip before. Would work as a PANIC BUTTON quite well.

This pin must get grounded, and so should you :wink:

And when you do start hooking up relays, watch out for dissapating too much heat in the IC. The individual channels might be able to take the current but often the package as a whole can't handle them all being on at once.
See Power & Heat
and
Power Examples

Sweet sweet sweet. Thanks to all of you. And, really excellent site, Mike. The information density is high there, and it's all very clear.

Madworm-- oh! I'd read the datasheet as saying SRCLR was the pin that needed to be held high to make the thing work, instead of drifting at will. Strange that G-bar has been... maybe capacitively coupling with its neighbor pin, SRCLR? Will move that wire over one spot.

The plan for using 12V is: power the Arduino with 12V DC, sending 5V via its internal converter to the Vcc in on the chip, and then use Arduino's "Vin" pin to send the incoming 12V straight to power the LEDs/Relays. (So they'd both come back to the Arduino's GND pins)

(Arduino says it can handle that. Shouldn't be drawing too much current as I've arranged to never have to fire more than one relay at a time, they'll go in succession 500ms or so apart. Maybe a bit quicker, but that seems to be ages in electro-time for things to settle down.)

Okay, now, transistors? Still don't really get those. Sorry to be a moron, but everything I read about them explains them in terms of water pipes or EE, and neither of those tells me how to actually use them in a circuit. I know it's mega-basic stuff, but... stuff that's not in my brain yet.

Tonight's project: Move SRCLR wire to G-bar. Replug the shift register on a better breadboard and see if I can get it working consistently. Will post results.

Transistors are basically an electronic switch.

The voltage between the Collector (C) and the Emitter (E) is turned either on or off by the Base (B), depending on which kind of transistor you have, this will either be a positive voltage, or ground.
Basically, you apply a small voltage to the Base, to flow a much larger current/voltage through the Collector and Emitter.
For example, you can use a transistor to power a motor from your Arduino. (or any other item that takes more than the 40 ma the digital pins offer on the Arduino)

It's nearly the same as a relay, but I believe relays can have a MUCH higher voltage/current rating. And also can be used as either "NO" or "NC" (Normally Open(normal switches)), or a (Normally Closed):

I'm sure I missed a few key points, but somebody will come along and correct me:D

Today's update:

New breadboard = works!

12V = still totally overheats the Arduino.

Video of 1/12 of what I'm trying to do. Ish. In this case I'm sending 12V to the Arduino, powering the IC off 5V via internal converter, and sending 12V from Vin to the rail that powers the LEDs and the relay/striker. The reason the video starts with me plugging the DC in is because that's about how long I like to let this run before I start to worry about burning up the board:

The striker you see is made by taking the case off a relay and using the mechanically moving part, attached to a lever, to strike something that makes a pitched, ringing sound. (Hard drive platters look pretty but are hard to suspend. Wine glasses are an option because they're easy to tune (Water, wine, oil, whiskey). Whatever, I can solve that part easily once I get the electronics working.)

The finished project will have 12 of these, not striking all the time but chiming chords at regular intervals.

Since 12V is overheating the Arduino... either

(a) there's another thing that my grasshopper brain is forgetting that's causing this, and a better circuit could allow 12V to run through the Arduino without killing it (perhaps a resistor somewhere?)

(b) I should keep the Arduino powered off 5V. Then send 3V3 or 5V, via the shift register, to control an array of transistors which will switch on a 12V supply to throw each relay/striker. This sounds slightly Rube Goldberg-y, but I guess it's not really SO many steps.

But, maybe there's a simpler way?

just get another power supply.

the regulated wallwarts nowadays are not expensive anymore. you can get a 3,4.5,5,6,7,9,12V 1A one for little money. the magic word here is regulated. cheap unregulated ones will spit out a lot more voltage when powering only small loads (arduino), which makes the voltage regulator fry. use your current wallwart for the 12V relays (they don't care) and power the rest with clean 7V going into the arduino's power jack.

if the relays (small ones ?) are just pulsed once in a while like shown in your video, I think the power shift registers can cope with it. if you're worried, just use 2 of them with only 4 relays per chip. less heat to spread.

if you're talking about more than say 250mA per relay, single transistors are better. a 2N2222 can deal with 800mA if fully switched on and is still quite small. after that comes the reign of other devices.

Madworm: Exactly!

(really, just powering Arduino off USB 5V and then using my crap power supply in 9V mode-- which actually reads about 12V on my meter with no load connected. Things to to: Buy a regulated one-- to power whatever's hooked to the shift register. It killed some of my LEDs, oops, higher resistor values next time, but the relays LOVE it. CLick click click click. So happy.)

The only other time I tried using two power supplies in a circuit I blew up my logic board. So, I guess things are looking up by comparison.

Today I'm building all the rest of the strikers and supports, and getting some solid core wire to hook it all up. Will post photos/videos.

C

Grumpy_Mike, CaptainObvious, madworn and others:

Here is the final version of this project. I got it all documented and wanted to share. This would have either never come together without your help, or else it would have been much, much more slow and frustrating. Thanks, all! Happy holidays!

Link: Circle of 5ths Clock - YouTube