Go Down

Topic: Arduino intermittentantly and randomly stops running code (Read 114 times) previous topic - next topic

yelsew007

Hello All, this is my first post here on the forum, so please excuse any posting misakes (did I post this in the right location?). I am currently having problems with my Arduino Uno connected to a Seeed Studio Relay Shield V3.0. My circuit is as follows: the shield is stacked on the Arduino, and each of the four relays have the Normally open terminal connected to the positive terminal of a solenoid valve. The other pole of the relay is connected to +12v, for the solenoid valves. The ground pin of all my valves are connected to the ground of my 12v power supply, which is also connected to Arduino's ground. Code:
Code: [Select]
const int ValvePinOne = 7;
const int ValvePinTwo = 5;
const int ValvePinThree = 6;
const int ValvePinFour = 4;
void setup()
{
  // put your setup code here, to run once:
pinMode(ValvePinOne, OUTPUT);
pinMode(ValvePinTwo, OUTPUT);
pinMode(ValvePinThree, OUTPUT);
pinMode(ValvePinFour, OUTPUT);
}
void loop()
{                                                        // put your main code here, to run repeatedly:
digitalWrite(ValvePinOne, LOW);                          //All Valves Closed, muscles relaxed
digitalWrite(ValvePinTwo, LOW);
digitalWrite(ValvePinThree, LOW);
digitalWrite(ValvePinFour, LOW);                           //equalize muscle pressures
delay(350);                         
digitalWrite(ValvePinTwo, HIGH);                         //contract right muscle
digitalWrite(ValvePinFour, HIGH);
delay(350);
digitalWrite(ValvePinTwo, LOW);                           //All Valves Closed, right contracted
digitalWrite(ValvePinFour, LOW);
delay(350);                       
digitalWrite(ValvePinOne, HIGH);                       //contract left muscle
digitalWrite(ValvePinThree, HIGH);
delay(350);
}


The (really simple) program works perfectly when I power the Arduino, turning the relays on and off as I intend. Powering on the 12v power supply and allowing the solenoid valves to recieve power through the relays creates some truly odd results: the Arduino pauses at random intervals and does not energize the relays for about a second. Then, it resumes, occasionally falling slightly out of time, adding an extra quarter second or so of delay at completely random intervals. Sometimes it works perfectly for 20 loops, sometimes it skips nearly every other relay activation. This problem does not occur when I disconnect my 12v power supply from the system. I am at a loss, after attempting to isolate the problem for hours on end, by removing one relay at a time, and by swapping out the arduino itself. I am far from an electrical engineer, but have a fair amount of Arduino experience, and have never seen anything like this. I will post a link to a video of the erratic behavior before the end of the day. I would really greatly appreciate any help that could be offered in my direction.

Update: Video of the problem happening: https://www.youtube.com/watch?v=cAIqnp7cmvI

codlink

Although you say the circuit is simple and you have tried to explain it, it would be better for us if you drew a schematic of your setup.  Even if it's pencil on paper.  What is the other relay shield doing?  Why is your 12V going there?  To troubleshoot I would take out everything that does not need to be connected.  What is the specs of your 12V?
//LiNK

Fox65535

The (really simple) program works perfectly when I power the Arduino, turning the relays on and off as I intend. Powering on the 12v power supply and allowing the solenoid valves to recieve power through the relays creates some truly odd results: the Arduino pauses at random intervals and does not energize the relays for about a second.
Are these classic electro-mechanical relays? If so, you will need something that will dissipate the power, stored in the relay coil, when you turn off the relay. If a little delay in drop out is OK, put a reverse-biased diode across the relay. If you need a faster drop-out, there are other devices that you can put across the relay coil.

Without such protection, your driver transistors can fail also.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy