Post Go back to editing

Wrong phase measurement with AD5933

Thread Summary

The user is experiencing incorrect phase measurements with the AD5933 when measuring capacitors, particularly at higher frequencies. The final answer suggests that the issue is likely due to the RFB voltage waveform being clipped, which occurs when the impedance of the capacitor is lower than the RFB value. The solution involves selecting an RFB value closer to the minimum expected impedance (Zmin) and using the formula from AN 1252 to calculate Rcal. The user should also consider using atan2() instead of atan() for phase calculations to avoid quadrant ambiguity. For unknown impedances, the user should perform calibration at multiple frequencies to ensure the signal remains within the ADC's dynamic range.
AI Generated Content
Category: Hardware
Product Number: AD5933

I'm trying to build an AFE circuit (image below) to better manipulate the AC signal AD5933 supply to my DUT. Everything works as intended, I can measure the impedance and phase of a resistor without problens, but when I try to do it with a capacitor it gets strange, it will give me values of impedance that makes sense but the phase values dont match. For example, when I try to measure a capacitor (like the 10 pF in the datasheet) on a frequency sweep of 10k Hz to 100k Hz with 200kOhm calibration and feedback resistors, the phase values will start at -90º and finish at aproximately -42º. 


This is the first stage with an ad8606, after that it is the DUT/Rcal and Rrfb.

I'm using an arduino with a code I found on the internet to make the measurements(.cpp file):

bool AD5933::calibrate(int real[], int imag[], double gain[], double phase[], long int ref, int n) {
    // REMOVIDO: A alocação dinâmica de memória
    // int *real = new int[n];
    // int *imag = new int[n];

    // Realiza a varredura de frequência, usando os arrays 'real' e 'imag' que foram passados como parâmetro.
    if (!frequencySweep(real, imag, n)) {
        // Não precisamos mais do 'delete', pois não usamos 'new'
        return false;
    }

    // Para cada ponto da varredura, calcula o fator de ganho e a fase do sistema
    for (int i = 0; i < n; i++) {
        // Cálculo do Fator de Ganho (para Magnitude)
        double magnitude = sqrt(pow((double)real[i], 2) + pow((double)imag[i], 2));
        gain[i] = (1.0 / ref) / magnitude;

        // Cálculo da Fase do Sistemas
        phase[i] = (atan((double)imag[i]/(double)real[i]) * 180.0 )/ 3.1415;
    }

    // REMOVIDO: A liberação de memória
    // delete [] real;
    // delete [] imag;
    
    return true;
}


How I get the real phase value (.ino file):

double faseSistema = (atan((double)imag/(double)real) *180.0)/3.1415;
double faseReal = faseSistema - phase[i];

I don't understand what I'm doing wrong.



Edit Notes

Justo correcting title
[edited by: Texspray at 9:24 PM (GMT -4) on 26 Sep 2025]
  • First thing to check would be that the voltage waveform on the RFB pin of the AD5933 is a well-formed sine wave without any distortion or clipping at the power supply rails.in the course of the frequency sweep (hopefully you have access to an oscilloscope). If not - try tracing the reason along the components of the AFE upstream the signal chain form that point towards the VOUT pin.
    Can you post the raw Re and Im readings from your circuit when:
    1. Nothing is connected instead of the DUT
    2. Rcal is connected  instead of the DUT
    3. The suspect capacitor is connected instead of the DUT
    ?

  • Hello, thanks for your help!

    Yes, I have an oscilloscope, and the sine wave at the RFB pin is perfect. This is awkward, but I've measured what you requested, and now the phase for the 10 pF capacitor seems fine (it's positive; could this be corrected in the code?). I took the opportunity to measure other capacitor values to check with you if they make sense given the RFB I'm working with. The issue is that with the 33 pF and 100 pF capacitors, I get some crazy jumps in the phase values, like jumping from 127º to -47º.

    Here is my data:
    XLSX

  • Thanks for posting the data in Excel, please find it modified with all the relevant calculations. The columns for 326k Ohm did not contain raw Re and Im data, so removed for now.
    The data for calibration with 220k Ohm resistor look OK and you mentioned that the RFB voltage waveform was good, presumably with the calibration resistor. The data however indicate that it was not the case with the 33pF and 100pF capacitors. The spreadsheet name presumably indicates that the Rfb resistor was 220k Ohms, but the equivalent impedance of those two capacitors ranged from about 161k Ohm and 53k Ohm at 30 KHz to about 60k Ohms and 20k Ohms at 80 KHz. This means that the system gain was larger than 1 throughout the entire frequency sweep and virtually guarantees that the RFB was clipped with the both capacitors leading to incorrect Re and Im readings. For 33pF capacitor at the low end of the frequency sweep there are a few points where its impedance was the highest and there was very little or no clipping, so the data makes sense and the impedance, phase and capacity calculated based on calibration was reasonable.
    The bottom line is: the voltage waveform at the RFB pin has to be well-formed sinewave throughout the calibration and measurements or the chip output data will be erroneous, so it is always necessary to watch the minimum expected value of the impedance under test Zmin. The connection between the Zmin and the Rfb is given by the formula on p.5 in the application note AN 1252. Since you are using the AFE, Vdcoffset = Vdd/2 and the denominator turns into just Vpk. Vpk in the formula is a half of the Vp-p in the Table 5 in the datasheet. For maximum accuracy calibration resistor Rcal should be equal or very slightly higher than Zmin and Zunknown in subsequent measurements should always exceed or be equal to the Zmin.
    Something was not right with the 10pF test – the signal was way too low, so either there was a poor contact or the capacitor was much lower than 10pF, the calculated capacitance indicates something like 0.6pF.
    There are some noticeable discrepancies between the values calculated in Excel based on raw Re and Im and the values calculated in the code, so something to look at. Jumps in phase you observed are likely because function atan() does not know in which quadrant the angle lies, so using function atan2() should probably give better results.
    XLSX

  • Thank you for answering my question!
    Sorry for the wrong readings with the capacitors... I redid my measurementes for two of them (10 pF and 33pF) to get a better idea of what is happening, using the two equations to calculate Rrfb and Rcal with their theoretical values in 30kHz and 80kHz. For the 33 pF capacitor, I got  aproximately 87878 kOhm to use as Rfb and 73333 for Rcal, so I redid  with Rrfb/Rcal = 100kOhm and got a more reliable data!

    But with 10 pF it got aa little strange... Calculating Rrfb and Rcal for the capacitor gave me 290kOhm for Rrfb and 242kOhm for Rcal, so I made two measurements, one with Rrfb/Rcal = 220kOhm and another with Rrfb/Rcal = 330kOhm ( I tried with Rrfb = 330kOhm and Rcal = 220kOhm, but it was not working). The data is way better than my previous, but I don't think the phase should change so much  in this frequency window, maybe it is because of the big difference of the min and max impedance and the proper way would be to make two frequency sweeps to measure the 10 pF capacitor in this frequency window?

    All my new data is within the excell documents below.

    I have other questions too! How do you know when the signal is saturated or too low for the ADC? If I want to measure an unknown (and complex) impedance in a frequency window, I need to divide the calibration process in two, right? One with the unknow impedance and a choosen Rrfb to select the better feedback resistor for each frequency and the next step being to calculate the Gain Factor and Magnitude for the selected Rrfb of each frequency? (I have read some articles that use multiplexers to measure unknows impedances with unknow magnitude of impedance and I think this is the correct process they use).

    Thanks for your help and attention!
    XLSXXLSXXLSX

  • using the two equations to calculate Rrfb and Rcal with their theoretical values in 30kHz and 80kHz.

    Not sure which two equations you used, but if you followed the application note AN 1252., only one formula there makes sense - the one on on p.5, which connects Zmin and the Rfb. Zmax is always infinity, Rcal should be equal to Z min or slightly higher. When it comes to capacitors, Zmin should be the expected value of the capacitor impedance at the highest frequency within the sweep.

    All my new data is within the excell documents below.

    All three measurements with the three different Rfb-s are valid. I added simple charts for |Z| (prime Y-axis) and Phase (secondary Y-axis) as a function of frequency to all spreadsheets for visual reference. Also added a 1/x trendline to the |Z| curve - all three datasets follow the expected capacitor impedance being inversely proportional to frequency pretty accurately: the power is very close to -1. Watching what is happening with the Phase over these three datasets:
    1. the pase is closer to the expected value of 90º at the lowest frequency within every sweep
    2. the phase is closer to the expected value at lower Rfb
    3. the noise (or scatter) in phase values is lower at higher Rfb  
    These likely point to parasitic inductance in the resistors used for Rcal - complex gain calculation assumed "ideal" resistor with zero reactive component in its impedance. The higher the resistance of a conventional carbon resistor the more likely for it to have a longer spiral groove along the cylindrical carbon layer causing parasitic inductance. For lower reactive response it is better to use carbon composite resistors and metal foil resistors and avoiding wire-wound resistors (unless specifically designed for low-inductance). For squeezing the last drop of accuracy from the setup it would be good idea to get some at least 0.1% (or better yet 0.005%) tolerance resistors and use those for calibration.

    How do you know when the signal is saturated or too low for the ADC?

    Unfortunately, the way the chip is designed, you do not. The built-in ADC mindlessly digitizes either the non-existent or grossly distorted sine wave and the on-chip so-called DFT is mindlessly crunching the data outputting whatever comes out of it into Re and Im registers. Figuring out whether the data makes sense or not is left to the user.
    Unless the frequency range is narrow and the impedance changes are not large, the user is supposed to devise the strategy as to how to keep the p-p signal of the sine wave as close to full available dynamic range of the ADC as practical throughout the sweep to keep discretization errors low. Your capacitor data illustrates this well - the phase measured at Rfb = 100k Ohm has more scatter than the one measured at higher Rfb-s. Prior to involving the multiplexers, it is worth considering the AD5933 both programmable gain and excitation voltage. With the 10pF capacitor example, say one wants to sweep from 10KHz to 100KHz, then the capacitor impedance would change from about 1.6M Ohm to  160k Ohm. So it would make sense to use Rfb of approximately the same 160k Ohm and using PGA gain of 5x when sweeping 10KHz to 20KHz. and switching to PGA gain of 1x when sweeping from 20KHz to 100KHz. Similarly one can do the same with the excitation voltage levels or in combination with the PGA gain. Yes, if maximum accuracy is required, the calibration would need to be performed for each part of the sweep with two Rcal suitable for each one. 
    BTW what was the reason for generating the DC bias using DAC?  The typical use of a simple DC-blocking capacitor at the VOUT pin found throughout application notes, while not without some drawbacks, seems to be a more straightforward way of getting the AFE DC operating point at Vcc / 2. What would be the function of the resistors R3 and R4 (unless R4 is needed for the current-output DAC)?
    XLSXXLSXXLSX

  • Thanks for your help, I was really struggling with the measurements for a while. Still, I'm scratching my head for over a week to figure out the best algorithm to select RFB and RCAL for an unknown impedance. I want to measure more complex circuits and materials, but it really gets difficult to figure out the best way to know if the data makes sense or not.

    I don't know how to cite your comment, but the DAC was an article idea that I read some time ago. At that moment I thought it was for changing the offset at will (and for me, it was a cool idea), but as I read the datasheet again and again, I realized it was for biasing the signal with the VIN pin. So, it didn't make sense at all for the same reason you told me: the circuit would change to an inverter with a buffer.

    Talking about the buffer, I tried to read some small impedance (in the 100-ohm range), but it did not go the way I thought. Does this data make sense to you? All of this was done with the 2 Vpp range and proper biasing.

    XLSX

  • Still, I'm scratching my head for over a week to figure out the best algorithm to select RFB and RCAL for an unknown impedance.

    When you start replying to a post, you can select text in the post, in most browsers a small dropdown marked "Quote appears, upon clicking it, the selected text appears as quote in your reply field.
    Yes, this is not straightforward, especially if you need to measure at a single frequency. When there is a sweep, you can usually guess as to how your DUT is supposed to behave with changing frequency and, if you see that the DUT starts deviating from the expected trend – one should be suspicious that the impedance of the DUT went out of measurable range. This all comes with experience. Even if you are dealing with completely unknown source of impedance you might know some approximate theoretical equivalent model and build a couple of “equivalent” test circuits using some R,C and L components.
    Otherwise the strategy would be to assume that Zmin is extremely low, from that calculate Rfb, use Rcal equal or slightly larger than Zmin. The unknown impedance larger than Zmin will produce valid results no matter how much larger it is. If the Re and Im are very low and noisy – Zmin was too low. Use large value of Zmin (increase, say, by factor of 3 to 5), from that calculate new Rfb, use Rcal equal or slightly larger than Zmin. See if the data quality improves while the general frequency response remains the same. These may take several trials.Please feel free to share your data if it looks confusing.

    it was for biasing the signal with the VIN pin

    Using DAC in the circuit you posted would require reprogramming its output every time you need to change the AD5933 excitation voltage. It would work, but a cheaper DC-blocking capacitor would do the same (albeit creating annoying transient voltage spikes when the chip is taken out of standby mode).

    Does this data make sense

    The data somewhat makes sense: the real part of the “unknown” impedance is practically independent of frequency and much larger than the imaginary one, the phase in single degrees. The gain, however, is calculated as if the Rcal were 100 kΩ instead of 100 Ω. The attached spreadsheet is modified a bit to account for that.
    XLSX

    The problem is that the absolute values of the “unknown” resistors measuring about 117 and 154 Ω instead of the expected 130 and 200 Ω. It seems too unlikely that not just one, but both “unknown” resistors are so far off from the expected values end even the ratio of the measured values are not what it should be. Which points at the matter of buffering: measuring low impedance may stress the OPAMPs used in the circuit. 2V p-p excitation voltage across 100 corresponds to ±10mA current, which is within the used OPAMPs ±80mA output current capacity, but the slew rate (which is specified at 5V/µs over Rload = 2 kΩ || Cload = 16 pF), may cause distortions in the sinewave as 100 Ω is so substantially higher load than the quoted one. When it comes to measuring low impedance it makes sense programming low excitation voltage into the AD5933, for example, the lowest 198 mV p-p and using Rfb about 10 times larger than it currently is. The currents required then would be 1mA, which should be easier for the OPAMPs to handle and will likely less affect the slew rate. Or/and building a more specialized low impedance circuit by using faster OPAMPs with higher output current rating.