PWM Generator
SourcesThe PWMGenerator block produces a Pulse-Width Modulated (PWM) switching waveform by comparing a normalized duty-cycle command against a periodic sawtooth or triangle carrier wave. It is designed to drive power electronic switches (MOSFET, ControlledSwitch) and proportional hydraulic/pneumatic valves without manually wiring carrier generators and comparators.
Modèle Mathématique
The normalized carrier phase is computed from the switching frequency and phase offset :
For a trailing-edge sawtooth carrier or a center-aligned triangle carrier , the output is:
Entrées & Sorties
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | duty |
D | number | Optional |
| ← Out | out |
PWM | number | Output |
| ← Out | carrier |
Carrier | number | Output |
Paramètres
| Paramètres | Label | Type | Défaut | Description |
|---|---|---|---|---|
frequency |
Carrier Frequency | number | 1000 |
PWM switching frequency f_sw |
dutyCycle |
Duty Cycle | number | 0.5 |
Default normalized duty cycle [0..1] when Duty input is disconnected |
highLevel |
High Level | number | 1 |
Output voltage when the PWM pulse is active |
lowLevel |
Low Level | number | 0 |
Output voltage when the PWM pulse is inactive |
carrierType |
Carrier Waveform | select | sawtooth |
Carrier wave shape used for comparator modulation |
phase |
Phase Offset | number | 0 |
Carrier phase shift in degrees for interleaved converters |
Exemples d'Utilisation
Open-Loop Buck Converter Gate Drive
Set frequency to 5000 Hz, dutyCycle to 0.4, highLevel to 10 V, and connect out to the gate g of a MOSFET to step down a Battery supply voltage.
Closed-Loop DC Motor Speed Control
Connect the normalized output of a PIDController (clamped to [0, 1]) to the duty input port, and drive a ControlledSwitch or MOSFET feeding a DCMotor.
Remarques & Bonnes Pratiques
- Nyquist Sampling Rate: Choose a simulation sample time so the duty-cycle resolution is accurately captured.
- Interleaved Phases: Use two
PWMGeneratorblocks withphaseset to0and180degrees to drive complementary or interleaved converter legs.
Composants Associés
- MOSFET/docs.md" class="bw-link">MOSFET
- ControlledSwitch/docs.md" class="bw-link">ControlledSwitch
- PulseGenerator/docs.md" class="bw-link">PulseGenerator