How to plot/find DNL and INL of a comparator?

Thread Starter

hsnakejindal

Joined Jan 16, 2024
14
1705435819794.png
I drew this circuit in LTSpice. I want to find DNL (Differential Non linearity), INL (integral non linearity) and THD ( Total Harmonic Distortion ) of the circuit. Please Help me. Its very urgent!!
 

Papabravo

Joined Feb 24, 2006
21,345
View attachment 312868
I drew this circuit in LTSpice. I want to find DNL (Differential Non linearity), INL (integral non linearity) and THD ( Total Harmonic Distortion ) of the circuit. Please Help me. Its very urgent!!
I'm not sure it makes any sense to talk about DNL and INL for a device whose outputs are continuous. It makes more sense in the case of an A/D converter where there is a discrete step size and things are not continuous. For THD you do a Fourier Analysis (.four) and take the ratio of the harmonic components to the fundamental components.
 

Thread Starter

hsnakejindal

Joined Jan 16, 2024
14
I'm not sure it makes any sense to talk about DNL and INL for a device whose outputs are continuous. It makes more sense in the case of an A/D converter where there is a discrete step size and things are not continuous. For THD you do a Fourier Analysis (.four) and take the ratio of the harmonic components to the fundamental components.
Can you please elaborate about THD, when I plot an FFT, a graph is coming out. How to find out Harmonic components?
1705440954161.png
Or what should I write in spice directive to get it?
Also do you know how to find the offset voltage of this circuit?
 

Thread Starter

hsnakejindal

Joined Jan 16, 2024
14
I'm not sure it makes any sense to talk about DNL and INL for a device whose outputs are continuous. It makes more sense in the case of an A/D converter where there is a discrete step size and things are not continuous. For THD you do a Fourier Analysis (.four) and take the ratio of the harmonic components to the fundamental components.
how to find thd?
 

Papabravo

Joined Feb 24, 2006
21,345
how to find thd?
  1. Go to the LTspice Help pages
  2. Look up the Fourier Analysis command. It would be .four
  3. Add that command to your simulation
  4. When the simulation is complete, you will find the results in the SPICE Error Log
  5. The SPICE Error Log can be shown via menu commands View | SPICE Error Log or using the keyboard shortcut Ctrl+L
  6. See the image below
1705927758500.png
 

Thread Starter

hsnakejindal

Joined Jan 16, 2024
14
  1. Go to the LTspice Help pages
  2. Look up the Fourier Analysis command. It would be .four
  3. Add that command to your simulation
  4. When the simulation is complete, you will find the results in the SPICE Error Log
  5. The SPICE Error Log can be shown via menu commands View | SPICE Error Log or using the keyboard shortcut Ctrl+L
  6. See the image below
View attachment 313324
I am getting the THD as 74.146324%(49146395638540.664000%). what does the number under the bracket signify? Also what is the generally acceptable range?
 

Papabravo

Joined Feb 24, 2006
21,345
I am getting the THD as 74.146324%(49146395638540.664000%). what does the number under the bracket signify? Also what is the generally acceptable range?
Since I cannot see what you are doing, I can't very well comment on the results. IIRC correctly THD looks at the magnitude of the fundamental Fourier component (NOT the DC component) with respect to the sum of the magnitudes of all the harmonic components from the 2nd out to infinity. In practice we satisfy ourselves with some finite number of harmonics so that the remaining components do not contribute much to the result. I believe the number of harmonics used is 9 unless you specify otherwise. A larger THD means the magnitudes of the harmonic components is large relative to the magnitude of the fundamental. There are two ways of looking at magnitude: absolute and normalized. At least that is what I think is going on in the example I posted. I have no idea what your seemingly incongruous numbers mean.
 

Papabravo

Joined Feb 24, 2006
21,345
Here is a spreadsheet check of the THD calculations in my example. The discrepancy comes from taking the displayed values instead of their cousins with more significant digits.

1705958540236.png
You can see that the results should be the same and for my example they are.
 
Top