Function that performs the movement of a generic unit, moving initially at a certain speed, to a target point to be reached with desired cruising speed and final speed.
Syntax |
real mv_to_vel (i32 return, real pAct, real vAct, real pDes, real vDes, real vFin, real baseTime, real acc [, real dec=acc] [, real perc=0.8]) |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
return |
Variable containing information about the status of the function (see returns codes).
|
||||||||||||||||||
pAct |
Current position |
||||||||||||||||||
vAct |
Current speed |
||||||||||||||||||
pDes |
Position to be reached |
||||||||||||||||||
vDes |
Desired speed (intended in absolute value) |
||||||||||||||||||
vFin |
Final speed (intended in absolute value) |
||||||||||||||||||
baseTime |
Time base (normally SI) |
||||||||||||||||||
acc |
Desired acceleration (intended in absolute value) |
||||||||||||||||||
dec |
Desired deceleration (intended in absolute value). (optional, default acc) |
||||||||||||||||||
perc |
Percentage value affecting deceleration (0-1). (optional, default 0.8) During arrival calculations at the target point, the number of samplings required to arrive from the current position to the desired position with the specified velocity vFin is evaluated. This number is truncated to the lower integer if the remainder is < perc (so the actual deceleration will be a little larger than dec) or will be increased to the next integer if the remainder is > perc (lower resultant deceleration) |
||||||||||||||||||
Result |
Updated position value |
||||||||||||||||||
Validity |
Rule |
||||||||||||||||||
Note |
vFin is understood to agree with the direction of the requested movement (if pDes > pAct, vFin is understood to be positive, otherwise it is understood to be negative). Updating the velocity vAct must be done externally to the function by the user |
If vFin > 0, the target position is passed, after which the function continues inertially as long as it is invoked. If vFin = 0, the function stops at the desired point.
If the deceleration parameter does not allow it to get from pAct to pDes with the specified vFin, mv_to_vel() still tends to reach vFin; pDes will be passed with a speed other than vFin, and the movement will continue inertially with speed tending progressively toward vFin.
NOTE: The function can also be called with the axis already in motion.
Example of use:
|