I have made a aquarium controller using a Arduino Mega but i have a problem with the relay.
The code works but randomly while the relays that are handling the 220V are switching the arduino blocks.
I have tried to let the relay operate with no load after them (pumps in may case) but still blocks the arduino. The arduino stops blocking only when i deactivate the pumps and by consequence the relays are not used any more.
The relay i am using is a 8 relay block like this one :
How many relays are you trying to turn on? Also - is this relay board an active HIGH or active LOW switched board?
These relay boards use an optocoupler to switch the relay (the little 4-lead square device); depending on the device used, this can be an issue - some of these devices sink 30-40 mA of current when "on". Check the datasheet for the component.
Depending on whether the board is an "active HIGH" or "active LOW" switched board, you can only pull or push 40 mA per pin (you should actually keep this to around 20 mA per pin) - and depending on whether you are pulling (active HIGH) or pushing (active LOW) current from a pin, the total amount of current you are allowed varies from 100 to 150 mA:
If this board is typical of what I have seen - it's an "active LOW" board, meaning you are only allowed 100 mA total to the Arduino - and given the needs of the optocouplers, that limits you to only a couple of relays "ON" at a time.
Again - check your datasheet for the optocouplers carefully. I suspect, though, that the board is pulling or pushing more current than the Arduino can reliably handle (because your system is switching "on" more relays than the Arduino can supply current for) - and this might be a cause of your issues.
It's only a guess, though, based on the limited information you have supplied. If you think it might be the case too, try unhooking all but one relay - and see what happens. Then add a second, then a third, etc.
the relay are active low, and i try to handle 16 relay (2 boards of 8 relay each) but i never had more then 9 relay ON ant the same time .
I will check the datasheet of the optocouplers ...
According to your schematic drawing, you are connecting together the grounds of the arduino and relay power supply. The whole reason for having opto couplers is the keep everything separate... Try connecting the arduino outputs and ground to the input side of the optos, and separately powering the relays with the other power supply on the other ground and input pins(remove the jumper which makes the power supplies common.
The grounds are most likely already common because of the single 24volt supply (24>5 DC/DC ground is passthrough).
The .pdf of the optos is not important. How much current is drawn depends on the current limiting resistor on the relay board. 2mA per opto in this case.
Did you remove the jumper on the relay board.
LED VCC power from Arduino, and opto transistor/relay power JD-VCC from relay supply.
Why use a 24volt supply and DC/DC converters.
Can you post the specs.
Leo..
i did removed the jumper on the relay board to get less current absorption from arduino
i use the 24v and dc/dc conv. because is a complex project . The 24v are powering high power leds, and the dc/dc power relay boards, RTC, temp sensors ....
the DC/DC
the specs: dc/dc cam output up to 3A (and i do not reach that load )
the relay can handle up to 10A (and i do not reach that load)
The problem i have is only showing on the relay board that is switching the 220V, while the second relay board that is switching 24v and 12V works perfect.
Also the problem doesn't show always , but randomly; it can run smooth for a day,2 days or a week (that is why i excluded a bug in the program) ; while the other relay board runs perfect always.
TomGeorge:
Hi,
If you are using a mega, you have 54 digital I/O.
What are you using them for?
How much load do you have on the power supply system?
Tom....
i use them for : 33 pins for 3.2" display ,1 for water level sensor,1 for temp sensors, 7 for PWM Led , fans, display dimming = 42.
I do not know the exact load on the power supply but i am sure is little because everything (including temp robes, RTC) are powered from DC/DC converters to minimize the load on Arduino, and the board is not getting hot.
TomGeorge:
Hi,
With all that connected to your arduino, have you got any bypassing capacitors fitted.
No i don't . Can you please explain me where to use them and what type of capacitors ?
Later today i will make a drawn of the circuit and post it ... for now i have it only 2 copy's one in my head and one that is build and handling my reef thank.
TomGeorge:
Can you please post a complete copy of your entire circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
As promised i attach the diagram of the circuit . I hope someone can help me .... because i become insane with this issue ... and i have no clue how to solve this .
With the risk of repeating myself ... i have problems only when the program (sketch) is switching the relay block that handle the 220V and only randomly (some relay are programmed to switch once every 20 minutes and i get the block of Arduino after a day ,2 days or even a week ... )
Try using the full opto isolation feature of your relay boards. In this case, do not use a GND connection from the relay board to the Arduino.
An MOV can work quite well in reducing contact arcing when switching AC loads. This MOV is rated for 275VAC and can be connected directly across the relay contacts (COM and NO) if those are the terminals you're using.
Increase the distance from the Arduino to the relay boards if possible - this will reduce its susceptibility to EMI interference.
I would not connect the RTC and temp sensor to the external 5volt and ground.
All sensors should get their supply and ground from the Mega.
Too many grounds is NOT ok. That can create groundloops.
Better to have the two buck supplies close to the main 24volt supply, and make a star ground there.
Leo..
@dlloid
i have good programming knowledge but my electronic sucks ....
i will try to modify the project as suggested to use the full isolation
this MOV .. should be connected on the 2 pin of relay where are connected the wires that i switch (in parallel with the wires on the 2 contacts of the relay ) .. right ?
3 . the relay block is powered like in the picture you posted ... except i did not connected 5v from arduino .... but because of the common ground it works anyway.
i have 10-15 cm from Arduino to relays ... should i increase it even more ?
you could be right with the RTC but for the temp. sensor i use Dallas Temperature Sensor and one wire protocol (i have 3 sensors on the same Arduino pin) and after some reading i understood is the best way to connect them with external power : Arduino Playground - OneWire
I created only one ground point where i connected all the grounds ... but it was easier to draw by hand like i did in the schematic i posted
I will try the solutions suggested and let you know the results . Thank you guys .
SSerpente:
Dallas Temperature Sensor and one wire protocol (i have 3 sensors on the same Arduino pin) and after some reading i understood is the best way to connect them with external power.
Confusing advice.
Normal (external supply) mode vs. parasitic mode.
I think it means 3-wire mode vs. two wire mode.
"External" as in not from the second (data) wire.
Just power them from the Mega.
The relay supply should just power the relays. Nothing else.
Leo..