PWM generator
power.pwm
Pulse width modulation with a rising sawtooth carrier of period T that starts at t = 0. In each period the output is 1 while the time since the period began is below d T, then 0, where d is the duty cycle input. A duty cycle at or below 0 gives 0, at or above 1 gives 1.
Ports
| Name | Domain | Direction |
|---|---|---|
d | signal | in |
y | signal | out |
Parameters
| Name | Unit | Default | Range | Description |
|---|---|---|---|---|
T | s | 0.0001 | 0 to ∞ | Switching period |
Variables
| Name | Unit | Start | Description |
|---|---|---|---|
period_start | s | 0 | Start time of the current period |
Equations
der(period_start) = 0 when time >= period_start + T then reinit(period_start, period_start + T) y = if time - period_start < d * T then 1 else 0