Stepper Motor Controller
I have been experimenting with controlling a stepper motor using the EB-011 Power Board.
This is a simple example of how to program a variable step / direction system.
Hardware Connections
EB-006 Multi-Programmer with PIC 16F877A
Port A = Custom 4 x 20 LCD Display
Port B = EB-007 Switch Board
Port C = EB-011 Power Board
Port C= EB-004 LED Board
Port D = EB-014 Keypad
Astrosyn Y129-5 Unipolar Stepper Motor (Rapid Electronics)
Bit 0 = A1 = Brown
Bit 1 = A2 = Red
Bit 2 = B1 = Orange
Bit 3 = B2 = Yellow
Center Taps = Ground = Black & White
Motor Details
Full Step Mode
1.8° / Step = 200 Steps / Revolution
Half Step Mode
0.9° / Step = 400 Steps / Revolution
Program Details
The LED board in series with the power board shows the status of the 4 lines driving the stepper motor.
A simple title screen is shown, with a slight delay to allow it to be read.
The title screen then clears.
The program first requests the direction the motor is needed to turn in.
Press Sw0 = Forward
Press Sw1 = Reverse
Then the number of steps needed is entered on the keypad.
If the number is less than 100, the # key is pressed to end the enter cycle.
The motor will then turn the required number of steps, showing the number on the display.
The display will then clear and ask for the direction for the next movement.
To change between full or half step the stepper component must be edited and the program recompiled to the device.
Slightly different version of the program
This allows the entry in degrees. Motor will turn through the value entered.
It does have a slight bug, in the accuracy as I've not used floating point math to calculate the steps from degrees
This is done by
Steps = ( Degrees / 1.8 )
Ive used
Steps = ( Degrees * 9 ) / 5
Stepper Motor Controller
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Stepper Motor Controller
Hi John!
Very nice project. I will test it later. At the moment I am a little busy. Nice you share your projects.
Best regard
Jorgen.
Very nice project. I will test it later. At the moment I am a little busy. Nice you share your projects.
Best regard
Jorgen.
-
- Posts: 95
- Joined: Sat Jun 11, 2011 4:12 am
- Has thanked: 87 times
- Been thanked: 31 times
- Contact:
Re: Stepper Motor Controller
Thanks for sharing this John! Your code looks really clean! I especially like the way you do your read keypad!! I ran it to the same problem with degrees so now I just do everything in steps. I ended up cheating on my turntable project incorporating a small stepper motor driver board: http://www.sparkfun.com/products/9402 that just uses step and direction inputs. This little thing works great and is really hard to beat at only $15 USD. It is amazing the amount of torque you can get with this little sucker. Here is a picture of the driver board on my EB-016 to give you an idea how small it is.
Have a great day Buddy!
Have a great day Buddy!
- Attachments
-
- DSC_0028_800x531.jpg (99.9 KiB) Viewed 5844 times
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: Stepper Motor Controller
Hi John! Nice work! Have you tried to enter 1 (one) degree, to see what is happens?