Shop OBEX P1 Docs P2 Docs Learn Events
Stepper control — Parallax Forums

Stepper control

NewzedNewzed Posts: 2,503
edited 2005-03-11 19:15 in BASIC Stamp
Here is a neat little program for controlling the position of your stepper and remembering where it was.· I think I got all the bugs out.

By whatever means, set your stepper to 0 degrees, or to what ever point you want to use as a reference.· The progrom will consider this point 0 degrees.

Load the program, disable Line 24 and reload it.· Your starting position is now in EEPROM.· Each time you send a rotational command to the stepper, the new position is written EEPROM, so that even if you reboot, the program knows its last position.

You will have to calculate the pulses per degree for your stepper and enter this in Line 18 as a constant.· Be sure to set the same figures in Lines 111 and 118.

If you travel more than 360 degrees in any direction, the program will display the total degrees travelled, plus the number of revolutions and any "leftover" degrees.

All programming is based on "user shaft" rotation, which may be the shaft of the motor itself or the shaft of whatever reduction gears you are using.· My stepper takes 11167 pulses per shaft revolution, which translates to 31 pulses per degree of rotation.

Enjoy!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
NEW! 4 MB EEPROM

http://hometown.aol.com/newzed/page4.html

Comments

  • CogburnCogburn Posts: 62
    edited 2005-03-09 13:55
    What does the circuit look like that you are using to drive your stepper using this program.· Are you using a ULN2003 chip?·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Showing up to school doesn't·mean you are a student any more than crawling up in an oven means that·you are a biscuit.
  • NewzedNewzed Posts: 2,503
    edited 2005-03-09 15:11
    No.· I am using a Gecko micro-step controller.· The whole thing was given to me - I just got it working and wrote the program for it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    NEW! 4 MB EEPROM

    http://hometown.aol.com/newzed/page4.html
    ·
  • Joe FishbackJoe Fishback Posts: 99
    edited 2005-03-11 18:45
    Sid,

    I work with CNC machines that use "gecko" controllers and your program is of great interest. I understand the general program. My question is, how do you know the number pulse per revoution? My steppers are 200 steps per revolution. How does this equate to pulses?

    Also how did you determine the lenght of pulse is 10?

    Thanks,

    joe Fishback
  • NewzedNewzed Posts: 2,503
    edited 2005-03-11 19:15
    Hello, Joe

    I positioned a protractor in front of the stepper and then put a 2" narrow pointer on the shaft.· I carefully positioned the stepper until the pointer was exactly on 0 degrees.· Then by cut-and-try I determined that it took 11167 pulses for one revolution with the stepper running at 18VDC.· Then 11167/360 gave me the number of pulses per degree.· The 31 I am using is not exact - should be 31.019 -· so over a long period of time I could gain a degree or two.· That is why I put in the "nudge" option, which is not considered by the program when it displays the rotational position.

    On the BS2, a pulse of 10 is actually 20us.· I tried pulses of 8 and 12 but it didn't seem to make any difference, so I just left it at 10.

    A step is a step.· The Geckos divide·a step·down into 5 or 10 or ? "ministeps", each ministep being a pulse.· Since I was given this thing, I had not idea of the steps or ministeps per revolution, hence the protractor approach.

    Seems to work [noparse]:)[/noparse])

    Sid
Sign In or Register to comment.