FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system)

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 1:

This function block represents a 3-phase set value 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 upon what type of parameter set is specified, it may become effective immediately (eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_Instant); alternatively, the current movement may first be completed, after which a new movement begins with a new set of parameters. (eNewPosType := eCTRL_NEW_PARAMETER_TYPE_NotInstant).

Note

1. Specifying a new parameter set may mean that the previous end position is exceeded. See example.
2. It is generally recommended that end position monitoring is included after the setpoint generator.

VAR_INPUT

VAR_INPUT
    bStart      : BOOL;
    bStop       : BOOL;
    bReset      : BOOL;
    fOverride   : LREAL;
END_VAR

bStart : Generation of the set values begins when a positive edge appears at the bStart input, provided the generator is not already active and that the bStop and bReset inputs are FALSE.

bStop : Generation of the set values is stopped by a positive edge at the bStop input. Braking is carried out using the deceleration specified in the current set of parameters, and any subsequent task that may be pending is deleted.

bReset : Resets the set value generator. If a positioning process is under way it is interrupted immediately, the fSetVelo and fSetAcc outputs are set to 0.0, the set position is set to the start position, and all internal states are cleared.

fOverride : 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; (* generated setpoint position *)
    fSetVelo        : LREAL; (* generated setpoint velocity *)
    fSetAcc         : LREAL; (* generated setpoint acceleration *)
    nSetDirection   : INT;   (* generated direction *)
     bCommandBuffered       : BOOL;  
    bDone       : BOOL;
    bCommandAborted     : BOOL;

    eErrorId        : E_CTRL_ERRORCODES;
    bError      : BOOL;
END_VAR

fSetPos : Set position

fSetVelo : Set velocity

fSetAcc : Set acceleration

nSetDirection : Direction of movement [-1, 0, 1],
1 --> movement direction is positive
0 --> generator is inactive
-1 --> movement direction is negative

bGeneratorActive : Indicates whether the generator is active.

bCommandBuffered : When this output is TRUE it indicates that the buffer store contains at a transport instruction that will begin when the current instruction has completed.
An instruction in the buffer store is cleared if the following special case is specified as parameter set:

          fAcceleration     
:= 0.0;

fDeceleration      := 0.0;

fStartPos      := 0.0;

fStartVelo     := 0.0;

fTargetPos     := 0.0;

fTargetVelo    := 0.0;

fVelocity      := 0.0;

tCtrlCycleTime     := T#0s;

tTaskCycleTime     := T#0s;

eNewParameterType  :=
eCTRL_NEW_PARAMETER_TYPE_NotInstant;

bDone : This output becomes TRUE when the movement has been completed and the destination position has been reached.

bCommandAborted : This output becomes TRUE when the current movement is interrupted. This can be caused, for instance, through a rising edge at the bStop input.

eErrorId : Supplies the error number when the bError output is set.

bError : Becomes TRUE as soon as an error situation occurs.

VAR_IN_OUT

VAR_IN_OUT
    stParams : ST_CTRL_3PHASE_SETPOINT_GENERATOR_PARAMS;
END_VAR

stParams : parameter structure of the setpoint generator. This consists of the following elements:

TYPE
ST_CTRL_RAMP_GENERATOR_PARAMS :
STRUCT
    tTaskCycleTime     : TIME;  (* task cycle time [TIME]      
*)
    tCtrlCycleTime     : TIME;  (* controller cycle time [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;
END_TYPE

tCtrlCycleTime : 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.

tTaskCycleTime: 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 : start position for the motion profile.

fStartVelo : start velocity of the motion profile.

fVelocity : velocity in units/second.

fTargetPos : target position for the motion profile.

fTargetVelo : target velocity of the motion profile.

Note The target velocity is retained when the target position has been reached (the bDone flag is set), but after this point the position is no longer calculated (constant position at velocity ≠ 0.0).

fAcceleration : acceleration in units / second2.

fDeceleration : deceleration in units / second2.

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, the new 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 target 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;

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 2:

 

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;

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 3:

 

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_NotInstant

stParams.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;

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 4:

 

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_Instant

stParams.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;

 

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 5:

 

Positioning example 5:

Start on 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_Instant

Restart at point 2:

stParams.fTargetPos := 400.0; 
stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_NotInstant;

Restart at point 3:

stParams.fTargetPos := 200.0; 
stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_NotInstant;

Restart at point 4:

stParams.fTargetPos := 600.0; 
stParams.fTargetVelo := 0.0;
stParams.eNewParameterType := eCTRL_NEW_PARAMETER_TYPE_NotInstant;

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 6:

Note

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 recording that the original target position of 1000 mm is exceeded, the reason being that the new parameter set had a reduced deceleration.

FB_CTRL_3PHASE_SETPOINT_GENERATOR(only on a PC system) 7:

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.8

PC (i386)

TcControllerToolbox.lib