PLC-API fbPwm_Out( eMode := eMode, stParams := stParams, bError => bError, eErrorId => eErrorId); bOut1_pos := ar_stPwmOutputs[1].bPwmOutBitPos; bOut1_neg := ar_stPwmOutputs[1].bPwmOutBitNeg; bOut2_pos := ar_stPwmOutputs[2].bPwmOutBitPos; bOut2_neg := ar_stPwmOutputs[2].bPwmOutBitNeg; bOut3_pos := ar_stPwmOutputs[3].bPwmOutBitPos; bOut3_neg := ar_stPwmOutputs[3].bPwmOutBitNeg; Requirements 5.8.4 FB_CTRL_PWM_OUT 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.
VAR_INPUT VAR_INPUT fPwmInput : FLOAT; (* controller output = PMW input [-100.0 ... 100.0] *) eMode : E_CTRL_MODE; END_VAR fPwmInput : Input value. TS4100 127 Version: 1.1 Development Environment Target System PLC libraries to include TwinCAT v2.8 PC (i386) TcControllerToolbox.lib TwinCAT v2.9 from Build 947 BC [} 10] TcControllerToolbox.lb6 TwinCAT v2.9 from Build 956 BX [} 10] TcControllerToolbox.lbx