I have connected two solenoid valves (12V DC) to a 2 channel Songle relay. The relay supports the power supply we want to give to the solenoids and the code is simple so I am surprised with the problems we're having. We have correctly connected the circuit as far as the NC/NO is concerned.
We wrote a simple code to turn solenoid 1 on for 5 seconds. Have both solenoids off for 5 seconds. Then turn solenoid 2 on for 5 seconds. Then have both solenoids off for 5 seconds.
For some reason the solenoids kept on overlapping and not following the commands we gave it.
I am a bit confused as to why this might be.
If anyone has had similar experiences or could shed some light on this I would appreciate it!
Welcome to the Forum. Without seeing your code, all we can do is wildly guess. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code looklike thiswhen posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.
I look forward to seeing the code as it should be very simple to do what you want. How is everything powered ? Are you driving the relays directly from the Arduino or via a transistor using a power supply external to the Arduino ?
OK, Aarg.. understood. I'll make sure to always post the code in the future and gave the guidelines a read through.
I am powering the arduino from the computer USB and we have an external power source (12V 1A - like the solenoids) that is powering the solenoids. We want the arduino to tell the relay when to close the circuit allowing the 12V current to power the solenoids.
We have the solenoid circuit connected to the COM and NO on the relay.
Obviously solenoids can be a little temperamental and can sometimes not shut exactly when you want them to depending on pressure and so on.. We can put this hypothesis to one side as the relay has 2 little lights that tell you when each channel is connecting. These lights do not follow the code and were on at the same time sometimes.
I'm not sure why this is happening.. should be a very simple operation but for some reason it isnt quite working.
When we adjusted the code so that just one channel would switch on and off this worked fine...
int relay1 = 11;
int relay2 = 10;
void setup() {
// put your setup code here, to run once:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relay1, HIGH);
delay(5000);
digitalWrite(relay1, LOW);
delay(5000);
digitalWrite(relay2, HIGH);
delay(5000);
digitalWrite(relay2, LOW);
delay(5000);
}
Otherwise the relay may switch or click-switch at setup.
The next thing is "switching inductive DC load".
If you are switching a DC valve, this is an "inductive DC load", and a correct hardware wiring would require a "freewheel diode" in your circuit.
Do you have those "freewheel diodes" in your solenoid circuits?