1) Is it possible to switch the excitation DAC to D5 and D6 at different times to generate two counter electrodes one on CE0 and one on AFE1?
2) Can you share an example code with us to see how the switching between these two main loops should be?
AD5940
Recommended for New Designs
The AD5940 and AD5941 are high precision, low power analog front ends (AFEs) designed for portable applications that require high precision, electrochemical...
Datasheet
AD5940 on Analog.com
1) Is it possible to switch the excitation DAC to D5 and D6 at different times to generate two counter electrodes one on CE0 and one on AFE1?
2) Can you share an example code with us to see how the switching between these two main loops should be?
GenevaC - Moved from How to Use EngineerZone to MEMS Inertial Sensors. Post date updated from Monday, December 8, 2025 9:18 PM UTC to Tuesday, December 9, 2025 3:16 PM UTC to reflect the move.
Hi,
Yes. It can be done inside measurement sequence as in example below:
/* Start sequence generator here */ AD5940_SEQGenCtrl(bTRUE); AD5940_SEQGpioCtrlS(AGPIO_Pin6); AD5940_SEQGenInsert(SEQ_WAIT(16*250)); /* @todo wait 250us?? */ sw_cfg.Dswitch = SWD_CE0; sw_cfg.Pswitch = SWP_CE0; sw_cfg.Nswitch = SWN_AIN1; sw_cfg.Tswitch = SWT_AIN1|SWT_TRTIA; AD5940_SWMatrixCfgS(&sw_cfg); AD5940_ADCMuxCfgS(ADCMUXP_HSTIA_P, ADCMUXN_HSTIA_N); AD5940_AFECtrlS(AFECTRL_WG|AFECTRL_ADCPWR, bTRUE); /* Enable Waveform generator, ADC power */ AD5940_SEQGenInsert(SEQ_WAIT(16*50)); AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT, bTRUE); /* Start ADC convert and DFT */ AD5940_SEQGenInsert(SEQ_WAIT(WaitClks)); /* wait for first data ready */ AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT|AFECTRL_WG|AFECTRL_ADCPWR, bFALSE); /* Stop ADC convert and DFT */ sw_cfg.Dswitch = SWD_AFE1; sw_cfg.Pswitch = SWP_AFE1; sw_cfg.Nswitch = SWN_AIN1; sw_cfg.Tswitch = SWT_AIN1|SWT_TRTIA; AD5940_SWMatrixCfgS(&sw_cfg); AD5940_ADCMuxCfgS(ADCMUXP_HSTIA_P, ADCMUXN_HSTIA_N); AD5940_AFECtrlS(AFECTRL_WG|AFECTRL_ADCPWR, bTRUE); /* Enable Waveform generator, ADC power */ AD5940_SEQGenInsert(SEQ_WAIT(16*50)); AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT, bTRUE); /* Start ADC convert and DFT */ AD5940_SEQGenInsert(SEQ_WAIT(WaitClks)); /* wait for first data ready */ AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT|AFECTRL_WG|AFECTRL_ADCPWR, bFALSE); /* Stop ADC convert and DFT */ sw_cfg.Dswitch = SWD_OPEN; sw_cfg.Pswitch = SWP_PL|SWP_PL2; sw_cfg.Nswitch = SWN_NL|SWN_NL2; sw_cfg.Tswitch = SWT_TRTIA; AD5940_SWMatrixCfgS(&sw_cfg); /* Float switches */ AD5940_SEQGpioCtrlS(0); AD5940_EnterSleepS();/* Goto hibernate */ /* Sequence end. */ error = AD5940_SEQGenFetchSeq(&pSeqCmd, &SeqLen); AD5940_SEQGenCtrl(bFALSE); /* Stop sequencer generator */
Dear Akila,
Thank you for your response to our inquiry.
We tried your code. I am afraid it did not work for us. Here is our follow up questions:
1) Why did you connect the P switch to CE0 on your line 8?
2) We want to have a separate reference electrode than the counter electrode. How do we set up the P switches to have access to a separate reference electrode?
3) Is there a more comprehensive schematic about the DAC for the high speed loop that you can share? There are inputs from the function generator to the DAC. At the same time, there are inputs from N and P switches to the DAC. We want to have a better understanding of what the relationship is between the inputs of the DAC and N and P switches.
4) What is the purpose of N switch that connects the input of the DAC to the input of the TIA?
5) Just to reiterate, we want to have a separate Counter and reference electrodes. Can you advise how the N and P switches need to be set up?
Thank you very much.
Payam
Dear Akila,
Thank you for your response to our inquiry.
We tried your code. I am afraid it did not work for us. Here is our follow up questions:
1) Why did you connect the P switch to CE0 on your line 8?
2) We want to have a separate reference electrode than the counter electrode. How do we set up the P switches to have access to a separate reference electrode?
3) Is there a more comprehensive schematic about the DAC for the high speed loop that you can share? There are inputs from the function generator to the DAC. At the same time, there are inputs from N and P switches to the DAC. We want to have a better understanding of what the relationship is between the inputs of the DAC and N and P switches.
4) What is the purpose of N switch that connects the input of the DAC to the input of the TIA?
5) Just to reiterate, we want to have a separate Counter and reference electrodes. Can you advise how the N and P switches need to be set up?
Thank you very much.
Payam
1) P is connected to CE0 for doing a 2 electrode measurement. If you want to do 3-electrode measurement, P may be connected to RE0.
sw_cfg.Pswitch = SWP_RE0;
3) P and N are +ve and -ve feedback to excitation amplifier.

4) N switch only connects to -ve feedback input of DAC. T switch connects pin to input of TIA, where input current is measured by TIA.
5) For separate reference electrode,
sw_cfg.Dswitch = SWD_CE0;
sw_cfg.Pswitch = SWP_RE0;
sw_cfg.Nswitch = SWN_AIN1;
sw_cfg.Tswitch = SWT_AIN1|SWT_TRTIA;
Thanks for your response. I will try your code. But the schematic shows the N switch is connected to +ve and P switch is connected to -ve. Can you explain why you said the N switch connects to -ve?
Another question that I have is related to the low speed loop.
Is it possible to use the switch matrix with the low speed loop?
Can the low speed loop be used with multiple working electrodes and at least 2 counter electrodes? The reference electrode can be one.
If yes, which pins can be used for working electrodes and which pins can be used for counter electrodes? Could you post some sample code for this pupose?
Please let me know. Thank you very much for your help.
Hi,
It is an inverting amplifier. Hence the sign reversal.
Inputs to LPTIA can be SE0 (via switch S7) or RE0 (by shorting it to SE0 via switch SW11) only.
Counter electrode (output of LPDAC) can be CE0(SW2) or RE0 (SW15).

Also. in the above code, AppIMPDataProcess() function must be updated, since you are reading two samples instead of one now.
Only then, the code works with proper result process and display.
Hi,
I couldn't find AppIMPDataProcess() function that needs to be updated.
Could you point me to where it is?
Thanks.
If you are measuring impedance, above modifications can be done on AD5940_Impedance example.
AppIMPDataProcess() is availbale in this example.
We are not measuring impedance. We are performing Square Wave Voltammetry, Chronoamperometry, and open circuit potentiometry, all by the high speed loop.
Could you share an example code for Square Wave Voltammetry by the high speed loop?
I don't have these examples in high speed loop as of now. Kindly refer to the high speed loop examples in Github to update as per your application.
Our Test Conditions
2-channel Amperometry with the following switch configuration: