Products > Test Equipment
LCR Impedance Viewer for Picoscope+Keysight+R&S Bode Plot Data (open source)
<< < (7/30) > >>
_Wim_:
Yikes  :o. That's alot of math to check this weekend. Maybe I will need a couple more...  :)
HalFET:

--- Quote from: _Wim_ on March 01, 2019, 07:03:38 pm ---Yikes  :o. That's alot of math to check this weekend. Maybe I will need a couple more...  :)

--- End quote ---
It just over-inflates very quickly if you don't use in-between answers and simplify some terms, it ain't as bad as it looks. The principle behind error/uncertainty calculations is really simple though: Error of Value = sqrt( sum of (dValue/dx1 * Error of x_i)^2 for all variables x_i)

So it'd be a lot more practical to calculate dValue/dx_i for each variable, and then just add it all up together like that like I did in the Matlab code. Just a bit too hazy to cut it up into pieces at the moment, should be easy enough to do if you fire that code up in Matlab or Octave though.

But the main interesting bit is that the gain error in practice stays quite flat until you go into the lower ranges, there the potential offset error of the scope can kill it for you.

--- Code: ---Series = 0.001:0.005:10;
[X, Y] = meshgrid(Series, Series);
Z = 20 .* log10(X./Y);

figure(1);
surf(X, Y, Z, 'edgecolor', 'none');
xlabel('V2 [V]');
ylabel('V1 [V]');
zlabel('Gain [dB]');
title('Voltage Gain - Decibel');

%Scope error =  Gain error + Offset error + ADC error
%            =  +/- 5% value +/- 5 mV +/- 0.25% range

Range1X = X <= 0.1;                         Range1Y = Y <= 0.1;
Range2X = xor(X <= 1, Range1X);             Range2Y = xor(Y <= 1, Range1Y);
Range3X = xor(X <= 10, Range1X | Range2X);  Range3Y = xor(Y <= 10, Range1Y | Range2Y);


XError = 0.05 .* X + 0.005 + 0.0025 .* (Range1X .* 0.1 + Range2X .* 1 + Range3X .* 10);
YError = 0.05 .* Y + 0.005 + 0.0025 .* (Range1Y .* 0.1 + Range2Y .* 1 + Range3Y .* 10);
ZError = (20 ./ log(10)) .* sqrt((YError./Y).^2 + (XError./X).^2 );

figure(2);
surf(X, Y, ZError, 'edgecolor','none');
xlabel('V2 [V]');
ylabel('V1 [V]');
zlabel('Gain Error [dB]');
title('Voltage Gain Error - Decibel Error');

--- End code ---

Operating on the assumption that the 39°C fever hasn't completely fried my brain, you're looking at something along the lines of <0.75 dB as of uncertainty throughout the practical range. Practical offset errors will probably be less than 2 mV, and the gain error on any modern scope frontend ought to be less than 5% really. See attached plots for 0 through 10V with the values of the code above.
_Wim_:
First let me explain the current calculation that is in the software:

        V1 o------+
              |
             | |
             | | Z_REF
             | |
              |
   V2 o------+
              |
             | |
             | | Z_DUT
             | |
              |
            ___
   GND     -

   Z_DUT = V2 / I

   I = Rref / (V2 - V1)
   
   => Z_DUT = Rref* V2 / (V1-V2)

   Angle between V1 and V2 = θ, V1 at 0°equal to siggen.

   Current in polar coordinates: [r=sqrt(X²+Y²) //  α= tan-1 (y/x) ]
   <=> I = Rref / sqrt((V1 - V2 * cosθ)² +(V2 * sinθ)²)
   <=> I = Ref / sqrt(V1²-2 * V1 * V2 * cosθ + V2²)


  Magnitude & angle of Z_DUT: [dividing vectors in polar coordinates = divide magnitudes and substract phases]
        Z_DUT = Rref* V2 / sqrt(V1²-2*V1* V2*cosθ + V2²)
        α =  θ – tan-1 ((-V2* sinθ)/(V1-V2* cosθ))

  To translate the above to “gain”, we know <=> gain = V2/V1

   -----------------------------------------------------------
   | Zmag = Rref* gain / sqrt(1-2*gain* cosθ + gain²) |
   ----------------------------------------------------------- (equation 1)
   -----------------------------------------------------
   | α =  θ – tan-1 ((-gain* sinθ)/(1-gain* cosθ)) |
   ------------------------------------------------- ---(equation 2)

   Capacitance:
   -------------
   Z_DUT expressed in rectangular format has only a real part equal to Resr and a negative imaginary part equal to 1/(2*π* f*C)
   
   Z_DUT = Resr – j / (2*π* f*C)
   
   Z_DUT = Zmag* cosα + j* Zmag*sinα
   =>

  --------------------------
  | Resr = Zmag* cosα  |
  -------------------------- (equation 3)
 
  Zmag* sinα = -1 / (2 * π * f * C) <=>

  ----------------------------------------
  | C = -1 / (2 * π * f * Zmag * sinα |
  ----------------------------------------(equation 4)

  Inductance:
  ------------

  Z_DUT expressed in rectangular format has only a real part equal to Resr and a positive imaginary part equal to 2*π* f*L

  Z_DUT = Resr + j * 2 * π * f * L

  Z_DUT = Zmag* cosα + j* Zmag*sinα
  =>

   --------------------------
   | Resr = Zmag* cosα  |
   -------------------------- (equal to equation 3)
   --------------------------------
   | L = Zmag* sinα / (2*π* f) |
   --------------------------------- (equation 5)
_Wim_:
Calibration:

If we perform the calibration with a purely resistive calibration resistor Rcal, we know Z_TOT  will consist of Rcal + Z_ERR

In rectangular coordinates we can express this as

Z_TOT = Zmag_err*cosα_err + Rcal + j* Zmag_err*sinα_err
Z_TOT =  Zmag*cosα                      + j*Zmag*sinα

=>
Zmag*cosα = Zmag_err*cosα_err + Rcal (1)
Zmag*sinα = Zmag_err*sinα_err (2)

(2) Can be changed to:

-----------------------------------------
| Zmag_err = Zmag*sinα / sinα_err |
----------------------------------------- (equation 6)

Substituting equation 6 into (1)

Zmag*cosα = = Zmag*sinα *cosα_err/sinα_err   + Rcal <=>

------------------------------------------------------------
| α_err = tan-1 (Zmag* sinα / (Zmag*cosα – Rcal))  |
------------------------------------------------------------ (equation 7)

This way we know the error vector that can be used to adjust the measurement in the future.
_Wim_:
Calculation of DUT with correction:

We know Z_TOT  will consist of Z_DUT + Z_ERR

In rectangular coordinates we can express this as
Z_TOT = Zmag_err*cosα_err + Zmag_DUT*cosα_DUT + j* (Zmag_err*sinα_err + Zmag_DUT *sinα_DUT)
Z_TOT =  Zmag*cosα                                                + j*Zmag*sinα
=>

Zmag*cosα =  Zmag_err*cosα_err + Zmag_DUT*cosα_DUT
Zmag*sinα = Zmag_err*sinα_err + Zmag_DUT *sinα_DUT
=>
------------------------------------------------------------------------
| Zmag_DUT = (Zmag*sinα - Zmag_err*sinα_err) / sinα_DUT   |
------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
| α_DUT = tan-1 ((Zmag*sinα - Zmag_err*sinα_err)/ (Zmag*cosα - Zmag_err*cosα_err)) |
------------------------------------------------------------------------------------------------------

The capacitance and inductance formulae above can now be changed with Zmag_DUT and α_DUT.


I am not a Matlab guy, so did not check this, just tried to make my written calculations in digital format.

Basic principle would be as follows:

- run a calibration with an Rcal reference resistor once. This file will be saved with values for Zmag_err and α_err for each frequency (interpollation will be used for in between frequencies)

- measure a DUT.
    * first calucalate Zmag + α
    * lookup Zmag_err + α_err from the calibration file for each frequency
    * based on the above, calculate Zmag_dut and α_DUT
    * caculate capacitance and inductance using these last 2

Am I missing something? Although I am currently not sick, my head also goes to 39°C when doing this stuff, so could be full with mistakes. So to all the math guru's, please check  :)

All of this is off course only true if Z_ERR can be thought of as an impedance in series with Z_DUT...


edit: some spelling mistakes, copy paste error and clarifications
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod