AnsweredAssumed Answered

AD5933 sensor data behavior with impedance measurement

Question asked by greyesgt on Jul 6, 2016
Latest reply on Aug 24, 2016 by Snorlax

Hello, I have an AD5933 with no AFE connected to a microcontroller. My configuration for the AD5933 is: freq=40kHz, Rfb=Rcal=10kohm, voutput=0.4Vpp, vdd=3.3V, gain=1x, internal clock.

 

I recorded several thousand measurements with the AD5933 connected to my object. If I plot my data with lines, everything looks good zoomed out at 5k-6kohm. My readings seem stable just below 5.8kohm. See plot in red.

 

If I plot the same data with an adjusted y-axis between 5.75kohm and 5.81kohm, you get the middle plot in green. However, if I switch to plotting points, it appears the impedance is separated across four "bands" or "modes" with a fairly consistent separation at 5.76k, 5.77k, 5.79k, and 5.8kohms. See blue plot.

 

Figure1.png

 

Is this the expected behavior for the AD5933 and has anyone seen this? If this was supposed to be noise, I would expect it to be less consistent. I've verified my circuit and it's fairly straightforward with sda, scl, vdd, and gnd connections. I'm guessing this is an issue in software or somehow expected behavior. I'm not averaging the impedance measurements as they arrive.

 

This is also happening when we collect impedance measurements and cause dynamic changes in our sample object in a different range (see below).

 

Figure2.png

 

My library and main code is adapted from here:

https://raw.githubusercontent.com/WuMRC/drive/master/AD5933_Library/AD5933.cpp

 

#define start_frequency 40000

#include "AD5933.h"
#include <i2c_t3.h>

const double calResistance = 10000;
const int calsamples = 10;

// double gainFactor = 171547.01;
// double phaseShift = 0.02;

double gainFactor = 0;
double phaseShift = 0;
int count = 0;

void setup()
{
  // Init 
  Serial.begin(115200);
  Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_INT, I2C_RATE_400);
  delay(2000);

  Serial.println("setting clock to internal");
  AD5933.setExtClock(false);

  Serial.println("resetting chip");
  AD5933.resetAD5933();
  
  Serial.println("setting start frequency");
  AD5933.setStartFreq(start_frequency);
  
  Serial.println("initialize with start frequency");
  int ctrReg = AD5933.getByte(0x80);
  ctrReg &= 0x0F;
  ctrReg |= 0x10;
  AD5933.setByte(0x80, ctrReg);

  Serial.println("setting PGA gain");
  AD5933.setPGA(GAIN_1);

  Serial.println("setting range");
  AD5933.setRange(RANGE_3);
  
  Serial.println("getting temperature");
  double temp = AD5933.getTemperature();
  Serial.println("Temperature is " + String(temp) + " degC");

  Serial.println("resetting settling time");
  AD5933.setByte(0x8A, 0x00);  
  AD5933.setByte(0x8B, 0x00);
  
  ctrReg = AD5933.getByte(0x80);
  if (AD5933.setCtrMode(STAND_BY, ctrReg) == false)
  {
    //return false;
  }
  if (AD5933.setCtrMode(INIT_START_FREQ, ctrReg) == false)
  {
    //return false;
  }
  if (AD5933.setCtrMode(START_FREQ_SWEEP, ctrReg) == false)
  {
    //return false;
  }

  // Calibration
  bool status;
  status = AD5933.getGainFactor(calResistance, calsamples, gainFactor, phaseShift, false);
  Serial.print("Gain Factor: ");
  Serial.println(gainFactor);
  Serial.print("System Phase Shift: ");
  Serial.println(phaseShift);
}

void loop()
{
  count++;
  Serial.print(count);
  Serial.print(",");
  Serial.print(millis());
  Serial.print(",");
  measureImpedance();
  Serial.print("\r\n");    
}

void measureImpedance()
{
  double impedanceValue = 0;
  double phaseValue = 0;

  // get impedance and phase
  while ( (AD5933.getStatusReg() & 0x02) != 0x02 ); // Wait until measurement is complete.

  int rComp, iComp;

  byte impData[4];
  AD5933.blockRead(0x94, 4, impData);
  rComp = impData[0] * 16 * 16 + impData[1];
  iComp = impData[2] * 16 * 16 + impData[3];

  double magSq = AD5933.getMag(rComp, iComp);
  impedanceValue = gainFactor / magSq;
  phaseValue = atan2(iComp, rComp) - phaseShift;
  
  // output data
  Serial.print(impedanceValue);
  Serial.print(",");
  Serial.print(phaseValue);
  
  // reset by setting repeat frequency
  AD5933.setCtrMode(REPEAT_FREQ);
}

 

Thanks for your help!

Outcomes