quiet start-up for shift register?

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?

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.

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.

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

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

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

Thanks

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!
:astonished: :astonished: :astonished: Oh! :astonished: :astonished: :astonished:

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.

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.

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
  }

}

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

I've found this works really well,for outputs 0 -7, but the overflow pin (which is not affected by the OE pin according to the datasheet) stubbornly remains on at startup and while the Arduino reset pin is being pressed. I'm not going to lose any sleep over it, it works well enough for my project (which will be transferred to an ATTiny so I'll run out of pins) but if anyone has any ideas - or spots an obvious flaw in my code - that would be useful, thanks.

  digitalWrite (latchPin, LOW);
   int i;
   for (i=0; i<=8; i++)      //Clear-down all outputs prior to O/P, inc overflow
      {
       digitalWrite (dataPin, 0);
       digitalWrite (clockPin, HIGH);
       digitalWrite (clockPin, LOW);
      }
    digitalWrite (latchPin, HIGH);

  pinMode (enablePin, OUTPUT);
  digitalWrite (enablePin, LOW);                //enable the ouput (hopefully!)

Sorry, you have a "snippets"problem - unless and until you actually post your code, I don't think it is worth figuring it out. :astonished:

Either that or go back and explain what is your purpose for using the cascade output.

Paul__B:
Sorry, you have a "snippets"problem - unless and until you actually post your code, I don't think it is worth figuring it out. :astonished:

Either that or go back and explain what is your purpose for using the cascade output.

No current (no pun intended!) use for it. I'm curious to know how to control this in case I need to know in future ta.

You can't. 595 has garbage in it. With OE you suppress it for the outputs but Q7' isn't affected by that. Would make daisy chaining a pain if it would... Aka, just use the outputs :slight_smile:

PS You could just use shiftOut() instead of your inline version of it :slight_smile:

septillion:
You can't. 595 has garbage in it. With OE you suppress it for the outputs but Q7' isn't affected by that. Would make daisy chaining a pain if it would... Aka, just use the outputs :slight_smile:

PS You could just use shiftOut() instead of your inline version of it :slight_smile:

I guessed it might be a design feature, never thought it might be to do with daisy-chaining but at least I know now, ta.

RMurphy195:
I guessed it might be a design feature, never thought it might be to do with daisy-chaining but at least I know now, ta.

Well, that is what it is for, and its crucial and in fact, only purpose.

Paul__B:
Well, that is what it is for, and its crucial and in fact, only purpose.

I disagree - it would be used for whatever a designer building the chip into a circuit would want,in the same way as a programmer using the shift instruction in a piece of software would use the overflow/remainder bit. And knowing how the chip behaves is the crucial thing.

Well, you can disagree all you want. :roll_eyes:

Yeah, the designer can use it how he likes. But if you use the Q7' for something other then daisy chaining I thing the designers of the chip will call that misusing it :smiley:

Well, I solved the problem of the overflow pin being unaffected by the OE.

Simply added a transistor NOT gate ..

Base - picked up from the supply to the OE (Pin 13) which is held High until I'm ready during Setup().I have a resistor and LED in this part of the circuit.

Collector is from the Q7' (overflow pin 9 on the shift register), with the resistor and LED to suit

Emitter to earth.

Both LED's are restricted to 5ma

The transistor I used to get it working was a 2N3904.

The basic NOT gate circuit filched from my copy of "Electronics for Dummies" - available online at <b>Electronics Projects: How to Create a Transistor NOT Gate Circuit</b> - dummies

The use of an LED on both paths means I have indication of when overflow is triggered, and also a visual indication of the startup phase of my application.

So I've worked out how to solve the problem, in case anyone wants to do something similar. At some point I'll produce a schematic and some notes to pop into an appropriate part of the forum, when I've found out where.

But new trouble, that does not work push pull :wink:

septillion:
But new trouble, that does not work push pull :wink:

Not sure what that means, or whether its relevant in my context (learning the behaviour of the overflow output and how to control it)

In your application, probably not. But in general, yes, because with your solution Q7' behaviors different from the rest.

The normal outputs are able to source (drive high) but also sink (drive low). If you add a single resistor you can only do one of those (depending on the type of transistor).

RMurphy195:
Well, I solved the problem of the overflow pin being unaffected by the OE.

Simply added a transistor NOT gate ..

Base - picked up from the supply to the OE (Pin 13) which is held High until I'm ready during Setup().I have a resistor and LED in this part of the circuit.

Collector is from the Q7' (overflow pin 9 on the shift register), with the resistor and LED to suit

Emitter to earth.

Both LED's are restricted to 5ma

The transistor I used to get it working was a 2N3904.

The basic NOT gate circuit filched from my copy of "Electronics for Dummies" - available online at <b>Electronics Projects: How to Create a Transistor NOT Gate Circuit</b> - dummies

The use of an LED on both paths means I have indication of when overflow is triggered, and also a visual indication of the startup phase of my application.

So I've worked out how to solve the problem, in case anyone wants to do something similar. At some point I'll produce a schematic and some notes to pop into an appropriate part of the forum, when I've found out where.

Hello RMurphy !
I have the exact same issue as yours and I tried your solution with a transistor but I can't get it work perfectly. I think I miswired it. Would you have a schema or a picture of the wiring to share ? It would be great !