Post Go back to editing

SWV Bidirectional Voltage v.s. Current

Category: Software
Product Number: AD5940

Hi,

I am using AD5940 to conduct SWV measurements and trying to process the measurement data. If I understand it correctly, the data stored in FIFO is the voltage measured at the working electrode and further divided by the RTIA and hence is the current flowing into the working electrode. But I was not sure what should be the corresponding voltage if I am drawing a plot with voltages as the x axis and current as the y axis.

Here is the parameters I am using for SWV measurement:

void AD5940SWVStructInit(void)

{

  AppSWVCfg_Type *pRampCfg;

 

  AppSWVGetCfg(&pRampCfg);

  /* Step1: configure general parmaters */

  pRampCfg->SeqStartAddr = 0x10;                /* leave 16 commands for LFOSC calibration.  */

  pRampCfg->MaxSeqLen = 512-0x10;               /* 4kB/4 = 1024  */

  pRampCfg->RcalVal = 10000.0;                  /* 10kOhm RCAL */

  pRampCfg->ADCRefVolt = 1.820f;                /* The real ADC reference voltage. Measure it from capacitor C12 with DMM. */

  pRampCfg->FifoThresh = 1023;                  /* Maximum value is 2kB/4-1 = 512-1. Set it to higher value to save power. */

  pRampCfg->SysClkFreq = 16000000.0f;           /* System clock is 16MHz by default */

  pRampCfg->LFOSCClkFreq = LFOSCFreq;           /* LFOSC frequency */

  pRampCfg->AdcPgaGain = ADCPGA_1;

  pRampCfg->ADCSinc3Osr = ADCSINC3OSR_4;

 

  /* Step 2:Configure square wave signal parameters */

  pRampCfg->RampStartVolt = -500.0f;            /* Measurement starts at -0.6V*/

  pRampCfg->RampPeakVolt = 0.0f;                /* Measurement finishes at 0V */

  pRampCfg->VzeroStart = 1300.0f;               /* Vzero is voltage on SE0 pin: 1.3V */

  pRampCfg->VzeroPeak = 1300.0f;                /* Vzero is voltage on SE0 pin: 1.3V */

  pRampCfg->Frequency = 60;                     /* Frequency of square wave in Hz */

  pRampCfg->SqrWvAmplitude = 25;                /* Amplitude of square wave in mV */

  pRampCfg->SqrWvRampIncrement = 5;             /* Increment in mV*/

  pRampCfg->SampleDelay = 0.2f;                 /* Time between update DAC and ADC sample. Unit is ms and must be < (1/Frequency)/2 - 0.2*/

  pRampCfg->LPTIARtiaSel = LPTIARTIA_24K;      /* Maximum current decides RTIA value */

  pRampCfg->bRampOneDir = bFALSE;         /* Measure ramp in two directions */

}

Thank you!

  • Hi,  .

    Can your team please help look into this query?

    Warm regards,
    Jo

  • Hi Nathan,

    Thank you very much! Could you please check again? I haven't received a reply from Akila yet.

  • Hi,

    Have you solved this ?? we also want to plot current vs voltage. Have you figured out how to get corresponding voltage to the current?

    Thank you

  • Hi,

    Square wave starts with RampStart Volt and goes till Ramp peak volt with waveform as below:

    Voltage shown above is VCE0-VSE0. Current is sampled at each T/2 phase of square wave.

    Note: T=1/Square wave Frequency

  • Hi,

    To plot voltage vs current, modified swv example like below and results when tested with 1K

    static AD5940Err AppSWVSeqADCCtrlGen(void)
    {
      AD5940Err error = AD5940ERR_OK;
      const uint32_t *pSeqCmd;
      uint32_t SeqLen;
    
      uint32_t WaitClks;
      ClksCalInfo_Type clks_cal;
    
      clks_cal.DataCount = 1; /* Sample one point everytime */
      clks_cal.DataType = DATATYPE_SINC3;
      clks_cal.ADCSinc3Osr = AppSWVCfg.ADCSinc3Osr;
      clks_cal.ADCSinc2Osr = ADCSINC2OSR_1067; /* Don't care */
      clks_cal.ADCAvgNum = ADCAVGNUM_2;        /* Don't care */
      clks_cal.RatioSys2AdcClk = AppSWVCfg.SysClkFreq / AppSWVCfg.AdcClkFreq;
      AD5940_ClksCalculate(&clks_cal, &WaitClks);
    
      AD5940_SEQGenCtrl(bTRUE);
      AD5940_SEQGpioCtrlS(AGPIO_Pin2);
    
      AD5940_ADCMuxCfgS(ADCMUXP_LPTIA0_P, ADCMUXN_LPTIA0_N);
      AD5940_AFECtrlS(AFECTRL_ADCPWR, bTRUE);
      AD5940_SEQGenInsert(SEQ_WAIT(16 * 100)); /* wait 250us for reference power up */
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);  /* Start ADC convert and DFT */
      AD5940_SEQGenInsert(SEQ_WAIT(WaitClks));                  /* wait for first data ready */
      AD5940_AFECtrlS(/*AFECTRL_ADCPWR |*/ AFECTRL_ADCCNV, bFALSE); /* Stop ADC */
    
    
        /*Measure VCE*/
      AD5940_ADCMuxCfgS(ADCMUXP_VCE0, ADCMUXN_VZERO0);   
      //AD5940_AFECtrlS(AFECTRL_ADCPWR, bTRUE);
      AD5940_SEQGenInsert(SEQ_WAIT(16*250));  /* wait 250us for reference power up */
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);  /* Start ADC convert and DFT */
      AD5940_SEQGenInsert(SEQ_WAIT(WaitClks));  /* wait for first data ready */
      AD5940_AFECtrlS(/*AFECTRL_ADCPWR|*/AFECTRL_ADCCNV, bFALSE);  /* Stop ADC */
    
      /*Measure VSE*/
    	AD5940_ADCMuxCfgS(ADCMUXP_VSE0, ADCMUXN_VZERO0);  
      //AD5940_AFECtrlS(AFECTRL_ADCPWR, bTRUE);
      AD5940_SEQGenInsert(SEQ_WAIT(16*250));  /* wait 250us for reference power up */
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);  /* Start ADC convert and DFT */
      AD5940_SEQGenInsert(SEQ_WAIT(WaitClks));  /* wait for first data ready */
      AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_ADCCNV, bFALSE);  /* Stop ADC */
    
      AD5940_SEQGpioCtrlS(0);
    
      AD5940_EnterSleepS(); /* Goto hibernate */
      /* Sequence end. */
      error = AD5940_SEQGenFetchSeq(&pSeqCmd, &SeqLen);
      AD5940_SEQGenCtrl(bFALSE); /* Stop sequencer generator */
    
      if (error == AD5940ERR_OK)
      {
        AD5940_StructInit(&AppSWVCfg.ADCSeqInfo, sizeof(AppSWVCfg.ADCSeqInfo));
        if ((SeqLen + AppSWVCfg.InitSeqInfo.SeqLen) >= AppSWVCfg.MaxSeqLen)
          return AD5940ERR_SEQLEN;
        AppSWVCfg.ADCSeqInfo.SeqId = SEQID_2;
        AppSWVCfg.ADCSeqInfo.SeqRamAddr = AppSWVCfg.InitSeqInfo.SeqRamAddr + AppSWVCfg.InitSeqInfo.SeqLen;
        AppSWVCfg.ADCSeqInfo.pSeqCmd = pSeqCmd;
        AppSWVCfg.ADCSeqInfo.SeqLen = SeqLen;
        AppSWVCfg.ADCSeqInfo.WriteSRAM = bTRUE;
        AD5940_SEQInfoCfg(&AppSWVCfg.ADCSeqInfo);
      }
      else
        return error; /* Error */
      return AD5940ERR_OK;
    }
    
    static int32_t AppSWVDataProcess(int32_t *const pData, uint32_t *pDataCount)
    {
      uint32_t i, datacount;
      datacount = *pDataCount;
      float *pOut = (float *)pData;
    
      for(i=0;i<datacount/3;i+=3)
      {
        pData[i] &= 0xffff;
    	pData[i+1] &= 0xffff;
        pData[i+2]&=0xffff;
    		
        
        pOut[i] = AD5940_ADCCode2Volt(pData[i], AppSWVCfg.AdcPgaGain, AppSWVCfg.ADCRefVolt)/AppSWVCfg.RtiaValue.Magnitude * 1e3f;  /* Result unit is mA. */
    	pOut[i+1] = AD5940_ADCCode2Volt(pData[i+1], AppSWVCfg.AdcPgaGain, AppSWVCfg.ADCRefVolt)* 1e3f;
        pOut[i+2] = AD5940_ADCCode2Volt(pData[i+2], AppSWVCfg.AdcPgaGain, AppSWVCfg.ADCRefVolt)* 1e3f;
       }
      return 0;
    }
    
    
    static int32_t RampShowResult(float *pData, uint32_t DataCount)
    {
      static uint32_t index;
      /* Print data*/
      printk("DataCount: %d\n", DataCount);
     for (uint32_t i = 0; i < DataCount/3; i += 3)
      {
        float I = pData[i];
        float V = pData[i + 1] - pData[i + 2];
    
        printk("I:%.3f V:%.3f\n", I, V);
        k_msleep(5);
      }
    
      return 0;
    }
    
    
    
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396
    I:0.531 V:1002.396

    Output  current and voltage are always same...

    Thankyou

  • Increase sample delay as each cycle samples 3 data instead of one.

  • Hi,

    Increased sample delay as you have suggested.

    Previous results are for

    pRampCfg->Frequency = 100;             /* Frequency of square wave in Hz */
    pRampCfg->SampleDelay = 0.5f;      (everything else is same as in git code)
    Tested with sampledelay 3 and 4 ms, results are as below
    I:-0.179 V:-1186.971
    I:-0.921 V:-617.789
    I:-0.179 V:1031.105
    I:9.996 V:-1245.061
    I:-0.182 V:1244.725
    I:10.120 V:-1245.173
    I:-0.180 V:1244.949
    I:10.120 V:-1244.763
    I:-0.179 V:1244.987
    I:10.120 V:-1244.912
    I:-0.180 V:1245.061
    I:10.120 V:-1244.987
    I:-0.180 V:1244.949
    I:10.120 V:-1244.987
    I:-0.179 V:1245.099
    I:10.120 V:-1244.875
    I:-0.180 V:1244.800
    I:10.120 V:-1245.024
    I:-0.181 V:1244.912
    I:10.120 V:-1244.949
    I:-0.181 V:1244.800
    I:10.120 V:-1245.061
    I:-0.181 V:1244.987
    I:10.120 V:-1244.912
    I:-0.180 V:1244.912
    I:10.120 V:-1245.061
    I:-0.180 V:1244.949
    I:10.120 V:-1244.800
    I:-0.180 V:1244.949
    I:10.120 V:-1244.912
    I:-0.178 V:1244.837
    I:10.120 V:-1244.875
    I:-0.180 V:1244.949
    I:10.120 V:-1245.173
    I:-0.180 V:1244.800
    I:10.120 V:-1244.800
    Thank you
  • You may check the square wave on oscilloscope for ensuring if excitation is as expected.

    No of cycles taken for each DAC update is:

    (LFOSCClkFreq*((1/Frequency*500) - SampleDelay)/1000.0f) - 4

    You may reduce the frequency and check too.

  • Hi,

    Captured square wave excitation on oscilloscope. Excitation is being applied as expected.

    Tested with reducing the frequency. Previous results are with EvalAD5940ELCZ+nRF54. With the same changes in code as mentioned in my previous reply, tested on ADI EVK also. Results are as below

    ADI_EVK
    Freq 100hz
    sample delay 3.0
    Hello AD5940-Build Time:11:49:48
    LFOSC Freq:32401.746094
    LPTIARTIA:1075.770630 -0.000036
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.136 V:0.000
    I:1.137 V:-2.464
    I:1.137 V:4.144
    I:1.137 V:0.000
    I:1.125 V:0.000
    I:1.137 V:-24.229
    I:1.137 V:31.472
    I:1.137 V:0.000
    I:1.091 V:0.000
    I:1.137 V:-103.077
    I:1.137 V:134.511
    I:1.137 V:0.000
    I:0.980 V:0.000
    I:1.137 V:-200.554
    I:1.137 V:231.764
    I:1.137 V:0.000
    I:0.889 V:0.000
    I:1.137 V:-298.703
    I:1.137 V:330.622
    I:1.137 V:0.000
    I:0.798 V:0.000
    I:1.137 V:-396.926
    I:1.137 V:428.174
    I:1.137 V:0.000
    I:0.710 V:0.000
    I:1.137 V:-495.187
    I:1.137 V:525.987
    I:1.137 V:0.000
    I:0.618 V:0.000
    I:1.137 V:-592.589
    I:1.137 V:624.248
    I:1.137 V:0.000
    I:0.527 V:0.000
    I:1.137 V:-691.112
    I:1.137 V:722.434
    I:1.137 V:0.000
    I:0.436 V:0.000
    I:1.137 V:-789.858
    I:1.136 V:821.666
    I:1.137 V:-3.882
    I:0.344 V:12.581
    I:1.137 V:-884.647
    I:1.115 V:920.412
    I:1.137 V:-31.360
    I:0.253 V:47.226
    I:1.137 V:-982.721
    I:1.055 V:1018.001
    I:1.137 V:-134.847
    I:0.161 V:165.349
    I:1.137 V:-1081.542
    I:0.953 V:1116.486
    I:1.137 V:-232.586
    I:0.069 V:263.460
    I:1.137 V:-1180.512
    I:0.863 V:1215.568
    I:1.137 V:-330.697
    I:-0.023 V:361.982
    I:1.137 V:-1279.221
    I:0.771 V:1310.618
    
    
    Freq-10hz
    sample delay 3
    LFOSC Freq:32411.718750
    LPTIARTIA:1075.770752 -0.000037
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:0.000
    I:1.137 V:-1.381
    I:1.137 V:3.621
    I:1.137 V:0.000
    I:1.126 V:0.000
    I:1.137 V:-22.922
    I:1.137 V:27.850
    I:1.137 V:0.000
    I:1.095 V:0.000
    I:1.137 V:-71.045
    I:1.137 V:124.991
    I:1.137 V:0.000
    I:0.988 V:0.000
    I:1.137 V:-192.676
    I:1.137 V:223.327
    I:1.137 V:0.000
    I:0.898 V:0.000
    I:1.137 V:-289.295
    I:1.137 V:320.505
    I:1.137 V:0.000
    I:0.806 V:0.000
    I:1.137 V:-388.153
    I:1.137 V:418.169
    I:1.137 V:0.000
    I:0.718 V:0.000
    I:1.137 V:-485.854
    I:1.137 V:518.110
    I:1.137 V:0.000
    I:0.627 V:0.000
    I:1.137 V:-583.368
    I:1.137 V:615.064
    I:1.137 V:0.000
    I:0.535 V:0.000
    I:1.137 V:-681.554
    I:1.137 V:713.997
    I:1.137 V:0.000
    I:0.444 V:0.784
    I:1.137 V:-780.823
    I:1.134 V:812.631
    I:1.137 V:-4.293
    I:0.352 V:13.701
    I:1.137 V:-875.500
    I:1.113 V:911.639
    I:1.137 V:-35.840
    I:0.260 V:57.008
    I:1.137 V:-974.620
    I:1.036 V:1010.198
    I:1.137 V:-143.658
    I:0.169 V:174.906
    I:1.137 V:-1073.067
    I:0.945 V:1108.459
    I:1.137 V:-241.658
    I:0.077 V:272.793
    I:1.137 V:-1171.888
    I:0.854 V:1208.624
    I:1.137 V:-339.956
    I:-0.016 V:371.540
    I:1.137 V:-1271.306
    I:0.762 V:1302.629

    nRF results

    SWV_1K_10HzVvsI.LOG

    Thank you

  • Hi,

    Can you just read LPDACDAT in use it in AppSWVDataProcess() by converting it to voltage,

    since output waveform is correct, 

    and problem seems to be only on reading SE0 and CE0.

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.