# Struggling to drive a stepper motor

#### Reggie

Joined May 8, 2010
16
Hi all, I have a project that uses a stepper motor to control the focuser on a telescope, this is connected to astronomy software via a PC and is used to focus a digital camera for long exposure astrophotography.

The current version uses a 12v, 5 wire unipolar stepper motor driven by a ULN2003 which is controlled by an Atmega 328. Unfortunately as the stepper motor is geared its quite slow so I want to replace it.

I have a replacement stepper motor: the MY3002, the first one in the list.
http://www.astrosyn.co.uk/docs/mini_hsm.pdf

from the maths it's a 3.3v, 0.95a, 3.4Ω per phase unipolar stepper.

As far as I understand things, I can't use the uln2003 as it cannot provide the full 0.95a current that the motor could use.

I also have an L293B and an L298N that I can use, again I don't believe the L293B can handle the 0.95a draw from the stepper, so that really leaves me with the L298N.

Am I correct in thinking that if I want to use the L298N I would have to wire the stepper as a bipolar stepper?

If that's correct, how do I deal with the phase resistance of the windings and power resistors to limit the current?

Lastly where do the resistors go in the circuit? Ignoring the common wires as they're not used in a bipolar configuration, do I use 1 resistor per pair of wires?

Regards,
Reggie.

#### bertus

Joined Apr 5, 2008
21,447
Hello,

Can you post a schematic of what you made upto now?
This will make the help more easy.

Bertus

#### Reggie

Joined May 8, 2010
16
Hi Bertus, The attached schematic is for the existing unit, I didn't want to start on a schematic for a new driver chip without knowing which driver chip I would be using Please ignore the atmega168 its pin/code compatible with a 328 which wasn't in the eagle parts library.

#### Attachments

• 23.2 KB Views: 139

#### bertus

Joined Apr 5, 2008
21,447
Hello,

the L293 can handle upto 1A with a non repetitive peak of 2A.
For the L298 the total current may not be larger than 4A for all channels together.

Bertus

#### Attachments

• 590.4 KB Views: 28
• 597.3 KB Views: 21

#### Reggie

Joined May 8, 2010
16
thats a non repeatable within 5ms peak of 1a per channel, that gives me around 200pps, I would however like to run at a faster rate than that.

Neither of the datasheets address my questions (actually they probably do but I don't have the knowledge to quite work it out ).

I have some 5R6 7w resistors (as I wanted to run it as a unipolar motor initially from a <12v variable regulated power source), but as the 293/298 don't work in a unipolar configuration, not using the centre tap affects the resistance, but I'm not sure exactly how.

For a unipolar driver I was planning on adding a resistor to each centre tap, but as I am assuming that I have to wire the motor in a bipolar configuration I'm not sure entirely where the resistors should go now.

ideally I would like to use a single resistor per coil, in reality I don't have much money to spend on this project so in a bipolar configuration I thought using the 4 resistors in serial pairs and regulating the power supply to suit the needed current would reasonable?

#### Reggie

Joined May 8, 2010
16
a lot of dead links, with no real information about the ICs I am asking about, nor my specific questions. I need clarity not more confusion but do appreciate you are trying to help

#### retched

Joined Dec 5, 2009
5,208
Ok, Im gonna throw you a link as well.

This should show you everything from code to wiring for Bi and uni polar steppers for high current.

This uses the 2003 and 2004 Darlington arrays.

The 2003 allows 500ma per pair. You can connect 2 pins to handle 1A safely. Think of heat sinking and you will be fine.

How often does this focus motor run, and for how long?

http://www.tigoe.net/pcomp/code/category/arduinowiring/51

#### Reggie

Joined May 8, 2010
16
Hi Retched, the motor is used 6 or times over an imaging session, depending how long the session is and how many targets there are.

In general, for a single target I would envisage it being in use for 1minute initially to get to close focus, then small bunches of steps/single steps as it hunts for full focus.

I need to experiment whether there is enough tension through the focus system to hold the focus position without needing to keep the coils energised. Its hard to say exactly what will be needed until I can start to drive it all and see it working in practice.

I don't quite see from the tigoe site how the current is limited to 1amp, or am I missing something fundamental here, in how the ic works maybe? Entirely possible....

I can see from the schematic that it is using just 2 pins for input control and how it is achieving that, but I don't see how pairs of pins from the IC are summed to give 1a

#### retched

Joined Dec 5, 2009
5,208
Sorry, the uln2003 is a Darlington pair array.

A Darlington pair is simply 2 transistors hooked together in a certain way.

The array simply puts 8 pair together across from each other in a smaller package.

Every transistor you add to another, splits its current. So if you use 2 pins in to two pins out, the .95A (well say 1 just for easy math) will be split into 2 wires before the input of the 2003.

So the upper left 2 pins will be used as 1 pin.
Then the output of that will go to the direct 2 pins across the chip.

Do the uln2003 allows 500mA on each (pair) pin, so splitting the 1A will satisfy that.

Look at page 4 of the datasheet to see how the internal pin connections are made.

Page 3 will show you the circuit that is on each pinset in the ULN2003.

http://www.st.com/stonline/books/pdf/docs/5279.pdf

#### SgtWookie

Joined Jul 17, 2007
22,221
The ULN2003/ULN2803 is rated for up to 500mA sink per output, but a more realistic limit is 350mA. You really don't want to run them at 500mA, because power dissipation simply becomes excessive.

Note that if you are sinking that much current from one output, it reduces the amount of current you can sink from other outputs.

Look at using a ULN2064, ULN2066, or ULN2068 instead. They are 4-channel Darlington IC's capable of 1.5A sink current per channel.
Datasheet: http://www.st.com/stonline/books/pdf/docs/1534.pdf

Mouser stocks a variety of them: http://www.mouser.com/Search/Refine.aspx?Keyword=ULN206

Under $2.50 each. Digikey also stocks them, under$3.00 each:

Last edited:

#### retched

Joined Dec 5, 2009
5,208
The ULN2003/ULN2803 is rated for up to 500mA sink per output, but a more realistic limit is 350mA. You really don't want to run them at 500mA, because power dissipation simply becomes excessive.
Oh. Thats what that smell is.

#### Reggie

Joined May 8, 2010
16
Ok, I still don't understand the external connection retched, or is my original schematic already ok in principal to use with approrpriate power resistors? (forgetting for teh moment that 350ma is the realistic limit)

Do you mean use 2 input pins to control 1 output pin? so setting the first 2 pins high energises the coil connected to output pin1? If thats the case, the uln2003 only has 7 pairs not 8 so not enough to connect all 4 coils?

SgtWookie, thanks for pointing that out too, although I am now confused by the uln2064 pin namings...

Really sorry if I'm missing stuff, I have no problems with writing code for this and I have a working unit using a different stepper but I am happy to admit that my electronics knowledge is not a strong point yet

Do the 2064 pin names translate to:
1 common
2 out1
3 in1
4 gnd
5 gnd
6 in2
7 out2
8 common

Please feel free to call me stupid if I am missing something.

Is my thinking correct on using a 5.6ohm 7w resistor in series with the common wire on the stepper motor and tailoring the input voltage appropriately using a variable voltage regulator?

regards,
Reggie.

#### SgtWookie

Joined Jul 17, 2007
22,221
Ok, I still don't understand the external connection retched, or is my original schematic already ok in principal to use with appropriate power resistors? (forgetting for the moment that 350ma is the realistic limit)

Do you mean use 2 input pins to control 1 output pin? so setting the first 2 pins high energises the coil connected to output pin1? If thats the case, the uln2003 only has 7 pairs not 8 so not enough to connect all 4 coils?
Right, you won't have enough channels. You'd need a ULN2803, which is an 8-channel version of the ULN2003. However, I recommend against using the ULN2003/ULN2803 for such a high current load. You could use three of them, but what's the point in doing that? Lots of extra wiring.

SgtWookie, thanks for pointing that out too, although I am now confused by the uln2064 pin namings...

Really sorry if I'm missing stuff, I have no problems with writing code for this and I have a working unit using a different stepper but I am happy to admit that my electronics knowledge is not a strong point yet

Do the 2064 pin names translate to:
1 common
2 out1
3 in1
4 gnd
5 gnd
6 in2
7 out2
8 common
You aren't confused; you have it exactly right.

Is my thinking correct on using a 5.6ohm 7w resistor in series with the common wire on the stepper motor and tailoring the input voltage appropriately using a variable voltage regulator?
OK, let's figure it out.

First, let's look at the specs for the ULN2064, for Vce(sat).
It shows in the datasheet on page 6, table 3, that with Ic=1A, Vce(sat) is 1.3v max. Let's assume on the safe side that it may be less; around 1.1v.

Motor specifications: 0.95A, 3.4 Ohms; that means 3.23V drop across the motor.

So far, you have a total Vdrop of 1.1v+3.23v = 4.43v.
If you want to run it from 12v, then:
12v - 4.43 = 7.57v. 7.57/.95A = 7.97 Ohms.
Let's round that to 8 Ohms.
Power dissipation will be 7.57v x .95A = 7.6 Watts. You want to double that for reliability's sake; so 15.2 Watts.

By some miracle of coincidence, Radio Shack carries an 8-Ohm 20 Watt non-inductive resistor, which will be perfect for your application: http://www.radioshack.com/product/i...8&filterName=Type&filterValue=Power+resistors

#### SgtWookie

Joined Jul 17, 2007
22,221
As far as decreasing the current when your motor is stopped, consider just using PWM on the particular output that's currently (sic) active. For example, if you used somewhere around 5kHz PWM at a 25% duty cycle, you'd cut your power consumption considerably yet still have some holding torque. You'll have to experiment with different PWM values to determine what will be sufficient holding torque. You may have to increase the frequency to reduce vibrations. I don't know offhand how fast the ULN2064 can be cycled.

#### Reggie

Joined May 8, 2010
16
Excellent, Im glad I got the pinout right So each common wire should be connected to its own common pin on the IC?

Rather than increase the resistor, can I lower the input voltage appropriately, 4.33 + 5.32 = 9.65v, that gets the power down to <7w, how unreliable and in what way unreliable would it be using 7w resistors?

I think the focuser in its own right should have enough tension to hold itself in place when the stepper is not moving.

Once its done the initial focusing I was going to disable it using a pin from the mcu to control power or just switch it off entirely. Power consumption is a very small consideration because of this. Using a 7ah battery should give me about 10 sessions with 60 targets total between charges, assuming a very generous 5 minutes worth of full current draw per target planet/star/galaxy etc.

#### SgtWookie

Joined Jul 17, 2007
22,221
Excellent, Im glad I got the pinout right So each common wire should be connected to its own common pin on the IC?
The OUTn pins sink the current from the "ends" of the motor's windings.
If you are going to use PWM, then you want to connect the commonn terminals to where the resistor connects to the motor winding center tap.
If you are not going to use PWM, then connect the common terminals to your +V supply.

Use some capacitors across your +V and GND. This will help to even out the current draw from the battery, and it will extend the run-time. Otherwise, more power will be dissipated in the battery during peak current.

Rather than increase the resistor, can I lower the input voltage appropriately, 4.33 + 5.32 = 9.65v, that gets the power down to <7w, how unreliable and in what way unreliable would it be using 7w resistors?
The higher your supply voltage, the faster you will be able to step the motor. This is because the high voltage overcomes the inductance of the motor more quickly.

If you use 7W resistors dissipating 7W, they will be very hot (burn hazard), and they will not last nearly as long as resistors with the correct power rating.

I think the focuser in its own right should have enough tension to hold itself in place when the stepper is not moving.
OK. Make certain that you ramp the speed of the stepper up and down instead of just trying to start at full speed/stop from full speed.

Once its done the initial focusing I was going to disable it using a pin from the mcu to control power or just switch it off entirely. Power consumption is a very small consideration because of this. Using a 7ah battery should give me about 10 sessions with 60 targets total between charges, assuming a very generous 5 minutes worth of full current draw per target planet/star/galaxy etc.
Well, you will have to experiment.

#### Reggie

Joined May 8, 2010
16
The resistor wil lbe dissappating 5.32w, will that increase the life by much? obviously it will be less heat generated.

#### SgtWookie

Joined Jul 17, 2007
22,221
I can't tell you offhand.

However, if you're stepping the motor pretty quickly and turn it off when it's not stepping, the dissipation in the resistor will be somewhat less than 5.32W.

If you use one resistor per center tap, your average power dissipation will be cut in half.

Last edited: