Go Down

Topic: quiet start-up for shift register? (Read 1 time) previous topic - next topic

kmwkmw

I have an arduino connected to a 74HC595 shift register, similar to the set-up in this tutorial (http://bildr.org/2011/02/74hc595/).  The output pins of the shift register are connected to some relays.  Output pin high sets relay off; output pin low sets relay on.

My problem is that when I start or reset the arduino, the relays chatter rapidly for a second or so.  I would like to avoid this.

What is the best way avoid fluctuations in the shift register output pins when the arduino is starting up?  I've tried writing to the shift register in the arduino setup() function, but that doesn't seem to be soon enough.  I'm using digital output pins 8, 9 and 10 on the arduino to control the shift register.  Would I have better luck with different pins?


CrossRoads

Only sure way is to control the output enable pin also.
Pull it high with 10K resistor, and pull all the outputs high also.
When your sketch starts up, don't drive output enable low until you have shifted 1's in and are ready to start driving the outputs high or low.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

magagna

How about - instead of tying OE to ground, connect it to an IO pin (any free Arduino pin) and a 10K pullup resistor.

The pullup resistor will keep OE high until you're ready for it, and when OE is high on a 74hc595 its output pins are in high impedance (disconnected).

When your startup & config code is done running in your Arduino sketch, do digitalWrite(yourPin, LOW) to enable the 74hc595's output pins, and away you go.

Good luck!
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

kmwkmw

Thank you the quick and helpful answers.  I had tried controlling OE; what I was missing was the pull-up resistors.

Hippynerd


How about - instead of tying OE to ground, connect it to an IO pin (any free Arduino pin) and a 10K pullup resistor.

The pullup resistor will keep OE high until you're ready for it, and when OE is high on a 74hc595 its output pins are in high impedance (disconnected).

When your startup & config code is done running in your Arduino sketch, do digitalWrite(yourPin, LOW) to enable the 74hc595's output pins, and away you go.

Good luck!



You can do that? That is beautiful.
https://sites.google.com/site/rgbledcubes

magagna

Quote
You can do that? That is beautiful.


Yep, I've done this before with a LED matrix -- shut off OE, update the shift registers and switch to the next row, then turn OE back on. This gets rid of any ghosting between the rows.
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

dhenry

Quote
shut off OE, update the shift registers and switch to the next row, then turn OE back on.


You can get flickering with this approach, if a lot of data is transmitted.

A better approach is to use the latch.

elamukil

Can someone help me with a schematic on where to connect and put the resistor. I am novice and defenitely need your help to solve the same problem of mine.

Paul__B

#8
Jan 30, 2016, 10:46 pm Last Edit: Jan 30, 2016, 10:46 pm by Paul__B
The problem described here is an extremely badly thought-out design.

If you know that the shift register will be cleared on reset - set to LOW - and there is a control pin specifically to do just this, then it is simply stupid to use it in an active-LOW arrangement to control relays - or anything else.  You are your own worst enemy if you make this blunder.

If you want to control relays, you use a TPIC6B595 (or its variants).  It pulls down respective outputs when the corresponding latch bit is HIGH, and can drive 150 mA (more with the "C" version) to relays running at up to 45 V.  Why would you ever do it any other way?

elamukil

#9
Jan 31, 2016, 06:06 am Last Edit: Jan 31, 2016, 06:21 am by elamukil
Hi Paul thanks for your reply. excuse me as I can understand only part of your answer. Let me ask you one more question.
1. for the very first time I run the program I want to connect my relay to the arduino board and want the relay to remain off until i turn it on through my program. Now when I turn on the board the relay toggles on/off for multiple times and then it stabilizes. i connected it to pin 13 or arduino uno.
2. When the power goes off and comes back i want the relay to return to its previous state (on/off)
3. How can i avoid the initial toggling. should i connect it to different pin? i am planning to connect at least 8 relays and i guess i have to use pin 13 also.

I have basic understanding of electronics and will need little extra help to understand more technical terms. once again thanks for your reply.

Paul__B

The problem is that you have suggested that you have it wired such that the relays are actuated when the shift register output is LOW or perhaps even, open circuit.

I want to see a diagram of what circuit you are using to connect the relays before any useful suggestions can be made.  Web link or photo of diagram.  (All photos to be taken in daylight and perfectly focussed if you please!)  "Connected to some relays" just isn't going to cut it, and we need to know what relays these are, their coil resistance and operating voltage.  Are you using a pre-made module?  If so, the Web link to this module.

elamukil

I am using the below diagram an link as reference to build my circuit

http://cdn.instructables.com/FXF/4R6Z/HRCK38OG/FXF4R6ZHRCK38OG.MEDIUM.jpg

http://www.instructables.com/id/Arduino-powered-bluetooth-remote-relay-switch/?ALLSTEPS

I am using uno bord and for the two green lines that goes to the relay i use pin 13 and 12


Thanks

Paul__B



Well now, that diagram does not in any way whatsoever refer to a 74HC595, so it is of no use whatsoever, nor is the (Ugh!) "instructable".

So let's have another try.

Oh wait!
:smiley-eek:  :smiley-eek:  :smiley-eek: Oh!  :smiley-eek:  :smiley-eek:  :smiley-eek:

You mean your problem has nothing to do with the thread that you have added to?  Now it makes more (or indeed, less!) sense!

I think you had better start again!

You are controlling a (twin) relay board.

You are using a UNO - at 5 V.

You are having some problems with spurious operation of the relays.  I can guess part of the problem because it appears here so often.

Right, you must give a weblink to the relay board you are using.

You must show the complete code you are using; go and read the instructions, then mark up the code as such so we can examine it conveniently and accurately.

elamukil

I bought the relay board on ebay the board uses optocoupler and jumper wires are connected to jd-vcc and vcc. There are four pins provided in the relay board. for which vcc and gnd I am connecting to the 5v and gnd pins in my uno. the other two pins I connected to pin 13 and 12.

Below is the code i am using. For now I am working with only one relay.

Code: [Select]


char val;         // variable to receive data from the serial port
int ledpin = 13;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  digitalWrite(ledpin, LOW);  // turn ON pin 2

    Serial.begin(9600);       // start serial communication at 115200bps

}

void loop()

{
  if( Serial.available() )       // if data is available to read
  {
    ;
  }
  val = Serial.read();         // read it and store it in 'val'

  if( val == 'a' )               // if 'a' was received led 2 is switched off
  {
        digitalWrite(ledpin, HIGH);    // turn Off pin 2
  }
 
  if( val == 'A' )               // if 'A' was received led 2 on
  {
        digitalWrite(ledpin, LOW);  // turn ON pin 2
  }

}


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy