How can I add variable duty cycle PWM to a CircuitLab simulation within a question?
This is an interesting question. I've never had to do it but this might work for you.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. Two sawtooth oscillators and a comparator.



Figure 2. Note the DC offset in the sawtooth configuration.



Figure 3. The result.

I seem to have configured the amplitude incorrectly on the triangle waves. They should probably be 2.5 V with 2.5 V offset but perhaps the graph is clearer like this.