Try a PLC free — no signup
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;

Free · no signup to try

Run this block in your browser

Try the instruction on a live rung before you copy it into a project — nothing to install.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

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.

Free · no signup to try

Wire this block up and run it

Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad