void frequencySweepRaw() { // Create variables to hold the impedance data and track frequency int real, imag, i = 0, cfreq = VALUE_fstart / 1000; // Initialize the frequency sweep if (!(AD5933::setPowerMode(POWER_STANDBY) && // place in standby AD5933::setControlMode(CTRL_INIT_START_FREQ) && // init start freq AD5933::setControlMode(CTRL_START_FREQ_SWEEP))) // begin frequency sweep { Serial.println("Could not initialize frequency sweep..."); } // Perform the actual sweep while ((AD5933::readStatusRegister() & STATUS_SWEEP_DONE) != STATUS_SWEEP_DONE) { // Get the frequency data for this frequency point if (!AD5933::getComplexData(&real, &imag)) { Serial.println("Could not get raw frequency data..."); } Serial.print(String(real) + " real"); Serial.print(String(imag) + " imag"); // Compute impedance double magnitude = sqrt(pow(real, 2) + pow(imag, 2)); double impedance = 1 / (magnitude * gain[i]); //Serial.print(" |Z|="); Serial.print(String(impedance) + " impedance"); // Increment the frequency i++; cfreq += VALUE_finc / 1000; AD5933::setControlMode(CTRL_INCREMENT_FREQ); } Serial.println("Frequency sweep complete!"); // Set AD5933 power mode to standby when finished if (!AD5933::setPowerMode(POWER_STANDBY)) Serial.println("Could not set to standby..."); }