📊

Pulse Generator

Sources
Run the live example Free · no sign-up · runs in your browser

The PulseGenerator block generates periodic or bounded square-wave pulse signals with configurable amplitude, period, duty cycle, and phase delay. It is commonly utilized in control and hardware-in-the-loop (HIL) simulations to synthesize digital clock signals, pulse-width modulation (PWM) carrier gates, synchronous sampling triggers, and diagnostic step bursts. The block also supports an optional external reset trigger port and a pulse-count limit for one-shot or burst generation.

Mathematical Model

For simulation time t≥0t \ge 0, effective time relative to the phase delay is defined as t′=t−tdelayt' = t - t_{\text{delay}}.

If t′<0t' < 0, the output remains inactive: y(t)=0y(t) = 0.

For t′≥0t' \ge 0, the current pulse sequence index is k=⌊t′/T⌋k = \lfloor t' / T \rfloor, where TT is period. If numberOfPulses (NN) is greater than zero and k≥Nk \ge N, the pulse sequence terminates and y(t)=0y(t) = 0.

Otherwise, the intra-cycle phase time τ\tau is evaluated using modulo arithmetic:

y(t)={A,0≤(t−tdelay) mod T<D100T0,otherwisey(t) = \begin{cases} A, & 0 \le (t - t_{\text{delay}}) \bmod T < \frac{D}{100} T \\ 0, & \text{otherwise} \end{cases}

where AA represents amplitude, TT is period (T>0T > 0), DD is dutyCycle (0≤D≤1000 \le D \le 100), and tdelayt_{\text{delay}} is phaseDelay.

When enableTrigger = true, the block exposes an external trigger input port. A detected rising edge (utrig>0u_{\text{trig}} > 0) immediately resets the internal timer to t′=0t' = 0 and restarts the pulse counter.

Inputs & Outputs

Direction ID Label Type Status
→ In trigger Trigger number Optional
← Out out Output number Output

Parameters

Parameters Label Type Default Description
amplitude Amplitude number 1
period Period number 1
dutyCycle Duty Cycle number 50
phaseDelay Phase Delay number 0
numberOfPulses Number of Pulses (0=∞) number 0 Number of pulses to generate (0 for infinite)
enableTrigger Show Trigger Input boolean false Enables the external reset trigger input

Usage Examples

Example 1: 10 kHz Pulse-Width Modulation (PWM) Power Inverter Gate Drive

Synthesizing gate control pulses for a power electronics H-bridge switching converter. Configuring period = 0.0001 s (10 kHz10\text{ kHz} switching frequency), amplitude = 15.0 V (gate drive level), and dutyCycle = 65.0% (65 μs65\ \mu\text{s} conduction time, 35 μs35\ \mu\text{s} off-time). Connecting the output to an ideal switch models inductive motor current ripple and switching losses.

Example 2: Synchronous Five-Pulse Diagnostic Burst via External Reset

Creating a bounded diagnostic test sequence. Setting period = 0.2 s (5 Hz5\text{ Hz}), dutyCycle = 20.0% (40 ms40\text{ ms} pulse width), numberOfPulses = 5, and enableTrigger = true. Whenever a supervisory fault detector emits a rising trigger edge, the block fires exactly five test pulses into an actuator diagnostic port and then safely turns off.

Remarks & Best Practices

  • Simulation Step Size Resolution: To capture pulse edges accurately without jitter or missed transitions, ensure the solver time step Δt\Delta t is significantly smaller than the active pulse duration: Δt≤0.1⋅min⁡(Ton,T−Ton)\Delta t \le 0.1 \cdot \min(T_{\text{on}}, T - T_{\text{on}}).
  • Zero Phase Accumulation Drift: Implemented in WebAssembly using continuous-time floating-point modulo arithmetic, preventing numerical timing drift over long simulation runs.
  • Single-Shot Monostable Operation: Setting numberOfPulses = 1 configures the block as a monostable multivibrator that emits a single pulse of duration TonT_{\text{on}} starting at t=tdelayt = t_{\text{delay}}.
  • External Synchronization: The optional trigger port allows multi-phase clocks to be synchronized dynamically with external master events or communication frames.

Related Components

  • Step: Generates a single continuous step transition at a designated time.
  • Ramp: Linearly increasing ramp signal generator.
  • SignalGenerator: Periodic sinusoidal, square, triangle, and sawtooth waveforms.
  • Clock: Monotonically increasing simulation time counter.