code for worst case" method to assess the effect of adc nonlinearity on the rms measurement error in matlab

To assess the effect of ADC nonlinearity on the RMS measurement error, we can use worst-case method. The basic idea behind the worst-case method is to assume the most pessimistic combination of input values that may occur, and evaluate the output that results from them.

The following code demonstrates how to compute RMS measurement error caused by ADC nonlinearity:

main.m
% Define a function to calculate RMS of measurement error
function err = calcMeasurementErrorRMS(k, nbits)
% k         = the full-scale input voltage of the ADC
% nbits     = the number of bits of the ADC

    % Define the input signal as a 1kHz sine wave
    fs = 10e3;  % Sampling frequency
    t = 0:1/fs:1-1/fs;  % Time vector
    f = 1e3;    % Signal frequency
    x = k*sin(2*pi*f*t);  % Input signal
    
    % Define the quantization step size of the ADC
    q = 2*k/(2^nbits);
    
    % Apply quantization to the input signal
    xn = round(x/q)*q;
    
    % Compute the measurement error signal
    en = xn - x;
    
    % Compute the RMS of the measurement error signal
    err = rms(en);
end

% Compute the RMS of measurement error for a 12-bit ADC
k = 1;      % Full-scale input voltage
nbits = 12; % Number of bits
err = calcMeasurementErrorRMS(k, nbits)
871 chars
29 lines

In the above code, we define a function calcMeasurementErrorRMS that takes the full-scale input voltage k and the number of bits nbits of the ADC as inputs. The input signal is defined as a 1kHz sine wave with peak amplitude k, and is quantized using a quantization step size q. The measurement error signal is computed as the difference between the quantized signal and the original signal, and the RMS of the error signal is returned as the output of the function.

To assess the worst-case effect of ADC nonlinearity on the RMS measurement error, we need to evaluate the function for the maximum possible values of k and nbits that the ADC can handle. For example, if the ADC has a maximum input voltage of 5V and a resolution of 16 bits, we can evaluate the function as follows:

main.m
% Compute the RMS of measurement error for a 16-bit ADC with 5V full-scale input voltage
k = 5;      % Full-scale input voltage
nbits = 16; % Number of bits
err = calcMeasurementErrorRMS(k, nbits)
197 chars
5 lines

Note that this approach assumes that the nonlinearity of the ADC is constant across the input range, which may not be the case in practice. To obtain a more accurate assessment of the ADC nonlinearity, it is necessary to characterize the ADC transfer function at different input voltages and use this information to model the nonlinearity in the measurement error analysis.

gistlibby LogSnag