Home Analog Multiplexing the inputs to an Incremental ADC

Multiplexing the inputs to an Incremental ADC

E-mail Print PDF
( 0 Votes )
Questions:

When I change the input to the incremental ADC, the result is not correct.  What could be the reason?
What are the various factors to remember when multiplexing the input signal to an incremental ADC like ADCINC, ADCINCVR, ADCINC12, ADCINC14 etc?

Answer:

An incremental ADC is a combination of an SC Block Modulator, a Timer or PWM that sets the integration time and a Counter to count the bit stream from the SC Block modulator. On end of conversion, the timer or PWM generates an interrupt and the CPU reads the result from the counter, resets the counter and the next conversion continues.   There are many options to change the input to the ADC.

Option-1:

The ideal place to switch an ADC input is exactly at the end of conversion before the CPU resets the counter for the next conversion. The incremental ADCs have a ADC ISR file like ADCINC_1INT.asm, ADCINCVR_1INT.asm, ADCINC_1INT.asm etc.  Inside the ISR, there is an area marked for adding custom user code.  Add the code that switches the input to the ADC inside this area.  For example, below is a code from the ADCINCVR's ISR.

    mov  [ADCINC_iResult + LowByte],[iTemp +LowByte]
    mov  [ADCINC_iResult + HighByte],A
    mov  [ADCINC_fStatus],1
ConversionReady:
    ;@PSoC_UserCode_BODY@ (Do not change this line.)
    ;---------------------------------------------------
    ; Insert your custom code below this banner
    ;---------------------------------------------------
    ;  Sample data is now in iResult
    ;
    ;  NOTE: This interrupt service routine has already
    ;  preserved the values of the A CPU register. If
    ;  you need to use the X register you must preserve
    ;  its value and restore it before the return from
    ;  interrupt.
    ;---------------------------------------------------
    ; Insert your custom code above this banner
    ;---------------------------------------------------
    ;@PSoC_UserCode_END@ (Do not change this line.)
    pop A
 
The code to switch the analog inputs should be inserted in the above user code area.


Option-2:

If the input is being switched in the foreground, then there is no guarantee that the input will be switched exactly at the end of conversion.  Under this situation, there will be cross talk between the two signals.  To overcome this, drop one sample after switching the input to the ADC.  For example:

// Change input to ADC
AMUX4_1_InputSelect(AMUX4_1_PORT0_1);

// Inside the for loop, do two ADC conversions.  The first one is automatically dropped and
// ADCResult will have the value of the second conversion which is correct.
for(i=0; i<2; i++)
{
while(ADC_fIsDataAvailable() == 0);
ADCResult = ADC_iGetData();
ADC_ClearFlag();


Option-3:

Instead of starting the ADC in continuous conversion mode, do single conversion.  In this method, the ADC is stopped after the end of conversion, and will be started only after the next conversion is initiated and no cross talk will be observed.

// Select P0[1] as Input
AMUX4_1_InputSelect(AMUX4_1_PORT0_1);

// Start conversion, wait for conversion and read result
ADC_GetSamples(1);
while(ADC_fIsDataAvailable() == 0);
ADCResult1 = ADC_iGetDataClearFlag();

// Select P0[3] as Input
AMUX4_1_InputSelect(AMUX4_1_PORT0_3);

// Start conversion, wait for conversion and read result
ADC_GetSamples(1);
while(ADC_fIsDataAvailable() == 0);
ADCResult2 = ADC_iGetDataClearFlag();


Tags: PSoC1 ADC Analog
Comments (2)
  • dabronx  - Problem with multiplexing inputs to a DUALADC
    Hi Ganesh!

    Is this problem extended to the DUALADC?

    I posted something in PSoCDeveloper about dynamic reconfiguration and about a problem I had with a DUALADC. I've just read this article and I've found it great! However, I think my problem is still there.

    I've used the above Option2, but for example, for ADC1 only when ACB00 and ACB01 have the same input I get at the ADC1 output the correct signal. If ACB00 and ACB01 have different signals, there is crosstalk between them.

    What should I do?I really need to do it and I don't find the solution.

    Thanks in advance! David

  • graaja
    Hi David,
    Option-2 applies to DualADC as well. I will update the PSoCDeveloper thread with some more thoughts.
    Best Regards,
    Ganesh
Only registered users can write comments!