FB_CTRL_3PHASE_SETPOINT_GENERATOR
This function block represents a 3-phase setpoint generator.
Description
This function block generates a 3-phase setpoint profile in which the acceleration has a rectangular curve.
It is possible to specify a new parameter set while the generator is active. Depending on the specified type of parameter set, it is activated immediately: eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_Instant
Alternatively, the current movement is first completed and then a new movement is started with the new parameter set: eNewPosType := eCTRL_NEW_PARAMETER_TYPE_NotInstant
Notice | |
Overrunning the end position Specifying a new parameter set may mean that the previous end position is exceeded. See the sample. |
VAR_INPUT
VAR_INPUT
bStart : BOOL;
bStop : BOOL;
bReset : BOOL;
fOverride : LREAL;
END_VAR
Name | Type | Description |
---|---|---|
bStart | BOOL | Setpoint generation begins when a positive edge appears at the |
bStop | BOOL | Generation of the setpoints is stopped by a positive edge at the |
bReset | BOOL | Reset of the setpoint generator; any positioning operation that may be active is immediately aborted, the outputs |
fOverride | LREAL | The set velocity can be scaled through an override in the range [ 0 .. 100.0 % ]. If the override is 100%, then the generated profile uses the set velocity as specified in the parameter set. The override implemented here does not scale the current runtime table when the override is changed. Instead, an internal restart instruction is generated having a different set velocity. The override has a resolution of 0.1%. |
VAR_OUTPUT
VAR_OUTPUT
fSetPos : LREAL;
fSetVelo : LREAL;
fSetAcc : LREAL;
nSetDirection : INT;
bCommandBuffered : BOOL;
bDone : BOOL;
bCommandAborted : BOOL;
eErrorId : E_CTRL_ERRORCODES;
bError : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
fSetPos | LREAL | Set position |
fSetVelo | LREAL | Set velocity |
fSetAcc | LREAL | Set acceleration |
nSetDirection | INT | Direction of movement [-1, 0, 1], |
bCommandBuffered | BOOL | When this output is TRUE it indicates that a motion command is stored that will begin when the current order has completed. fAcceleration := 0.0; |
bDone | BOOL | This output becomes TRUE when the movement has been completed and the target position has been reached. |
bCommand | BOOL | This output becomes TRUE when the current movement is interrupted. This can be caused, for instance, through a rising edge at the |
eErrorId | E_CTRL_ERRORCODES | Supplies the error number when the output |
bError | BOOL | Becomes TRUE as soon as an error situation occurs. |
VAR_IN_OUT
VAR_IN_OUT
stParams : ST_CTRL_3PHASE_SETPOINT_GENERATOR_PARAMS;
END_VAR
Name | Type | Description |
---|---|---|
stParams | ST_CTRL_3PHASE_ | Parameter structure of the setpoint generator |
stParams
consists of the following elements:
TYPE ST_CTRL_RAMP_GENERATOR_PARAMS :
STRUCT
tTaskCycleTime : TIME;
tCtrlCycleTime : TIME;
fStartPos : LREAL;
fStartVelo : LREAL;
fVelocity : LREAL; (* >= 0.0 *)
fTargetPos : LREAL;
fTargetVelo : LREAL;
fAcceleration : LREAL; (* > 0.0 *)
fDeceleration : LREAL; (* > 0.0 *)
eNewParameterType : E_CTRL_NEW_PARAMETER_TYPE;
EN_STRUCT
END_TYPE
Name | Type | Description |
---|---|---|
tTaskCycleTime | TIME | Cycle time with which the control loop is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input value to calculate internally whether the state and the output values have to be updated in the current cycle. |
tCtrlCycleTime | TIME | Cycle time with which the function block is called. If the function block is called in every task cycle this corresponds to the task cycle time of the calling task. |
fStartPos | LREAL | Start position for the motion profile |
fStartVelo | LREAL | Start velocity for the motion profile |
fVelocity | LREAL | Velocity in units/second |
fTargetPos | LREAL | Target position of the motion profile |
fTargetVelo | LREAL | Target velocity of the motion profile. |
fAcceleration | LREAL | Acceleration in units / second2 |
fDeceleration | LREAL | Deceleration in units / second2 |
eNewParameterType | E_CTRL_NEW_ |
and
|
Special characteristics for eNewParameterType
TYPE E_CTRL_NEW_PARAMETER_TYPE :
( eCTRL_NEW_PARAMETER_TYPE_NotInstant := 0,
eCTRL_NEW_PARAMETER_TYPE_Instant := 1);
END_TYPE
eCTRL_NEW_PARAMETER_TYPE_Instant: When a restart instruction is issued with a new parameter set, this set is adopted immediately. In other words a transition from the current state of movement to the data represented by the new parameter set is calculated, and the old parameters are discarded.
eCTRL_NEW_PARAMETER_TYPE_NotInstant: When a restart instruction is issued with a new parameter set, the new set is not adopted immediately. In other words the current movement is first executed to completion, after which positioning to the new destination is carried out with the new parameters. A TRUE at the bCommandBuffered output indicates that a non-instantaneous restart instruction is stored. An order that has already been stored can be overwritten or deleted by a further new, non-instantaneous parameter set.
Positioning examples
Positioning example 1: | stParams.fStartPos := -500.0; stParams.fTargetPos := 2500.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1000.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; fOverride := 100.0; |
| |
| |
Positioning example 2: | stParams.fStartPos := 1000.0; stParams.fTargetPos := -2500.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1000.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; fOverride := 100.0; |
| |
| |
Positioning example 3: | stParams.fStartPos := -500.0; stParams.fTargetPos := 2500.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1000.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_NotInstant; fOverride := 100.0; parameter change if fSetPos > 1000.0, eNewPosType := eCTRL_NEW_POS_TYPE_NotInstantstParams.fTargetPos := 0.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1300.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; fOverride := 100.0; |
| |
| |
Positioning example 4: | stParams.fStartPos := -500.0; stParams.fTargetPos := 2500.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1000.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_NotInstant; fOverride := 100.0;parameter change if fSetPos > 1000.0, eNewPosType := eCTRL_NEW_POS_TYPE_InstantstParams.fTargetPos := 0.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 1300.0; stParams.fTargetVelo := 0.0; stParams.fAcceleration := 1000.0; stParams.fDeceleration := 2000.0; fOverride := 100.0; |
| |
| |
Positioning example 5: | Start at point 1: stParams.fStartPos := -100.0; stParams.fTargetPos := 200.0; stParams.fStartVelo := 0.0; stParams.fVelocity := 250.0; stParams.fTargetVelo := 150.0; stParams.fAcceleration := 500.0; stParams.fDeceleration := 400.0; stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_InstantRestart at point 2: |
|
Notice | |
Target position overshoot! If a new parameter set of type "eCTRL_NEW_POS_TYPE_Instant" in which the deceleration is reduced is given to the function block it is possible that the old target position will be exceeded. |
Sample:
stParams.fTargetPos := 1000.0;
stParams.fStartPos := 0.0;
stParams.fVelocity := 500.0;
stParams.fAcceleration := 1000.0;
stParams.fDeceleration := 1000.0;
IF fSetPos > 800.0 THEN
stParams.fTargetPos := 400.0;
stParams.fVelocity := 500.0;
stParams.fAcceleration := 1_000.0;
stParams.fDeceleration := 500.0;
stParams.eNewPosType := eCTRL_NEW_POS_TYPE_Instant;
END_IF
It can clearly be seen in the following scope trace that the original target position of 1000 mm is exceeded, the reason being that the new parameter set had a reduced deceleration.