Shop OBEX P1 Docs P2 Docs Learn Events
Micro Stepping a BiPolar Stepper motor — Parallax Forums

Micro Stepping a BiPolar Stepper motor

Jim FouchJim Fouch Posts: 395
edited 2005-01-16 19:25 in General Discussion
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

Comments

  • PJMontyPJMonty Posts: 983
    edited 2005-01-14 06:34
    Jim,

    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
  • BeanBean Posts: 8,129
    edited 2005-01-14 12:36
    I thing I caught is that your stepindex variable should go from 0 to 3, instead of 1 to 4 like you have it.



    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 WilliamsJon Williams Posts: 6,491
    edited 2005-01-14 20:18
    What I do know is that you're going to need more than four steps in your sequence. If you do half-steps you'll double the resolution. To get better than that, you have to control the power applied to the two phase coils that are affecting the armature.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jim FouchJim Fouch Posts: 395
    edited 2005-01-15 01:04
    Thanks for the reply. I think I'm going to try to microstep it into 16 smaller steps. Not sure if this will work, but I have a few ideas I'm going to try. I'll post my results.

    Thanks,

    Jim Fouch
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-16 19:25
    With direct on and off control (no voltage variation) you will only be able to use eight steps. Here's a couple tables from one of my BS2 programs to give you an idea.

    Full Steps:
    '                          __
    '                        ABAB
    '                       -----
    Step1           DATA    %1100
    Step2           DATA    %0110
    Step3           DATA    %0011
    Step4           DATA    %1001
    


    Half Steps:
    '                          __
    '                        ABAB
    '                       -----
    Step1           DATA    %1000
    Step2           DATA    %1100
    Step3           DATA    %0100
    Step4           DATA    %0110
    Step5           DATA    %0010
    Step6           DATA    %0011
    Step7           DATA    %0001
    Step8           DATA    %1001
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.