PWMPLCopen motion icon

FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. block - generate a PWM signal.

Inputs

XIN : REAL Input analog value
XinMin : REAL Minimum input value
XinMax : REAL   Maximum input value
MinPulse : TIME Minimum pulse time on output
Period : TIME Period of the output signal

Outputs

Q : BOOL Blinking PWM signal

Remarks

The input value is truncated to [XinMin .. XinMax] interval. XinMax must be greater than XinMin.

The signal is TRUE during:

(Xin - XinMin) * Period / (XinMax - XinMin)

ST Language

PWM1 is a declared instance of PWM function block.

PWM1 (rIn, rInMin, rInMax, tMinPulse, tPeriod);
Signal := PWM1.Q;

Example