-
Relay Problem
Posted by
Bskitter
on 08 May, 2016 23:44
-
Hey Guys,
So I have a problem with a college project I am doing,
I have 8
relays these realys are then connected to N2222 tranistors and then those transistors are connected a shift register and the shift register is connected to an Arduino.
I began to test the relays now and I find a problem !
If I connect a light to the relay and turn the light on and off all 8 relays are somehow effected by this and in some case all the relays "bounce" to there off state.
This is the configuration I am using on the board ! just 8 times
Here is the actual board I made
This board then connects to this board
and then this connects to an Arduino.
So once again the problem is when I connect a light to the relay the is already on it creates some sort interference and cause the realy or relays to turn off sometimes the realys go completely crazy and they all turn on and off 3 or 4 times until staying at a certain state,
Please note that I am a computer Science Major and have limited knowledge in Electrical Engineering !
Also note the light bulb is working off 230V mains.
Byron
-
#1 Reply
Posted by
wraper
on 08 May, 2016 23:48
-
Sounds like a problem in your code, circuit should work if properly assembled..
-
#2 Reply
Posted by
Signal32
on 09 May, 2016 00:06
-
Hook up some LEDs with 1k resistors in series to each of the output of the shift register.
If the LEDs are also misbehaving, same as the relays, then the relays are doing what they're suppose to be doing and the problem is with the code / arduino hookup of the shift register.
Try to check the clock / data / latch of the shift register on an oscilloscope.
-
#3 Reply
Posted by
Bskitter
on 09 May, 2016 00:08
-
-
#4 Reply
Posted by
Fank1
on 09 May, 2016 00:10
-
What is the IC on the second board and where does it get it's power from?
-
#5 Reply
Posted by
danadak
on 09 May, 2016 00:15
-
Are the outputs, in code, of Arduino being tri-stated at any point,
which would make them subject to coupling caused by turning on/off
a big load.
Are grounds for high current separated from Arduino and only meet at point power
enters the board ? Use a scope and look for ground bounce in the system. Look
at Arduino power pin also, set scope to trigger on V transient of say .5 volts from
nominal for starters.
Regards, Dana.
-
#6 Reply
Posted by
Bskitter
on 09 May, 2016 00:23
-
It is actually not the code,
The Relays are still acting fishy,
The Chip on the second board is a 74HC595 shifting register.
The realys get their power from a 12V switch PSU.
I then Use a 2575T voltage regulator to get 5 volts for the IC
danadak, what is tri-stated ?
-
#7 Reply
Posted by
Bskitter
on 09 May, 2016 01:17
-
I have changed the program again and now it works a lot better !
I presume when you program it, and ask the Arduino to do the same thing with different types of programming the compiler does not compile the code to the exact same thing,
Example,
Code 1 -- Compiler -- CompiledP1
Code 2 -- Compiler -- CompiledP2
Even if code 1 and 2 do the exact same thing the compiler will still tell the arduino to do the same task differently, the first and second method I was using did not work well but method 3 looks like there is no problems but I am still doubtful.
Thanks for the help guys.
Byron
-
#8 Reply
Posted by
AF6LJ
on 09 May, 2016 01:30
-
It is actually not the code,
The Relays are still acting fishy,
The Chip on the second board is a 74HC595 shifting register.
The realys get their power from a 12V switch PSU.
I then Use a 2575T voltage regulator to get 5 volts for the IC
danadak, what is tri-stated ?
I didn't think it was the code and here is what may be going on...
If you are using the same supply for both the relays and the microcontroller you may have dynamic cross talk in short the relays may be generating noise that is causing your microcontroller to act goofy.
Try running it off a separate supply...
Another bit that may help you out. make sure the relay board has it's own return path to the power supply, that might help...
-
#9 Reply
Posted by
Johnb5012
on 09 May, 2016 01:50
-
Consider using pull down resistors on the relays to debounce them.
-
#10 Reply
Posted by
danadak
on 09 May, 2016 09:41
-
-
#11 Reply
Posted by
wraper
on 09 May, 2016 10:31
-
The Chip on the second board is a 74HC595 shifting register.
Either your code works incorrectly with 74HC595, or there is no decoupling capacitor connected near to it. Or ground connection is not good, like passing high current through a weak ground wire between arduino and 74HC595.
-
#12 Reply
Posted by
Bskitter
on 11 May, 2016 11:13
-
It is defiantly creating interference one the ground.
@wraper, how do you recommend me to connect the a decoupling capacitor ?
-
#13 Reply
Posted by
AF6LJ
on 11 May, 2016 12:41
-
It is defiantly creating interference one the ground.
@wraper, how do you recommend me to connect the a decoupling capacitor ?
Try running a separate ground from the relay portion of the circuit and one from the micropcontroller part of the circuit back to the power supply's negative terminal.
-
#14 Reply
Posted by
Ian.M
on 11 May, 2016 13:04
-
I'd separate all the emitters of the relay driver transistors from the 74HC595 GND and run a separate ground wire back to the PSU just for the transistors. That assumes the Arduino and '595 is powered by the same supply as the relays.
You may also need RC filtering on the '595's shift and store clock pins - try 1K in series and 100pF to the '595 GND pin, (giving a time constant of 100ns) to prevent double-clocking if there are any glitches on the edges and false clocking on fast spikes.
Decoupling should be 0.1uF from Vcc to GND at the '595 chip.
-
#15 Reply
Posted by
danadak
on 12 May, 2016 11:41
-
Be careful with RC networks that shape risetime for fast
logic inputs. The issue is too slow a risetime will keep a
CMOS input in its active region which can lead to oscillation
and noise triggering.
Regards, Dana.
-
#16 Reply
Posted by
Ian.M
on 12 May, 2016 15:10
-
Yes. Thankfully, 100ns time constant doesn't keep it in the transition zone for long, but I certainly wouldn't want to increase it. If it doesn't help, *DON'T* leave it in circuit.
RC networks on normal logic inputs are *NOT* the proper way to solve signal integrity or edge timing issues. Pick a time constant appropriate to the logic family. If you are slugging its response time by more than an order of magnitude, you should probably reconsider. One should only use them into a Schmitt trigger input, but that would need an extra buffer chip in this application. For a prototype or one-off one can get away with tweaking it till it works, but you'd better have the underlying issue sorted before production.
-
#17 Reply
Posted by
Bskitter
on 13 May, 2016 10:01
-
Understood, So ill put a 100pf cap in series with a 1 k from the ST_CP pin (Storage register clock pin (latch pin)) and the SH_CP pin (Shift register clock pin) but if it does not help I take these off !
What about putting a 1K resistor on the OE Pin (Output Enable Active low) to Ground ?
Regards
Byron
-
#18 Reply
Posted by
Bskitter
on 13 May, 2016 10:04
-
By the way the Arduino is connected to a lm7809 circuit the 595 is connected to a lm2575 regulator circuit and the relays are connected directly to the 12V PSU
-
#19 Reply
Posted by
danadak
on 13 May, 2016 11:19
-
The RC network should be a Low Pass configuration, a series R pin to
pin, and a cap to ground from the input pin / series R junction to ground.
If you have a DSO use it to detect runt and noise type pulses by setting up
its triggering to screen for pulses less then expected clock and data widths.
Then go probing around to seek the source, what pins are being affected.
Regards, Dana.
-
#20 Reply
Posted by
Ian.M
on 13 May, 2016 11:42
-
100pF to ground at the shift clock input pin, and between 100R and 1K (max) between the input pin and the signal driving it. Chances are the store clock doesn't need it because a glitch will only store the same data twice Don't filter data pins!
*IF* your problem is caused by a glitch on the clock edge double-clocking the '595 so the data bits after the glitch are sent to the wrong relay, the RC network will probably cure it.
Are you driving /OE from anything? If not, simply tie it to ground. /MR *MUST* have a pullup if you aren't driving it.
Are there any other loads on your 5V bus from the LM2575? Do you know if its output is stable? (scope it!)
All the grounds *MUST* connect together, but the connection for the emitters of the relay driver transistors should be separate back to the regulator board ground or even right back to the PSU.
You may do better replacing the transistors and resistors with a ULN2803 as the Darlington inputs with integral 2.7K base resistor have a higher threshold (so will be more tolerant of ground bounce) and will draw far less current from the '595 outputs, reducing noise on its supply. Again, don't connect its ground to the Arduino or '595 grounds except at the regulator board or PSU. If you've already got diodes across the relay coils you can ignore its COM pin.
Also, I strongly recommend RC snubbers (get prepackaged mains rated ones) across the relay contacts if you are switching mains loads to reduce EMI and contact burn.
-
#21 Reply
Posted by
Bskitter
on 18 May, 2016 10:16
-
Hey Guys !
Sorry for the long reply !
So I put a 1uf cap on the latch pin of the 595 ! This helps but does not fix the problem.
I tried to put a .1uf cap in series with a 47ohm resistor between - and + of all the relays,
This does not help either.
I then put a scope between one of the realys coils (NOTE this is a crappy DIY scope from china) and I see I negative voltage just after I put 230VAC through relays ! and then the relays turn off.
I am using a 1n0007 diode for the flyback on each coil.
NOTE when I power the Arduinoo on the Project PSU (using a lm7805 regulators with a .33uf cap on the input and a .1uf cap on the output) the problem is A LOT more apparent !
when I power the Arduino off the USB problem shows up a lot LESS !
Am i using the wrong Diode here ?
I am going to quick try a RC configuration between the switch of the relay
Byron
-
#22 Reply
Posted by
Bskitter
on 18 May, 2016 10:25
-
Relay board here
-
#23 Reply
Posted by
Bskitter
on 18 May, 2016 11:22
-
Tried an RC snubber in this configuration
did not work,
but I am get a slight shock from roil coils, I dont know exactly where its coming from.
I will double check all the diodes on the board.
I have found out if I just put the GND probe of the scope to a ground point on the breadboard it effects all the relays.
might use PNP transistors to see if this changes anything
Byron
-
#24 Reply
Posted by
Lee Leduc
on 18 May, 2016 13:34
-