AnsweredAssumed Answered

Measuring impedance with AD5933 and MSP430G2553, but slow

Question asked by slund89 on Nov 6, 2012
Latest reply on Nov 6, 2012 by musach

Hello

 

I'm interfacing the AD5933 with a microcontroller (MSP430G2553), and are making successful readings, both temperature and real/imag data. Unfortunately it takes too much time compared to the USBinterface to the PC. It takes about 10 seconds to make 10 frq increments and readings, and the computer does 100 increments and readings in 1 second.

 

I hope some of you have an idea what i should do different.

 

Kindest regards Simon

 

 

 

The code is as below:

 

void StartFrqSwp(void)

{

    //PROGRAM x Hz to the START FREQUENCY register

    ei_vI2cWriteTwo(Freq_low, StartFrequencybyte0);

    ei_vI2cWriteTwo(Freq_mid, StartFrequencybyte1);

    ei_vI2cWriteTwo(Freq_high, StartFrequencybyte2);

   

    //The sweep is going to have x points in hex

    ei_vI2cWriteTwo(NumInc_low, NumberIncrementbyte0);

    ei_vI2cWriteTwo(NumInc_high, NumberIncrementbyte1);

   

    //The sweep is going to have a frequency increment of x Hz between successive points in the sweep

    ei_vI2cWriteTwo(FreqInc_low, FrequencyIncrementbyte0);

    ei_vI2cWriteTwo(FreqInc_mid, FrequencyIncrementbyte1);

    ei_vI2cWriteTwo(FreqInc_high, FrequencyIncrementbyte2);

   

    //The DDS is going to output 15 cycles of the output excitation voltage before the ADC will start sampling

    //The settling time cycle multiplier is set to x1

    ei_vI2cWriteTwo(NumSettle_low, SettlingTimebyte0);

    ei_vI2cWriteTwo(NumSettle_high, SettlingTimebyte1);

   

    //Standby mode command = B0 hex

    ei_vI2cWriteTwo(Control_high, StandbyMode);

 

    ei_vI2cWriteTwo(Control_low, 0x08);        //Enable external Oscillator

    ei_vI2cWriteTwo(Control_high, 0x01);    //Set the output excitation range to be 2vp-p and the PGA setting to = x1

 

 

    ei_vI2cWriteTwo(Control_high, Reset);    //Initialize Sensor with Start Frequency

    msDelay(2);    

    ei_vI2cWriteTwo(Control_high, 0x20);    //Start Frequency Sweep

}

 

void ReadFrqSwp(void){

    EraseBuffer();

   

    StatusNum = ei_uiI2cRead(Status);

    StatusNum = StatusNum & 0x04;        //00000100 = Frequency sweep complete

   

    while(StatusNum != 0x04 && place_counter<(NumberIncrementbyte0))            //as long as sweep hasn't completed

    {

        StatusNum = ei_uiI2cRead(Status);

        StatusNum = StatusNum & 0x02;    //00000010 = valid real and imaginary data available

       

        while (StatusNum != 0x02){        //(!(ei_uiI2cRead(Status) & 0x02))

            //if(StatusNum == 0x02){

                //do nothing, proceed with sweep

            //}

            //else{

                ei_vI2cWriteTwo(Control_high, 0x40);        //repeat sweep point

            //}

            StatusNum = ei_uiI2cRead(Status);

            StatusNum = StatusNum & 0x02;    //00000010 = valid real and imaginary data available

            remeasures++;

        }

       

        SaveFrqMeas();

        place_counter++;

       

        StatusNum = ei_uiI2cRead(Status);

        StatusNum = StatusNum & 0x04;        //00000100 = Frequency sweep complete

       

        ei_vI2cWriteTwo(Control_high, 0x30);    //Increment to next frequency point

    }

}

 

void SaveFrqMeas(void)

{

    RxBuffer[0] = ei_uiI2cRead(Real_high);

    RxBuffer[1] = ei_uiI2cRead(Real_low);

    RealData = (RxBuffer[0]<<8)+RxBuffer[1];

    if (RealData <= 0x7FFF){

        //number is positive

    }

    else{

        RealData = RealData & 0x7FFF;

        RealData = RealData-65536;

    }

    RealBuffer[place_counter] = RealData;

   

    RxBuffer[0] = ei_uiI2cRead(Imag_high);

    RxBuffer[1] = ei_uiI2cRead(Imag_low);

    ImagData = (RxBuffer[0]<<8)+RxBuffer[1];

    if (ImagData <= 0x7FFF){

        //number is positive

    }

    else{

        ImagData = ImagData & 0x7FFF;

        ImagData = ImagData-65536;

    }

    ImagBuffer[place_counter] = ImagData;

}

Outcomes