Smooth acceleration and deceleration of a stepper motor
#1
Posted 29 February 2012 - 07:15 AM
#2
Posted 05 March 2012 - 08:25 PM
- inxtremo likes this
#3
Posted 07 March 2012 - 06:45 AM
Hi there,
I am used to working on DSP designs where it is sometimes necessary to step through an array of values at a fractional rate.
For example, generating a sine wave with an arbitrary frequency using a 256 point sine wave lookup table that is stored in an array. To do this you need an integer index to access the table, but the index needs to increment (or decrement) in non-integer steps
This sounds like a similar problem as you are trying to solve.
The solution for generating a sine wave is to store the floating point increment in a variable and add it to a running floating point counter when each sample period comes round.
To fetch a value from the array, we simply use the integer part of the counter.
In the background the fractional parts will eventually add up to an extra step every so often and this gives the impression that the table is being stepped through at a non-integer rate.
How does this help you? Stepping though an array at a fractional rate is similar to stepping through time at a fractional rate.
Create a floating point millisecond counter variable.
Each time you need to implement a delay between steps, take your desired floating point millisecond delay value and add it to the counter.
Then, take the integer part of the counter and use it for the next millisecond delay.
Deduct that integer value from the counter.
Doing this will average out the fractional parts that you can't express in a delay of integer milliseconds, and the result should be a smooth stepper movement.
Hope this helps - Paul
Wow, thanks a lot.
I think at weekend i have the time to think about your answer in more detail. I´ll post my results.
So far, i re-implemented a method for trapezoidal acceleration i seen for the Arduino. Works fine but i´m sure there are lot of space to improve this.
Thanks and best regards,
Daniel
#4
Posted 07 March 2012 - 03:55 PM
Total BOCS Traveled Distance: 9708 miles | States Visited: 5
Track the Box
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users