Post Go back to editing

ADuCM355 and EVAL-ADuCM355 - issues with 4-electrode sensor

Category: Software
Product Number: EVAL-ADuCM355

Hi everyone,

I am trying to run an M355_ECSns_DualWE example on an EVAL-ADuCM355 board. I adjusted RTIA values, load resistors (RLOAD) and Bias. Jumpers on the eval board are shorted as well (picture below). 

pAmpCfg->SensorCh0.LpTiaRf = LPTIARF_400K; /* 400kohm Rfilter, 4.7uF cap connected external on AIN4 */
pAmpCfg->SensorCh0.LpTiaRl = LPTIARLOAD_50R; /* NO2 sensor datasheet specifies 50ohm Rload */
pAmpCfg->SensorCh0.LptiaRtiaSel = LPTIARTIA_512K; /* LPTIA gain resistor is 512kohm */
pAmpCfg->SensorCh0.Vzero = 1110; /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
pAmpCfg->SensorCh0.SensorBias = 0; /* 0V bias voltage */

//CO Sensor is connected to CH1 on EVAL-ADuCM355QSPZ
pAmpCfg->SensorCh1.LpTiaRf = LPTIARF_400K; /* 400kohm Rfilter */
pAmpCfg->SensorCh1.LpTiaRl = LPTIARLOAD_50R; /* 50 ohm rload */
pAmpCfg->SensorCh1.LptiaRtiaSel = LPTIARTIA_512K; /* Tia gain resistor is 512kohm */

Output for the CH0 is correct and the sensor seems to respond to humidity / temperature changes, however CH1 seems to be unresponsive (Picture 2 below). Looking at the Calibrated Rtia could show the reason why is that, but I am not sure what is causing the calibration for channel 1 be so low and differ that much from channel 0.

Any help or guidance would be appreciated.

Best,

Michal

Picture 1. Jumpers for 4-electrode connection

Picture 2. Eval board output for M355_ECSns_DualWE example

Parents
  • Hi,

    Are you using the same Vzero for both channels (i.e., same LPDAC for both channels)?

    if(SnsSel == M355_CHAN0)
    {
    LPDAC_SEL = LPDAC0;
    LPAMP_SEL = LPAMP0;
    }
    else if(SnsSel == M355_CHAN1)
    {
    LPDAC_SEL = LPDAC1;
    LPAMP_SEL = LPAMP1;
    }

    ......

    ......

    .....

    AD5940_ADCMuxCfgS(ADCMUXP_AIN4, ADCMUXN_VZERO0);

    ......

    AD5940_ADCMuxCfgS(ADCMUXP_LPTIA1_P, ADCMUXN_VZERO1);

    Below is the code for M355_ECSns_EIS_ FOR 2 CHANNELS:

    /**
     *****************************************************************************
       @addtogroup EC sensor
       @{
       @file     M355_ECSns_EIS.c
       @brief    Electrochemical Impedance Spectroscopy.
       @par Revision History:
       @version  V0.6
       @author   ADI
       @date     December 2018
       @par Revision History:
       - V0.1, April 28th 2017: initial version.
       - V0.2, June 23rd 2017:
          - Enable ADC input buffer chop for measurements up to 80kHz
          - Disable ADC input buffer chop for measurements >80kHz
       - V0.3, March 2018:
          - Register/bit naming changes
          - HS DAC update calculation changes
       - V0.4, July 2018:
          - Added check of AFEDIESTA at startup.
       - V0.5, September 2018
          - Modified low frequency settings
          - Added support for 0.1 and 0.5Hz measurements
       - V0.6, December 2018
          - Added Real/Imag component of magnitude for Nyquist plots
    
       Decription:
         -- UART baud rate 57600, 8 data bit, 1 stop bit
         -- EIS test selects a few frequencies from .016Hz to 200KHz. Enabling low frequencies will lead measurement to take several minutes.
         -- EC gas sensor required to be connected to channel 0 or star resistor model as alternative
         -- For a biased sensor, set macro EIS_DCBIAS_EN to 1. This sets a 600 mV bias. To change bias, set Vzero and Vbias in main().
         -- For 2 lead sensor, set macro EN_2_LEAD to 1. Connect 2 lead sensor across CE0-SE0.
         -- "Frequency, Magnitude, Phase, Real component of magnitude, Imag component of magnitude" is printed to UART. This can be stored for later analysis.
    
    All files for ADuCM355 provided by ADI, including this file, are
    provided  as is without warranty of any kind, either expressed or implied.
    The user assumes any and all risk from the use of this code.
    It is the responsibility of the person integrating this code into an application
    to ensure that the resulting application performs as required and is safe.
    
    **/
    #include "M355_ECSns_EIS.h"
    #include "M355_ECSns_DCTest.h"
    
    #include <math.h>
    
    /*
       Uncomment macro below to add DC bias for biased sensor(ex. O2 sensor) Impedance measuremnt
       bias voltage is configured by SnsInit,which means (VBIAS-VZERO) will be added to excitaion sinewave as a DC offset.
       1 - EIS for biased gas sensor
       0 - EIS for none-biased gas sensor
    */
    #define EIS_DCBIAS_EN   0
    
    /*
        Configure measurement for 2/3 lead sensor
        0 - 3 lead sensor
        1 - 2 lead sensor
    */
    #define EN_2_LEAD   0
    
    void ClockInit(void);
    void UartInit(void);
    void GPIOInit(void);
    void ChargeECSensor(void);
    char getcmd(void);
    void emptycmdfifo(void);
    
    volatile uint8_t dftRdy = 0;
    volatile uint32_t ucButtonPress =0 ;
    volatile char cmd_input;
    volatile int channel = 0;  //Assume CHAN0 is measurement channel at P-On
    SNS_CFG_Type * pSnsCfg0;
    SNS_CFG_Type * pSnsCfg1;
    volatile uint32_t u32AFEDieStaRdy = 0;         // Variable used to load AFEDIESTA
    float FCW_Val = 0;
    /*
       user can modify frequency of impedance measurement
    */
    ImpResult_t ImpResult[] =
    {
    // low frequency measurement takes longer because of big period 
    //   {10,{0,0,0,0},0,0},
    //   {20,{0,0,0,0},0,0},
    //   {50,{0,0,0,0},0,0},
    //   {125,{0,0,0,0},0,0},
    //   {146,{0,0,0,0},0,0},
    //   {171,{0,0,0,0},0,0},
    //   {199,{0,0,0,0},0,0},
    //   {233,{0,0,0,0},0,0},  
    //   {272,{0,0,0,0},0,0},
    //   {318,{0,0,0,0},0,0},
    //   {371,{0,0,0,0},0,0},
    //   {433,{0,0,0,0},0,0},
    //   {506,{0,0,0,0},{0},0,0},
    //   {591,{0,0,0,0},{0},0,0},
    //   {690,{0,0,0,0},{0},0,0},
    //   {806,{0,0,0,0},{0},0,0},
    //   {942,{0,0,0,0},{0},0,0},      
    //   {1100,{0,0,0,0},{0},0,0},
    //   {1285,{0,0,0,0},{0},0,0},
    //   {1501,{0,0,0,0},{0},0,0},
    //   {1754,{0,0,0,0},{0},0,0},
    //   {2049,{0,0,0,0},{0},0,0},
    //   {2393,{0,0,0,0},{0},0,0},
    //   {2795,{0,0,0,0},{0},0,0},      
    //   {3265,{0,0,0,0},{0},0,0},
    //   {3814,{0,0,0,0},{0},0,0},
    //   {4455,{0,0,0,0},{0},0,0},
    //   {5203,{0,0,0,0},{0},0,0},
       {10000,{0,0,0,0},{0},0,0},
       {11220,{0,0,0,0},{0},0,0},
       {12589,{0,0,0,0},{0},0,0},      
       {14125,{0,0,0,0},{0},0,0},
       {15849,{0,0,0,0},{0},0,0},
       {17783,{0,0,0,0},{0},0,0},
       {19953,{0,0,0,0},{0},0,0},
       {22387,{0,0,0,0},{0},0,0},
       {25119,{0,0,0,0},{0},0,0},
       {28184,{0,0,0,0},{0},0,0},      
       {31623,{0,0,0,0},{0},0,0},
       {35481,{0,0,0,0},{0},0,0},
       {39811,{0,0,0,0},{0},0,0},
       {44668,{0,0,0,0},{0},0,0},
       {50119,{0,0,0,0},{0},0,0},
       //user can add frequency option here
    };
    
    void main(void)
    {
      
    #if EIS_DCBIAS_EN //add bias voltage. Setup for O2 sensor 600mV bias
       //Bias = Vzero - Vbias
       if((pSnsCfg0->Enable == SENSOR_CHANNEL_ENABLE))
       {
          pSnsCfg0->Vzero = 1500;
          pSnsCfg0->Vbias = 900;
       }
       if((pSnsCfg1->Enable == SENSOR_CHANNEL_ENABLE))
       {
         pSnsCfg1->Vzero = 1500;
         pSnsCfg1->Vbias = 900;
       }
    #endif
      
       u32AFEDieStaRdy = AfeDieSta();              // Check if Kernel completed correctly before accessing AFE die             
       if ((u32AFEDieStaRdy & 1) == 1)             // Kernel initialization of AFE die was not successful
       { 
         UartInit();                               // Initialize UART for 57600-8-N-1
         printf("AFE DIE Failure" EOL);
         while(u32AFEDieStaRdy == 1)               // AFE die has not initialized correctly.
         {}                                        // trap code here 
       }
       AfeWdtGo(false);                            // Turn off AFE watchdog timer for debug purposes
       GPIOInit();                                 // init GPIO pins
       ClockInit();                                // Init system clock sources
       UartInit();                                 // Init UART for 57600-8-N-1
    
    // Power-on will assume CHAN0 is measurment channel   
       pSnsCfg0 = getSnsCfg(CHAN0);
       pSnsCfg1 = getSnsCfg(CHAN1);
       if((pSnsCfg0->Enable == SENSOR_CHANNEL_ENABLE))
       {
    //      printf("Sensor Initializing Ch0...");
          SnsInit(pSnsCfg0);
          for(uint32_t i=0;i<5000;i++)delay_10us(100);
    //      printf("Finish" EOL);
       }
       if((pSnsCfg1->Enable == SENSOR_CHANNEL_ENABLE))
       {
    //      printf("Sensor Initializing Ch1...");
          SnsInit(pSnsCfg1);
          for(uint32_t i=0;i<5000;i++)delay_10us(100);
    //      printf("Finish" EOL);
       }
    
       ChargeECSensor();
    
       while(1)
       {
          cmd_input = getcmd();  // first ch represents command
          cmd_input |= 0x20;
          if( cmd_input=='g' ) //Press S2
          {
             if( channel==0 )
             {
    //            printf("\n\rStarting Test CH0");
                SnsACInit(CHAN0);
                SnsACTest(CHAN0);
             }
             else 
             {
    //            printf("\n\rStarting Test CH1");
                SnsACInit(CHAN1);
                SnsACTest(CHAN1);
             }
    
             SnsMagPhaseCal();   //calculate impedance
             
             /*power off high power exitation loop if required*/
             AfeAdcIntCfg(NOINT); //disable all ADC interrupts
             NVIC_DisableIRQ(AFE_ADC_IRQn);
             AfeWaveGenGo(false);
             AfeHPDacPwrUp(false);
             AfeHpTiaPwrUp(false);
    
             /*print Impedance result*/
             printf("\x02");                // printf STX
             printf("Freq,MAG,PHASE,Re_Mag,Im_Mag"EOL);
             for(uint32_t i=0;i<sizeof(ImpResult)/sizeof(ImpResult_t);i++)
             {
                printf("%5.f,%.4f,%.4f,%.4f,%.4f"EOL,ImpResult[i].freq, 
                                                     ImpResult[i].Mag,            
                                                     ImpResult[i].Phase,
                                                     ImpResult[i].Re_Mag,
                                                     ImpResult[i].Im_Mag);
             }
             printf("\x03");                // print ETX
          }
          else if( cmd_input=='i' )  //initialize the AFE again
          {
             if( channel==0 )
             {
                pSnsCfg0 = getSnsCfg(CHAN0);  // Channel 0 now on
                pSnsCfg1 = getSnsCfg(CHAN1);
             }
             else
             {
                pSnsCfg0 = getSnsCfg(CHAN1);   // Channel 1 now on
                pSnsCfg1 = getSnsCfg(CHAN0);
             }
             if((pSnsCfg0->Enable == SENSOR_CHANNEL_ENABLE))
             {
    //            printf("Sensor Initializing Ch0...");
                SnsInit(pSnsCfg0);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p"EOL);
             }
             if((pSnsCfg1->Enable == SENSOR_CHANNEL_ENABLE))
             {
    //            printf("Sensor Initializing Ch1...");
                SnsInit(pSnsCfg1);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p" EOL);
             }
          }
          else if( cmd_input=='1' )   // set to use CHAN0
          {
             channel = 0;
             pSnsCfg0 = getSnsCfg(CHAN0);   // Channel 0 now on
             pSnsCfg1 = getSnsCfg(CHAN1);
             if((pSnsCfg0->Enable == SENSOR_CHANNEL_ENABLE))
             {
     //           printf("Sensor Initializing Ch0...");
                SnsInit(pSnsCfg0);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p" EOL);
             }
             if((pSnsCfg1->Enable == SENSOR_CHANNEL_ENABLE))
             {
    //            printf("Sensor Initializing Ch1...");
                SnsInit(pSnsCfg1);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p" EOL);
             }
          }
          else if( cmd_input=='2' )   // set to use CHAN1
          {
             channel = 1;
             pSnsCfg0 = getSnsCfg(CHAN1);
             pSnsCfg1 = getSnsCfg(CHAN0);  //Channel 1 now on
             if((pSnsCfg0->Enable == SENSOR_CHANNEL_ENABLE))
             {
    //            printf("Sensor Initializing Ch0...");
                SnsInit(pSnsCfg0);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p" EOL);
             }
             if((pSnsCfg1->Enable == SENSOR_CHANNEL_ENABLE))
             {
    //            printf("Sensor Initializing Ch1...");
                SnsInit(pSnsCfg1);
                for(uint32_t i=0;i<5000;i++)delay_10us(100);
                printf("p" EOL);
             }
          }
          else printf("f"EOL);
       }
    }
    // On initialization, this function is called to temporarily close SW1 in the Low Power loop.
    // This results in the LPTIA output being shorted to its input.
    // For a short duration, the amplifier can handle this
    // This greatly speeds up the settling time of the gas sensor.
    void ChargeECSensor(void)
    {
      pADI_AFE->LPTIASW0 |= 0x2;                   // Close SW1 in LP loop to shot LPTIA0 output to inverting input
      delay_10us(400000);                          // delay 4S 
      pADI_AFE->LPTIASW0 &= ~(0x2);                // Open SW1 in LP loop to shot LPTIA0 output to inverting input
    }
    void GPIOInit(void)
    {
       /*S2 configuration*/
       DioCfgPin(pADI_GPIO1,PIN0,0); //configure as gpio
       DioIenPin(pADI_GPIO1,PIN0,1); //enable input
       DioPulPin(pADI_GPIO1,PIN0,1);  //enable pull-up
       DioIntPolPin(pADI_GPIO1,PIN0,1);           // Set polarity of P1.0 interrupt to low-high transition
       DioIntPin(pADI_GPIO1,PIN0,INTA,1);         // Enable External interrupt A on P1.0
       NVIC_EnableIRQ(SYS_GPIO_INTA_IRQn);         // Enable GPIO_INTA interrupt source in NVIC
    }
    
    /**
       @brief uint8_t SnsACInit(uint8_t channel)
              Initialization for AC test, setup wave generation and switches
       @param channel :{CHAN0,CHAN1}
          - 0 or CHAN0, Sensor channel 0
          - 1 or CHAN1, Sensor channel 1
       @return 1.
    */
    uint8_t SnsACInit(uint8_t channel)
    {
       uint32_t ctia;
       /*DFT interrupt enable*/
       AfeAdcIntCfg(BITM_AFE_ADCINTIEN_DFTRDYIEN);
       NVIC_EnableIRQ(AFE_ADC_IRQn);
       /******setup exitation loop and TIA********/
       AfeHpTiaPwrUp(true);
       AfeHpTiaCon(HPTIABIAS_1V1); /*Normal power mode, 1.1V biased HP TIA*/
       AfeSwitchFullCfg(SWITCH_GROUP_T,SWID_T9);
       ctia = BITM_HPTIA_CTIA_16PF|BITM_HPTIA_CTIA_8PF|BITM_HPTIA_CTIA_4PF| \
                BITM_HPTIA_CTIA_2PF|BITM_HPTIA_CTIA_1PF;
       //AfeHpTiaSeCfg(HPTIASE_RTIA_5K,ctia,0);   /*rtia,ctia,no diosel*/
       AfeHpTiaSeCfg(HPTIASE_RTIA_1K,ctia,0);   /*reduce gain for PGA = 4*/
       AfeHpTiaDeCfg(CHAN0,HPTIADE_RLOAD_OPEN,HPTIADE_RTIA_OPEN);
       AfeHpTiaDeCfg(CHAN1,HPTIADE_RLOAD_OPEN,HPTIADE_RTIA_OPEN);
       /*switch to RCAL, loop exitation before power up*/
       AfeSwitchDPNT(SWID_DR0_RCAL0,SWID_PR0_RCAL0,SWID_NR1_RCAL1,SWID_TR1_RCAL1|SWID_T9);
       /*********Initialize ADC and DFT********/
       /*ADC initialization*/
       AfeAdcFiltCfg(SINC3OSR_5,SINC2OSR_178,LFPBYPEN_NOBYP,ADCSAMPLERATE_800K); //900Hz as default
       AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW50);
       AfeAdcPgaCfg(GNPGA_4,0);
       AfeAdcChan(MUXSELP_HPTIA_P,MUXSELN_HPTIA_N);
       AfeAdcChopEn(1);   //Enable ADC input buffer chop for LP mode (up to 80kHz)
        /********sinewave generation**********/
       AfeHPDacPwrUp(true);
       /*DAC attenuator = 1/5, Excitaion Amplifier Gain=1/4,DAC update rate = 320KHz,bandwidth=50KHz*/
       AfeHPDacCfg(HPDAC_ATTEN_DIV5,HPDAC_RATE_REG,HPDAC_INAMPGAIN_DIV4);
       AfeHPDacSineCfg(SINE_FREQ_REG,0,SINE_OFFSET_REG,SINE_AMPLITUDE_REG);
       AfeHPDacWgType(HPDAC_WGTYPE_SINE);
       return 1;
    }
    
    /**
       @brief uint8_t SnsACSigChainCfg(float freq)
             ======== configuration of AC signal chain depends on required excitation frequency.
       @param freq :{}
                - excitation AC signal frequency
       @return 1.
       @note settings including DAC update rate, ADC update rate and DFT samples can be adjusted for
       different excitation frequencies to get better performance. As general guidelines,
           - DAC update rate: make sure at least 4 points per sinewave period. Higher rate comsumes more power.
           - ADC update rate:  at least follow Nyquist sampling rule.
           - DFT samples should cover more than 1 sine wave period. more DFT sample reduce variation but take longer time.
              the configuration can be optimised depending on user's applicationn
    */
    uint8_t SnsACSigChainCfg(float freq)
    {
       uint16_t DacCon;
       uint32_t WgFreqReg;
    
       DacCon = pADI_AFE->HSDACCON;
       DacCon &= (~BITM_AFE_HSDACCON_RATE);  //clear rate bits for later setting
      // WgFreqReg = (uint32_t)((((uint64_t)freq)<<30)/16000000.0+0.5);  //ATE version 0x14
       //WgFreqReg = (uint32_t)((((uint64_t)freq)<<26)/16000000.0+0.5); //ATE version less than 0x03
       if (freq < .11){
          
          ClkDivCfg(1,1);                       // digital die to 26MHz 
          AfeHFOsc32M(0x0);                       //AFE oscillator change to 16MHz
          AfeSysClkDiv(AFE_SYSCLKDIV_1);        //AFE system clock remain in 16MHz
    
          AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW250);       
          AfeHpTiaCon(HPTIABIAS_1V1);
          
          
         
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= (0x1b<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for LP mode   
          
          
          pADI_AFE->AFECON &= (~(BITM_AFE_AFECON_SINC2EN));          // Clear the SINC2 filter to flush its contents
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_SINC2EN;               // re-enable SINC2 filter
          
          AfeAdcFiltCfg(SINC3OSR_4,
                        SINC2OSR_1067,
                        LFPBYPEN_BYP,
                        ADCSAMPLERATE_800K); // Configure ADC update = 800KSPS/5 = 200KSPS SINC3 output. 200K/800, SINC2 O/P = 250 SPS
          
          //DFT source: supply filter output. 
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN;// re-enable DFT
                
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,
                       DFTNUM_16384,
                       DFTIN_SINC2); // DFT input is from SINC2 filter. 16384 * (1/250) = 65.5 seconds to fill
          
          FCW_Val = (((freq/16000000)*1073741824)+0.5);
          WgFreqReg = (uint32_t)FCW_Val; 
       }
       
       else if (freq < .51){
          
          ClkDivCfg(1,1);                       // digital die to 26MHz 
          AfeHFOsc32M(0x0);                       //AFE oscillator change to 16MHz
          AfeSysClkDiv(AFE_SYSCLKDIV_1);        //AFE system clock remain in 16MHz
    
          AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW250);       
          AfeHpTiaCon(HPTIABIAS_1V1);
          
         
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= (0x1b<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for LP mode   
          
          pADI_AFE->AFECON &= (~(BITM_AFE_AFECON_SINC2EN));          // Clear the SINC2 filter to flush its contents
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_SINC2EN;               // re-enable SINC2 filter
          
          AfeAdcFiltCfg(SINC3OSR_4,
                        SINC2OSR_640,
                        LFPBYPEN_BYP,ADCSAMPLERATE_800K); // Configure ADC update = 800KSPS/5 = 160KSPS SINC3 output. 160K/640, SINC2 O/P = 250 SPS
          
          //DFT source: supply filter output. 
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN;// re-enable DFT
          
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,
                       DFTNUM_8192,
                       DFTIN_SINC2);// DFT input is from SINC2 filter. 2048 * (1/250) = 8.2 seconds to fill
          
          WgFreqReg = 0x21; //(.5Hz * 2^30)/16MHz = 33 (0x21)
          FCW_Val = (((freq/16000000)*1073741824)+0.5);
          WgFreqReg = (uint32_t)FCW_Val; 
       }
       
       else if(freq<5)   
       {
          ClkDivCfg(1,1);                          // digital die to 26MHz 
          AfeHFOsc32M(0);                          // AFE oscillator change to 16MHz
          AfeSysClkDiv(AFE_SYSCLKDIV_1);           // AFE system clock remain in 16MHz
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= 
            (0x1b<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for LP mode   
          AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW250);       
    		AfeHpTiaCon(HPTIABIAS_1V1);
    
          pADI_AFE->AFECON &= (~(BITM_AFE_AFECON_SINC2EN)); // Clear the SINC2 filter
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_SINC2EN;
       
          AfeAdcFiltCfg(SINC3OSR_4,
                        SINC2OSR_533,LFPBYPEN_BYP,
                        ADCSAMPLERATE_800K);       // Configure ADC update = 800KSPS/4 = 200KSPS SINC3 output. 200K/533, SINC2 O/P = 375 SPS
          //DFT source: supply filter output. 
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN;// re-enable DFT
        
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,  // DFT input is from SINC2 filter. 8192 * (1/375) = 21.83 seconds to fill
                       DFTNUM_8192,
                       DFTIN_SINC2);
          FCW_Val = (((freq/16000000)*1073741824)+0.5);
          WgFreqReg = (uint32_t)FCW_Val;                     
        }
       else if(freq<450)   /*frequency lower than 450 Hz*/
       {
          ClkDivCfg(1,1);                          // digital die to 26MHz 
          AfeHFOsc32M(0);                          // AFE oscillator change to 16MHz
          AfeSysClkDiv(AFE_SYSCLKDIV_1);           // AFE system clock remain in 16MHz
         
          AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW250);       
    		AfeHpTiaCon(HPTIABIAS_1V1);
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= 
            (0x1b<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for LP mode   
          /*ADC 900sps update rate to DFT engine*/
          pADI_AFE->AFECON &= 
            (~(BITM_AFE_AFECON_SINC2EN));          // Clear the SINC2 filter to flush its contents
          delay_10us(50);
          pADI_AFE->AFECON |= 
            BITM_AFE_AFECON_SINC2EN;               // re-enable SINC2 filter
          AfeAdcFiltCfg(SINC3OSR_4,
                        SINC2OSR_178,LFPBYPEN_BYP,
                        ADCSAMPLERATE_800K);       // Configure ADC update = 800KSPS/4 = 200KSPS SINC3 output. 200K/178, SINC2 O/P = 1123 SPS
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN;// re-enable DFT
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,  // DFT input is from SINC2 filter. 4096 * (1/1123) = 3.64 seconds to fill
                       DFTNUM_4096,
                       DFTIN_SINC2);
          FCW_Val = (((freq/16000000)*1073741824)+0.5);
          WgFreqReg = (uint32_t)FCW_Val; 
       }
       else if(freq<80000)  /*450Hz < frequency < 80KHz*/
       {
         ClkDivCfg(1,1);                           // digital die to 26MHz 
         AfeHFOsc32M(0);                           // AFE oscillator change to 16MHz
         AfeSysClkDiv(AFE_SYSCLKDIV_1);            // AFE system clock remain in 16MHz  
          /*set middle DAC update rate,16MHz/18=~888KHz update rate,skew the DAC and ADC clocks with respect to each other*/
          AfeSysCfg(ENUM_AFE_PMBW_LP,ENUM_AFE_PMBW_BW250);   
    		AfeHpTiaCon(HPTIABIAS_1V1);
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= 
            (0x1b<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for LP mode   
          /*ADC 160Ksps update rate to DFT engine*/
          pADI_AFE->AFECON &= 
            (~(BITM_AFE_AFECON_SINC2EN));          // Clear the SINC2 filter to flush its contents
          delay_10us(50);
          pADI_AFE->AFECON |= 
            BITM_AFE_AFECON_SINC2EN;               // re-enable SINC2 filter
          AfeAdcFiltCfg(SINC3OSR_4,SINC2OSR_178,
                        LFPBYPEN_BYP,
                        ADCSAMPLERATE_800K);      //bypass LPF, 200KHz ADC update rate
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN;// re-enable DFT
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,
                       DFTNUM_16384,
                       DFTIN_SINC3);               //DFT source: Sinc3 result. 16384 * (1/200000) = 81.92mS
         FCW_Val = (((freq/16000000)*1073741824)+0.5);
          WgFreqReg = (uint32_t)FCW_Val; 
       }
       else/*80KHz < frequency < 200KHz*/
       {
          /*****boost ADC sample rate to 1.6MHz****/
          AfeAdcChopEn(0);  //Disable ADC input buffer chop for HP mode (>80kHz)
          AfeSysCfg(ENUM_AFE_PMBW_HP,ENUM_AFE_PMBW_BW250);   //set High speed DAC and ADC in high power mode
    		 AfeHpTiaCon(HPTIABIAS_1V1);
          ClkDivCfg(2,2);
          AfeSysClkDiv(AFE_SYSCLKDIV_2);   //AFE system clock remain in 8MHz
          AfeHFOsc32M(BITM_AFE_HPOSCCON_CLK32MHZEN);   //AFE oscillator change to 32MHz
          ClkDivCfg(1,1);
          /*set High DAC update rate,16MHz/9=~1.6MHz update rate,skew the DAC and ADC clocks with respect to each other*/
          DacCon &= 0xFE01;                        // Clear DACCON[8:1] bits
          DacCon |= 
            (0x07<<BITP_AFE_HSDACCON_RATE);        // Set DACCLK to recommended setting for HP mode   
          /*ADC 400Ksps update rate to DFT engine*/
          pADI_AFE->AFECON &= 
            (~(BITM_AFE_AFECON_SINC2EN));          // Clear the SINC2 filter to flush its contents
          delay_10us(50);
          pADI_AFE->AFECON |= 
            BITM_AFE_AFECON_SINC2EN;               // re-enable SINC2 filter
          AfeAdcFiltCfg(SINC3OSR_2,SINC2OSR_178,LFPBYPEN_BYP,ADCSAMPLERATE_1600K); //800KHz ADC update rate
          pADI_AFE->AFECON &=
            (~(BITM_AFE_AFECON_DFTEN));            // Clear DFT enable bit
          delay_10us(50);
          pADI_AFE->AFECON |= 
            BITM_AFE_AFECON_DFTEN;                 // re-enable DFT
          AfeAdcDFTCfg(BITM_AFE_DFTCON_HANNINGEN,
                       DFTNUM_16384,DFTIN_SINC3); //DFT source: Sinc3 result 16384 * (1/800000) = 20.48mS
         FCW_Val = (((freq/16000000)*1073741824)+0.5);
         WgFreqReg = (uint32_t)FCW_Val;
       }
       pADI_AFE->HSDACCON = DacCon;
       AfeHPDacSineCfg(WgFreqReg,0,SINE_OFFSET_REG,SINE_AMPLITUDE_REG);  //set new frequency
       return 1;
    }
    
    /**
       @brief uint8_t SnsACTest(uint8_t channel)
              start AC test
       @param channel :{CHAN0,CHAN1}
          - 0 or CHAN0, Sensor channel 0
          - 1 or CHAN1, Sensor channel 1
       @param pDFTData :{}
          - pointer to DFT result:6x word
       @return 1.
    */
    uint8_t SnsACTest(uint8_t channel)
    {
       uint32_t freqNum = sizeof(ImpResult)/sizeof(ImpResult_t);
       for(uint32_t i=0;i<freqNum;i++)
       {
          SnsACSigChainCfg(ImpResult[i].freq);
          pADI_AFE->AFECON &= ~(BITM_AFE_AFECON_WAVEGENEN|BITM_AFE_AFECON_EXBUFEN|   \
                               BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN); //disable loop before switching
          /*********Sensor+Rload AC measurement*************/
          /*break LP TIA connection*/
          AfeLpTiaSwitchCfg(channel,SWMODE_AC);  /*LP TIA disconnect sensor for AC test*/
    #if EIS_DCBIAS_EN //add bias voltage to excitation sinewave
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DACBUFEN;   //enable DC buffer for excitation loop
          if(channel>0)
          {
             pADI_AFE->DACDCBUFCON = ENUM_AFE_DACDCBUFCON_CHAN1;   //set DC offset using LP DAC1
          }
          else
          {
             pADI_AFE->DACDCBUFCON = ENUM_AFE_DACDCBUFCON_CHAN0;   //set DC offset using LP DAC0
          }
    #endif
    
          /*switch to sensor+rload*/
          if(channel>0)
          {
             /*disconnect RTIA to avoid RC filter discharge*/
             AfeLpTiaCon(CHAN1,pSnsCfg1->Rload,LPTIA_RGAIN_DISCONNECT,pSnsCfg1->Rfilter);
             
    #if EN_2_LEAD
            AfeSwitchDPNT(SWID_D6_CE1,SWID_P12_CE1,SWID_N7_SE1RLOAD,SWID_T7_SE1RLOAD|SWID_T9);  
    #else
            AfeSwitchDPNT(SWID_D6_CE1,SWID_P6_RE1,SWID_N7_SE1RLOAD,SWID_T7_SE1RLOAD|SWID_T9); 
    #endif
            
          }
          else
          {
             /*disconnect RTIA to avoid RC filter discharge*/
             AfeLpTiaCon(CHAN0,pSnsCfg0->Rload,LPTIA_RGAIN_DISCONNECT,pSnsCfg0->Rfilter);
             
    #if EN_2_LEAD
            AfeSwitchDPNT(SWID_D5_CE0,SWID_P11_CE0,SWID_N5_SE0RLOAD,SWID_T5_SE0RLOAD|SWID_T9);  
    #else
            AfeSwitchDPNT(SWID_D5_CE0,SWID_P5_RE0,SWID_N5_SE0RLOAD,SWID_T5_SE0RLOAD|SWID_T9);
    #endif
            
          }
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN|BITM_AFE_AFECON_SINC2EN|BITM_AFE_AFECON_WAVEGENEN| \
                               BITM_AFE_AFECON_EXBUFEN|BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN;
          delay_10us(30);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN;
          delay_10us(20);   //200us for switch settling
          /*start ADC conversion and DFT*/
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN|BITM_AFE_AFECON_ADCCONVEN;
          while(!dftRdy)
          {
             PwrCfg(ENUM_PMG_PWRMOD_FLEXI,0,BITM_PMG_SRAMRET_BNK2EN);
          }
          dftRdy = 0;
          ImpResult[i].DFT_result[0] = convertDftToInt(pADI_AFE->DFTREAL);
          ImpResult[i].DFT_result[1] = convertDftToInt(pADI_AFE->DFTIMAG);
          /***************Rload AC measurement*************/
          pADI_AFE->AFECON &= ~(BITM_AFE_AFECON_WAVEGENEN|BITM_AFE_AFECON_EXBUFEN|   \
                               BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN); //disable loop before switching
          if(channel>0)
          {
             /*this stage measures Rload by disconnecting CE1 from D terminal - D terminal connected to Rload directly */
             AfeSwitchDPNT(SWID_D8_WE1,SWID_P9_WE1,SWID_N7_SE1RLOAD,SWID_T7_SE1RLOAD|SWID_T9);
          }
          else
          {
             /*this stage measures Rload by disconnecting CE0 from D terminal - D terminal connected to Rload directly */
             AfeSwitchDPNT(SWID_D7_WE0,SWID_P7_WE0,SWID_N5_SE0RLOAD,SWID_T5_SE0RLOAD|SWID_T9);
          }
          /*switch to rload*/
    #if EIS_DCBIAS_EN //add bias voltage to excitation sinewave
          pADI_AFE->AFECON &= ~BITM_AFE_AFECON_DACBUFEN;   //Disable DC buffer for excitation loop
    #endif
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN|BITM_AFE_AFECON_SINC2EN|BITM_AFE_AFECON_WAVEGENEN| \
                               BITM_AFE_AFECON_EXBUFEN|BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN;
          delay_10us(30);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN;
          delay_10us(20);   //200us for switch settling
          /*start ADC conversion and DFT*/
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN|BITM_AFE_AFECON_ADCCONVEN;
          while(!dftRdy)
          {
             PwrCfg(ENUM_PMG_PWRMOD_FLEXI,0,BITM_PMG_SRAMRET_BNK2EN);
          }
          dftRdy = 0;
          ImpResult[i].DFT_result[2] = convertDftToInt(pADI_AFE->DFTREAL);
          ImpResult[i].DFT_result[3] = convertDftToInt(pADI_AFE->DFTIMAG   );
          /************RCAL AC measurement***************/
          pADI_AFE->AFECON &= ~(BITM_AFE_AFECON_WAVEGENEN|BITM_AFE_AFECON_EXBUFEN|   \
                               BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN); //disable loop before switching
          /*switch to RCAL, loop exitation before power up*/
          AfeSwitchDPNT(SWID_DR0_RCAL0,SWID_PR0_RCAL0,SWID_NR1_RCAL1,SWID_TR1_RCAL1|SWID_T9);
          AfeLpTiaSwitchCfg(channel,SWMODE_NORM);  //LP TIA normal working mode
          if(channel>0)
          {
             AfeLpTiaCon(CHAN1,pSnsCfg1->Rload,pSnsCfg1->Rtia,pSnsCfg1->Rfilter);//connect RTIA
          }
          else
          {
             AfeLpTiaCon(CHAN0,pSnsCfg0->Rload,pSnsCfg0->Rtia,pSnsCfg0->Rfilter);//connect RTIA
          }
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN|BITM_AFE_AFECON_SINC2EN|BITM_AFE_AFECON_WAVEGENEN| \
                               BITM_AFE_AFECON_EXBUFEN|BITM_AFE_AFECON_INAMPEN|BITM_AFE_AFECON_TIAEN;
          delay_10us(30);
          pADI_AFE->AFECON |= BITM_AFE_AFECON_ADCEN;
          delay_10us(20);   //200us for switch settling
          /*start ADC conversion and DFT*/
          pADI_AFE->AFECON |= BITM_AFE_AFECON_DFTEN|BITM_AFE_AFECON_ADCCONVEN;
          while(!dftRdy)
          {
             PwrCfg(ENUM_PMG_PWRMOD_FLEXI,0,BITM_PMG_SRAMRET_BNK2EN);
          }
          dftRdy = 0;
          ImpResult[i].DFT_result[4] = convertDftToInt(pADI_AFE->DFTREAL);
          ImpResult[i].DFT_result[5] = convertDftToInt(pADI_AFE->DFTIMAG   );
          /**********recover LP TIA connection to maintain sensor*********/
          AfeSwitchDPNT(SWID_ALLOPEN,SWID_ALLOPEN,SWID_ALLOPEN,SWID_ALLOPEN);
          AfeWaveGenGo(false);
       }
    
       return 1;
    }
    
    
    /**
       @brief uint8_t SnsMagPhaseCal()
              calculate magnitude and phase of sensor
       @param pDFTData : {}
          - input array which stored 6 DFT data
       @param RMag :{}
          - calculated Magnitude of sensor
       @param RPhase :{}
          - calulated Phase of sensor
       
       @return 1.
    */
    uint8_t SnsMagPhaseCal()
    {
       float Src[8];
       //float Mag[4];
       float Phase[4];
       float Var1,Var2;
    
    
       uint32_t testNum = sizeof(ImpResult)/sizeof(ImpResult_t);
       for(uint32_t i=0;i<testNum;i++)
       {
          for (uint8_t ix=0;ix<6;ix++)
          {
             Src[ix] = (float)(ImpResult[i].DFT_result[ix]); // Load DFT Real/Imag results for RCAL, RLOAD, RLOAD+RSENSE into local array for this frequency 
          }
          
          // The impedance engine inside of AD594x give us Real part and Imaginary part of DFT. Due to technology used, the Imaginary 
          // part in register is the opposite number. So we add a negative sign on the Imaginary part of results. 
       
          for (uint8_t ix=1;ix<6;ix+=2)
          {
             Src[ix] = - Src[ix];
          }
          
          Src[6] = (float)(Src[2]-Src[0]);                   // RLoad(real)-RSensor+load(real)
          Src[7] = (float)(Src[3]-Src[1]);                   // RLoad(Imag)-RSensor+load(Imag)
          
          for (uint8_t ix=0;ix<4;ix++)
          {
             ImpResult[i].DFT_Mag[ix] = Src[ix*2]*Src[ix*2]+Src[ix*2+1]*Src[ix*2+1];
             ImpResult[i].DFT_Mag[ix] = sqrt(ImpResult[i].DFT_Mag[ix]);
             
             Phase[ix] = atan2(Src[ix*2+1], Src[ix*2]);  // returns value between -pi to +pi (radians) of ATAN2(IMAG/Real)
        
             // DFT_Mag[0] = Magnitude of Rsensor+Rload
             // DFT_Mag[1] = Magnitude of Rload
             // DFT_Mag[2] = Magnitude of RCAL
             // DFT_Mag[3] = Magnitude of RSENSOR   (RSENSOR-RLOAD)
          }
          
          // Sensor Magnitude in ohms = (RCAL(ohms)*|Mag(RCAL)|*|Mag(RSensor)) 
          //                            --------------------------------------
          //                            |Mag(RSensor+Rload)|*|Mag(RLoad)) 
          Var1 = ImpResult[i].DFT_Mag[2]*ImpResult[i].DFT_Mag[3]*AFE_RCAL; // Mag(RCAL)*Mag(RSENSOR)*RCAL
          Var2 = ImpResult[i].DFT_Mag[0]*ImpResult[i].DFT_Mag[1];          // Mag(RSENSE+LOAD)*Mag(RLOAD)   
          Var1 = Var1/Var2;
          ImpResult[i].Mag = Var1;
          
          // RSensor+Rload Magnitude in ohms =    (RCAL(ohms)*|Mag(RCAL)|*|Mag(Rload)) 
          //                                       --------------------------------------
          //                                       |Mag(RSensor+Rload)|*|Mag(RSensor+Rload)| 
          Var1 = ImpResult[i].DFT_Mag[2]*ImpResult[i].DFT_Mag[0]*AFE_RCAL; // Mag(Rload)*Mag(Rcal)*RCAL
          Var2 = ImpResult[i].DFT_Mag[0]*ImpResult[i].DFT_Mag[0];          // Mag(RSENSE+LOAD)*Mag(RSENSE+LOAD)   
          Var1 = Var1/Var2;
          ImpResult[i].RloadMag = (Var1 - ImpResult[i].Mag);               // Magnitude of Rload in ohms
          
          // Phase calculation for sensor
      //  Var1 = -(Phase[2]+Phase[3]-Phase[1]-Phase[0]); // -((RCAL+RSENSE - RLOAD-RLOADSENSE)
          Var1 = (Phase[2]+Phase[3]-Phase[1]-Phase[0]); // ((RCAL+RSENSE - RLOAD-RLOADSENSE)
          Var1 = Var1*180/PI;                      // Convert radians to degrees.
          /*shift phase back to range (-180,180]*/
          if(Var1 > 180)
          {
             do
             {
                Var1 -= 360;
             }
             while(Var1 > 180);
          }
          else if(Var1 < -180)
          {
             do
             {
                Var1 += 360;
             }
             while(Var1 < -180);
          }
          ImpResult[i].Phase = Var1;
          
          // Re and Im component of Magnitude
          ImpResult[i].Re_Mag = ImpResult[i].Mag * cos(ImpResult[i].Phase * (PI/180));
          ImpResult[i].Im_Mag = - ImpResult[i].Mag * sin(ImpResult[i].Phase * (PI/180));
          
       }
    
    
       return 1;
    
    }
    
    //rewrite putchar to support printf in IAR
    int putchar(int c)
    {
       UrtTx(pADI_UART0,c);
       while(!(pADI_UART0->COMLSR&BITM_UART_COMLSR_TEMT));
       return c;
    }
    
    //define a getcmd from UART to for command input
    char getcmd(void)
    {
       char cmd;
       
       while( (pADI_UART0->COMLSR&0x0001)==0 ); // wait for something in the FIFO
       cmd = pADI_UART0->COMRX;
       
       return cmd;
    }
    //define a emptycmdfifo from UART for command input
    void emptycmdfifo(void)
    {
       UrtFifoClr(pADI_UART0, BITM_UART_COMFCR_RFCLR);// Clear the Rx FIFOs
    }
    
    void ClockInit(void)
    {
       DigClkSel(DIGCLK_SOURCE_HFOSC);
       ClkDivCfg(1,1);
       AfeClkSel(AFECLK_SOURCE_HFOSC);
       AfeSysClkDiv(AFE_SYSCLKDIV_1);
    }
    
    void UartInit(void)
    {
       DioCfgPin(pADI_GPIO0,PIN10,1);               // Setup P0.10 as UART pin
       DioCfgPin(pADI_GPIO0,PIN11,1);               // Setup P0.11 as UART pin
       pADI_UART0->COMLCR2 = 0x3;                  // Set PCLk oversampling rate 32. (PCLK to UART baudrate generator is /32)
       UrtCfg(pADI_UART0,B57600,
              (BITM_UART_COMLCR_WLS|3),0);         // Configure UART for 57600 baud rate
       UrtFifoCfg(pADI_UART0, RX_FIFO_14BYTE,      // Configure the UART FIFOs for 8 bytes deep
                  BITM_UART_COMFCR_FIFOEN);
       UrtFifoClr(pADI_UART0, BITM_UART_COMFCR_RFCLR// Clear the Rx/TX FIFOs
                  |BITM_UART_COMFCR_TFCLR);
    }
    
    void AfeAdc_Int_Handler()
    {
    	uint32_t sta;
    	sta = pADI_AFE->ADCINTSTA;
    	if(sta&BITM_AFE_ADCINTSTA_DFTRDY)
    	{
          pADI_AFE->ADCINTSTA = BITM_AFE_ADCINTSTA_DFTRDY;	//clear interrupt
          dftRdy = 1;
          pADI_AFE->AFECON &= (~(BITM_AFE_AFECON_DFTEN|BITM_AFE_AFECON_ADCCONVEN|BITM_AFE_AFECON_ADCEN));  //stop conversion
    	}
    }
    
    void GPIO_A_Int_Handler()
    {
       unsigned int uiIntSta = 0;
    
       uiIntSta = DioIntSta(pADI_GPIO1);
       if ((uiIntSta & 0x0001) ==0x0001)
       {
          DioIntClrPin(pADI_GPIO1,PIN0);
          ucButtonPress = 1;
       }
    }
    
    
    
    /**@}*/
    

    Below is the output with O2 sensor and CO sensor:

    O2 SENSOR and CO sensor measured with M355_ECSns_EIS_DualSensor code

    Freq:200000.00 CH0: RzMag: 203.917206 Ohm , RzPhase: -166.216980
    Freq:200000.00 CH1: RzMag: 61.181301 Ohm , RzPhase: 112.951126
    Freq:200000.00 CH0: RzMag: 203.898926 Ohm , RzPhase: -166.232742
    Freq:200000.00 CH1: RzMag: 61.203049 Ohm , RzPhase: 113.009361
    Freq:200000.00 CH0: RzMag: 204.172134 Ohm , RzPhase: -166.220657
    Freq:200000.00 CH1: RzMag: 61.190407 Ohm , RzPhase: 113.131615
    Freq:200000.00 CH0: RzMag: 203.953293 Ohm , RzPhase: -166.229706
    Freq:200000.00 CH1: RzMag: 61.207294 Ohm , RzPhase: 113.064407
    Freq:200000.00 CH0: RzMag: 203.894974 Ohm , RzPhase: -166.216522
    Freq:200000.00 CH1: RzMag: 61.199684 Ohm , RzPhase: 112.991188
    Freq:200000.00 CH0: RzMag: 203.869598 Ohm , RzPhase: -166.222366
    Freq:200000.00 CH1: RzMag: 61.209972 Ohm , RzPhase: 112.911400
    Freq:200000.00 CH0: RzMag: 203.954132 Ohm , RzPhase: -166.231827
    Freq:200000.00 CH1: RzMag: 61.188663 Ohm , RzPhase: 112.872879
    Freq:200000.00 CH0: RzMag: 203.869354 Ohm , RzPhase: -166.228897
    Freq:200000.00 CH1: RzMag: 61.195705 Ohm , RzPhase: 112.963852
    Freq:200000.00 CH0: RzMag: 204.011902 Ohm , RzPhase: -166.225647
    Freq:200000.00 CH1: RzMag: 61.219330 Ohm , RzPhase: 113.050400
    Freq:200000.00 CH0: RzMag: 203.960663 Ohm , RzPhase: -166.225540
    Freq:200000.00 CH1: RzMag: 61.233391 Ohm , RzPhase: 112.900215
    Freq:200000.00 CH0: RzMag: 203.742035 Ohm , RzPhase: -166.209915
    Freq:200000.00 CH1: RzMag: 61.201435 Ohm , RzPhase: 113.043388
    Freq:200000.00 CH0: RzMag: 203.952240 Ohm , RzPhase: -166.225372
    Freq:200000.00 CH1: RzMag: 61.199684 Ohm , RzPhase: 112.991188
    Freq:200000.00 CH0: RzMag: 204.015854 Ohm , RzPhase: -166.216110
    Freq:200000.00 CH1: RzMag: 61.188663 Ohm , RzPhase: 112.872879
    Freq:200000.00 CH0: RzMag: 203.921951 Ohm , RzPhase: -166.209656
    Freq:200000.00 CH1: RzMag: 61.200150 Ohm , RzPhase: 112.900589
    Freq:200000.00 CH0: RzMag: 203.942123 Ohm , RzPhase: -166.221954
    Freq:200000.00 CH1: RzMag: 61.152279 Ohm , RzPhase: 113.006561
    Freq:200000.00 CH0: RzMag: 204.072922 Ohm , RzPhase: -166.234604
    Freq:200000.00 CH1: RzMag: 61.214573 Ohm , RzPhase: 112.913269
    Freq:200000.00 CH0: RzMag: 203.890808 Ohm , RzPhase: -166.215408
    Freq:200000.00 CH1: RzMag: 61.261604 Ohm , RzPhase: 112.951126
    Freq:200000.00 CH0: RzMag: 203.977814 Ohm , RzPhase: -166.221710
    Freq:200000.00 CH1: RzMag: 61.250664 Ohm , RzPhase: 112.832710
    Freq:200000.00 CH0: RzMag: 204.231247 Ohm , RzPhase: -166.222031
    Freq:200000.00 CH1: RzMag: 61.223938 Ohm , RzPhase: 113.014839
    Freq:200000.00 CH0: RzMag: 203.968918 Ohm , RzPhase: -166.227966

  • Hi, thank you for an answer.

    I believe I'm setting the same Vzero value for CH0 and CH1 in the config. Is it enough or I should change it in other place?

    oid AD5940AMPStructInit(void)
    {
      AppAMPCfg_Type *pAmpCfg;
      
      AppAMPGetCfg(&pAmpCfg);
      pAmpCfg->WuptClkFreq = LFOSCFreq;
      /* Configure general parameters */
      pAmpCfg->SeqStartAddr = 0;
      pAmpCfg->MaxSeqLen = 512; /* @todo add checker in function */  
      pAmpCfg->RcalVal = 200.0;
      pAmpCfg->NumOfData = -1;      /* Never stop until you stop it mannually by AppAMPCtrl() function */	
      pAmpCfg->AmpODR = 4;
      
      pAmpCfg->NumSamplesAvg = 8;   /* Take 8 samples each time device wakesup to average */
      
      pAmpCfg->M355FifoThresh = 2*pAmpCfg->NumSamplesAvg;  
      
      /* Configure EC Sensor Parameters */
      //NO2 WE Sensor is connected to CH0 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh0.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter, 4.7uF cap connected external on AIN4 */
      pAmpCfg->SensorCh0.LpTiaRl = LPTIARLOAD_50R;          /* CO sensor datasheet specifies 10ohm Rload */
      pAmpCfg->SensorCh0.LptiaRtiaSel = LPTIARTIA_512K;      /* LPTIA gain resistor is 30kohm */
      pAmpCfg->SensorCh0.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
      pAmpCfg->SensorCh0.SensorBias = 0;                    /* 0V bias voltage */
      
      //NO2 AUX Sensor is connected to CH1 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh1.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter */
      pAmpCfg->SensorCh1.LpTiaRl = LPTIARLOAD_50R;          /* 10 ohm rload */
      pAmpCfg->SensorCh1.LptiaRtiaSel = LPTIARTIA_512K;      /* Tia gain resistor is 2kohm */
      pAmpCfg->SensorCh1.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
    
      
    }

Reply
  • Hi, thank you for an answer.

    I believe I'm setting the same Vzero value for CH0 and CH1 in the config. Is it enough or I should change it in other place?

    oid AD5940AMPStructInit(void)
    {
      AppAMPCfg_Type *pAmpCfg;
      
      AppAMPGetCfg(&pAmpCfg);
      pAmpCfg->WuptClkFreq = LFOSCFreq;
      /* Configure general parameters */
      pAmpCfg->SeqStartAddr = 0;
      pAmpCfg->MaxSeqLen = 512; /* @todo add checker in function */  
      pAmpCfg->RcalVal = 200.0;
      pAmpCfg->NumOfData = -1;      /* Never stop until you stop it mannually by AppAMPCtrl() function */	
      pAmpCfg->AmpODR = 4;
      
      pAmpCfg->NumSamplesAvg = 8;   /* Take 8 samples each time device wakesup to average */
      
      pAmpCfg->M355FifoThresh = 2*pAmpCfg->NumSamplesAvg;  
      
      /* Configure EC Sensor Parameters */
      //NO2 WE Sensor is connected to CH0 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh0.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter, 4.7uF cap connected external on AIN4 */
      pAmpCfg->SensorCh0.LpTiaRl = LPTIARLOAD_50R;          /* CO sensor datasheet specifies 10ohm Rload */
      pAmpCfg->SensorCh0.LptiaRtiaSel = LPTIARTIA_512K;      /* LPTIA gain resistor is 30kohm */
      pAmpCfg->SensorCh0.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
      pAmpCfg->SensorCh0.SensorBias = 0;                    /* 0V bias voltage */
      
      //NO2 AUX Sensor is connected to CH1 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh1.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter */
      pAmpCfg->SensorCh1.LpTiaRl = LPTIARLOAD_50R;          /* 10 ohm rload */
      pAmpCfg->SensorCh1.LptiaRtiaSel = LPTIARTIA_512K;      /* Tia gain resistor is 2kohm */
      pAmpCfg->SensorCh1.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
    
      
    }

Children
  • Hi,

    what about bias voltage on channel 1

  • I tried both with and without setting Vbias and Vzero on the same level for both channels CH0 and CH1. I can see that problem is visible when RTIA for channel 1 is being calibrated, it is much lower than for channel 0.

    Here is the code I tried to run as well. I haven't changed anything rather than number in this config structure:

    void AD5940AMPStructInit(void)
    {
      AppAMPCfg_Type *pAmpCfg;
      
      AppAMPGetCfg(&pAmpCfg);
      pAmpCfg->WuptClkFreq = LFOSCFreq;
      /* Configure general parameters */
      pAmpCfg->SeqStartAddr = 0;
      pAmpCfg->MaxSeqLen = 512; /* @todo add checker in function */  
      pAmpCfg->RcalVal = 200.0;
      pAmpCfg->NumOfData = -1;      /* Never stop until you stop it mannually by AppAMPCtrl() function */	
      pAmpCfg->AmpODR = 4;
      
      pAmpCfg->NumSamplesAvg = 8;   /* Take 8 samples each time device wakesup to average */
      
      pAmpCfg->M355FifoThresh = 2*pAmpCfg->NumSamplesAvg;  
      
      /* Configure EC Sensor Parameters */
      //NO2 WE Sensor is connected to CH0 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh0.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter, 4.7uF cap connected external on AIN4 */
      pAmpCfg->SensorCh0.LpTiaRl = LPTIARLOAD_50R;          /* CO sensor datasheet specifies 10ohm Rload */
      pAmpCfg->SensorCh0.LptiaRtiaSel = LPTIARTIA_512K;      /* LPTIA gain resistor is 30kohm */
      pAmpCfg->SensorCh0.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
      pAmpCfg->SensorCh0.SensorBias = 0;                    /* 0V bias voltage */
      
      //NO2 AUX Sensor is connected to CH1 on EVAL-ADuCM355QSPZ
      pAmpCfg->SensorCh1.LpTiaRf = LPTIARF_1M;              /* 1Mohm Rfilter */
      pAmpCfg->SensorCh1.LpTiaRl = LPTIARLOAD_50R;          /* 10 ohm rload */
      pAmpCfg->SensorCh1.LptiaRtiaSel = LPTIARTIA_512K;      /* Tia gain resistor is 2kohm */
      pAmpCfg->SensorCh1.Vzero = 500;                       /* Set Vzero = 1110mV. Voltage on SE0 & SE1 pin*/
      pAmpCfg->SensorCh1.SensorBias = 0;                    /* 0V bias voltage */
    
      
    }

  • Hi,

    Some differences between the measurements of the 2 channels in DualWE code:

    In the default code, ADC mux configuration is as below:

    /* Measure Ch0 */
    AD5940_ADCMuxCfgS(ADCMUXP_AIN4, ADCMUXN_VZERO0);
    ........

    /* Measure Ch1*/
    AD5940_ADCMuxCfgS(ADCMUXP_LPTIA1_P, ADCMUXN_VZERO1);
    ........

    1) Channel 0 is measured after Low pass filter.

        Channel 1 is measured before Low pass filter.

    2) You may just use ADCMUXN_VZERO0 and -ve input for both channels.

    (LPDAC1 and LAMP1 are anyway turned off)