More experiments with motion curves for steppers

Though I have been experimenting with Arduino, I realize that as soon as the computing requirements grow a bit the results quickly show the processor is actually slowing down my results. So now I am using a DOIT Espduino featuring an ESP32 processor that makes that sensitivity go away.

It was a bit of a challenge to get this board to work with CNCshield v3. The culprit was resistor R1 (enable pin) that would affect the booting capability of the ESP32. Once R1 was removed (brutally destroyed with a wire cutter in my case) the problem was gone and I could upload and run code with the Arduino IDE.

I created a simple program that uses some pre-calculated delays to perform the motion using different expressions for the acceleration. Four have been used and shown in the video below:

  1. Uniform acceleration a=k
  2. Sinusoidal acceleration a=1-cos(t)
  3. Exponential a=(e^(cos(t/2)-1)*sin(t/2))/2
  4. Exponential2 a=(e^(-(t-sin(t))/pi)*(1-cos(t)))/pi
The expectation from a former entry was that adding the exponential effect to the acceleration will hopefully reduce the acceleration values as the motor speeds up (and loses torque). The next graph shows the difference between the two different exponential accelerations considered (that are also smoothed out using sinusoidal function too):
And the next video shows the results of running the sample code linked here.  The result is that for a selected acceleration time (that corresponds in the graphs above with the range (0,2Π)), the first two accelerations cause the motor to stall consistently, while the third and fourth ones achieve the motion flawlessly each time. 

Please note that the four movements of the video are done so motion durations is the same. While two patterns fail to move properly the other two succeed. However, it can be argued, if you look at the data on the delay tables, that those who fail do reach a higher speed and that may well be the reason of the stall. But what I find more relevant is that a movement that the two types of acceleration cannot complete in a given amount of time, it is, however, possible and successful by just changing the timing of the pulses.

Anyway, if I change the code so each movement is performed reliably and as fast as possible (no common maximum speed nor time duration), what I get is the "triangular" motion of 2000 steps takes 103.25 ms for the uniform acceleration, 105.42 ms for the sinusoidal acceleration, 87.19 ms for the first exponential acceleration and just 84.95 ms for the fourth one.

So that means that a 20% reduction in acceleration time can be achieved by selecting the fourth acceleration pattern. For triangular movements, this is a huge gain.

A bit more experimentation with the motor driving a carriage did not show such a huge gain though, but you can see it working on the video below.


Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Arduino mood light