PWM generator
Compares the duty-cycle input (0…1) with a sawtooth to produce fire and its complement.
- signal
- Boolean
- Modelica Standard Library
- 3 ports
- 1 parameter
pwmSignalLibraryConvertersDescription
Generates a pulse-width-modulated fire signal and its complement. The duty-cycle input is clipped to 0…1, sampled at the start of each switching period, and compared with a sawtooth carrier that rises from 0 to 1 once per period.
Example
DC-DC converters Buck, boost, and bidirectional half-bridge converters switching at 10 kHz with 50 % duty.
Also in this example:DC voltageVoltage sensorConstantGroundResistorCapacitorInductorBuck converterBoost converterBuck-boost converter
Ports
Inputs 1
-
d
dutyCycleDuty cycle, dimensionless. Values outside 0…1 are clipped.
Outputs 2
-
fire
PWM output (Boolean): true while the held duty cycle exceeds the carrier.
-
fire̅
notFireComplement of fire.
Parameters
-
Switching frequency
f10000 Hz≥ 0
Switching frequency, in Hz. Positive; the switching period is 1 / f.
Equations
dk = min(max(dutyCycle(k / f), 0), 1), held for k / f ≤ time < (k + 1) / f carrier = f · time − floor(f · time) fire = dk > carrier, notFire = not fire
Implementation
Modelica.Electrical.PowerConverters.DCDC.Control.SignalPWMAssumptions and limitations
- Sawtooth carrier only, starting at time 0 (trailing-edge modulation). No dead time between fire and notFire.
- The duty cycle is sampled once per period, so the output lags the input by up to one period.
Tips
- Each period adds two events; keep the maximum step size well below 1 / f.
Used in
These larger examples use it too. Open them from Examples in the app.
- 480 VAC → 24 VDC flyback
See also
Select a block in Gradara and press F1 to open its page offline.