Pulse width modulation signal

B87_PULSE_WIDTH_MODULATION

PROGRAM TEST_B87
   VAR
 BOOL1,BOOL2 : BOOL;
 REAL1 :REAL;
    TIME1 : TIME;    
   FB: LIB.CORE.V1_0.B87_PULSE_WIDTH_MODULATION;
   END_VAR
 FB(IN:= REAL1, ENABLED:= BOOL1,T:=T#10S,MIN:=0,MAX:=100,OUT=>BOOL2,TRES=>TIME1);
END_PROGRAM

LIB\CORE

V1.0

The block generates PWM (pulse width modulation) signal with variable duty time according to the input signal.

Input TypeDescription Default value
IN REALInput value 0
ENABLEBOOLGenerator enable (true = running)True
T TIMESignal period 15m
MIN REALValue for duty time = 0 % 0
MAX REALValue for duty time = 100 % 100
OutputTypeDescription
OUT BOOLPWM output
OUTN BOOLPWM output negated
TRES TIMERemaining time to the end of the period

he block generates PWM (pulse width modulation) signal. The  analogue input In is converted to binary pulsing signal with period of t. The input signal value is proportionally converted  (for minInmax). If Inmin then out = false, if In >= max then out=true permanently.

The output outn is a negated value of out. The block also provides remaining time to the end of the current period tres.

The input enable sets out=false and tres=0, if set to False.

If in is hidden or min > max or min ⇐ 0 then out= false.


The block is used as a signal generator for thermic valve actuators or electric heating bodies controlled by solid state relays. It is preferred to use dedicated I/O modules (Domat M312, M313). Do not use mechanical relays to control the power circuits as the number of switching cycles may be too high for mechanical relays.

  • © Energocentrum Plus, s.r.o. 2017 - 2024