# Stepped Sine Wave in Spice

I'm interested in simulating a circuit using a stepped sine wave input. I want to sample a sine wave at regular intervals and have the output constant during each interval, making an output that looks like:

(pardon my silly Excel plot!)

What's the best way to do this? Is there an easy way to create a source that generates an output like this? Am I better off carefully looking at the frequency response of my circuit and comparing it to the frequency content of this input?

A solution relevant to LTSpice or Orcad would be ideal.

• I've done a "real" circuit like that with a CD4017. Different value resistors from each output into an opamp. (Caution, for good cancellation of the lower harmonics you need to take the output impedance of the CD4017 into account.) Oct 21, 2014 at 13:21

LTspice has a 'sample' block which implements a simple sample-and-hold. E.g. the below circuit

gives this waveform:

LTSpice allows you to use the PWL(piece wise linear) format to plot customized waveforms.

As a suggestion you can use PWL file which is a text file, store your data i.e. "what voltages at what time" in the text file. Take a general voltage source on schematic

Right click on the voltage source to add your PWM file using PWL Tab. As an example I plotted waveform using the PWL.txt shown below.

> 0 0 1n .1 2n .5 3n 1.0 4n 1.5 5n 2.0 6n 2.5 7n 2.5 8n 2.0 9n 1.5 10n 1.0 11n 0.5 12n 0.1 13n 0 14n .1 15n .5 16n 1.0 17n 1.5 18n 2.0 19n 2.5 20n 2.5 21n 2.0 22n 1.5 23n 1.0 24n 0.5 25n 0.1

Waveform:

Similarly you can plot your customized waveform. I don't see exact data points on your waveform, or would have tried to plot waveform exactly like yours.

Hope this helps.

• Repeat each voltage value twice, at the start and end of the sample period, to reproduce a stepped waveform. Allow a small time (say 1 ns) between the end of a sample period and the start of the next. Oct 21, 2014 at 9:15

Micro-cap has a component called "sample and hold" so, if you feed in a sinewave, the output will be a sampled version of the sinewave. Micro-cap also has the facility to have user-defined signal sources.

Like AKR I cannot give recommendations for OrCAD because I don't use it.