Square Wave Generator
An ideal voltage source that produces a periodic square-wave output. Commonly used to drive digital logic, test switching power supplies, clock circuits, and observe transient responses.
Properties
| Property | Description | Default | Range |
|---|---|---|---|
| Amplitude | High-state voltage (V) | 5 V | 0.1 V – 1 000 V |
| Frequency | Switching frequency (Hz) | 1 000 Hz | 0.001 Hz – 10 MHz |
| Duty cycle | Fraction of each period the output is high (%) | 50 % | 1 % – 99 % |
| Rise time | Time to transition from low to high (s) | 1 µs | 1 ns – 1 ms |
Simulation behavior
The output alternates between 0 V (low) and amplitude (high). The high time is duty_cycle / frequency and the low time is (1 – duty_cycle) / frequency.
Transitions are modeled with the configured rise time rather than an instantaneous edge, which prevents numerical instability in the solver and more accurately models real-world drivers.
The generator is an ideal voltage source — it can source or sink unlimited current to maintain the programmed waveform.
Tips
- Set duty cycle below 50 % to model a PWM signal for dimming an LED or controlling motor speed — observe the average brightness or current change in real time.
- Increase rise time to model a slow or heavily-loaded driver and watch the effect on a downstream RC circuit.
- Combine with an inductor and diode to build a simple boost converter and observe how switching frequency affects output ripple.