FB_CTRL_PWM_OUT

FB_CTRL_PWM_OUT 1:

This function 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:

FB_CTRL_PWM_OUT 3: VAR_INPUT

VAR_INPUT
    fPwmInput  : FLOAT;
    eMode      : E_CTRL_MODE;
END_VAR

Name

Type

Description

fPwmInput

FLOAT

Input value

eMode

E_CTRL_MODE

Input that specifies the operation mode of the function block.

FB_CTRL_PWM_OUT 4: VAR_OUTPUT

VAR_OUTPUT
    bPwmOutBitPos  : BOOL;
    bPwmOutBitNeg  : BOOL;
    eState         : E_CTRL_STATE;
    bError         : BOOL;
    eErrorId       : E_CTRL_ERRORCODES;
END_VAR

Name

Type

Description

bPwmOutBitPos

BOOL

PWM signal, when fPwmInput > 0.0.

bPwmOutBitNeg

BOOL

PWM signal, when fPwmInput < 0.0.

eState

E_CTRL_STATE

State of the function block

bError

BOOL

Supplies the error number when the output bError is set.

eErrorId

E_CTRL_ERRORCODES

Becomes TRUE, as soon as an error occurs.

VAR_IN_OUT

VAR_IN_OUT
    stParams    : ST_CTRL_PWM_OUT_PARAMS;
END_VAR

Name

Type

Description

stParams

ST_CTRL_PWM_OUT_PARAMS

Parameter structure of the PWM element

stParams consists of the following elements:

TYPE ST_CTRL_PWM_OUT_PARAMS:
STRUCT
    tTaskCycleTime     : TIME
    tPWMPeriod         : TIME;
    bInstantPWMUpdate  : BOOL;
END_STRUCT
END_TYPE

Name

Type

Description

tTaskCycleTime

TIME

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

TIME

Period of the PWM signal

bInstantPWMUpdate

BOOL

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