Well saw that people still are having quite some doubts on the stepper motor post that i had put up. so i thot to make that abstact clear i better put the exact circuit and the code here.
The exact circuit to connect the stepper motor to 16F877A is given below
In this the common is connected to the 16V supply(12 v is actually enough actually higher current drives the motor better as far as i know*). If u are new here and donot know how to find the common line in a unipolar Stepper motor then see here
The MicroC code for running the motor is as below.
void main()
{
TRISB = 0x00;
PORTB = 0x00;
//routine to move in one direction
for (i=0;i<50;i++)// increse i=50 no i=100 to cover double the distance
{
PORTB=0x80;
delay(20ms);
PORTB=0x40;
delay(20ms);
PORTB=0x20;
delay(20ms);
PORTB=0x10;
delay(20ms);
}
//routine to move in the other direction
for (i=0;i<50;i++) // increse i=50 no i=100 to cover double the distance
{
PORTB=0x10;
delay(20ms);
PORTB=0x20;
delay(20ms);
PORTB=0x40;
delay(20ms);
PORTB=0x80;
delay(20ms);
}
}
There are much easier ways to write the above code but then i am not worried about the memory it’l take nor have any pressing need to keep my code small and trim ,so i guess this will make you absolutely clear of what i’m trying to do to make my motor run.
If you din know MicroC well,let me brief. The line PORTB = 0x80 (1000000)makes my 8th pin of the PORT “B” that’s b7 pin or the 40th pin go high.The next line PORTB = 0x40(01000000) will make the 39th pin go high and all other low.
Now whenever the pin at the input of the ULN2003 goes high say pin 1 the output pin 16 drains the current throuh the motor thus completing the circuit from supplt 16V through motor to the ground in that line. When you keep doing this in series as i called it the abcd pulse the motor will rotate . When your reverse the pulse order the motor rotates in the other direction. As simple as that. For most robotic application atleast at contest level you may use this circuit uinless you go for bigger stepper motors that need more current to drive and is greater than the 500mA that the ULN2003 can sink!!
i guess i was clear about using ULN2003 to drive a sstepper motor. pl post your comments and doubts
–Madan
I like keeping all my circuits small and simple and not crowd it with resistors and capacitors.Afterall its a hobby and we need not complicate it.Cheers.
thanks buddy..this is really helpful..u doing a gr8 job!
🙂
as iam a begginer plz tell how to enter programs in microcontrollers
you’l need a programmer… that’s a device…. u need to connet it to the computer and transfer the code u wrote on computer to the microcontroller… see it in the ‘Micro-controller’ page in the top.
Funny Stuff …
I wish it really was surfer :). so how is amsterdam man?
plz send me the deails of (,hardware and software)stepper motor speed controller in my above mentain email id
change the delay to change the speed. that’s all to it.
delay(20ms);
Hey, you dint ground your ULN correctly.
I guess it should be like, PIN 8 to GND and PIN 9 to high, i.e. 16V.
I tried your circuit, it is not working.
This is what I am sayign is correct :
http://electronics-diy.com/stepper_motors.php
Yes you are right . in 8 should be grounded . i made a mistake here. i forgot to change that. i had noted it though. i’l try to change it as soon as poosible.
Thanks for reminding
The circuit has been modified, the circuit now is CORRECT!! 🙂 . Thanks rishi for bringin it to my notice.
hi madan..
i trying to move stepper motor with the help of AT89S51 using ISP(in system programming)…
from ur referance i m not getting the pin configuration of ULN2003 ..
8-PIN is ground .. where is Vcc ..
and also if u having AT89S51 ISP ckt. plz send me..
finally i corrected the circuit diagram. Sorry for all the ones above.
@ Vishal Uln Will get not have any direct VCC. It will have ground at pin 8. And read datasheet or the post carefully to know what uln does here vishal.
ISP? u want a circuit for that form me?
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. First time acually experimenting with this field of electonics so some help would be great…
Thanx Ryan
Hi Madan
Is it necessary to put a diode between the COM line and the power supply(16V)? I heard it is to prevent the back emf of the stepper motor…
For small motors it is not. if the rating is higher you might swell put a optical coupler to avoid the bacf emf problem completely.
hi madan,
i just needed 2 knw dat isnt dre ne need 2 power d ic’s… i mean wat abt vcc’s… is dis d complete circuit… don mind.. actually m a noobie in dis field… just askin.. n ya i wanted to knw dat is dre ne way 2 drive a motor of 3.25 A.. i hv heard dat uln2003 cannot drive motors above 1.2 A or sumthin…
@Rohit To drive 3.2 A motors try to use relays. or 2 uln’s one over
the other. And pls try to type your questions fully.
Thankyou
hi madan…
thnx for ur reply… i really want ur help regarding dis circuit… i hv seen the datasheet of 877a also n frankly speaking m unable 2 understand it fully.. m a mechanical engg student. plz help me regarding powering 877A n uln2003(i mean vcc’s).. i need the complete circuit.. hope 2 receive ur reply
madan …dont u think u have to declare i first … int i;
@Mukul
Well do i need to include that? 🙂
for me … it says …an undeclared identifier[i] in expression
in mikroC only
hey that problem is solved…
but i have to change delay to delay_ms and 20ms to 20 before i was able to run …thanks it worked….
but as u know it limits the current to 500ma ….wat if i need to run a motor of around 3.25 A as i need to take up high load….
@mukul
You are right . and i said do i have to mention that means you have to !!!.
Then the syntax in MicroC is delay_ms and not delay(20ms)
That was just a representaiton.
Sir,
I am very new in stepper motor field.So,I have some problems.Please help me-
1)please,tell me the significance of the 5th,6th and 7th pin of the ULN2003 IC.
2)Is there any chip select input in ULN2003?
3)please,give me the most cost efficient and easy circuit diagram for driving three and six stepper motors by using ULN2003,parallel port and other IC’s(At any time only one stepper motor will be active and others will be disable)but without using AND gates.
4)Send me the complete C code for robot gripper(three stepper motors) and robot leg(six stepper motors).
Hi all…
I am very new to stepper motors.
i have to control a UNIPOLAR stepper motor to control a sluice gate in my college Mini project.
I am using PIC16F877A for my project and i have develope a PIC simulation board and a PIC programmer.
im using MikroC to program and ic-prog to burn .hex to the chip.
You guya anyone have a complete circuit diagram (PCB top and Bottom) to do this task?
do i have to use ULN2003 to do this task????
does anyone have the source code for above thing???
pls post a reply or reply to isuru66@gmail.com
Thanx.
Isuru
Hi all,
i have try out above source code.
but it provide 3 errors.. tell me whats wrong in this code….
void main()
{
TRISB = 0×00;
PORTB = 0×00;
//routine to move in one direction
for (i=0;i<50;i++)// increse i=50 no i=100 to cover double the distance
{
PORTB=0×80;
delay_ms(20);
PORTB=0×40;
delay_ms(20);
PORTB=0×20;
delay_ms(20);
PORTB=0×10;
delay_ms(20);
}
//routine to move in the other direction
for (i=0;i<50;i++) // increse i=50 no i=100 to cover double the distance
{
PORTB=0×10;
delay_ms(20);
PORTB=0×20;
delay_ms(20);
PORTB=0×40;
delay_ms(20);
PORTB=0×80;
delay_ms(20);
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
error message is
‘;’ expected but x found
internal error
internal error
i think errors are in line 3 o 11
please give me a solution…
the problem is that: you have to declare i as type int,write delay_ms(value without units)insteady of delay(20ms)and lastly you have to write x in proper way.
hey madan …
u are well known of the fact that with uln2803 i get around .6A what if i need more current as the motor i wanna use has the max rating of 3.25A ,10kg-cms holding torque.Its kinda important for the project to use such high torque motors and these cant be avoided so i m kinda stuck with it.
@mukul
use a relay to drive motor, and the uln to switch relays.
can you please tell me how to accomplish the above without the microcontrollers???(…i am very much familiar with them.)
Which libraries do I have to use to run this code?
Thanks
I have another doubt, does this code work for bipolar (6 wires) motors? If not, could you please help me? I’m stagnant about how to drive it using C code.
Hey Madan, I was just asking if this code can be put in the MPLAB software and be made to work?
Regards
Kushal
i have the same problem with ICEMAN, i use 4 stepper motor.my problem is how is the command to make the stepper motor run the different rotation at the same time?
like motor a turn clockwise direction while another motor run at counter clockwise direction.
should i change this code to make both run but at the different direction?
TRISB = 0×00;
PORTB = 0×00;
it already has code to run in either directions. Just put them in diff functions and call when needed
i want to know the program to run stepper motor.
i use pic 16f628 and the driver ic is 3967. also i want the interfacing onnection between these ic’s.
hi all..
I want to know the
“configuration of stepper motors”
to be used in
“micromouse”
which are sufficient enough to drive my bot..Im not going for a complicated and high standard bot, but for a simple one ,as a beginner.
Thankyou for the reply…
void main()
{
TRISB = 0×00;
PORTB = 0×00;
//routine to move in one direction
for (i=0;i<50;i++)// increse i=50 no i=100 to cover double the distance
{
PORTB=0×80;
delay(20ms);
PORTB=0×40;
delay(20ms);
PORTB=0×20;
delay(20ms);
PORTB=0×10;
delay(20ms);
}
//routine to move in the other direction
for (i=0;i<50;i++) // increse i=50 no i=100 to cover double the distance
{
PORTB=0×10;
delay(20ms);
PORTB=0×20;
delay(20ms);
PORTB=0×40;
delay(20ms);
PORTB=0×80;
delay(20ms);
}
}
i have written this code but when i built then three error is shown below:
‘;’ expected but x found
internal error
internal error
plz give me solution
hi i have a step motor produced by philips and its model MB 11. but i dont know i can drive it. i have a circuit eith ULN integer but i dont know how i can connect the integer and motor. i mean i dont know wire connection. please help me.
if you want to help me.
please send me your information:
adnanmerter@gmail.com
hello sir,
where r the pins of port b connected in 16f877a .i m using 16f877a
to generate PWM which is connected to the power drive circuit to run the stepper motor.how r the interrupts used.
Hey thank you for posting this.
Does this circuit work only for unipolar Stepper motors? Or it also works for Bipolar Stepper motors. Also, can we distinguish between different pins of the bipolar Stepper motors in the same way as you explained for the Unipolar Stepper motors?
Thank you
Sir,
I am very new in stepper motor field.So,I have some problems.Please help me-
1)please,tell me the significance of the 5th,6th and 7th pin of the ULN2003 IC.
2)Is there any chip select input in ULN2003?
3)please,give me the most cost efficient and easy circuit diagram for driving three and six stepper motors by using ULN2003,parallel port and other IC’s(At any time only one stepper motor will be active and others will be disable)but without using AND gates.
4)Send me the complete C code for robot gripper(three stepper motors) and robot leg(six stepper motors).
Sir,
I am very new in stepper motor field.So,I have some problems.Please help me-
1)please,tell me the significance of the 5th,6th and 7th pin of the ULN2003 IC.
2)Is there any chip select input in ULN2003?
3)please,give me the most cost efficient and easy circuit diagram for driving four and six stepper motors by using ULN2003,parallel port and other IC’s(At any time only one stepper motor will be active and others will be disable)but without using AND gates.
4)Send me the complete C code for robot gripper(four stepper motors) and robot leg(six stepper motors).
@shahin_198:
1.they also similar to the pins 1,2and3 inputs.
2.so far i didn’t heard any chip select in ULN..
aravinth.s
What about half stepping or microstepping. how can it be done? Does any one have code for that?
Hi,
I’m currently uskng PIC16F877A and CCS c compiler to do the programming, is it possible to use the above codes with ccs c? i’m relatively new to stepper and micro-controller. hope you would be able to help with this issue. Thanks alot.
hi CAn you help me? I need to control four stepper motor with the pic 16f877, then I need the circuit and d the code..
help please
dear sir,
I am new in robotics field. I wasted my uptill 14000/- rupees in bilding micromouse . please help I am ery much in trouble. Please tell me the exact coding flood fill algo. or Djiktar’s algo. and there are very few days left in competition please help!!!
regards
gaurav
hi, i need ur help.i am doing robotic arm project.In ur project we r using 89c51microcontroller.to drive stepper motors we r using latch,optocouplers-(4N35),steppermotordriver(TIP122)in order to run stepper motor.But u r saying that with only one device uln2003 is sufficient to run stepper motors.so wat r the advantages and disadvantages in using uln2003 and cant we use ur method to run motors. which is efficient one in taking into consideration all the factors like cost,efficiency,accuracy etc. i am circuit also.please giv reply at my mailid
Unable to compile it in MicroC
hey, i am pretty new 2 to stepper motors
can any body help me with micro c code to control ir sensors pls send ur reply 2 my mail id
hi i need circuit and how to give pulse for 4 wire stepper motor
hi
i need circuit and how to give pulses for 4 wire stepper motor
hi
i have to do the project on fault analysis of dual stepper motors using pic such that on is stopped by some fault the other motors should automatically starts wotking.the pic i am using is 16F873A WITH TWO ANALOGUE MULTIPLEXER
hi
i have to do the project on fault analysis of dual stepper motors using pic such that one is stopped by some fault then the other motor should automatically starts wotking.the pic i am using is 16F873A WITH TWO ANALOGUE MULTIPLEXER.
i want the code for pic in micro c language
helo sirr i ws rely informtive but cn u plzz advice me how to control speed of a 12v dc motor …i m begner and only know how to synronice led using atmega 16…..my im is to buid a line ollower …i am in 2nd yer….plz avdice me
sir
i new in stepper motor. I dont know how to derive a stepper motor using ULN2003.How i find out the stepper motor wire configuration.
Hi Madan
I am doing my final year project for the completion of computer engg degree. THe project is all about controlling the movements of a battery operated robotic arm through the PC’s parallel port.
THe arm is OWI-007(made by OWI Inc.) The stepper motors need a 3v supply while the parallel port giving me 5 volts! So Should I use a voltage regulator here to step down the voltage or simply use ULN 2803 with my circuit?
waiting for reply
I’ve tried your code but my unipolar stepper is rotating in the same direction for both loop, what could be the problem??? pls help!!!
Hi Madan
I am doing my final year project for the completion of computer engg degree. THe project is all about controlling the movements of a battery operated robotic arm through the PC’s parallel port.
The arm is OWI-007(made by OWI Inc.) The motors need a 3v supply while the parallel port giving me 5 volts! So Should I use a voltage regulator here to step down the voltage or simply use ULN 2803 with my circuit?
waiting for reply
hi,
I am new to this feild of robotics & don’t have any idea about it.I want some help on how to build a robot that can solve the maze i.e. micromouse kind of thing.please help me out
plz send me the code 2 rotate 2stepper motors simultaneously & independently
pls ineed help on circuit diagram using 2 stepper motor with 16f877a via uln2003
ineed help on circuit of 2stepper motor with 16f877a via uln2003
hi madan,
we need to control a stepper motor using 89c51. we used the same circuit you have posted, using uln 2003. But the problem we are facing is the stepper rotates two steps clockwise and two steps anti clockwise continuously. Its not rotating in the same direction. Help us to fix it…
I want to know circuit diagram of 28 v dc stepper motor with input equal to 0.01 v to 15 volts
hai madan i m getting a problem in installing the LPT1.exe in my system it is asking for the file HanDes.dll but when i run the file after downloading it is not wprking properly can u please sujjest the optimum solution for this.
Hello sir i need the program in arm7tdmi based pograming
plz send me the deails of (,hardware and software)stepper motor speed controller in my above mentain email id
A lot of thanx dear…….
Nice efforts…….
has someone control 2 dimentional motors through mouse using 59c51?
hi,
ur pgm is nice,can u pls help modify the pgm so as to provide rotating a certain angle then a 10 sec pause,again rotating at an angle then pause hence providing a complete 360deg…this is regarding our project
Mam,
I am a final year engineering student.In our project,we use stepper motor and ULN2003 as the driver..We have to rotate the stepper motor in both clockwise and anticlockwise directions……..When a condition,say true, is met,stepper must rotate in clockwise direction otherwise in anticlockwise direction.program must be written in mikroc..So please help us.pls send me the prgrm.it’s very urgent
thank u thank u thank u i will try this ,..how can i rate this ,..oh star star star star star ^_^ sooo happy
can u please send the code… having a real problem with it
i am not getting it run…sir/madam….
The above program is correct.
Thanks buddy, this was realy very useful for me. we are in the process of making a micromouse. your posts are very much useful for not only to us but also to many other robotics enthusiast…keep up the good work
Hi..just a question… and what is the ULN2003 Vcc? 16v too?
i try to connect my ULN2803 to 12V and I burned it!! 😦 do you know why?
Hello sir,
i m working on a project using stepper motor
Model: 24BYJ48-01
Rated voltage: 12VDC
Number of Pole: 4
Speed Variation Ratio: 1/64
Stride Angle: 5.625 /64
DC resistance: 200ohm +-7%(25k)
Idle In-traction Frequency: >600Hz
Idle Out-traction Frequency: >1000Hz
In-traction Torque: >29.4mN.m(120Hz)
Self-positioning Tor: >29.4mN.m
insulated resistance: >10M ohm(500V)
insulated electricity power :600VAC/1mA/1s
Insulation grade: A
Rise in Temperature:<40K(120Hz)
Noise; <40dB(120Hz,No load,10cm)
Weight About: 40g
i m confused which driver ic would b the perfect as its current rating is high.
Please inform me the suitable driver ic and possible coding.
thanks
hello,i am using microbasic ,if i want the motor to rotate only 45 angle clkwise,90 angl anticlkwise,180 angle anti clkwise ,what modificatiion shall i do?
Hello
I am currently working on a robotics project that requires using 2 stepper motors and 3 gear heads to control a 5 DOF robot. I am using either MicroC ar CCS C. I will love any hints available on the coding. Also if anyone has done something like this before, I would please love to see the code used.
please send me the code for half step sequence
please send me the code for 90 degree rotation of the stepper motor.
please reply..
hello..i’m doing final year project…can i ask..i m using 16f877a to generate PWM which is connected to the power drive circuit (h-bridge…L298) to run the stepper motor…I’m currently using PIC16F877A and CCS c compiler to do the programming, is it possible to use the above codes with ccs c? I hope you would be able to help with this issue. (^_^)
hi, i tried to interface stepper motor with 89s52 and used uln 2003e.. Not able to drive motor.can any one mail the circuit and program to Irshadahmedakp@gmail.co thank you..
stepper motor should be rotated for 90degree
hai, i have interfaced a sensor with the pic and once its output is “1” the stepper motor should move to 180 degree. i have tried different methods but the motor is stopping it is continuously running till the sensor is “on”. plz help me how to stop it. m using mplab and c code…
Hye, thanks for your code.
I need your help. If i want to rotate stper motor in a 90 degree rotation then what modefication is need.
Is it possible with yous code or need to write new code???
this program is for….??? clockwise rotation or anticlockwise rotation…..plz tell me….
I need code that can control stepper motor, buzzer and LED (green and red), inerval btn motor and the two ie. (red led and buzzer) is 30sec. bt red led and the buzzer are all on at the same time
i want project wireless notice bord can you help me,Rajnigandha
how to make the stepper motor goes to 72 degree and stop
How to rotate the stepper motor to 180 degree for forward and reverse in left direction and forward and reverse in right direction..I tried ,but it rotates only one direction ..