Shop OBEX P1 Docs P2 Docs Learn Events
Help with stepper motor ramp profile — Parallax Forums

Help with stepper motor ramp profile

mynet43mynet43 Posts: 644
edited 2010-10-04 07:10 in Propeller 1
I have a propeller board that controls two small stepper motors that move an X/Y table to a requested position.

The stepper motors have 20 steps per rev and 16 micro-steps per full step, so it takes 320 micro steps to turn one rev. This motor drives a worm gear that drives a larger gear at a ratio of 50 to 1, so it takes 320 X 50 = 16000 micro steps to rotate the large gear one rev. Each turn of the large gear moves the table 0.5 mm. So you can see I have very fine control of the table (microns).

This all works fine most of the time. Occasionally the motor stalls while ramping up to speed.

The ramp algorithm I'm using is linear. It divides the maximum step rate into 32 evenly spaced speed intervals. It starts at the slowest and changes the step rate to the next level after a given number of micro steps.
  n_steps := 32                 ' number of ramp steps
  repeat ix from 0 to n_steps-1
    pulse_delay[ix] := (constant(80_000_000/max_sps)*(n_steps/2))/(ix+1) ' div by 2 to get half cycle time

I'm using the Pololu stepper driver, which needs only direction and step input signals. Right now I'm driving at a maximum micro-step rate of 25000 steps per second using an assembly language program. The pulse_delay[ ] array is used to control the assembly waitcnt command to precisely send the step pulses.

Once the motor gets going at full speed, it's fine. Occasionally it stalls on the ramp up.

I suspect the problem may be that I'm using a linear ramp. Can someone point me to a ramp profile that will work better in this kind of situation? Or a better way of doing this.

I'll be happy to supply the assembly code if anyone is interested.

Thank you for your help.

Jim

Comments

  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-02 12:44
    I wish I had steppers that could handle 25000 steps per second, even if they are only micro steps. The salvaged stepper motors I have set aside for X / Y positioning (PCB) will only go up to 500-600 steps / sec. Even then I have to half step to keep torque.

    I had it going from stop - full speed in just 4 chunks, and the same on the way down.

    I now recon that I could just use ordanary motors and track the bed with the innards of a couple of optical mice.
  • mynet43mynet43 Posts: 644
    edited 2010-10-02 13:23
    Hi Toby,

    Thanks for the interest.

    Here's a picture of the stepper motor. It's a custom motor imported from Germany.

    Jim
    1024 x 768 - 119K
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-10-02 17:18
    Hi Jim,

    I have got a small portal mill with steppermotors and trapezoidal threads from a friend. Which I want to reactivate to collect experience with CNC-milling.

    I have some questions.
    What bearings do you use?

    Is the table driven through a standard metric thread or is it a trapezoidal thread or even a recirculating ball thread?

    Did you measure the backlash tolerance? (not sure about this word)

    I mean if you change the direction is there some "air" in the thread?
    Which means the thread turns a little bit while the table is not moving for a part of one rotation and then starts moving again.

    Is there some "air" in the gear?

    Whenever I saw steppermotors drive something at high precision a stiff tooth-belt was used and no tooth-wheels.

    If I remember right the ramp can be a quadratic function. If the motor stalls some time, I would think about a steppermotor with a higher torque.

    Do you use a chopper-circuit for the h-bridge? (Something like the steppermotor-chips L297-L298?)

    best regards

    Stefan
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2010-10-03 05:46
    If the stepper stalls when ramping up then most probably it is just too high an acceleration rate. A linear ramp up is totally normal.

    If you really need that speed then increase the voltage to the motors, lower the load or change the motors.

    More steps in your ramp may also help as each step in itself represents a high acceleration.

    Graham
  • mynet43mynet43 Posts: 644
    edited 2010-10-03 07:40
    Thanks for the great responses. They really help.

    I think i may have solved the problem. I was ramping up to speed but not ramping down at the end. The problem shows up when I try to change direction too quickly. The inertia of the system tries to keep it going one direction while I'm driving it the other.

    I think I've solved this by putting a small delay between the time it stops and the time it starts up again. I'll keep watching it.

    Stefan,

    You asked a number of questions. I don't have the answer to all of them. I'm doing the electronics and the firmware, not the mechanical on this project.

    The bearings look like standard ball bearings (very small).

    I'm not sure about the thread profile.

    Your backlash question is a good one. I'm handling this the same way you do on a milling machine. When I'm going forward, I ignore it. When I'm going backward, I purposely overshoot a little, then come back to the requested position in a positive direction. This means the slack is always taken out of the gearing, regardless of the tolerance.

    I'm using the Pololu stepper driver which provides all the phasing and power control. It's a 12V motor supply and 3.3V logic, to match the Propeller.

    Jim
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-03 09:47
    I have used elastic bands to pull back the bed and so counter act the backlash. This only works for a free moving table, as in move to next location, stop, do action, stop action and the move on to the next location. I would like to plan for some very light duty milling of the PCBs too so any backlash would come back to haunt me.

    The assembly in the pic makes my experiments look like meccano, and thats probably an insult to meccano
  • mynet43mynet43 Posts: 644
    edited 2010-10-03 10:43
    I'm running two cogs, each with identical code, for the stepper control. One for each motor. That way, both motors can operate at the same time, with different parameters.

    I control them by looking for a variable to be set in the spin code. It's set to the number of steps needed.

    I'm still finishing up the backlash coding.

    If anyone is interested, I'll be happy to supply the code.

    Thanks for all the help.

    Jim
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-10-03 11:18
    Hi Jim,

    for moving in X and Y-direction at the same time with any x-y-speed-ratio
    I'm using the bresenham-algorythm.

    With this algorythm it is very easy to realize any direction (with different xy-ratios

    I mean f.e. five steps in x-dir and only 1 step in y-dir. The bresenham-algorithm does this with simply adding and substracting integervalues without any multiplikation or division. This will save you a cog and the pulsetrains for the axes are always synchronised as both pulsetrains are created by one loop

    If a tool is working on the object and you always move a little bit too far and move back the result will look not the way it is meant to be.

    Does this maschine do only x-y-positioning and then drive down z-axis
    for drilling and only move in x-y-direction while the tool is "in the air"?

    best regards

    Stefan
  • mynet43mynet43 Posts: 644
    edited 2010-10-03 11:41
    Hi Stefan,

    Interesting algorithm. Glad you brought it up. I'll look into it.

    I don't think it would work with my application because of the speed. At 25 to 30,000 steps per second for each motor, and doing some processing between half-cycles, there isn't much time to spare, even with assembly code. I need to do the ramp processing (at different times for each motor), monitor two encoder lines per motor and look for contact with limit switches. All this while stepping the motor at just the right time.

    When I was talking about the backlash, and referring to a milling machine, I was talking about manual milling, where you always set your dimensions in one direction. This wouldn't work if I was cutting a piece of metal while I was moving. However, for this application, I'm not cutting anything. I'm moving a target under an electron microscope at 30,000 times magnification, X/Y only, no Z axis movement. So hopefully it will work. I haven't finished the backlash code yet. The last measurement I made showed 0.012" backlash between the worm gear and the bigger gear. This is a big number for my application.

    Thanks again for the great feedback.

    Jim
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-04 01:24
    As I said earlier if the bed is a free agent, then a sinple pull back system can help. The trick is to keep it as linear as posible, this would mean a levered spring (kept in its linear range) or a longer single action spring from a more remote point. That was my choise, an cut elastic band around a pully to equalize the pull at the extremities. Obviously they do not last too long, with perishing, but they come in big bags.
  • mynet43mynet43 Posts: 644
    edited 2010-10-04 07:10
    Hi Toby,

    That's a good suggestion. Unfortunately, I have no control of the mechanical design of this system. I'm doing the electronics and software.

    I'm still working on the backlash code. The concept is easy but the devil is in the details. How much to overshoot, should I control it in the assembly or the spin code, how much time delay between stop and start, etc., etc...

    Keep up the suggestions. If anyone has a better way to do this, I'm all ears :)

    Jim
Sign In or Register to comment.