3 Replies Latest reply on Oct 31, 2019 1:26 AM by MoTa_728816

    PSOC4100S DieTemp

    make_3248316

      您好:

      我在CY8CKIT-041-41XX开发板上跑ADC_SAR_Seq_DieTemp_PSoC401例程,我将ADC的参考元设置成了VDDA:

      并在代码的180行修改了相应的值:

      但是转换结果依旧不正常,我查看了论坛中的类似问题:

      PSOC 4 Die Temperature Measurement

      修改了VDDA的值,测量结果仍没有改善。

      我不知道哪里出了错误。

        • 1. Re: PSOC4100S DieTemp
          MoTa_728816

          Hi,

           

          I tried with a TSoC board, which has CY8C4146LQI-S433.

           

          Although I did not "correct" adc count,

          the DieTemp_CountsTo_Celsius() function seems to give us reasonable value.

          But you are welcome to tweak with my program if you wish.

           

          The schematic

          001-schematic.JPG

          ADC Settings

          002-ADC_Settings.JPG

           

          main.c

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

          #include "project.h"

          #include "stdio.h"

           

          #define STR_LEN 64

          char str[STR_LEN+1] ;

          void print(char *str)

          {

              UART_UartPutString(str) ;

          }

           

          int32_t measure(void) ;

           

          void init_hardware(void)

          {

              CyGlobalIntEnable; /* Enable global interrupts. */

              UART_Start() ;

              ADC_SAR_Seq_Start() ;

              measure() ; // discard the initial garbage data

          }

           

          void cls(void)

          {

              print("\033c") ; /* reset */

              CyDelay(100) ;

              print("\033[2J") ; /* clear screen */

              CyDelay(100) ;

          }

           

          void splash(char *title)

          {

              cls() ;

              if (title && *title) {

                  print(title) ;

              }

              sprintf(str, " (%s %s)\n", __DATE__, __TIME__) ;

              print(str) ;

          }

           

          int32_t measure(void)

          {

              int16_t adc_count = 0 ;

              int32_t celcius ;

            

              ADC_SAR_Seq_StartConvert() ;

              ADC_SAR_Seq_IsEndConversion(ADC_SAR_Seq_WAIT_FOR_RESULT) ;

              adc_count = ADC_SAR_Seq_GetResult16(0) ;

              celcius = DieTemp_CountsTo_Celsius(adc_count) ;

              return( celcius ) ;

          }

           

          int main(void)

          {

              int32_t temp ;

            

              init_hardware() ;

            

              splash("DieTemp Test") ;

           

              for(;;)

              {

                  temp = measure() ;

                  sprintf(str, "%d\n", temp) ;

                  print(str) ;

                  CyDelay(1000) ;

              }

          }

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

           

          Tera Term log

          000-TeraTerm-log.JPG

           

          You may need to change the device and UART pins to make it work with your system.

           

          moto

          • 2. Re: PSOC4100S DieTemp
            make_3248316

            HI moto:

            Thanks for your help.

            I test your project and it can work well.Then I try to change the ADC's VREF.It can't work well when I select VDDA as my VREF.

            Your project give me inspiration.Maybe I have found my project problem.

            As the PSoC 4100/4200 Family PSoC Architecture TRM said:

             

            but the PSoC 4100S don't have this reference.I can't find the message about what reference is Temperature Sensor used.

            According to your project I guess It use internal Vref(1.2V).

             

            If I download the code example(ADC_SAR_Seq_DieTemp_PSoC4) directly,It can't measure tempreture well.

            I have to changed the code as:

            than it can measure well.

             

            If I want to change the VREF to VDDA in your project,I should add the code like:

             

            Please let me know if you have any other ideas.

             

            Thanks again for your help!

             

            kejie.

            • 3. Re: PSOC4100S DieTemp
              MoTa_728816

              Dear Kejie-san,

               

              Thank you very much for your detailed observation!

               

              From your information (Vref = 1.2V), your code addition

              >> adc_count = (int16_t)(adc_count * (3.3/1.2)) ;

              seems reasonable to me.

               

              Anyway, I'm glad that you could make it work ;-)

               

              Best Regards,

              31-Oct-2019

              Motoo Tanaka