4 Replies Latest reply on Nov 14, 2011 2:47 AM by vvsk

    Precision Temperature measurement using PSoC 3

    udayan.umapathi

      Are you wondering if is it possible to interface temperature sensors like thermocouple, RTD, Thermistor with PSoC3? Are you wondering how to go about it and about the accuracy and effort required. The answer to these questions is explained very well in the following article:

         

      Precision Temperature Sensing

         

      Cypress will be bringing out a kit to evaluate all the above mentioned temperature sensor. It will be available in Q2, 2011. The following App Notes describe temperature measurement usign diode and Thermistor respectively:

         

      AN60590 - PSoC® 3 / PSoC 5 - Temperature Measurement Using Diode

         

      PSoC® 3 and PSoC 5 Temperature Measurement with Thermistor - AN66477

         

      Regards,

         

      Udayan

        • 1. Re: Precision Temperature measurement using PSoC 3
          laurent.turcotte

          temperature calculation can be improved.

             

          in code example, Adc_I1 and Adc_I2 are int32.  Using float would avoid to truncate the decimal part. and would produce a more precise CurrentRatio

             

          int32 Adc_I1, Adc_I2
              /* Take average of 8 readings */
              Adc_I1 = Adc_I1 / 8;
              Adc_I2 = Adc_I2 / 8;
             
              /* Subtract the ADC offset from the measured values */
              Adc_I1 = Adc_I1 - AdcOffset;
              Adc_I2 = Adc_I2 - AdcOffset;
             
              /* IDAC Current ratio is the ratio of the ADC counts */
              CurrentRatio = (float)Adc_I2 / (float)Adc_I1;
           

             

           

             

          later in GetDiodeTemperature()
          same problem. Vbe1_count and Vbe2_count are int32 and divided by 8 before convertion to float

             

           

             

              /* Take average of 8 readings. Divide by 8 is done as Right shift by 3 to speed up computation */
              Vbe1_count = Vbe1_count >> 3;
              Vbe2_count = Vbe2_count >> 3;

              Vbe_diff = (Vbe2_count - Vbe1_count);
             
              diode_temperature =(Vbe_diff * multiply_factor) - ZERO_DEGREE_CELSIUS_KELVIN; 

             

          //Temperature in degree Centigrade 
           

             

           

             

          see attached file for modified source code

          • 2. Re: Precision Temperature measurement using PSoC 3
            vvsk

            Hi Lauren,

               

            I wrote the code for that diode project. The suggestions you have provided are another method of computing the same temperature.

               

            1.) I can as well remove the averaging in the ADC offset calculation and move it to one place where IDAC current ratio is calculated. This will simplify the computation. But I dont want to change it because for a new user or anyone who wants to reuse that offset calculation routine as a general purpose function for other ADC measurements in the application, it would mean that they have to introduce a divide-by-8 in any other place they call this "calculateoffset" function.

               

            2.) Regarding, using a divide-by-8 instead of a ">>3" operation, it wouldn't make much of a difference. The reason is in my project the ADC is in 20-bit mode which means at most I may lose 7 counts (because the remainder is lost). But 7 counts for ADC in such a high resolution will be too low to give any improvement in temperature measurement (< 0.1 C). So I traded off computation for accuracy there.

               

            All the changes suggested by you are correct anyway. Let me know if you have further thoughts on this.

               

            Regards,

               

            Vivek

            • 3. Re: Precision Temperature measurement using PSoC 3
              laurent.turcotte

              Hi

                 

              My implementation was for a PSOC3, using a 12 bits ADC.

                 

              In that case, the multiplying factor is larger  (  x 1.86  )

                 

              This produce 2 degree steps with the previous calculation method

              • 4. Re: Precision Temperature measurement using PSoC 3
                vvsk

                Lauren,

                   

                For lower resolution ADC configurations, the method you suggested is the better method. I am updating this project over next few weeks for next version of software. During that time, I will add comment in the code with regards to this computation.

                   

                Regards,

                   

                Vivek