Go Down

Topic: General weirdness with 8 way relay board (Read 532 times) previous topic - next topic

FullOfBadIdeas

Hey All,

I've asked a few Qs on this relay, and gotten some great advise.  I have moved the board into my production system, and getting a few weird results. 

1.  low is high, high is low.  if I switch the logic in code, all is well.  it just bugs me. 

2. on program load, or board reset - all 8 relays "flutter" very fast.  no harm, I guess.  it stops.  then code works as written.  I do set pinmode on each pin, and do turn each pin off in setup.  maybe adding a delay in setup?

3. I am testing on a  DC power supply, not my main 12V (high amp) battery.  I have noticed, that sometimes - and only sometimes - when the relay switches off - it flutters they system.  I suspect this is low amp on my 5v side, not sure.  I do have a high amp 5v source, just the testing DC supply is showing amp strain in this situation (when it flutters).   I am controlling a solenoid with the relay (water valve) - and just have it straight  hooked up to the relay.  the relay just gives it the 12v.  no other circuitry there.

thanks!

Wawa

1. low is high, high is low.  if I switch the logic in code, all is well.  it just bugs me.

2. on program load, or board reset - all 8 relays "flutter" very fast.  no harm, I guess.  it stops.  then code works as written.  I do set pinmode on each pin, and do turn each pin off in setup.  maybe adding a delay in setup?

3. I am testing on a  DC power supply, not my main 12V (high amp) battery.  I have noticed, that sometimes - and only sometimes - when the relay switches off - it flutters they system.  I suspect this is low amp on my 5v side, not sure.  I do have a high amp 5v source, just the testing DC supply is showing amp strain in this situation (when it flutters).   I am controlling a solenoid with the relay (water valve) - and just have it straight  hooked up to the relay.  the relay just gives it the 12v.  no other circuitry there.
Inverted logic is common. Get used to it. You have also gotten used to seeing yourself 'wrong' in a mirror.

Write a HIGH to the pin BEFORE you set the relay pin to OUTPUT in pinMode, and all is well.
digitalWrite(relayPin, HIGH);
pinMode(relayPin, OUTPUT);
Don't use pin 0, 1, or 13 for relays.

? Maybe your supply drains too slow. That could upset the Arduino below 4volt ?
Leo..

terryking228

Hi,
Quote
1.  low is high, high is low.  if I switch the logic in code, all is well.  it just bugs me. 

2. on program load, or board reset - all 8 relays "flutter" very fast. 
This is understood and can be controlled. See THIS PAGE for how to initialize these relays properly so there is no unexpected flutter.

---------------------( COPY )---------------------
IMPORTANT NOTE: There is a issue with start-up of Arduino programs that control these relays. All of these 2,4, or 8 relay boards input controls are Active LOW, meaning that setting a pin LOW turns them ON. To assure that no relays activate at Reset or Power-On until you want them to, the initialization sequence in SETUP should be:
digitalWrite(Relay, HIGH);
pinMode(Relay, OUTPUT);

This design is intentional, so that it is possible to guarantee that at power-on of a system, or system reset, that no relays activate except when expected under program control. There may be pumps, lights etc attached and chaos could ensue if this was not controlled definitively for each output port being used.
-----------------( END COPY )----------------------

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

promacjoe2

I agree with the statement above. And I would like to add, certain pieces of equipment, machinery and other devices can be dangerous if activated on startup. The above procedures is a good practice to get in to for all output pins. Bad habits are hard to break, But you don't need to break a good habit.

The goal is to try to make good habits. And avoid the bad ones.

.

outsider

Most people new to electronics have the "hot wire -> switch -> light bulb -> neutral" scheme ingrained in their brain and low side switching is akin to putting the faucet in the drain pipe.

FullOfBadIdeas

wawa - thanks man - I am doing pinmode BEFORE I set the relays off.  I am changing that, and will test it tomorrow (my production system is outside and its cold!).  I'll just accept fate with low/high reversed.  I do have it well documented in code, and physically.  I am using pin 13.  should I ask why to avoid it, or just be quite and avoid it?

TerryKing - great link, lots of good info.  I dont see anything directly related to flutter, but I will reread - a lot on that page, thank you. 

Promac - I hear ya.  a little relay flutter no biggie, until its fluttering a bunch of bigger motors, or basically fluttering a few amps.  then fuses start popping.  I'm trying to get it right. 

I think I messed up my Q 3 - let me retry, since I tested it today with negative real word results.   

I am using one of the relays to control a solenoid controlled water valve.    the wiring is simplistic - on the 12v side, the negative leg is split on the relay (then to solenoid)- the positive leg right to the solenoid. 

when I turn relay on - it does active the solenoid (valve opens).  however, when the valve switches off, it flops, and its like the whole board does a reset.  I can see that relay 8 turns on, then off (the water valve relay is 2).

in test - like when blowing through solenoid valve - it worked.  give it 12v, I can blow through.  close 12v, I cant.  in real world - with a 30g full water bucket behind valve, it would open, but not shut off  maybe too much water pressure.   

am I missing anything on the circuitry to make this work better, or might be valve just be under rated?

terryking228

Hi,
Quote
when I turn relay on - it does active the solenoid (valve opens).  however, when the valve switches off, it flops, and its like the whole board does a reset.
That sounds like ElectroMotive Interference (EMI)  . I suggest you start with this page:

http://arduino-info.wikispaces.com/Arduino-Project-Planning-Electrical

Switching inductive loads like solenoids often creates interference that trashes Arduino until it's restarted.
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Wawa

#7
Jan 15, 2018, 01:26 am Last Edit: Jan 15, 2018, 01:31 am by Wawa
I am using pin 13.  should I ask why to avoid it..
Pin13 is connected to an onboard status LED.
The LED could be programmed to flash during bootup.
That will also chatter your relay.

Solenoids need a diode across the coil, to stop back-EMF spikes resetting your Arduino.
Assuming the solenoids are (12volt) DC powered.
Leo..


FullOfBadIdeas

Solenoids need a diode across the coil, to stop back-EMF spikes resetting your Arduino.
Assuming the solenoids are (12volt) DC powered.
Leo..


so - yes, they are 12v.  no, I am not using a diode now.  I assume the directionality wont matter much, and just put it from positive flowing to negative - like wire it directly on between the legs of the solenoid. 

I'll also assume the diode used shouldn't matter much, if its rated for the volts/watts involve.  like these.

https://www.amazon.com/Set-Diode-1N5349B-Zener-AXIAL/dp/B0086FBOFQ/ref=sr_1_5?ie=UTF8&qid=1515976978&sr=8-5&keywords=12v+diode

good assumptions, or not so much?


CrossRoads

"I assume the directionality wont matter much"

It matters very much - anode to the supply, cathode to transistor that sinks current thru the coil.
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.

Wawa

#10
Jan 15, 2018, 03:00 am Last Edit: Jan 16, 2018, 12:09 am by Wawa
No zener... Just use a common diode that matches the current of the solenoid.

A 1N4004 might do.

The diode is connected across the coil, with cathode (ring) towards 12volt/positive.

The diode shorts the back-EMF spike of the coil when the relay turns off.
Leo..

outsider

If it's a pilot operated valve, it may need a minimum pressure to close, head pressure of a foot or 2 from a bucket may not be enough. For very low pressures you should use a direct operated valve, larger, more powerful coil, and less flowrate, but thats the way the world works.  :)

FullOfBadIdeas

Thank a ton all.  I'm going to mark this SOLVED for the relay issues.  The reversal of shutting off, then pin mode did it.  I also think the big flutter on code push was that pin 13 led flashing.  I switched that pin out. 

I'll play with solenoid/valve  more, and post new thread if needed.   

Thanks again.

Go Up