Stepper Motor Driver Circuit

Have you been searching for a goot damn circuit to drive your stepper motor?? Well even i did when i was learning robotics. Most stepper motor circuits that are available onlne have a bunch of transistors, Sometimes power trnsistors too quite a complicted circuit that drives you away far frm using it. Well i felt for most robotic use the stepper motor can be driven by a simple ULN2003 IC that costs just 12 bucks in my backyard.


The above are the most common types of stepper motors that you’l find in the market.

There are two types of stepper motor that normally is used.1)Unipolar 2)Bipolar . In simle terms they can be thought about like this. In unipolar there are 5 wires.One common wire and four wires to which power supply has to be given in a serial order to make it drive. Bipolar (not normally used in robotics) can have 6 wires and a pair of wires are given supplt at a time to drive it in steps.

STEP ANGLE :The angle with which the stepper motor turns for a single pulse if supply toone wire or a pair is called step angle.

Driving a stepper motor:

1) Identify the wire : Common and windings

As you may see that out of the five wires two are grouped as coomon. The other four are the windings you’l have to give your supply to. Now major crux here is to identify the common line. that’s pretty simple. Just take your multimeter and check the resistance between the wires. Hold one wire a common and it must bear a resistance of 75 ohms with all the other wires then that is the common wire.
Once you have done that the reset of the issue is just a cake walk.

Connect this circuit:

I guess you understand the connections: in case you find the fpic above messy have a look below,

So this is it.Now use your Microcontroller PIC16F877A to give +5v supply to pins a,b,c,d one by one that’s:

a=5v,b=0,c=0,d=0
a=0,b=5v,c=0,d=0
a=0,b=0,c=5v,d=0
a=0,b=0,c=0,d=5v
Then stand aside and watch your motor run.!!

A stepper motor is hard to make it usable in a robot yet the square type of stepper motor seememed to work pretty well for me. My Micoromouse Robot was built on stepper motor . I fount this mechanical design for a stepper mototr robo that’l help you design yours,have a look.

guys.. get your bot up and running

Madan
If you are new to stepper motors and don’t get this clearly get the exact circut and code

P.S:-
–>
Stepper motors are are mostly suited for contests where precession is most inportans like maze solving and path finding robots. where you’l need to know the distance you’d travelled or take a 90′ turn. these things are difficult to handle on a normal DC motor.

–>The minimum time between the two pulses given to ‘a’ , ‘b’ must be greater that 200 micorseconds(it depends on your motor)

–> Microcontroller can always be replaced with your computer parallel port

–> UlLN2003 can drain upto 500 mA so most stepper motors can be drivin satisfactorily.

Author: Madan Thangavelu

Software Engineer

112 thoughts on “Stepper Motor Driver Circuit”

  1. Actually this circuit can be understood this way. unipolar motors needs to drain the current in that series through the pins so i do it using a Inverting darlington pair IC (ULN2003). Actually any type of application which needs to drain (pull low) or rather High too , can b interfaced trough the IC.

    You can use The above circuit to work with the HDD platter motors,Just that you’l have to manage the signalling sequence properly to the many pins that needs to be addressed.
    You’l find it here:
    http://www.epanorama.net/circuits/diskstepper.html

    Follw these procedures as given there
    1. Deactivate the WRITE GATE line (pin 6)
    2. Activate the DRIVE SELECT line (pin 26,28,30 or 32)
    3. Wait for READY and SEEK COMPLETE signal to be true.
    4. Select the direction with DIRECTION signal. (pin 34)
    5. Send the movement pulses using STEP line. (pin 24)

    Point to note here is that in the circuit in my post, you are required to give a high in the input pins of ULN2003 to pull output low.

    But while signalling for the 5 teps above you’l have to pull the input of ULN2003 Low to get a Output as High.

  2. Crux is that Since your PIC or Parallel port can’t handdle current levels of that magnitude you p[ut an intermediate IC wiz ULN2003. and then give the signalling as required to drive any device.
    I guess i’m clear. incase you still need clarification pl don’t mind and comment again.

  3. this article is cool..it clarified my doubts on how uln2003 driver ic should be connected to stepper motor..

    it would be of great help if u could explain how this uln2003 ic must be connected to the microcontroller and how the “abcd” pulses must be generated..pls send in the code too ..thanks buddy

  4. Pingback: Anonymous
  5. that info was really useful buddy..we got an uln2003 ic n a stepper motor n other required components..we are gonna test them today and wil let u know of our progress..keep up ur cool job!

  6. me n my frends we r trying to make a humanoid robo..we r in the beginning stages of it..didnt now how to proceed..but now got a kick start..we made the pcb ckt for motor operation..soldering n stuff is over..gotta test it today..wil keep u updated.. ya joined the robotics forum recently to get some guidance for the project..

  7. oh cool… me am in final year ECE in SVCE. me goin to start off with humanoid soon.. geme your mail harrynee(nopesibly haryne). my IM is madan3030. do let me know yours.

  8. Hi,
    i am searching circiut to run hard disk motor continiously at highspeed for my hoby project .i do have hdd motor of a samsung 40 gb hdd,i need full details of that motor ,imean about the terminal detail and the circuit to power the motor for the constant rotation of that motor if detail available pls reply to my mail

  9. Hi,
    @ Ib / Vce : Very nice thing to post here the circuit diagram for wiring the stepper with the ULN2003. I try to use it these days for driving a stepper for my telescope motorized mount (the difference is that I don’t use a PIC mC but I use my parallel port of the laptop for drive sequence). Two remarks though: please take care that different steppers have different internal resistance, therefore you have to control somehow the curent that flows throught the motor coils (the maximum output of the ULN2003 is 500mA). So some resistors might be required for other applications (in case your application must drive e slightly more powerful stepper). The second remark is that you may drive your motor with half step sequence, with a slight change of the PIC code. You fin on the net dozens of sites that explain how that works.
    Anyway, very nice work and congratulations!

    @ A.Stalin : It might be a little more difficult for you to drive such a motor if you say that it comes from a 40gb hdd. I highly doubt that your motor is a stepper motor because as I know curent HDDs don’t use steppers anymore. Older HDDs used steppers to move the read/write head of the HDD.

    Regards,
    Quasar

  10. May i ask whether the wheel can directly connect to the stepper?? Will it run off as the torque of the stepper is very big…

  11. at first shot. i think 7414 is a schmit trigger and doesn giv eout enough current to drive your motor. i’l appreciate if you can try it out and post a comment here.

  12. madan plz can you tell me which driver ic to use with the bipolar stepper motor. actually i have bought a stepper motor with 4-wires and now unable to find an ic to drive it. Can you help me with the circuit, wiring and interfacing to an 8051. With regards.

  13. can i know that what is the purpose that we using uln2003 driver to control stepper motor.Besides ULN2003 is it stil got any IC we can use?

  14. @Meesam
    U can use uln2003 . hust see the pulse sequence properly which will be 2 pulses at a time. ( essentially 2 pins of your 8051 must be grounded at a time)

    @Darkside
    Uln2003 is nothing but a darlington array. which can drain good amount of current. There are many ic’s that goes like ULN—-
    There’s a good list of those, You need to search.

  15. i interfaced ULN2003 with the steper motor but ic got heated up and motor slowed down it cant pull load.(i use 1 to 3 kg of load in our project).
    will u plz provide a solution to pull and push load of 1 to 3 kg. i am in chennai doing my final yr project so if u can provide any shop it will be better for me.plz mail me the answer g_barath@yahoo.co.in ( i am new to this forum)

  16. 1-3 KG load? well why do you want to use only stepper motors there? any positioning application? Furthere the motor which you mentioned will not lift that load.

  17. For the load which you want you may find bigger motors at ritchi and those can’t be run with ULN since they draw more current and ULN can drain only upto 500mA.

  18. Hi,

    Pls tell me how to interfacea stepper motor to a PIC16F877A controller..the motor require 3.5ampers current..

  19. Hi,

    Pls tell me how to interface a stepper motor to a PIC16F877A controller..the motor require 3.5ampers current..

  20. @Bikram
    What you ask for is given on this site. if not 89c51 its for PIC. all you have to do is understand how it works and use it for your microcontroller.

    Use search option adn search for “Stepper motor” and you’l find the details you require

  21. Hi Madan
    Was wondering is this the easiest way to interface between 4 stepper motors and my PIC16F877 development board, have seen circuits were two motors can be controlled using the ULN2003, is it possible that you might be able to send me a circuit design like this or maybe another alternative. I am also making use of 5 DS1868 digital POTS as these are the only ones i would be able to use so i dont have to write the driver files for them myself.If you could send me a link explaining the connection of these to the PIC16F877 that would help alot.
    First time acually experimenting with this field of electonics so some help would be great…

    Thanx

  22. hi, i was wondering how can i design or connect a circuit using a PIC16F877A to a motor driver which is the ULN2803 to control a stepper motor?

    If it’s possible, can someone include some circuit diagram so that I can have a clearer picture of the circuit? Thanx

  23. @ jan

    Have that exact circuit for you, i am using it in one of my own small projects, as i need to run multiple stepper motors from my PIC16F877. Am unsure how to post the diagram on the web so if you send me an e-mail ill send you the cct.
    my e-mail: s20532085@nmmu.ac.za

  24. i have a load of 10 kgs.A stepper motor with a torque of 18 kgcm and 2 amp per phase current would work???
    For the controller what should i do as ULN2003 won’t work???

  25. @arpit
    plese use uln foloower by a relay. ULN should activate relay switch instead of the stepper motor coils. the relay should inturn be connected to the motors.

  26. @SInventor
    Your four line stepper motor is a bipolar motor and it doesnot have a com line as said in this tutorial above. Secondly i have never heard of a 3 wire one. if you find it out pls post a comment here

  27. the 3 wire stepper motor – from CD/ROM drive (LG,Teac)
    and 4 wire – from Hard Disk drive (JVC motor)
    and each no colors for wire.

  28. 4 wire = 1 common and 3 phase windings. just connect the common to power and pulse the rest (ground potential) sequentially. how to know which wire is common? the resistance between common and a winding will be about half of that between 2 windings.

    3 wire = brushless dc motor? (unconfirmed). again, 1 common, and the other 2 are like 2 phase stepper, just pulse 1 at a time. to reverse either of these motors reverse power and ground potential.

  29. Hello sir,

    We are building a micromouse using stepper motors. We have 2 stepper motors with following ratings-
    1. 3.5V , 0.7A
    2. 3.8V , 0.67A

    The ratings of the two motors are different and we have to overdrive the motors at around 12V.
    For that purpose we are using IC SLA7024M (ALLEGRO MICROSYSTEMS) which is a PWM CHOPPER
    IC.
    So, we are facing certain difficulties,plzz help to sort them out.

    1. Can we overdrive the stepper motor of this rating at 12V?
    2. Which IC is better to use for driving it-IC SLA7024M or IC UCN5804B?
    3. If using IC SLA7024M , how the current through stepper motor is to be controlled?
    4. Will the different ratings of the two stepper motors affect the response much?

  30. u req lot of improvements in technic u hav suggested.
    u should read book ‘STepper motors’ by “neon fabrigas”

  31. hi madan!
    can you plz tell me the torque of the stepper motor to be used in the micromouse, i.e. how much load should it carry? should 500gm load carrying stepper motor be sufficient for micromouse?

  32. Hi All

    Mainly for SInventor (post 47)

    I have a 3 wire Stepper Motor (?) salveged from an old 8″ disk drive. I think it operates on either 12 or 24V. The roatation sequence is normally 1 2 3 1 2 3 ….. and can be reversed by reversing the sequence at any point ie 1 2 3 2 1 3 2 1 ……. {reverse occures at the first 3 to 2 transition. Reverting to first rotation direction is done in the same way as the inital reversal.

    I have not yet set this up via a micro controller, but have experimented just by applying power to the respective terminals.

    Hope this helps

    Regards

    Jaye Monroe
    _____________________

  33. 3 Wire opps

    I just checked the motor and it is a 3 Phase not 3 wire. Checking it with a 12 volt supply, each phase draws 1.6 amps. The info on steping sequence still holds.

    Regards

    Jaye
    ____________________________

  34. hey madan..
    i hv used stepper motor in my micromouse..starter in dis field..
    motor hs ratin of 7.5dig..
    bt i dnt knw abt its torque nd current nd voltage rating..
    cn u plz hlp me.. to knw these values..

  35. i m using ucn5804 to drive that stepper motors(7.5dig)..
    so wht reading of voltage i hv to use ucn so that motor run with highst efficiency.

  36. hi madan, i m total newbie.

    i m confused.
    do i have to connect power supply to common wire or to the other four wire.
    And i m using atmega32 micro. but as you said
    a=5v,b=0,c=0,d=0
    a=0,b=5v,c=0,d=0
    a=0,b=0,c=5v,d=0
    a=0,b=0,c=0,d=5v

    atmega cant provide 5v(as far as i know).
    and i m totally confused about power sypply. aint there any need to cooncet supply to uln2003 i mean without it how can it provide 500ma current.
    pls help me here

    thank you very much

  37. somebody if knows the driver circuit of hard disk drive or its sequencing………..
    ULN is not my quest .
    i need it urgently and looking for people who can help my team in quest or HYBRID SUV drive automated systems ……
    if any one is interested in automotive robotics plz contact me on mail>>>>>>
    danieloceanrecon@gmail.com

  38. hello ,
    can u help me for controlling the speed of a stepper motor with the help of microcontroller . the speed should be controlled such that when load will be given , the motor speed should be the same as the initial speed . that is every time the motor should maintain the same speed , if the load is applied or removed . please get me the circuit diagram to my mail .
    thank you .

  39. hello ,
    can u help me for controlling the speed of a stepper motor with the help of microcontroller . the speed should be controlled such that when load will be given , the motor speed should be the same as the initial speed . that is every time the motor should maintain the same speed , if the load is applied or removed . please get me the circuit diagram to my mail . my mail id is debashishsahoo87@gmail.com.
    thank you .

  40. hey,
    i used the uln ckt.. it works great ………but its draining the battrey in no time……… and so i used a high power battery which burnt off the i c…… can u help me plz.

  41. hello,
    I using 4 stepper motor in my project,my question is
    when s1 is working,s2,s3,s4 will not work.after sometime s1 will
    off,s2 will work.s1, s3,s4 will not work.after sometime s2 will
    off,s3 will work.s1,s2,s4 will not work.after that s4 will off,then ist s3will work,s2 will work,s1 will work.after that the process will continue.
    thank u

  42. hi madan, i m total newbie.

    i m confused.
    do i have to connect power supply to common wire or to the other four wire.
    And i m using atmega32 micro. but as you said
    a=5v,b=0,c=0,d=0
    a=0,b=5v,c=0,d=0
    a=0,b=0,c=5v,d=0
    a=0,b=0,c=0,d=5v

    atmega cant provide 5v(as far as i know).
    and i m totally confused about power sypply. aint there any need to cooncet supply to uln2003 i mean without it how can it provide 500ma current.how i access stepper motor without parallel port.If i use parallel port please send me the diagram i used.
    pls help me here.

    thank you very much

  43. viz Says:
    January 13, 2008 at 6:00 am

    hi madan, i m total newbie.

    i m confused.
    do i have to connect power supply to common wire or to the other four wire.
    And i m using atmega32 micro. but as you said
    a=5v,b=0,c=0,d=0
    a=0,b=5v,c=0,d=0
    a=0,b=0,c=5v,d=0
    a=0,b=0,c=0,d=5v

    and i m totally confused about power sypply. aint there any need to cooncet supply to uln2003 i mean without it how can it provide 500ma current.
    pls help me here

    thank you very much

  44. >>elias
    these 5V is TTL logic 1 , i think it will work wid atmega try dis code:
    #include
    #include
    void main()
    {

    DDRA=0xFF;
    DDRC=0xFF;
    PORTC=0x03;
    while(1)
    {
    PORTA=0x01;
    delay_ms(300);
    PORTA=0x02;
    delay_ms(300);
    PORTA=0x04;
    delay_ms(300);
    PORTA=0x08;
    delay_ms(300);
    }
    }

  45. hi madan,i am jus a beginner…i tried a simple ir circuit given in this site can u jus tell me wat actuator i can connect to tat circuit…lik one havin linear motion so that it clicks a camera

  46. i hav already asked u bfore abt this….i wanna know a simple mechanism 2 kick a ball ( as in a football robot )….

  47. hi can anyone post the 4 amps & 3volts stepper motor driver circuit using mosfets having four channels .plz iam requesting everyone plz send this ckt to me.coz i need this for my project for connecting HS-50 stepper motor.

  48. Does anyone have a good example of a Pic controled H-Bridge to control a motor.

    I want to use PWM to control the speed and direction of a 12v DC motor. I suspect that the motor will draw up to 10A. I suspect that I will need to use N-Channel and P-Channel Mosfets. I have tryed one schematic, but it did not work, so I have been searching the net, and thought I would ask the experts

  49. hi
    i made one home cnc router but unknow who that driving
    if have driver for step motor please send me pcb and shematic
    please help me
    thankyou

  50. hi
    i made one home cnc router but unknow who that driving
    if have driver for step motor please send me pcb and shematic
    please help me
    thankyou
    step 1.8 deg – 6.5v – 1.3a

  51. It is recommended to connect a 12v zener diode between the power supply and VDD (Pin 9) on the chip(ULN2003), to absorb reverse (or “back”) EMF from the magnetic field collapsing when motor coils are switched off.
    Plus there is an 8 bit version of this chip “ULN2803”. So this single chip is enough to drive both the motors.

  52. hi madan…
    ur doing a gr8 job..keep going man.
    plz can u tell me how to interface a bipolar stepper motor(6 pins) to the pic16f877a microcontroller.i knw the connections for 5 wires..if possible plz send me the cod and ckt diagram..its realy urgent…help me

  53. hi madan…
    ur doing a gr8 job..keep going man.
    plz can u tell me how to interface a bipolar stepper motor(6 pins) to the pic16f877a microcontroller.i knw the connections for 5 wires..if possible plz send me the cod and ckt diagram..its realy urgent…help me

  54. am using STM981 stepper motor which uses 9v and 1.4 amps having 6 wires…so can i use uln2003 or shud i go 4 some other ic…plz reply

  55. hi
    i made one stepper motor driver(bipolar). using L297 and L298 but it cannot operate. I try to solve that but nothing interesting result. so i would like to commit sucide..please help me…tension!!!!aarrrgggghhhhh!!!

  56. alease send me abstract of this project……because i have desined this nd now i hv requred its ABSTRRACT

  57. how to connect 4pin relay to89c51(connect with telephon hook switch) also the suitable relay
    the ircuit and the internal discrption.plz very argent

  58. I want to drive the stepper motor using msp430fg4618 thru uln2003…but will there be any current or voltage mismatch that would cause damage to my msp…

  59. I want to drive a bipolar stepper motor with Atmega 8. Can I use ULN2003(motor driver) to drive this bi-polar motor in both (forward& reverse) direction?

  60. a=5v,b=0,c=0,d=0
    a=0,b=5v,c=0,d=0
    a=0,b=0,c=5v,d=0
    a=0,b=0,c=0,d=5v
    Assuming the sequence is for a bipolar stepper motor.
    This sequence will run the stepper motor; Its right..
    But this wont give enough torque for the stepper motor.

    Its better to use a sequence where u activate two lines at a time.
    eg:
    1. a=5v,b=5v,c=0,d=0
    2. a=0,b=5v,c=5v,d=0
    3. a=0,b=0,c=5v,d=5v
    4. a=5v,b=0,c=0,d=5v
    and again
    1. a=5v,b=5v,c=0,d=0

    This is for full step drive.

    If one needs to run the same motor on half step, try this sequence.
    1. a=5v,b=5v,c=0,d=0
    2. a=0,b=5v,c=0,d=0
    3. a=0,b=5v,c=5v,d=0
    4. a=0,b=0,c=5v,d=0
    5. a=0,b=0,c=5v,d=5v
    6. a=0,b=0,c=0,d=5v
    7. a=5v,b=0,c=0,d=5v
    8. a=5v,b=0,c=0,d=0
    and again
    1. a=5v,b=5v,c=0,d=0

    This sequence can be created with a TTL circuit costing within US$ 10.00.
    A driver with L298 would be needed to drive the stepper motor. Dont expect the TTL output to source the Motor directly!!

    Anil

  61. @ Mishuk

    Yes Bipolar Motor can be run in reverse if the above sequence is reversed.
    Forward, Reverse, Half step Forward and Half step Reverse is possible.

    Anil

  62. Hello, I think your site may be having internet
    browser compatibility issues. When I look at your website
    in Safari, it looks fine however when opening in IE, it has some overlapping issues.
    I just wanted to provide you with a quick heads up! Apart from that, wonderful website!

Leave a reply to Ib / Vce(sat) Cancel reply