My arduino reset my sketch during the program.

Hi Im using my arduino and I have 2 reles, I think the problem is because of them. Each one need 10mA to work, I conect them from the DigitalOut of my Arduino directly, without resistors.

Always only one of them are turned on, and the problem happen when I swith o the other, I think that maybe is because in an instant both are turned on and maybe I'm asking for too much power.

I try to fix my problem with a delay of 100 between the change. But I dont try if the new fix works, do you think about another source of the problem, any other idea?

Q1: Do you power the Arduino and relays with an USB cable or do you have a separate powersupply?

Q2: do you have a datasheet of the relays?

Each one need 10mA to work

Are you sure of this? I have never come across a relay that takes so little current. You normally need a transistor to drive a relay you can't do it directly from an arduino. You also need a diode across the coil to stop back EMF.

Hello again!

Q1: Yes I'm using the USB because I read the USB port can give a max of 500mA and If I and my datasheets are right, I'm only using 2 relays of 10mA each, and never use both at the same time. (+ the Arduino)

(I also have 2 tiny servos but theseone's barely moves)

Q2: The relay (or signal relay, as the DS says) is this one: http://www.sunhold.com/md.html (5 volts of course)

With that relay I activate a power relay: http://www.sunhold.com/ras2.html

but I think that one dont interfere with the Arduino because is in a complete separate circuit powered with another source.

I'm not sure about the EMF, I read a little bit and I understood that the EMF is a voltage induced by the coil of the relay, I'm right? I need the diode with the kind of relays I'm using?

And as I said, sorry I can't apply this solutions instantly to my circuit, but I dont have access to my school lab every day (because my schedule).

THanks!!

P.S. the problem usually happen (but not every time) when the Arduino de-activated one Rele and activate the other. That's why my first idea was the delay of 100 between activate the second.

The data on the datasheet doesn’t quite add up. 5V and 500 ohms is 10ma but is 0.05W, not 0.5W. Next time you are in your lab could you check the coil resistance with a ohmmeter just to make sure?

Also, reed relays sometimes have the EMF protection diode built in. In that case it is important to connect the coil the right way round. If it’s the wrong way round the diode will conduct the current instead of the coil, acting a bit like a short circuit. This could possibly cause the reset behaviour you describe.

I agree with the last poster. If you look at that data sheet you posted to you will see that there can be an internal diode option ordered (will result in a letter ‘D’ in the last position. If you happen to have wired either of the coils backwards it would result in a high current draw situation when turning on a relay. Check to see if your relays have this diode option and wire coil polarity correctly if that is the case.

Lefty

Yes it sounds like the lack of a diode is causing a reset. This will only happen when the relay turns off because at that point the magnetic field collapses and induces the reverse voltage which in effect powers the arduino off. Which is why you see a reset.

I can use a multypurpuse diode to correct the problem? or the EMF are faster than the diode?

Pretty much any diode will work. Cheap and cheerful 1N4001 or 1N4148 ?

The problem persist, already add the diodes to the relays. I think maybe Im overloading the Arduino. I have the 2 relays (never works bouth at the same time), and two servos like this one:

http://www.giantcod.co.uk/162g-dys0207-mini-servo-23kg-torque-p-402468.html

(also 2 pots conected to 5v, resistor and analog inputs, to change the values of my inputs)

All atached to my arduino diecimilla powered by USB.

The problem still happening usually when the arduino turn off the relays.

Ideas? My idea is conect the servos to an external 5v source and conect the same ground for both.

Yes it is likely that the servos are drawing more current than your supply can cope with.

It doesn't help that all this information is dripped out a bitt at a time, it makes giving good advice impossible.

Sorry grummer, I reply your suggesitions too late because I dont have my project everytime with me and I need to read the suggestions, and then apply them to my circuit.

I will try to solve this connecting the servos to another power source. I think that without them If the problem persist, I can discard the power stuff as the problem. im right?

THanks

The trick is to measure the voltage with the motors not moving and then again with the motors moving. There should be no difference in voltage. If there is then the supply is not good enough to give the current.

THank you Grumpy, as you said the voltage changed when the motor start moving, so I attach them to another power source, now the problem is almost gone, with a lot of tests only one or two fail and I think that was exactly when I was playing with the pots at the same time the arduino finish the delay (on my sketch) and read the inputs, but this is aceptable, because the pots are only to set the initial point and then I dont need to move them anymore.

If all continue like this I think this topic will be solved, just let me continue testing and I post here my conclusion

Thanks