Electronic – How to add variable duty cycle PWM to a CircuitLab simulation within a question

circuitlabduty cyclepwm

This is my first attempt to simulate a circuit in the time domain with CircuitLab. In order to ask a proper question about something similar driven with PWM, I'd like to add an adjustable duty cycle to the square wave, and then if possible ramp it.

How can I add variable duty cycle PWM to a CircuitLab simulation within a question?

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here

Best Answer

This is an interesting question. I've never had to do it but this might work for you.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Two sawtooth oscillators and a comparator.

enter image description here

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

enter image description here

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.