Methods of Calculating Position

64 Views Asked by At

Suppose we have the following code (Euler Method?) to determine Position versus Velocity, Acceleration and Time:

For Time := 1 to 10
Do begin
  Velocity := Velocity + Acceleration;
  Position := Position + Velocity;

We end up by overshooting Position.

From what I can see, the following code is the preferred way of determining the exact position in most motion controller:

For Time := 1 to 10
Do Begin
  Velocity := Velocity + Acceleration;
  Position := Position + Velocity + Acceleration/2;

However, when I run the code, I end up with an even larger overshoot. Have I implemented this incorrectly? Does this method have an official name? Why is it preferred to the Verlet method, which also gives exact position with a constant acceleration?

Any information on this method (VK = VK-1 + A; PK = PK-1 + VK-1 +A/2) would be greatly appreciated. I'm struggling to find anything online.

1

There are 1 best solutions below

0
On

Assuming constant acceleration between the time steps, for a time increment of $\Delta t$, we have for the velocity and displacement at successive times $t_n, t_{n+1}$:

$\begin{align} v_{n+1} &= v_n + a \Delta t \tag{1}\\ s_{n+1} &= s_n + \frac{1}{2}(v_{n+1} + v_n) \Delta t \tag{2} \end{align}$

Then (2) becomes

$s_{n+1} = s_n + \dfrac{1}{2}(v_{n+1}+v_{n+1}-a\Delta t)\Delta t$

which reduces to $\boxed{s_{n+1} = s_n + v_{n+1} \Delta t - \dfrac{1}{2}a{\Delta t}^2}$

Since the program first updates velocity then position, the input to the displacement update computation is $v_{n+1}$ not $v_n$. If the time increment is not 1 unit, you will need to modify the position update equation in line with (3); otherwise, if $\Delta t = 1$, all you need to do is change the sign of the acceleration term in the last line of code.