PWMSim

Showcase

Your LTspice file in the browser

An LTspice schematic opens in the browser as it was drawn, runs, and agrees with LTspice's own run of the same file.

Try it yourself What it does not show

1Overview

LTspice is where most power-electronics circuits already are. PWMSim opens an LTspice schematic (.asc) in the browser: it reads the file as it was drawn, places its parts where the file puts them, runs its own .tran, and compares the result with LTspice's.

The file on this page is BUCK_PCM, a peak-current-mode buck converter from 5 V to 1 V at 1 A, switching at 1 MHz, its loop closed by a type-2 compensator built around LTspice's own UniversalOpAmp2. It comes from the LTspicePowerSim examples by kosokno (MIT license). Nothing was changed in it.

2In LTspice

BUCK_PCM.asc open in LTspice: the schematic, and its switch-node, inductor-current and output waveforms over the last 10 µs
Fig. 1: The file in LTspice, as its author shows it (from the repository, MIT license).

3In PWMSim

BUCK_PCM.asc as PWMSim imports it
Fig. 2: The same file as PWMSim imports it, drawn from the import.

The import read 73 constructs of the file and its symbols: 71 exactly, 2 approximated, and none refused. It needed nothing but the file's own repository: LTspice's standard parts, and the UniversalOpAmp2 the compensator uses, are built into the import, and the converter's blocks are symbols that sit beside the file.

Once it is open, Model trust lists every construct the same way.

4Run for run

The file asks for .tran 0 0.3m 0.29m: LTspice runs 300 µs and saves the last 10 µs. Fig. 3 lays PWMSim's run over LTspice's across that span, the one the author's screenshot shows.

0.9994 0.9996 0.9998 v(out) [V] v(out), PWMSim v(out), LTspice 0.975 1.000 1.025 i(L1) [A] i(L1), PWMSim i(L1), LTspice 290 292 294 296 298 300 Time (µs) 0.0 2.5 5.0 v(sw) [V] v(sw), PWMSim v(sw), LTspice
Fig. 3: PWMSim (solid) and LTspice 26.0.2.1 (dashed), from 290 µs to 300 µs: output voltage, inductor current and switch node.

The app's Compare with LTspice reads LTspice's waveform file (the .raw it writes) and checks every signal both runs have over the cursors' span. Over the span LTspice saved:

SignalPWMSim meanLTspice meanPWMSim p-pLTspice p-pDifference
i(@1)-3.47e-21 A7.84e-15 A1.73e-18 A3.33e-13 A0.78%
i(C1)37.7 µA20.5 µA80 mA80.4 mA0.02%
i(L1)1 A1 A80 mA80.5 mA0.00%
i(R1)1 A1 A473 µA472 µA0.00%
i(V1)-201 mA-201 mA1.04 A1.04 A0.00%
v(IL)1 V1 V80 mV80.6 mV0.01%
v(in)5 V5 V0 V0 V0.00%
v(out)1 V1 V473 µV472 µV0.00%
v(pwm)211 mV211 mV1 V1 V0.00%
v(r)0 V2.48 µV0 V1 V0.00%
v(sw)1 V1 V6.02 V4.99 V0.01%
v(vc)1.05 V1.05 V443 µV536 µV0.02%

All 12 shared signals agree within 1%. The difference is the gap between the two means over LTspice's peak-to-peak, or over its level where the signal is flat.

Where the means agree but the peak-to-peak do not:

PWMSim marks its run with one warning: the step controller accepted an estimated error above the requested tolerance at some step. The app says so beside the result, and a smaller maximum step certifies the run.

5Try it yourself

6What this does not show

The PWMSim drawing, waveforms and numbers above come from BUCK_PCM.asc as PWMSim imports it, run by PWMSim; LTspice's from LTspice's own run of the same file. The comparison is the app's Compare with LTspice.