Stepper motor help
Would some one be kind enough to explain briefly how I can use a stepper motor with my propeller. I am having a hard time understanding a way to code it. I am using an Allegero A2919SB IC. Here is my schematic.

Comments
P1 is turning ON/OFF the current of PHASE2 (0=ON, 1=OFF)
P2 steers the direction of the current for PHASE2 (0=positive, 1=negative)
P3 same as P1 but for PHASE1
P4 same as P2 but for PHASE1
P5 lowers the output current.
You have to do the timing like the diagram in the attachment shows. It depends how you will drive the motor:
- Halfstep (save method with no risk of oscillations)
- Fullstep
- 1 phase mode
- 2 phase mode
I hope this helps a bit
Saluti Joerg
http://www.parallax.com/Resources/NutsVoltsColumns/NutsVoltsVolume7/tabid/450/Default.aspx
"Column #136: Stepping Out with Spin" is what you're looking for.
connect P1 to P0, P2 to P1, P3 to P2 and P3 to P2 (first p is your controller, the second your Propeller chip!)
connect P5 to GND (VSS) or open (the propeller chip is a 3.3V chip!!)
'stepper_A2919 {{MotStat Bit 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | State: 0 | 1 I I I I I I I I-------> Stop | Run I I I I I I I-----------> Forward | Backward I I I I I I---------------> Halfstep | Fullstep not implemented yet I I I I I-------------------> SPhase | TPhase not implemented yet I I I I-----------------------> Continous | Controled not implemented yet I I I---------------------------> NU I I-------------------------------> NU I-----------------------------------> NU Pin0 = P1 Pin0+1 = P2 Pin0+2 = P3 Pin0+3 = P4 P5 = VSS!!! (GND) }} VAR long Stack[noparse][[/noparse]14] 'Stack space for new cog byte Cog 'Hold ID of cog in use, if any byte StepNr 'the actual step number long MCounter 'counter to hold the waitcycles CON Run = 1 Backward = 2 FullStep = 4 TPhase = 8 Synch = 128 PUB Start(Pin0,AdrMotStat, AdrStepTime): Success Stop Success := (Cog := cognew(ManageMotor(Pin0,AdrMotStat, AdrStepTime), @Stack) + 1) PUB Stop {{Stop toggling process, if any.}} if Cog cogstop(Cog~ - 1) PUB ManageMotor(Pin0, AdrMotStat, AdrStepTime) StepNr~ 'clear the StepNr counter dira[noparse][[/noparse]Pin0+7 .. Pin0]~~ 'sets the needed pins as output dira[noparse][[/noparse]16..23]~~ repeat repeat until byte[noparse][[/noparse]AdrMotStat] & Run 'wait until motor has to run! if byte[noparse][[/noparse]AdrMotStat] & Backward --StepNr 'backward if StepNr == 255 StepNr := 7 else ++StepNr 'foreward if StepNr > 7 StepNr := 0 outa[noparse][[/noparse]Pin0+3 .. Pin0] := STEPTBL[noparse][[/noparse]StepNr] 'set the outputs depending on the StepNr waitcnt(clkfreq / 1_000_000 * long[noparse][[/noparse]AdrStepTime] + cnt) 'Wait for steptime cycles DAT STEPTBL byte 4, 0, 1, 2, 6, 10, 9, 8 'table for controling the motor (halfsteps)and a little program for testing your hardware:
{{MotionController2.spin}} VAR long StepTime long ActPos long RefPos byte MotStat byte SynchControl byte Pin0 OBJ Motion : "Stepper_A2919" PUB Main StepTime := 100_000 MotStat := 0 Pin0 := 0 '' dira[noparse][[/noparse]16..19]~~ Motion.Start(Pin0,@MotStat,@StepTime) repeat if ina[noparse][[/noparse]11..8] == 14 MotStat := 1 elseif ina[noparse][[/noparse]11..8] == 12 MotStat := 3 else MotStat := 0I hope it works
Saluti Joerg