Learn PLCs free
Process ControlIntermediateIEC 61131-3

PWM (Pulse Width Modulation)

Converts analog percentage to pulsed digital output with proportional duty cycle.

The PWM (Pulse Width Modulation) function block converts an analog percentage value (0-100%) into a pulsed digital output signal. The duty cycle of the output matches the input percentage: 50% input produces a signal that is ON half the time and OFF half the time within each period. PWM is used to control devices with digital outputs that need proportional control, such as heaters controlled by solid-state relays, solenoid valves, and simple motor speed control where analog outputs are not available.

Parameters

Inputs

NameTypeDescription
INREALInput value 0-100% (duty cycle)
PERIODTIMEPWM cycle period
MIN_PULSETIMEMinimum on-time (prevents short pulses)

Outputs

NameTypeDescription
QBOOLPWM output signal

Structured Text Example

VAR
    Heater_PWM : PWM;
    PID_Output : REAL;   // 0-100%
    Heater_SSR : BOOL;  // Solid state relay
END_VAR

Heater_PWM(
    IN := PID_Output,
    PERIOD := T#2s,
    MIN_PULSE := T#100ms
);
Heater_SSR := Heater_PWM.Q;

20 Production-Ready Ladder Logic Templates

Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.

Platform-Specific Implementation

S

Siemens (TIA Portal)

Use PULSEGEN function block in TIA Portal for PID output to PWM conversion.

AB

Allen-Bradley (Studio 5000)

Implement using timer logic or dedicated pulse output module.

C

CODESYS

OSCAT library provides PWM function block, or implement with timer logic.

Common Applications

  • Heater control via SSR
  • Simple motor speed control
  • Valve proportional control
  • LED brightness control
  • Time-proportional control

Frequently Asked Questions

What is PWM (Pulse Width Modulation) in PLC programming?

Converts analog percentage to pulsed digital output with proportional duty cycle. The PWM (Pulse Width Modulation) function block converts an analog percentage value (0-100%) into a pulsed digital output signal. The duty cycle of the output matches the input percentage: 50% input produces a signal that is ON half the time and OFF half the time within each period.

What are common applications of PWM (Pulse Width Modulation)?

PWM (Pulse Width Modulation) is commonly used for: Heater control via SSR, Simple motor speed control, Valve proportional control, LED brightness control, Time-proportional control.

How do I use PWM (Pulse Width Modulation) in different PLC platforms?

Siemens: Use PULSEGEN function block in TIA Portal for PID output to PWM conversion. Allen-Bradley: Implement using timer logic or dedicated pulse output module. CODESYS: OSCAT library provides PWM function block, or implement with timer logic.

Stop Writing Ladder Logic From Scratch

Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →