2 Replies Latest reply on Nov 4, 2019 5:00 PM by MoTa_728816

    PSoC 6 unexpected results from ADC

    EuGe_296116

      I have a project with an ADC wired as follows:

      and configured as follows:

       

      VDDA is 3.3V.  When I feed a voltage of 2.00V into VBatIn, I get a result of approximately 430 counts, which comes out to approximately 1.4V.  The behaviour is the same if I buffer the signal internally with an Opamp component.

       

      Is something misconfigured here?  What do I need to do to get the right values coming out of the ADC?

        • 1. Re: PSoC 6 unexpected results from ADC
          EuGe_296116

          When can I expect a Cypress response to this question?  Is there another support avenue where I could get responses more reliably?

          • 2. Re: PSoC 6 unexpected results from ADC
            MoTa_728816

            Hi,

             

            Have you tried to use ADC_CountsTo_mVolts() function?

             

            I tried the following using CY8CKIT-062-WIFI-BT (CY8C6247BZI-D54ES on board)

            (1) Schematic

            000-schematic.JPG

            (2) ADC Config

            Note: Although I tried to duplicate your config, I noticed that the "Scan duration" is quite different from yours.

            002-ADC-Config.JPG

             

            (3) Pin assign

            001-pin-assign.JPG

            (4) main.c

            ====================

            #include "project.h"

            #include "stdio.h"

             

            #define STR_LEN 128

            char str[STR_LEN+1] ;

            void print(char *str)

            {

                UART_PutString(str) ;

            }

             

            void init_hardware(void)

            {

                __enable_irq() ;

                UART_Start() ;

                ADC_Start() ;

            }

             

            void splash(void)

            {

                snprintf(str, STR_LEN, "PSoC 6 ADC Test (%s %s)\n", __DATE__, __TIME__) ;

                print(str) ;

            }

             

            void measure(void)

            {

                int16_t adc_count ;

                int16_t mV ;

                ADC_StartConvert() ;

                ADC_IsEndConversion(CY_SAR_WAIT_FOR_RESULT) ;

                adc_count = ADC_GetResult16(0) ;

                mV = ADC_CountsTo_mVolts(0, adc_count) ;

                snprintf(str, STR_LEN, "%5d mV : %4d\n", mV, adc_count) ;

                print(str) ;

                return ;

            }

             

            int main(void)

            {

                init_hardware() ;

             

            //    __enable_irq(); /* Enable global interrupts. */

            //    /* Enable CM4.  CY_CORTEX_M4_APPL_ADDR must be updated if CM4 memory layout is changed. */

            //    Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);  /* this time I use only CM0+ */

             

                splash() ;

             

                for(;;)

                {

                    measure() ;

                    CyDelay(1000) ;

                }

            }

            ====================

             

            (5) Tera Term output

            003-TeraTerm-log.JPG

            (6) I connected 3.3V, GND, and A0 (P10[0]) from the board to a POT (10K)

            At 0.000V (~ -0.000V): program reported -2mV ~ 3mV, adc_count -1 ~ 2

            0V.JPG

             

            At 1.001V program reported 1014 mV ~ 1022 mV, adc_count 629 ~ 632

            1V.JPG

             

            At 2.007V program reported 2037 mV ~ 2045 mV, adc_count 1264 ~ 1269

            2V.JPG

             

            At 3.006V program reported 3055 mV ~ 3060 mV, adc_count 1896 ~ 1899

            3V.JPG

             

            So IMHO, the voltage reported via ADC_CountsTo_mVolts() seems to be reasonable for my hardware setup.

            You may want to take a look at inside this function to confirm how they convert ADC count to mV.

             

            moto