0

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.

M-R
  • 219
  • How do you know you are overshooting Position? Can you give a very concrete example of actual results of this code, including the numbers it generated, the numbers it should have generated, and how those numbers are calculated, that demonstrates what you mean by "overshooting"? – David K Jul 10 '15 at 20:38
  • @DavidK, By the end of the loop, the final position should be 500, with the second method mentioned, we overshoot by 100. – M-R Jul 11 '15 at 22:27
  • Why do you think it should be 500? How do you know the correct answer is not 650 (meaning your program undershot by 50)? – David K Jul 12 '15 at 03:17

1 Answers1

1

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.

Marconius
  • 5,635