Go Down

Topic: Controlling relays with ULN2003 (Read 3 times) previous topic - next topic

Varkey

I am new to Arduino Mega2560. For one of my projects I have to control 8 DC motors for direction and another 8 DC motors as pairs for direction. The motors are driven directly by pairs of relays. The relays are driven by ULN2003. The inputs for the ULN2003 are given by the Digital output pins. High on one pin drives a input of the ULN2003 which activates the relay which drives the motor in a particular direction. There are 3 numbers of ULN2003 with a total of 20 inputs from the Mega2560
The motors are driven at 12V from an independent power source fed directly to ULN2003 from that of the Mega which is powered by the USB of my laptop. Now the outputs from the Arduino have been tested and found to be working properly. but when conected to the ULN2003 they just start to oscillate randomly. The Mega2560 hangs up and then the system has to be shutdown and rebooted for it to start working. I thought there is more current being drawn from the output pins of the Mega and maybe they could not drive all the pins of the ULN2003
I have tried adding 20K between the mega2560 and the input of ULN2003 to limit the current but with no success.
To put a long story short I have blown the Mega2560 and am getting a new one. But before I fry another board I would like to know what I am doing wrong. I came across
Loading/stalling DC motor temporarily breaks serial communication to PC over USB
http://arduino.cc/forum/index.php/topic,58217.0.html
There is a reference to adding 0.1uF capacitors to the end of motors. Here I can try adding them to the relay coil as they are both inductive load.
http://www.pololu.com/docs/0J15/9
Another solution to limit back EMF would be to add diodes to the digital output of the mega2560 to the ULN2003
Would this be a solution?
but why is the mega hanging up?
Has anybody else faced a simillar problem?
Please help.

MarkT

Firstly without the circuit diagram we can but guess.

You haven't mentioned flywheel diodes for the relays - you have used freewheel diodes?

What are the relays?  How are the relays powered?  Are all grounds commoned up?
[ I won't respond to messages, use the forum please ]

Varkey

Dear MarkT
I am sending the circuit diagram i have used as an attachment.
The freewheeling diodes are added as shown though the ULN2003 has its own diode on each output.
The relays are 12V relays driven by 12V supply (Red line)
The grounds are commoned for the arduino mega 2560 also (Blue line) as shown in the diagram.
I thank you in advance.

Graynomad

#3
Apr 24, 2011, 05:40 pm Last Edit: Apr 24, 2011, 05:45 pm by Graynomad Reason: 1
The way those relays are drawn they won't control the motors, it looks like you either have 12v on both sides or 0v on both sides of the motors.

Not that that would have anything to do with your symptoms.

Are you sure you've blown your Mega, I can't see how you would from that circuit.

Quote
add diodes to the digital output of the mega2560 to the ULN2003

I don't see any point in that.

Quote
but when conected to the ULN2003 they just start to oscillate randomly.

That's very weird and doesn't make much sense, do you have the chips in the right way? (well it's been known)



_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Varkey

Dear Greynomad,
the relays are conected so that when the input to the ULN2003 is the same for then the relays don't rotate the motor. but when either of the inputs to the ULN2003 is different then one of the relays will conduct to the motor rotating it in one direction. The relays are working almost as a H bridge. Thus I can have two direction for the motor rotation and full stop of the motor when not required. I have tested the circuit independently and it works. It works for al the 20 relays when it is not connected to the mega 2560.
The moment the mega is conected it works fine. but when any of the mega output is high, all the relays start oscillating.
The output from the mega is tested and works fine without the further circuit. It follows according to the software very nicely.
From what I could gather there is either
Too much current drawn from the mega or
There is a back EMF or some parasitic oscillation setup because of the circuit which could not be ascertained.
I could not understand why the mega locks up
My mega 2560 is not being recognised by the computer USB though the green light is switched on.

Go Up