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

NameDomainDirection
dsignalin
ysignalout

Parameters

NameUnitDefaultRangeDescription
Ts0.00010 to ∞Switching period

Variables

NameUnitStartDescription
period_starts0Start 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