22543Views16Replies

Driving a unipolar stepper motor with ULN2004 and arduino and a 9V battery, motor shaft rotates some time then stops?! Answered

I'm using the circuit below to drive a 6 wire unipolar stepper motor (1.8 degree/step , 2A/phase , 3.2 V , 1.6 ohm/phase). the problem is that the motor shaft rotates according to the program i wrote for just some time (about 20 seconds) then the shaft begins to stop moving gradually and its like it wants to move but it cant. i dont know where the problem and how to solve it , so any help will be appreciated.
here is the code i used to programe the Arduino Uno to drive the motor.
Note: the circuit attached uses the digital pins 8 , 9, 10 ,11 of the arduino while i'm using the pins 6,7,8,9 in my circuit.

#include <Stepper.h>

Stepper myStepper(200 , 6, 7, 8, 9);

void setup() {

myStepper.setSpeed(30);
}

void loop() {
myStepper.step(200);

delay(500);

myStepper.step(-200);

delay(500);

}

Tags:

The forums are retiring in 2021 and are now closed for new topics and comments.

Perhaps you are driving an unipolar stepper as if it was bipolar.

Your battery is dying. A 9V battery can't produce the energy your motor needs.

But the motor only needs 3.2 volts and the ULN 2004 needs any voltage in the range of 6-15 volts (according to its data sheet), so how the battery is not enough?, and what do you recommend ?

The winding resistance is 1.6Ohm, the voltage you're applying to the winding is 9V. Therefore NEARLY SIX AMPS wants to flow.

You mean that is more than enough ? sorry i'm new to this. what shoud i do ?

You should really have current limiting resistors for a start - limiting the current to no more than 2A, and then you need a decent power supply....that can supply around 5A, if you want the rated performance from your motor. Otherwise, pick some big, fat power resistors sized by

R=(Vsupply-ImotxRmot}/Imot or R= Vsup/Imot -Rmot

I used a power supply that supplies constant DC voltage (12 V) and can supply up to 3A, i used it instead of the battery, what happened is that the uln 2004 got super heated, the motor shaft did not move, the arduino refuses to upload any program and when i upload this message appears:

avrdude: stk500_getsync(): not in sync: resp=0x00

does this mean that the Arduino board was damaged?

Yes, its been destroyed by too much current flowing in the ULN2004, because you didn't use current limiting resistors, and the 2004 can only handle 0.5A per channel.

I thought that the current going to the load is variable according to what the load needs, i mean that the motor shouldnt take 2A unless when he needs 2A to move , i believe it takes less current to work in (no load ) condition which is my condition, and i guess the uln 2004 should be the same. and if there should be resistors why they are not added in the Arduino web site circuit that is attached in the main post?, also many people on the web applied that circuit and worked with them.

NO. A stepper motor ALWAYS draws the rated current. A DC motor draws a current proportional to the load. It is one of the drawbacks of steppers.

And why aren't they on the Arduino website circuit ? Are you using the identical stepper motor ? It may well be they are using a 500mA/winding stepper. You are not. They may have "got away" with not using resistors, because they are using a decent 3V supply. I am just telling you, on the basis of 30 odd years of experience with electric drives of all sorts that you need to limit the current.

in the datasheet of uln 2004 i found it has an internal resistance of 10.5Kohm in the inlet for each driver, and when i checked the circuit today i found that i missed the connection between the supply Vcc and the driver. i guess that was the reason, but now i have to get a new arduino to test it.

You probably only need a new Arduino processor. They are a lot cheaper than a whole board. Forgetting the tie for the Vcc on the ULN2004 won't usually blow it.

Do you understand Ohm's Law ? If not, I suggest you learn about it, and then work out what happens when one of your coils is connected, via the ULN2804 to ground and the supply.

Your wiring is correct BUT your motor is overloading the little little little battery which as Steve said pulls SO much current it can NOT supply the power to your micro.

Run the micro on a separate battery and two or three D cells for the motor.

He should still use current limiting resistors though ! Even on 4.5V, he's going to get 2.8 A into the windings, and likely to cook them, since they're only designed for 2A. He needs some 0.6 Ohm, 1.2W resistors.

The Arduino is powered by a laptop through its USB port. i think i have to get a power supply for the motor that can supply it with enough current instead of the battery.