FB_CTRL_PWM_OUT

FB_CTRL_PWM_OUT 1:

This block creates a PWM modulated signal on the basis of the input signal.

Description of the output behavior:

This function block creates a PWM signal at the outputs with a mark-to-space ratio corresponding to the fPwmInput input. The mark-to-space ratio is specified at the input in %; the range from -100% to 100% is available. If a positive value is specified, the pulse width modulated signal is made available at the bPwmOutBitPos output. If the specified mark-to-space ratio is negative, the signal is output at bPwmOutBitNeg. These two signals therefore make it possible to control two different actuators, depending on the arithmetic sign.

If the bInstantPWMUpdate is set to TRUE it is possible to adopt a new input value instantly. The new input value, in other words, is effective even in the current PWM cycle. If this parameter is FALSE, then a new input value is only adopted at the start of a new PWM cycle.

FB_CTRL_PWM_OUT 2:

VAR_INPUT

VAR_INPUT
    fPwmInput       : FLOAT;        (* controller output = PMW input [-100.0 ... 100.0] *)
    eMode       : E_CTRL_MODE;
END_VAR

fPwmInput : Input value.

eMode : Input that specifies the block's operating mode.

VAR_OUTPUT

VAR_OUTPUT
    bPwmOutBitPos   : BOOL;         (* PWM output bit *)
    bPwmOutBitNeg   : BOOL;         (* PWM output bit *)
    eState      : E_CTRL_STATE;
    bError      : BOOL;
    eErrorId        : E_CTRL_ERRORCODES;
END_VAR

bPwmOutBitPos : PWM signal, when fPwmInput > 0.0.

bPwmOutBitNeg : PWM signal, when fPwmInput < 0.0.

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 occurs.

VAR_IN_OUT

VAR_IN_OUT
    stParams        : ST_CTRL_PWM_OUT_PARAMS;
END_VAR

stParams : Parameter structure of the PWM element. This consists of the following elements:

TYPE
ST_CTRL_PWM_OUT_PARAMS:
STRUCT
     tTaskCycleTime         : TIME     (* task cycle time
[TIME] *)
     tPWMPeriod         : TIME;    (* PWM period
duration [TIME] *)
     bInstantPWMUpdate      : BOOL;
END_STRUCT
END_TYPE

tTaskCycleTime : Cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task.

tPWMPeriod : Period of the PWM signal.

bInstantPWMUpdate : If this flag is TRUE, then a new input value is immediately adopted, even in the present PWM cycle.

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