# LTSpice - Is there a way to plot nonlinearity

Discussion in 'General Electronics Chat' started by eblc1388, May 15, 2011.

1. ### eblc1388 Thread Starter AAC Fanatic!

Nov 28, 2008
1,543
102
The attached image shows the response of a diode through a temperature sweep. It appears to be linear.

Is there a way to plot the deviation of the response against a straight line of approximate the same slope? i.e. just to show the deviation or non-linearity?

I know I might be able to get that by using waveform arithmetic but I just can't seem to be able to use 'temp' as the x-axis variable in the calculation to get the deviation.

Thanks

File size:
19.9 KB
Views:
158
2. ### ifixit Distinguished Member

Nov 20, 2008
639
110
Hi eblc1388,

One method would be to use a behavioral model (bv) to plot a linear function close to the expected values and then compare with the actual diode characteristic. I used 20°C as a reference point where the two are assumed to be almost equal. Use 2mV per °C for the estimated perfect slope.

Have Fun,
Ifixit

File size:
97.8 KB
Views:
51
3. ### Ron H AAC Fanatic!

Apr 14, 2005
7,049
659
On the waveform, change v(out) to d(v(out)). Decrease your step size to 1°C or less. The model appears to have discontinuities or something, because you get little bumps in the curve.

File size:
12.8 KB
Views:
51
4. ### rapidcoder Member

Jan 16, 2011
37
3
No, the original SPICE diode model does not have discontinuities in it. These bumps are caused by inacurracies of the LTSpice simulation engine, probably by running the NR loop too few times. Try to lower the RELTOL setting.

5. ### eblc1388 Thread Starter AAC Fanatic!

Nov 28, 2008
1,543
102
Thanks all for the fast response.

ifixit offers what I wanted as I would be reading the actual diode voltage and using a linear relationship to calculate the temperature. I need to know how linear is the diode voltage vs temperature and the non linearity error to decide if I need to apply any correction to the final calculated temperature.

Looks like the linearity is very good for all practical purposes.

6. ### rapidcoder Member

Jan 16, 2011
37
3
The forward diode current is given by the formula:

I = IS(T) * (Exp(VD / (VT * N)) - 1)

where IS is the saturation current of the diode, dependent on the temperature according to the formula:

IS(T) = IS * Pow(T / TNOM, XTI / N) * Exp(q * EG * (T - TNOM) / (k * T * TNOM * N))

Because all the temperatures are in K, in the close neighbourhood of TNOM (300K) the characteristic is quite linear.