beckhoff TS4100 — 5.8.3 FB_CTRL_MULTIPLE_PWM_OUT

PLC-API bWaitTimeActive : A TRUE at this output indicates that the waiting time between the switching actions of the output signals is active. This output can be used to hold an I component that may be present in the prior controller constant during this time. TYPE ST_CTRL_MULTIPLE_PWM_OUT_DATA : STRUCT Interne Struktur. Auf diese darf nicht schreibend zugegriffen werden. END_STRUCT END_TYPE Sample: PROGRAM PRG_MULTIPLE_PWM_OUT_TEST VAR CONSTANT nNumberOfPwmOutputs : USINT := 3; END_VAR VAR ar_fPwmInput : ARRAY[1..nNumberOfPwmOutputs] OF FLOAT; ar_stWaitTimesConfig : ARRAY[1..nNumberOfPwmOutputs] OF ST_CTRL_MULTIPLE_PWM_OUT_TIMES; ar_stPwmOutputs :

ARRAY[1..nNumberOfPwmOutputs] OF ST_CTRL_MULTIPLE_PWM_OUT_OUTPUTS; ar_stPwmDataVars : ARRAY[1..nNumberOfPwmOutputs] OF ST_CTRL_MULTIPLE_PWM_OUT_DATA; eMode : E_CTRL_MODE; stParams : ST_CTRL_MULTIPLE_PWM_OUT_PARAMS; eErrorId : E_CTRL_ERRORCODES; bError : BOOL; fbPwm_Out : FB_CTRL_MULTIPLE_PWM_OUT; bInit : BOOL := TRUE; fIn1 : FLOAT; fIn2 : FLOAT; fIn3 : FLOAT; bOut1_pos : BOOL; bOut1_neg : BOOL; bOut2_pos : BOOL; bOut2_neg : BOOL; bOut3_pos : BOOL; bOut3_neg :

BOOL; END_VAR IF bInit THEN (* set values in the local arrays *) ar_stWaitTimesConfig[1].tMinOnTime := T#500ms; ar_stWaitTimesConfig[1].tMinOffTime := T#300ms; ar_stWaitTimesConfig[1].tMinWaitTime := T#3.5s; ar_stWaitTimesConfig[2].tMinOnTime := T#400ms; ar_stWaitTimesConfig[2].tMinOffTime := T#250ms; ar_stWaitTimesConfig[2].tMinWaitTime := T#4.5s; ar_stWaitTimesConfig[3].tMinOnTime := T#400ms; ar_stWaitTimesConfig[3].tMinOffTime := T#200ms; ar_stWaitTimesConfig[3].tMinWaitTime := T#5.5s; (* set values in the parameter struct *) stParams.tTaskCycleTime := T#2ms; stParams.tPWMPeriod := T#2s; stParams.nNumberOfPwmOutputs := nNumberOfPwmOutputs; (* set the ctrl-mode *) eMode := eCTRL_MODE_ACTIVE; bInit := FALSE; END_IF (* set the addresses *) stParams.pPwmTimesConfig_ADR := ADR( ar_stWaitTimesConfig); stParams.nPwmTimesConfig_SIZEOF := SIZEOF( ar_stWaitTimesConfig); stParams.pPwmInputArray_ADR := ADR( ar_fPwmInput ); stParams.nPwmInputArray_SIZEOF := SIZEOF( ar_fPwmInput ); stParams.pPwmOutputArray_ADR := ADR( ar_stPwmOutputs ); stParams.nPwmOutputArray_SIZEOF := SIZEOF( ar_stPwmOutputs ); stParams.pPwmData_ADR := ADR( ar_stPwmDataVars ); stParams.nPwmData_SIZEOF := SIZEOF( ar_stPwmDataVars ); ar_fPwmInput[1] := fIn1; ar_fPwmInput[2] := fIn2; ar_fPwmInput[3] := fIn3; TS4100 126 Version:

1.1