Alastair Barber

Creating PWL Files For LTSpice for PWM Signals

Here is a very simple tool that can be used to simulate producing sine waves from PWM pulses and an appropriate filter in LTSpice. It can be downloaded and built or run online…

The source code is in C++ and available on github. The same code can be run here in a webpage (read more about how that can be achieved - and should run here:

For example, if we were to use this to try and simulate PWM outut of a teensy 4.1 with the following parameters:

It would produce a file that could be read into LTSpice, which, in the following basic circuit LTSpice Circuit

when run would produce the following waveforms LTSpice waveform

When implemented in a real ciruit: Real Teensy-Op-Amp Circuit

the waveform on a scope is thus: Real waveform