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
| Name | Type | Description |
|---|---|---|
| IN | REAL | Input value 0-100% (duty cycle) |
| PERIOD | TIME | PWM cycle period |
| MIN_PULSE | TIME | Minimum on-time (prevents short pulses) |
Outputs
| Name | Type | Description |
|---|---|---|
| Q | BOOL | PWM 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
Siemens (TIA Portal)
Use PULSEGEN function block in TIA Portal for PID output to PWM conversion.
Allen-Bradley (Studio 5000)
Implement using timer logic or dedicated pulse output module.
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.
Related Function Blocks
PID (Proportional-Integral-Derivative Controller)
Closed-loop feedback controller using proportional, integral, and derivative terms.
View Reference →TP (Timer Pulse)
Generates a fixed-duration pulse on rising edge of input.
View Reference →RAMP (Ramp Function / Rate Limiter)
Limits rate of change to create smooth transitions between values.
View Reference →LIMIT (Limiter / Clamp)
Clamps a value between minimum and maximum boundaries.
View Reference →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.
Instant download - 30-day money-back guarantee - Use on unlimited projects