I'm trying to program an arduino to generate a Trapezoidal Motion Profile to control a DC motor with a quadrature encoder.
Essentially, the user will input the desired Target Position, Max Velocity and Acceleration (decel = -accel) and the code will calculate the target position versus time which will then be compared with the actual position. The result will then be subject to a PID calculation
My initial assumption was that I could use basic Newtonian physics to determine position (i.e. PT = P0 + V0T + 1/2AT2, VT = V0 + AT). However, after reading through documentation for pre-existing motion controllers, I discovered that the prevalent method was to use a discrete time method, which is as follows:
VK = VK-1 + A (A = Acceleration) PK = PK-1 + VK-1 + A/2
I'm having a hard time understanding quite how this equation would generate the target position versus time. In the case of Velocity, it seems to just add the acceleration to the current velocity. But what about everything in between?
Could anybody take a shot at explaining to me how this method is used? I've spent ages searching for answers online but have had no such luck.
Discrete means that time goes from 1 second to 2 seconds, there is no time in-between. In this case you can just multiply acceleration by the step size of time to get the change in velocity. The step size of t seems to be one, which is why it seems like the new velocity is just the old velocity plus acceleration. As for the other equation, I don't know for sure, but it looks like they took the continuous version and made it discrete.