FB_CTRL_RAMP_GENERATOR

FB_CTRL_RAMP_GENERATOR 1:

The function block provides a parameterisable ramp generator.

Description:

This function block generates a ramp connecting the starting value fStart and the final value fTarget. The slope of the ramp (i.e. the velocity) is given in units/s by means of the fVeloPos and fVeloNeg parameters. The starting value is adopted when a rising edge appears at bEnable; calculation of the ramp then begins. As long as the signal bEnable remains TRUE the final value can be changed, and the output value changes, taking the form of a ramp as it moves from the current value to the presently active final value.

Behaviour of the output value:

FB_CTRL_RAMP_GENERATOR 2:

VAR_INPUT

VAR_INPUT
    bEnable     : BOOL;
    fStart  : FLOAT;
    fTarget     : FLOAT; (* target value *)
END_VAR

bEnable : Start of ramp generation.

fStart : Starting value for the ramp.

fTarget : Finishing value for the ramp.

VAR_OUTPUT

VAR_OUTPUT
    fOut        : FLOAT;
    bValueReached   : BOOL;
    eState      : E_CTRL_STATE;
    eErrorId        : E_CTRL_ERRORCODES;
    bError      : BOOL;
END_VAR

fOut : Output of the ramp generator.

bValueReached : This output indicates by going TRUE that the output fOut has reached the value fTarget.

eState : State of the function block.

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_RAMP_GENERATOR_PARAMS; (* RAMP_Generator parameter struct *)
END_VAR

stParams : Parameter structure of the ramp 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]
*)
    fVeloPos     : FLOAT; (* velocity ramp by time range:
> 0.0 *)
    fVeloNeg     : FLOAT; (* velocity ramp by time range:
> 0.0 *)
END_STRUCT
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.

fVeloPos : Velocity in unit/s, with which the output is changed from a lower value to a higher one.

fVeloNeg : Velocity in unit/s, with which the output is changed from a higher value to a lower one.

Requirements

Development Environment

Target System

PLC libraries to include

TwinCAT v2.8

PC (i386)

TcControllerToolbox.lib

TwinCAT v2.9 from Build 947

BC

TcControllerToolbox.lb6

TwinCAT v2.9 from Build 956

BX

TcControllerToolbox.lbx