Drawing the Analog to Digital Line in LTSPICE, Part 2
#1
Take a look at Part 1 of this series first. The issue at hand is where does analog stop and digital begin? A square wave produced by a digital output will begin to look more like a sine wave as the maximum frequency of operation is approached because the transition from one logic level to the other is not instantaneous. Here in Part 2, we will morph a sine wave into a square wave by gradually steepening the slope while limiting the amplitude. The simulation will help to visualize the impact of slew rate on the transition between the analog and digital realms. In Part 1, we started on the digital side and ended with a sine wave. Here, we begin with the sine wave.

One single LTSPICE behavioral does the entire job. The formula is again based on the function, sin(time), where “time” is a LTSPICE defined variable giving the elapsed time in seconds since the start of the simulation. The sin(time) function produces a sine wave centered on zero with an amplitude of +/-1 volt and a period of 2 pi. That makes the frequency about 0.159 Hz. The result of the sine function is multiplied by (1 + time/500). There is nothing special about dividing by 500. It simply paces the transition. Then put the entire formula inside a limit function to get:

V=limit(sin(time)*(1+ time / 500),1,-1)

If you have LTSPICE available, you can type that formula in, or copy it from here into a behavioral voltage, BV. The only other piece needed is a .tran expression to define the simulation, like:

.tran 0 10000 0 1m

That will set up 10,000 seconds worth of transient simulation with a maximum timestep of 1ms. Don't worry, it will run fast. Early on, the time multiplier term is very near to unity, so the multiplication will barely change the waveform. As time passes, the multiplier term grows above one. Then, the limit statement which surrounds the calculation comes more into play. The limit clamps the result since it cannot be more than 1 or less than -1. The waveform gradually develops steeper slopes and a flatter top and bottom as time progresses.

Observe the top axis in the figure below, which starts at time zero. The flattening is already quite noticeable by the third cycle. The middle axis is the same simulation out at 1000 seconds elapsed. The waveform is now trapezoidal, with about one quarter of each period spent in transition.

   

The lowest axis is the same simulation after 10,000 seconds. The waveform is squaring up nicely, and is looking very much like a digital output waveform. This process is a pretty good representation of what actually happens in a digital output stage. The more gain it has, the faster it can slew, the squarer the shape, and the higher the maximum operating frequency.

As an extension to Part 1, we are using SPICE as a visualization and teaching tool, as opposed to using it for circuit design. Does anyone have other examples they would be willing to share of harnessing SPICE for illustrating abstract concepts?


Tom Lawson
February 23, 2021
Reply


Messages In This Thread
Drawing the Analog to Digital Line in LTSPICE, Part 2 - by Tom - 02-23-2021, 06:23 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)