# How to check for slope of a square wave output in LTspice

I want know if there is a certain formula that needs to be used to get the positive and negative slope of a square wave. Let Vn001 be the indication if its positive and negative? Or can I simply trust the measurement in LTspice :slope:?

Kindly use this image as a reference. From my knowledge you can calculate the slope with $$\\frac{\Delta V}{\Delta T}\$$.

Ideally, the $$\\small\Delta V\$$ is constant, or is this not the case and should I still get the difference between the two cursors?

So, from the values, the positive slope of this output is:

$$\\frac{\Delta V}{\Delta T} = \frac{13.6\ \mathrm{V}}{2.12\ \mathrm{ms}} = 6415.09 \neq 53.75\$$

• Why don't you plot dv/dt? Mar 21 at 8:56
• @Andyaka how do you do that? Mar 21 at 9:02
• I don't use LTspice but, I expect it has the facility. Mar 21 at 9:03
• im unfamiliar to it as well. This astable circuit was supposed to be done in a lab class however I'm unsure of the values I obtained from the oscilloscope so I'm hoping I could verify using LTspice as it the only program we are exposed to right now. Mar 21 at 9:07
• You can check this thread. Here is a similar question: electronics.stackexchange.com/questions/410684/… Mar 21 at 15:36

You used the voltage from the first cursor instead of from the difference. $$\frac{114.45~mV}{2.13~ms}=53.73~V/s$$

So taking rounding error into account the reported value is correct.

• yes if you apply it like that however im not positive if thats the slope since when i probe it the value it too low. Mar 22 at 6:28
• @jaxillrplusone Well it depends on where you put the cursors. You appear to have them on the flat part of the square wave, so it will give you the slope of that. If you want the slope of the rising edge of the square wave you have to position the cursors so cursor 1 is near the bottom of the edge and cursor 2 is near the top. Mar 22 at 14:15
• OH now that's helpful! thanks! Mar 22 at 17:46

LTSPICE supports waveform arithmetic. Specifically, if you have a node X you can plot D(V(X)) to get the derivative of V(X) (which is its slope). In this case I created a waveform that rises/falls by 10V in 10us so the plot shows ±1MV/s during the rise times and zero while V(X) is flat.

To plot a formula, you can right click on the plot or press the "A" key to bring up a dialogue box where you can add a new trace. From there just type in the formula for what you want to plot.

The MEASURE facility in LTspice allows a TRANsient run to be post-processed for determining maximum slope. The result appears in SPICE ERROR LOG. You can add the MEASURE parameter with the .OP button:

.meas TRAN slope_V(out) MAX d(V(out))/d((time))


Note that a small time step is required for accuracy; a fast square wave rise time helps here as well (a one picosecond rise time improved slope accuracy slightly).

• a time step of 1 microsecond yielded a slope of 996 V/s
• a time step of 1 nanosecond yielded a slope of 999.767 V/s