Invobot : Artificially intelligent

Lets make machines intelligent

Stepper Motor Driver Circuit

Posted by Ib / Vce(sat) on June 24, 2006

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.

97 Responses to “Stepper Motor Driver Circuit”

  1. fever said

    nice.
    can we use this ckt to run HDD platter motors too. http://www.pcguide.com/ref/hdd/op/z_000923spindlemotor.jpg

    some steppers got less cables ie 4 and some got hight 6.can i use this same ckt to run any stepper.(just by identifying the ground cable)
    and if possibl pls upload the complete schematic with PIC and its code.
    thanks

  2. 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.

  3. 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.

  4. Harrynee said

    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

  5. Anonymous said

  6. hi harrynee .. i have posted what you asked for get it here
    http://madan.wordpress.com/2006/06/29/exact-circuit-and-microc-code-for-stepper-motor/

  7. Harrynee said

    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!

  8. wat is that u are makin and were u from harynee. saw u on roboics india forum before i saw your comment here!!

  9. Harrynee said

    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..

  10. Harrynee said

    so r u from svce? i am 2nd yr btech IT from velammal engg coll

  11. Harrynee said

    so r u from svce? i am in 3rd yr btech IT from velammal engg coll

  12. 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.

  13. are u online now???

  14. Harrynee said

    its ha_rini5@yahoo.com mail in..

  15. a.stalin said

    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

  16. Quasar said

    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

  17. madan said

    thanks for that quasar!!!

  18. Knight said

    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…

  19. Madan said

    yeah man. can connect wheels to stepper. i have done that.

  20. firoz said

    i found this ckt on net
    http://grant.solarbotics.net/Circuits.htm
    we can use this to run hdd motor.
    iam not sure but will it work for all types of stepper motors?

  21. madan said

    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.

  22. meesam said

    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.

  23. darkside said

    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?

  24. madan said

    @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.

  25. [...] Posts Micromouse : Maze solving algorithmStepper Motor Driver CircuitPC Based Osciloscope : Winscope 2.51Exact Circuit and MicroC code for stepper motorIR SensorMobile [...]

  26. kedar said

    can u tell me the color code for stepper motor tointerface it with microcontroller using ULN2003

  27. barath said

    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)

  28. barath said

    i used the left hand side motor in picture( top of this page)

  29. barath said

    square one

  30. madan said

    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.

  31. madan said

    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.

  32. jayanth said

    hi,
    plz can u tell me how to interface a bipolar stepper motor(6 pins) to the 8051 microcontroller.

  33. Sandesh said

    Hi,

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

  34. Sandesh said

    Hi,

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

  35. madan said

    use relays instead of ULN in the aboce circuit diagram. I hope that works!! pl try it and comment it back here.

  36. bikram said

    REGARDING INTERFACING OF STEPPER MOTOR AND IR SENSOR WITH 89C51. plz send circuit diagram also.

  37. madan said

    @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

  38. Iceman said

    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

  39. @iceman
    This is the easiest way of doing it. if you have any other pls suggest me man. do mail me, I’l put them here.

  40. jan said

    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

  41. Iceman said

    @ 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

  42. Iceman said

    @ jan

    Check out this site just found it, it really concentrares on the basics but should give you a good indication, sunrom also have a premade circuit which you can purchase for $8.33.
    Here is the site for the uln2803: http://www.scribd.com/doc/19188/Seminar-on-Mobile-Robotics

    goodluck

  43. rohan said

    i would like to know how a stepper motor runs using 8051 micro controller pls reply me………

  44. rohan said

    pls send d ckt so tht i can get things clr its very urgent for me tnx……….

  45. Arpit said

    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???

  46. madan said

    @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.

  47. SInventor said

    please!
    my motor stepper has 3 lines
    and other has 4 lines only
    how to use it?

  48. madan said

    @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

  49. SInventor said

    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.

  50. jay said

    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.

  51. sumeet sharma said

    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?

  52. MOEIN said

    HI
    I NEED TO DATASHIT HARD DISK STEPER MOTOR FOR MAKE PULSE FROME A ROUND
    TANKE YOU

  53. sumit said

    it was nice

  54. avg said

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

  55. can i have link to that? at amazon or a ebook too.

  56. prateek said

    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?

  57. madan said

    yeah that should do well for your work

  58. Jaye Monroe said

    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
    _____________________

  59. Jaye Monroe said

    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
    ____________________________

  60. Madan said

    Thanks for the info Jaye

  61. RAJEEV said

    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..

  62. RAJEEV said

    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.

  63. viz said

    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

  64. madan said

    ULN will not provide 500mA but drain 500mA.
    And connect supply to common

  65. vandana said

    hi madan
    can u tel me which ic has to be used to drive a stepper motor of 6 amps, 10v rating. as uln2003 wont work

  66. vandana said

    plz mail man …. its urgent…….. thanku .

  67. madan said

    @vandana
    hey use uln to drive relays and let the relays provide the 6a current to the stepper motor….

  68. Chetan said

    hi,

    Can I use ULN2001 instead of ULN 2003?

    Thank you

  69. daniel ocean said

    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

  70. DEBU said

    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 .

  71. DEBU said

    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 .

  72. ravishankar said

    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.

  73. kathiravan said

    what is the speed that can be in such square stepper motor shown in fig in rpm

  74. Mr. Keen said

    http://freeringtones.ifastnet.com

  75. tiwari said

    hi madan!
    could u pl tel me wats d major difference between PIC n MICROCONTROLLER 8051.its preferrable to use pic rather than MC8051

  76. ozman said

    sir

    can i use ULN2003/2004 to control BLDC motor???

  77. virender yadav said

    plz tell me some application of stepper motor

  78. ashish said

    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

  79. Elias said

    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

  80. Elias said

    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

  81. praveen said

    >>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=0×03;
    while(1)
    {
    PORTA=0×01;
    delay_ms(300);
    PORTA=0×02;
    delay_ms(300);
    PORTA=0×04;
    delay_ms(300);
    PORTA=0×08;
    delay_ms(300);
    }
    }

  82. praveen said

    after first include it is mega.h
    delay.h

  83. aravind said

    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

  84. vijay said

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

  85. 10 dollar robo said

  86. basham said

    can you calibrate using the circuit

  87. Basham said

    Can you regulate and then generate with the circuit.

  88. bhavesh said

    please let me know that can stepeer mottor rewind again

  89. aravind said

    yes i want the stepper motor to rewing again

  90. Basham said

    can you regulate then be able to integrate then generate with the circuit?

  91. s.chetan said

    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.

  92. s.chetan said

    iam requesting u again and again can anyone plz send the ckt

  93. chethan said

    can i control the stepper motor by using a dsp kit ie 6713dsk… by writing a c code for it…

  94. amjid niazi said

    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

  95. farhad said

    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

  96. farhad said

    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

  97. Sreekanth said

    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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>