FB_BA_PWM

Pulse width modulation function block

FB_BA_PWM 1:

Functional description

The function block calculates switch-on and switch-off times from an analog input signal rIn (0..100%, internally limited) and a period udiPrd [s], which are displayed at the outputs as rActTiOn and rActTiOff in seconds.

The following relationships apply:

In addition, udiMinOnTi [s] can be used to set a lower limit for the duty cycle, in order to prevent damage to drives caused by too short actuating pulses. However, this behavior is only valid for 0>rIn>100!
For the input signals:

Switching characteristics

  1. A FALSE signal at input bEn disables the function block and sets bQ to FALSE. Only the switch-on and switch-off times are continuously calculated and displayed at the outputs rActTiOn/rActTiOff [s].
  2. A rising edge at input bEn enables the function block: It will initially jump to a decision step. Depending on the previous state of switching output bQ, it now jumps to the switching step, unless input rIn is 0.0. It then jumps to the off step (bQ=FALSE).
  3. A countdown timer with the current calculated starting value runs in the respective active step (ON or OFF), which is based on the pulse/pause ratio. The on- or off-step is completed with the calculated time, irrespective of whether the pulse/pause ratio changes in the meantime. The respective countdown is displayed at the outputs udiRemTiOn/udiRemTiOff in full seconds.
  4. Completion of the on- or off-step is followed by a jump back to the decision step (point 2).

Inputs/outputs

VAR_INPUT

bEn        : BOOL;
rIn        : REAL;
udiPrd     : UDINT;
udiMinOnTi : UDINT;

bEn : activation of pulse width modulation

rIn: input signal, internally limited to 0...100 %

udiPrd: period time [s]

udiMinOnTi: minimum switch-on time [s]

VAR_OUTPUT

bOut        : BOOL;
bLmtSwiTi   : BOOL;
rActTiOn    : REAL;
rActTiOff   : REAL;
udiRemOnTi  : UDINT;
udiRemOffTi : UDINT;

bOut: PWM output.

bLmtSwiTi: information output to indicate that the input signal is so low that the minimum switch-on time is used as limit.

rActTiOn: information output: calculated switch-on time

rActTiOff: information output: calculated switch-off time

udiRemOnTi: countdown switch-on timer

udiRemOffTi: countdown switch-off timer

Requirements

Development environment

Target system

required library

required supplement

TwinCAT 2.11 R3/x64

PC/CX

TcBA library from V1.0.0

TS8040 | TwinCAT Building Automation from V1.0.0