# Generate PWM Signal in LTSpice [closed]

How can I generate a 100KHz PWM Signal in Ltspice? How do I calculate Ton and Tperiode?

## closed as unclear what you're asking by RoyC, Mitu Raj, Michel Keijzers, Finbarr, Dmitry GrigoryevApr 17 '18 at 8:07

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Please edit your question, its unclear what your asking. If you want to modulate the signal, then you'll need a multiplier (as in comm modulate). If you want to generate 100kHz then please say so. – laptop2d Apr 10 '18 at 18:09

## 2 Answers

A 100kHz signal must change every 1/T seconds, or 0.00001s, If you want a square wave with a 50% duty cycle then the Tperiod sets the time that the signal will be on and Ton sets the time during that period or 'window' that the signal is at Von.

Calculate your period: 1/f=Tperiod Calculate how long the signal is on for 50% of the time (symmetrical square wave) would be t*Duty cycle = Ton.

If your looking to generate a PWM signal then use a PULSE Voltage source with a signal changing at 100kHz Tperiod is set to 0.00001s. The Ton will be half that for a 50% duty cycle, or 0.000005s. The rise and fall times may be left at zero. If you wanted a 20% duty cycle the Ton time would be 0.000002

• Thank you so much, now it is clear to me. In retrospect, it is so logical. – Luigi Apr 10 '18 at 20:28
• If you like the answer, upvote and mark – laptop2d Apr 10 '18 at 20:29

If you need this to serve your previous question, you'll be needing a time-varying PWM. You can set a ramp voltage in LTspice like this:

PULSE(0 1 0 {0.99/f} {0.01/f} 0 {1/f})


which is a ramp from 0 to 1V, with period given by the frequency f. You could have used {1/f} for rise time and zero for fall and Ton, but that setting can have adverse effects in the dynamic range in long runs.

Then, you can find the best comparator for the job in [Digital]/schmitt. See this answer.