<?xml version="1.0" encoding="utf-8"?>

<UserFunctionMgr>
   <UserFunction
       Expression="(*&#13;&#10;Calculate the position at which to begin decelerating in order to reach the slow velocity at the requested position.&#13;&#10;*)&#13;&#10;&#13;&#10;FUNCTION dPoint : REAL&#13;&#10; &#32;&#32;VAR_INPUT&#13;&#10; &#32;&#32;&#32;&#32;&#32;FinalPoint : REAL;&#13;&#10; &#32;&#32;&#32;&#32;&#32;Decel : REAL;&#13;&#10; &#32;&#32;&#32;&#32;&#32;FinalV : REAL;&#13;&#10; &#32;&#32;&#32;&#32;&#32;StartV : REAL;&#13;&#10;&#9;LoopTime : REAL;&#13;&#10;&#13;&#10; &#32;&#32;END_VAR&#13;&#10;&#13;&#10; &#32;&#32;VAR&#13;&#10; &#32;&#32;&#32;&#32;&#32;t : REAL;&#13;&#10; &#32;&#32;&#32;&#32;&#32;d : REAL;&#13;&#10; &#32;&#32;END_VAR&#13;&#10;&#13;&#10;&#9;//Calculate distance needed to decel to new speed.&#13;&#10;&#9;t:= (StartV-FinalV)/Decel;&#13;&#10;&#9;d:=(StartV*t)-(0.5*Decel*t*t);&#13;&#10;&#13;&#10;&#9;//Caulate position and compensate for the loop time delay&#13;&#10;&#9;dPoint := FinalPoint - d - (StartV* LoopTime);&#13;&#10;&#13;&#10;END_FUNCTION&#13;&#10;"/>
</UserFunctionMgr>
