Issues while reading multiple analog values on single channel ADC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
ansh_2022771
Level 2
Level 2
First like received First like given

Hello everyone,

I am using "ADC SAR Seq" component (only 1 channel) and using it to read 8 analog inputs with help of mux. I am setting select lines on Mux and based on selected lines on Mux I am reading values for 8 different ADC values. Here is code snippet

static uint8 L1_ReadAnalogInput(_sAdcHandle *pAdcHandle)

{

    static uint8 FlagL1 = L_1_STATE_1;

    static uint8 u8Index = 0; // Start reading ADC from Index 0

    switch(FlagL1)

    {

        case L_1_STATE_1:

        {

          // Custom function for setting select lines

            SetSelectLines(u8Index);

           

            /*Start Conversation here*/

            ADC_StartConvert();     // Cypress API

           

            FlagL1 = L_1_STATE_2;

            break;  

        }

       

        case L_1_STATE_2:

        {

            if(ADC_IsEndConversion(ADC_WAIT_FOR_RESULT))

            {

                u16Analog = ADC_GetResult16(ADC_CHANNEL)>>1;     // Cypress API

                if(u16Analog > 0x7FF)

                    u16Analog = 0;

                

               // copying ADC value in global var using jump table

                pAdcHandle->AnalogValue[AnalogIndex[u8Index]] = u16Analog;

                ADC_StopConvert();     // Cypress API

                // Code for changing select lines

               u8Index = ( u8Index < 7) ? u8Index + 1 : 0;

               FlagL1 = L_1_STATE_1;

               return L_1_SUCCESS;

               

            }

            break;

        }

    }

    return FlagL1;

}

With help of this function I am reading data on each input and select lines are checked for accuracy. My problem is once in a while data is getting corrupted on ADC.

I am not sure what the issue is, but to me it seems either averaging is causing this or maybe there is some issue with ADC settings (images attached).

Problem: If Analog input 1 is changing and suppose it has high analog value around 700 then sometimes it's affecting analog input 2's value. Similarly if analog input 1 is stable or zero then analog input 2 is never getting affected. Again if analog input 2 has high analog value it's affecting analog input 3.

My testing so far:

1. Issue is not with select lines. I tried adding delays after setting select lines but there is no change in behavior.

If anyone has experience in ADC or faced similar issues please let me know.

PS - I want to create a case on this as I am unable to see that option in the page where it used to be.

Thanks,

A

0 Likes
1 Solution
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Hi,

Use version 2.10 of the ADC.

There is an option to set the sample mode as "Single shot".

I believe the problem is related to configuring the ADC as "Free Running" while starting/stopping the conversion.

View solution in original post

2 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Anish,

Will you be able to share your project so that we can have a look into it ?

Best Regards,
VSRS

0 Likes
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Hi,

Use version 2.10 of the ADC.

There is an option to set the sample mode as "Single shot".

I believe the problem is related to configuring the ADC as "Free Running" while starting/stopping the conversion.