I am working on a workbook which calculates an object moving between 2 points.

The variables I have are:-

Start position - this can be any value including negative values and represzents a measurement in mm

End position - as start position

Travel. This is the distance travelled and therefore an absoute value

Accel/Decel. This represents is the same for both acceleration and deceleration and is expressed in mm/sec^2

Time - The desired time taken to complete the task

Speed - the speed of the object derived from the time variable

The object has certain minimum and maximum values which are variables

AccelMin, AccelMax, SpeedMin, SpeedMax

I am trying to find the optimum value which will essentially accelerate and then immediately decelerate without reaching the MoveSpeed or SpeedMax value (whichever is lower).

I could figure this using a loop but figure there is a much cleaner mathematical solution to this

The variables I have are:-

Start position - this can be any value including negative values and represzents a measurement in mm

End position - as start position

Travel. This is the distance travelled and therefore an absoute value

Accel/Decel. This represents is the same for both acceleration and deceleration and is expressed in mm/sec^2

Time - The desired time taken to complete the task

Speed - the speed of the object derived from the time variable

The object has certain minimum and maximum values which are variables

AccelMin, AccelMax, SpeedMin, SpeedMax

I am trying to find the optimum value which will essentially accelerate and then immediately decelerate without reaching the MoveSpeed or SpeedMax value (whichever is lower).

I could figure this using a loop but figure there is a much cleaner mathematical solution to this

Here is an attempt to find the fastest time.

```
Sub Fastest()
Dim MaxAccel As Single
Dim MaxSpeed As Single
Dim StartPos As Single
Dim EndPos As Single
Dim distance As Single
Dim TimeToMax As Single
Dim TravelTime As Single
Dim DistanceToMax As Single
MaxAccel = 250 'mm/sec^2
MaxSpeed = 600 'mm/sec
StartPos = 2007 'mm
EndPos = -1899 'mm
distance = StartPos - EndPos
'v = u + at
TimeToMax = MaxSpeed / MaxAccel
DistanceToMax = MaxSpeed / (2 * MaxAccel)
If DistanceToMax > distance / 2 Then
TravelTime = 2 * TimeToMax + distance - (2 * DistanceToMax) / MaxSpeed
Else
TravelTime = 2 * Sqr(distance / MaxAccel)
End If
MsgBox TravelTime
End Sub
```

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.