Thursday, September 13, 2007

Computer Controlled Stepper Motor



A few months ago, I bought a stepper motor for only Rs.75 (about USD $1.50). I had almost forgotten about that motor until I found it lying in a secluded corner of my bedroom, collecting dust the other day. I searched the internet for information on controlling stepper motors with a computer and I was surprised at how easy it was! My stepper motor has five wires, and it is a unipolar stepper motor with a step angle of 7.5 degrees.


Here's the simple circuit I had used for controlling it:

(Note: If you can't find ULN2003, you can simply use use a single transistor for each winding as shown here.)

As you can see in the diagram, each successive coil in the motor is connected to successive data pins on the parallel port. If the coils are not connected in the correct sequence, the motor will not rotate, but will only wiggle from side to side. Identifying the wires on the stepper motor was probably the only time consuming step. Click here for information on how to do this.

Now, since each coil can be programatically controlled, you can experiment with different types of stepping modes. The simplest stepping mode is called Single-Stepping. In this mode, each successive coil is energized and the motor moves one full step at a time. For example, my motor will make a full step of 7.5 degrees whenever the coils are energized in the following sequence (D0 - D3 represent parallel port data pins):

Step No.D0D1D2D3
11000
20100
30010
40001

Another interesting stepping mode is Half-Stepping. The difference between single-stepping and half-stepping is that for the same step rate, half-stepping gives you half the speed but twice the resolution of a single step. Since my motor has a step angle of 7.5 degrees, half-stepping it would result in approximately 3.75 degrees of rotation. Here's the sequence in which coils are energized for half-stepping:

Step No.D0D1D2D3
11000
21100
30100
40110
50010
60011
70001
81001

You can achieve other types of steps by energizing the coils in different ways. For example, here's how high torque stepping works:

Step No.D0D1D2D3
11100
20110
30011
41001

For more information on these stepping modes, read this article.

My program allows me to control the motor with the scroll wheel on my mouse and I can press the right mouse button to switch between different stepping modes. Watch the video above to see it working. I'm still thinking of ways to use this stepper motor with my projects. I guess I could use it as a camera panner. It would be better, efficient and more compact than my floppy drive camera panner. My floppy drive camera panner could only rotate through an angle of 45 degrees because of mechanical limitations. This stepper motor can rotate a camera through 360+ degrees!

Here's something interesting I found while googling - Neil Fraser's "Computerized Etch A Sketch". Neil has used two computer controlled stepper motors for turning the horizontal and vertical knobs on an Etch A Sketch. His work is just amazing! I just wish he posted some videos of the device in action.

79 comments:

Anonymous said...

Muy Buena PAGINA, saludos desde argentina.

Very Good PAGE, greetings from argentina.

Anonymous said...

Dude, that kicks butt.

Charith Jayasinghe said...

Hi dude,

ur work is brilliant. I am a student as well as a web programmer from Colombo, Sri Lanka and seeking ur advice for my degree project. I am not much in to hardware interfacing. I want to control a panel of LEDs using either COM or USB port. simply i need to blink the LED which i select from my SW. Will u be able to help me out on this ? Feddback is highly appreciate. Write me to charithj@teamwork.lk or charith@charith.net

Thanks!

OptimusTronic said...

Thanks

this proyects is wonderful

Saludos desde GUatemala!

Anonymous said...

Brilliant!!!!!!!!!!!!!!!!!!!

ris8_allo_zen0 said...

Hello,
I'd like to let you know that some time ago I made a little program to drive unipolar stepper motors in exactly the same way you did; maybe you find it useful. Here is its page: http://freshmeat.net/projects/stepm

Cheers from Italy!
Enrico

Anonymous said...

EXCELLENT! Once in a while you see something that is really cool, and this is one of those! Thanks!

Todd S.

Anonymous said...

I've looked for something like this for ages!

Is it posible to download your software? I can't find a place to download it :(

Ashish Derhgawen said...

Yes, you will find a download link on my article - http://blogs.msdn.com/coding4fun/archive/2007/11/02/5848155.aspx

Happy Stepping! :)

ReIncArNated said...

Really good info . To the point !

Anonymous said...

Dude...that really rocks..first time i know that stepper motor can be run by computer.. http://stepper-motor.blogspot.com

Anonymous said...

hey ! i was wondering how do u power up the stepper motors? i am using 3 stepper motors to design a robotic arm.
Could u suggest me how i power up my 3 motors ?
i need to find a cheap alternative to using standard adaptors .
plz revert back to me soon on this forum or at my mail-id : iamtheone.ankur@gmail.com

Thnx....


ALso , could u gimme which motors i shall buy or d specs for using motors for a robotic arm.
I need low speed high precision stepper motors.
What should be the voltage ratings, step angle and torque ?

Anonymous said...

Hi Ashish,
I'm from Slovakia and I'm really into your work. I wanna ask you how you're programming that motor to control it by mouse wheel and what program do you use for it. Thank's.
PS: Sorry for my english, I'm just learning.

Ashish Derhgawen said...

Hey there,

Read this article on Coding4Fun for information on how to do it - http://blogs.msdn.com/coding4fun/archive/2007/11/02/5848155.aspx

Ashish

Anonymous said...

hi Ashish,

thanks for this idea, do i still need zener diode for the power of the uln?
i'm using a 2.3v stepper motor and the uln2003 is heating, will this be good or bad for the uln2003?

thanks,,

Ashish Derhgawen said...

Hey Gian,

Could you tell me how much your supply voltage is?

Ashish

Anonymous said...

can u send me part numbers and circuit schematic thanks? also need a schematic for a ceilling fan

Anonymous said...

Dude,
Just for your information, a stepper motor is wound in such a way that the rotation has a certain number of discrete "steps". I only know of stepper motors being DC motors. These steps are where the magnetic fields cause the motor to want to settle in one of these positions. The number of steps per revolution is rather high, around two hundred or so, and varies by model and manufacturer. What this means is that the motor has effectively a resolution (smallest controlled movement) equal to the number of steps for that motor. Everything seems to have exceptions, and that applies to steppers also - there are some called micro step, with a higher resolution, but I don’t know much about them. Stepper motors may or may not have position feedback.

For more information on stepper motor you go this one website that gathers information about stepper motor from around the web :

http://stepper-motor.blogspot.com

Shreesh Chhabbi said...

hi ashish,
good works.Hey i needed the tool to know that you are using efficiently in processing the images or motion video captured from webcam,in one of your other projects.And i was trying to use parallel port and glow LEDs.I used assembly language TASM and i tried in C.But i am not ablt to get high at any of the data pins.What may be my problem?

Anonymous said...

hey
ashish u have done a good job. about ur programing which language do u use. and y didnt u published the programing code for the steprt motor? an u please post the code and can give me ur email add mine is rumieee@gmail.com

Joel Pinto said...
This comment has been removed by the author.
Anonymous said...

hi dude.....
im from NU-FAST univ. pakistan....read ur work and found it very interesting ....could u tell me what is the black(usb looking) wire comming from ????it is in one of ur proj. pics.hope ull reply back...thnks..

Ashish Derhgawen said...

The black wire is the 12V power supply for powering the motor.

Chris Ballard said...

interesting project! I have one or two motors left over from various bits and pieces, I think I might try to build a computer-controlled stepper motor as well.

Jishnu Dave said...

Hi, don't we have to use pull-up resistors at the ourput of ULN2003? I remember reading somewhere that it's outputs are open collector.. What do you say?

Anonymous said...

Awesome! Amazing work!xw

Anonymous said...

hai, im student from UNIMAP malaysia,
i need ur help, i not know much about vb..
can you show me the interface and code of vb that can controlled stepper motor without using mouse..
please help me..

wanfazlinz@gmail.com

blue said...

hey ashish how u doing?
m a student of BCA final yr working on ur stepper motor project. i need ur help regarding the code for controlling its rotation via parallel ports in visual basic. i wud be thankful if u e-mail me. my id-bluephilnature@yahoo.co.in.
c ya!

Anonymous said...

hey!!!!!!!!!!!!!

can u help me providing a circuit to control thrree stepper motors????
the motors will work one by one....
its urgent

Unknown said...

hey sup. Listen I want to make a motor controller on my computer so i can controll just a motor not a stepper motor just a nice 5-12 volt motor. I was wondering if you could send me some codes for it or if theres a chip or curcuitry involved you could send me a scematic. It would be much apreciated for feed back and an email back. spartan3.0@hotmail.com tnks.

Anonymous said...

Hello, I am from argentina

I have tried to change your program to use 2 stepping motors with a single mouse ... but I can not make it work to achieve the second.
I used the MouseMove rather than MouseWheel to control x, but it does not work e.Y
Besides I can not do work with the 8 digits instead of 4 ...
You could help with the program in VB?
I Connect 2 uln2803 each with a Stepper. The first to move in X and Y. for the second

The entire project is to make a DV camera with pan and tilt with a single mouse, also in the future I would like to incorporate a webcam and connected to a PC follow the movement of an object and control the whole.


My email: rmzornoza@hotmail.com

Your work is incredible ... I really appreciate your help.

Rodrigo Martín Zornoza

Anonymous said...

wow excellent im from colombia i have 13 years olds

thanks this project is helping
wiht this project i make a blimp

Anonymous said...

hi all,

here is my tiny assembly program which can control stepper motor with / from parallel port of your pc.

Hope it'LL help you guys

http://samet.kilictas.com/2008/12/06/assembly-tutorials-program-controlling-dc-motor-and-stepper-motor-from-parallel-port/

Rahman said...

hey ...i wanted to know using roborealm how do u switch on the data pins of the parallel port do u use the setVariable"outputport1" 1 type statements....

GR said...

hi t hr asish .... im a doing a project with stepper motor . but i dont hav much idea abt vb.... i need the code to run steppr motor using vb ... so could u send me the code in vb.... my email id is faustine40@gmail.com

birni said...

hey there,

you've accidentally forward-biased the zener/avalance diode in the schematic.

i'm currently using a very similar circuit for my CNC gantry router and it works well.

prateek said...

ashish that was great yaar but i have a doubt with my stepper motor as i dnt knw which winding is first n which is second & 3,4 so how do i interface it with ULN which wire to which O/P of ULN as microcontroller gives ground only to 1 at a tym can i find the coil number 1,2,34 by any means need help asap or can i get ur cell number

Anonymous said...

Mr ashish. may i know ur email? i'm very like this project. i want to learn about that. this project can be use in my last study. thank's.
this is my email. achienz_88@hotmail.com

Anonymous said...

hi asish .... im a doing a project with stepper motor . but i dont hav much idea abt vb.... i need the code to run steppr motor using vb via parallel port... so could you send me the code in vb.... my email id is gracehskuo@gmail.com

thanks for help!

Anonymous said...

hiiiiiiiii Ashish,
this is mohan im n engg student ....

in nit karnataka..
im doin project on candy cannon for my mechatronics sub...

i wud like u to help me out ...


wat ever help u cn give ...most welcome..


my id is mohan3001@gmail.com

Rian said...

How do you save this program:
10 REM Stepper Motor Controller
20 PORT = &H3BC
30 STATE = STATE + DIRECTION
40 IF STATE > 4 THEN STATE = 1
50 IF STATE < 1 THEN STATE = 4
60 PRINT STATE,
70 IF STATE = 1 THEN OUT PORT, 3: REM 1100
80 IF STATE = 2 THEN OUT PORT, 6: REM 0110
90 IF STATE = 3 THEN OUT PORT, 12: REM 0011
100 IF STATE = 4 THEN OUT PORT, 9: REM 1001
110 FOR W = 1 TO DELAY: NEXT W
120 X$ = INKEY$
130 IF X$ = "<" THEN DIRECTION = -1: REM Backwards
140 IF X$ = ">" THEN DIRECTION = 1: REM Forwards
150 IF X$ = "?" THEN DIRECTION = 0: REM Stop-locked
160 IF X$ = "-" THEN DELAY = DELAY + 100: REM Slow down
170 IF X$ = "+" THEN DELAY = DELAY - 100: REM Speed up
180 IF X$ <> CHR$(27) THEN GOTO 30
190 OUT PORT, 0: REM 0000 (Stop-free)?
I've tried: .exe, but it closed immediately.

Cheap Kamagra said...

Great site,this information really helped me , I really appreciate it.Thanks a lot for a bunch of good tips. I look forward to reading more on the topic in the future. Keep up the good work! This blog is going to be great resource. Love reading it.

Dissertation Help said...

Nice, accurate and to the point. Not everyone can provide information with proper flow. Good post. I am going to save the URL and will definitely visit again. Keep it up.
--------------------------------------------------
Dissertation Help | Custom Dissertation

UD said...

hi...ur site is really great and useful.....
i am rying to make a 8051 mivcrocontoller controlled door (so that i dont hv to get up to open my door :) )....using a stepper motor very much like u hv done in this post..however, i'm not sure the motor wud b able to take the load of a full size wooden door(62.5*15*1.25 inches)....any suggestions???
-upasanadatta@hotmail.com

Farid said...

Yes upasana, u'r right a small motor cannot be able to take the load of the door. but by connecting the motor or the mechanism to the horizontal end of the door. such that the effort is applied to the one end of the door or the load arm while the load is lifted at the middle of the door. like LEVER OF 2nd KIND

http://www.oracledba.in said...

i like this

AVS said...

your work is awesome,i've become a fan!!i just got a stepper motor from my old floppy drive,trying that with parallel port.do you think my comp will get damaged if i do something wrong?sorry , im a noob at this,but very interested .
thanks

Ashish Derhgawen said...

@AVS: Just be little careful, and you should be fine. :) Nothing to worry about. If you are really worried, get a I/O card which has a parallel port and use that. If you do something wrong, you'll just damage the card..not your computer's motherboard. :)

Good luck!

Twitter followers said...

Wow Impressive! Your blog is very informative. However, it is pretty hard task but your post and experience serve and teach me how to handle and make it more simple and manageable.Thanks for the tips… Best regards.

Dissertation help said...

In this era of blog ,we easily get nice & updated information for research purposes... I'd definitely appreciate the work of the said blog owner... Thanks!

Anonymous said...

hi,
i am trying to control a stepper motor in visual basic 6 via the parallel port.i am a noob in programing and i cant get started..can u helo with some codes plz

Anonymous said...

hi,
i am trying to control a stepper motor in visual basic 6 via the parallel port.i am a noob in programing and i cant get started..can u help me with some codes plz

SMVEC_ICE said...
This comment has been removed by the author.
SMVEC_ICE said...

i made the program in visual basic 6 to control the 2 stepper motor and 8 relays using the transistor......
if you need any help just
mail me at sriram1854@gmail.com

here is the link

http://www.mediafire.com/file/pd5p9vbncing5dw

bye....

Unknown said...

hi ashish..really great work ..just wanted to ask ..can i do the programming part with actionscript3!

Aficionado said...
This comment has been removed by the author.
Mukesh Harsh said...

dear ashish,
m am mukesh harsh from rajasthan. i am computer troubleshooter. i have been visited this blog many times. i am working on a project and seeking help from you. basically my project is making a camera crain with pt functionality. i have been left electronics 17 year ago. my crain is almost ready and now webcam pt controller is pending.i am looking help for pt controller for my webcam. would you like to help me.

thanks
mukesh harsh

brianwalt said...

I think you have a good knowledge about such kind of topic. Computer Controlled Stepper Motor is one of hard to know about it's specification but you have present so simply.

Integrated Stepper Motor

Junaid Ahmed said...

your work is awesome

Nokia Applications | Nokia Games | Nokia Themes | Nokia Prices | Nokia Reviews

Anonymous said...

Hi Ashish,
i m rohit i current work on a proj in which we need five dc moter control by the wireless network if u have any idea about it then tell me
my email id:choudharyrohit444@gmail.com

διαγωνισμοι said...

I used to be more than happy to seek out this internet-site.I wanted to thanks in your time for this glorious read!! I positively enjoying each little bit of it and I have you bookmarked to check out new stuff you weblog post. this thread is amazing i like your work and i appreciate you that you have share a useful stuff thanks for sharing

stepper motor said...

Yes i am agree with you that it is Such a great post and interesting comments. I found this post while surfing the web for Thanks for sharing this article.

denver hotel downtown said...

Wonderful article, It is a nice site here we post our comments and create our blogs. I'm sending it to some friends!

Anonymous said...

sir ur project is rlly appreciable
plz!!cn i hav ur circuit implementation details including circuit diagram!!as we are using i/o card for protecting pc parallel port!!we need to know full circuit connection details!!as directly implenting it quite be a risky one!!

SHALL B WAITING FOR UR RPLY
MY EMAILID IS:priyanshijain111@gmail.com

ab.ghani said...

Just want it to say that I admire your effort, there should be more like you to stand for what is right.

commercial playground
daycare playground sets
daycare playground equipment

romancito2010 said...

Hermoso sitio!!

http://cespedartificialpreciosymas.com/
http://cespedartificialpreciosymas.com/cesped-artificial-barato/

Shady Mohsen said...

greate work. So simple, so easy

Shady Mohsen said...

So simple, so easy

stepper-motor said...

Thanks for posting this wonderful post with us.The information are really informative in terms of stepper moter.

uk dissertation writing said...

this new technology is really great, computer world become more vibrant these days

Lex said...

can i use assembly language to run the stepper motor??? pls email me ilaganlexan@gmail.com

Unknown said...
This comment has been removed by the author.
Unknown said...

greate work. So simple, so easy
Best online games

Seo Content Writing Service said...

Ggreat! This content is innovative, there are a lot of new concept,it gives me creativity.

Unknown said...

Sir really nice project
i am pradeep chavana. i am interest to do ur project
plz!!can i hav ur program implementation details including circuit diagram!!as we are using i/o card for protecting pc parallel port!!we need to know full circuit connection details.
i am waiting for u reply
E-mail: chavanapradeep24191@gmail.com

Tongji said...

Good article. How to control two or more stepper motor use parallel port. That is posible?

Anonymous said...

:)

ISL Products said...

Thank you for posting this blog.
If you want to know more information - ISL Products International is among the leading stepper manufacturers in the world with the highest level of client focus. We provide many types of stepper motors ranging from Hybrid Stepper Motors, as small as NEMA 8, to Flat Permanent Magnet Stepper Motors.

Karolinax said...

sohbet hattı
telde sohbet
sohbet hattı
sohbet hattı
sohbet hattı
sohbet hattı