Thursday, January 30, 2020

ADC INL/DNL testing with SciLab

ADC INL/DNL testing using histogram is pretty simple. AnalogMAX DAQx support files include a capture utility that already emits data in format readable direclty in SciLab. To calculate INL/DNL run following SciLab script:

mode(0)

x = read("C:\temp\capture.txt", -1, 1)
trunc = 16

minbin = min(x)
maxbin = max(x)
h = histc(minbin:maxbin,x)
ch = cumsum(h)
T = -cos(%pi*ch/sum(h))
hlin = T(2:$) - T(1:$-1)

hlin_trunc = hlin(trunc+3:$-trunc)
lsb = sum(hlin_trunc)/(length(hlin_trunc))

dnl = [0 hlin_trunc/lsb-1]
inl = cumsum(dnl)

It may take a little bit of thinking to understand what the code does, short explanation: cumsum (cumulative sum) calculates a function that looks like inverse sinus, applying cosinus function converts it to linear rising function(range -1..+1), taking a difference between adjacent values of this result will give DNL. That's it!

Note the input to ADC should sinus with small clipping.

Example plots with SciLab:

Histogram from input

Cumulative sum from the histogram
Cosinus from cumulative sum of the histogram

DNL Plot


No comments:

Post a Comment