PWL that loops forever
LT Spice – How to simulate a repetitive signal?
There is a quick and easy way to do this. Set the voltage source up as a PWL (Piece Wise Linear), with one period’s worth of data. A PWL string will appear next to the voltage source in the GUI – e.g. for a signal stepping between 0, 1 and 2V every second the string would say PWL(0u 0 1u 5 2u 0). Right click on this string and write in a “repeat forever” and a “endrepeat”, so it looks like this: PWL(repeat forever 0u 0 1u 5 2u 0 endrepeat). Done!
If you want the signal to repeat only 5 times, for instance, you would put “repeat for 5” instead of “repeat forever”.
To make a square wave, with 10 ns raise/fall time and 1kHz frequency: PWL(repeat forever 0u 0 0.01u 5 0.5u 5 0.51us 0 1u 0 endrepeat)
Ensure you are in steady state when giving the time window to calculate the spectrum. 1 ms of data is sufficient. Giving long time dataset to FFT can plot lower frequencies but the highest frequency is limited.