Page 1 of 1

Stepper Motor Controller

Posted: Sun Dec 04, 2011 5:42 pm
by JohnCrow
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.
Stepper Driver.JPG
Stepper Driver.JPG (127.85 KiB) Viewed 6496 times
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

Re: Stepper Motor Controller

Posted: Mon Dec 05, 2011 2:06 pm
by jgu1
Hi John!

Very nice project. :D I will test it later. At the moment I am a little busy. Nice you share your projects.

Best regard

Jorgen.

Re: Stepper Motor Controller

Posted: Tue Dec 06, 2011 3:17 am
by Werner
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. :D 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!

Re: Stepper Motor Controller

Posted: Sun Dec 23, 2012 5:27 pm
by bercioiu
Hi John! Nice work! Have you tried to enter 1 (one) degree, to see what is happens?