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
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