Step direction acceleration for stepper motors

21 Apr 2011

Hi,

The solution is probably quite simple, but I can't seem to figure out how to implement it. What I'm looking for is: A DigitalOut to give pulses at a linearly increasing frequency, so that the stepper motor accelerates linearly.

Variables: Acceleration in steps/s^2, Speed in steps/s

If you know how to toggle the digital out at the linearly increasing frequency that'd help allot already!

Cheers,

Melchior

22 Apr 2011

Found something that might come in handy as I am using a polulu A4983.. http://mbed.org/users/gyurma/programs/stepper_motor_control/lndxej

.>

Melchior

22 Apr 2011

Hi Melchior, my first solution: In a loop with 1 step and a wait-time, decrease the wait-time every step. ( I am using this simple solution to ramp up a stepper motor )

DigitalOut stepper(LED1);  // or output

int pause=100; // msec

void pulse() {
stepper =! stepper;
if (pause >1) wait_ms(pause--);
}

int main() {
stepper = 1;
    while(pause > 1) {
    pulse();
    }   
}

I am not sure this is a linear acceleration. Everey time interval n steps, and then increase the n in that interval is linear. But i think you wil calculate the time interval between the steps ?

I am very busy this weekend, so i hope that this helps you. (in spite of my bad English)

Hugo

22 Apr 2011

Yea I've tried something like that. Made one that works like you described:

#include "mbed.h"

DigitalOut myled(LED1);
Timer timer;
Ticker ticker;
int accel=1; // steps/sec^2

void step () {
    myled=!myled;
    wait(0.001);
    myled=!myled;
    wait((1/(timer*accel))-0.001);
}    
    
int main() {
    timer.start();
    wait(1);
    
    while(1) {
        step();
    }
}

Depending if wait() checks the actual value, or sample&holds one value, it might be lineair acceleration.

In the mean time I've been playing in excel a bit, got some stuff that looks okay, but there are little glitches when I start decelerating. I know where the problem is tho, now I just have to fix it. And once it's fixed, I have to transfer it into .c somehow ;)

Melchior

02 May 2011

I ended up with something like this:

Import programlazysteppercontrol

Simple pulse direction program for testing stepper motors.