Page 1 of 1
stepper motor
Posted: Mon Mar 08, 2010 1:44 pm
by ben
Hello
I am trying to get a stepper motor to rotate 180 degrees and back, with respect to a sensor attached to a port. I know I need to introduce some kind of interrupt, but so far I have failed. would anyone give me a little advice on this please. Many thanks.
Ben
Re: stepper motor
Posted: Fri Mar 19, 2010 12:28 pm
by Benj
Hello Ben,
Have you played around with the timer interrupt before. You may want to have a look at some of the examples available in the examples pack and on the forum as they will give you a good insight onto how this works.
You should be able to use a direction flag variable and a counter variable to keep track of where the motor is and which direction it is moving in. This way you can move to your desired position, change the direction flag and then move back to where you started from.
Re: stepper motor
Posted: Sun Mar 21, 2010 9:44 am
by ben
Hi Benj
Thank you for your reply. I am very novice when it comes to programming. Although I have tried to look for timer interrupt, but I can't work it out. I am not too sure how to use a direction flag and a counter variable.
Re: stepper motor
Posted: Mon Mar 22, 2010 9:20 am
by Benj
Hello Ben
This should help you to get started.
Re: stepper motor
Posted: Mon Mar 22, 2010 12:24 pm
by ben
Hi Benj
As ever thank you very much, I will try.
Regards
Ben
Re: stepper motor
Posted: Mon Mar 29, 2010 10:19 am
by ben
Hi Benj,
I did try, but I am afraid I can't get it working. Is there anything I should do on the hardware ? I have basically compiled and programmed the chip(Successfully) and layed the hardware by connecting the ports to a stepper motor, power and the earth. Many thanks.
Regards
Ben
Re: stepper motor
Posted: Mon Mar 29, 2010 1:04 pm
by Benj
Hello Ben,
For a 5, 6 or 8-pin motor do as follows.
You will probably need to amplify the current provided by the microcontroller to allow the stepper motor to work. Running the motor coils directly from an output pin will probably not work.
The way I do this is to use NPN transistors as shown here, 1 for each coil.

- Stepper.jpg (5.01 KiB) Viewed 7619 times
The TIP122 devices are fairly inexpensive and can switch up to 5A per coil.
I then connect the common leads of the stepper motor to +V eg 5V or 12V depending on the motor. When a transistor connected to one of the coils is activated there is a direct path from the common lead to ground via the motor coil.
For a 4 pin motor you will need to use a H-Bridge configuration as each coil needs to be able to push and pull current.
The MIAC's transistor outputs can drive a 4,5 or 6-wire stepper motor directly.
Re: stepper motor
Posted: Tue Mar 30, 2010 8:47 am
by ben
Hi Benj,
Once again thank you, but I think I didn't explain myself proprely !! The motor driver side is fine and I have used H- bridge for my 4 pin motor, as you suggested. I am not sure about my connection on PIC device 16f88. There are no pulses from the port on the device and this let me think, may be the PIC configuraion is wrong.
Re: stepper motor
Posted: Tue Mar 30, 2010 9:18 am
by Benj
Ah I see the problem.
Either you have not called the motor enable component macro, you must do this before it will allow the pins to be activated.
Or the configuration is incorrect. You can change to config settings via the Chip -> Configure menu.
Re: stepper motor
Posted: Tue Apr 13, 2010 9:18 am
by ben
Hi Benj
I am sorry I still can't get this working, although simulation is fine, but when I connect the hardware nothing happens. Is it possible for me to E-mail my flowcode for you check please. Thank you.
Re: stepper motor
Posted: Tue Apr 13, 2010 12:15 pm
by Benj
Hello
YOu can attach your program to the forums or PM me with your program if you do not want it to be publically released to the forum community.