Skip to content

Pulse

Outputs the amplitude during the configured duty portion of each period and zero for the remainder.

Generic over the float width: T is f64 unless the instance binds it, and every parameter and the output take that width.

With t(0) = 0:

t(n+1) = t(n) + dt - period when t(n) + dt >= period
t(n+1) = t(n) + dt otherwise
y(n) = amplitude when t(n) < duty * period
y(n) = 0.0 otherwise
Direction Name Type
Output y T
Name Type Default Meaning
amplitude T 1.0 Pulse output while on
period T (s) 1.0 Time between pulse starts
duty T 0.5 On-time fraction of each period

period should be positive; duty is normally between 0 and 1. The implementation subtracts one period at most once per tick, so choose dt < period for a normal pulse train.

With dt = 0.25, period = 1, duty = 0.5, and amplitude = 2, outputs at t = 0, 0.25, 0.5, 0.75 are 2, 2, 0, 0.