One table to run them all

In previous entries, I have delved into the idea of using different shapes for the speed pattern for a motion using steppers and have presented how the timing can be based on a look-up table. Such a table would be pre-calculated and flashed with the firmware. But a single table provides a pattern for a given max speed, acceleration, number of steps and speed shape.


You can use that for timing the steps of the motor and it will accelerate properly as many steps as entries on your table. But it won't be practical if we want to change any of these parameters for other movements.

The idea

I am not yet sure this works as expected, but first tests look ok, finally, as it took me a while to figure this out.

I have created a lookup table as the graph above, where each entry contains the delay needed for each step, for a movement of 1000 steps total, where speed will increase to 2Π while time goes till 2Π too. Maximum speed for each different motion pattern will be different though, but that can later be compensated for.

Therefore the table summarizes the relationship between distance and time, but instead of using a linear time scale we use a linear scale for the distance.


The key is to learn how to scale the table values so we can apply it to different motion cases where the max speed or the acceleration is different than the one used for the table. Changing max speed will, in turn, change the distance required to accelerate, which will mean more or fewer steps.

At the same time, changing the acceleration will mean now the time (and distance) devoted to acceleration will change and so will the number of steps too. 

The problem is that this distance/time relationship is not linear and when we change the max speed or acceleration or both, then acceleration distance changes, acceleration time changes too and so does the number of steps required. The graph above shows different cases where acceleration happens faster or slower with more and with fewer steps. 

So for a given motion, what I do is:
  1. to calculate the acceleration time
  2. to calculate the number of acceleration steps (N) 
  3. extract exactly N values from the look-up table which are equally spaced in distance
  4. multiply the delay of these N values so the total time matches acceleration time
Doing so would make sure the speed profile matches the one the table was created with. Still, if only a handful of steps are used for acceleration this motion profile would be roughly represented though.

And because I reckon an example can bring some light after a not so bright explanation, here you have it. 

Please let me know if you find it flawed, as I am not yet sure it is right.



Comments

Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino