Pulse Generator
SourcesThe 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 , effective time relative to the phase delay is defined as .
If , the output remains inactive: .
For , the current pulse sequence index is , where is period. If numberOfPulses () is greater than zero and , the pulse sequence terminates and .
Otherwise, the intra-cycle phase time is evaluated using modulo arithmetic:
where represents amplitude, is period (), is dutyCycle (), and is phaseDelay.
When enableTrigger = true, the block exposes an external trigger input port. A detected rising edge () immediately resets the internal timer to 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 ( switching frequency), amplitude = 15.0 V (gate drive level), and dutyCycle = 65.0% ( conduction time, 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 (), dutyCycle = 20.0% ( 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 is significantly smaller than the active pulse duration: .
- 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 = 1configures the block as a monostable multivibrator that emits a single pulse of duration starting at . - 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.