Micro Stepping a BiPolar Stepper motor
Jim Fouch
Posts: 395
I'm quite new to the SX & SX/B but have used the Basic Stamp 2 & 2SX for a while.
·
I'm interested in making a homebrew NC Drill for drilling PCBs. Being a cheap guy I'm trying to make the XY table out of old computer parts. I have a nice scanner that has agreed to be sacrificed for the better good of my enjoyment. I have managed to take control of the stepper using an L293D Double H-Bridge. I can get the movement ·down to .00328”/step but am looking to get closer to .0005”/step.
·
Does anyone have any sample code that will allow me to micro-step a Bi-Polar motor using the SX?
·
Thanks,
·
Jim
Here is a sample of my code so far...
MotorSteps:
· Data %0000
· Data %0011
· Data %0110
· Data %1100
· Data %1001
Forward:
· INC StepIndex
· If StepIndex<5 then SendMotorCommand
· StepIndex=1 ' Rollover
· Goto SendMotorCommand
Reverse:
· Dec StepIndex
· If StepIndex>0 then SendMotorCommand
· StepIndex=4
SendMotorCommand:
· TRIS_B = %11110000 ' Setup Outputs
· Read MotorSteps + StepIndex, RB
· Pauseus 1800
Return
RelaxMotor:
· TRIS_B = %11110000
· RB=%0000
Return
Start:
For J=1 to 100
· For I=1 to 50
··· For Counter=1 to 5
····· Gosub Forward
··· Next
··· pause 50
··· For Counter=1 to 5
····· Gosub Reverse
··· next
··· Gosub RelaxMotor
··· Pause 50
· next ' I
· Pause 60000
next ' J
End
·
I'm interested in making a homebrew NC Drill for drilling PCBs. Being a cheap guy I'm trying to make the XY table out of old computer parts. I have a nice scanner that has agreed to be sacrificed for the better good of my enjoyment. I have managed to take control of the stepper using an L293D Double H-Bridge. I can get the movement ·down to .00328”/step but am looking to get closer to .0005”/step.
·
Does anyone have any sample code that will allow me to micro-step a Bi-Polar motor using the SX?
·
Thanks,
·
Jim
Here is a sample of my code so far...
MotorSteps:
· Data %0000
· Data %0011
· Data %0110
· Data %1100
· Data %1001
Forward:
· INC StepIndex
· If StepIndex<5 then SendMotorCommand
· StepIndex=1 ' Rollover
· Goto SendMotorCommand
Reverse:
· Dec StepIndex
· If StepIndex>0 then SendMotorCommand
· StepIndex=4
SendMotorCommand:
· TRIS_B = %11110000 ' Setup Outputs
· Read MotorSteps + StepIndex, RB
· Pauseus 1800
Return
RelaxMotor:
· TRIS_B = %11110000
· RB=%0000
Return
Start:
For J=1 to 100
· For I=1 to 50
··· For Counter=1 to 5
····· Gosub Forward
··· Next
··· pause 50
··· For Counter=1 to 5
····· Gosub Reverse
··· next
··· Gosub RelaxMotor
··· Pause 50
· next ' I
· Pause 60000
next ' J
End
Comments
First, the steppers you pulled from the scanner are going to be very weak. Depending on how much weight, mass, and friction is involved in the X-Y table, they could easily be too small for the job. Second, probably everything you want to know about do it yourself micro-stepping can be found here:
www.fromorbit.com/projects/picstep/index.php
The code is for the PIC, but it's all open source source (as is the hardware design) so you can go nuts with it.
Thanks, PeterM
MotorSteps:
Data %0000
Data %0011
Data %0110
Data %1100
Data %1001
Forward:
INC StepIndex
StepIndex = StepIndex AND 3
Goto SendMotorCommand
Reverse:
Dec StepIndex
StepIndex = StepIndex AND 3
SendMotorCommand:
TRIS_B = %11110000 ' Setup Outputs
Read MotorSteps + StepIndex, RB
Pauseus 1800
Return
RelaxMotor:
TRIS_B = %11110000
RB=%0000
Return
Start:
For J=1 to 100
For I=1 to 50
For Counter=1 to 5
Gosub Forward
Next
pause 50
For Counter=1 to 5
Gosub Reverse
next
Gosub RelaxMotor
Pause 50
next ' I
Pause 60000
next ' J
End
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Thanks,
Jim Fouch
Full Steps:
Half Steps:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA