cancel
Showing results for 
Search instead for 
Did you mean: 

Code Examples

odissey1
Honored Contributor II

Hi All,

   

Attached is my Thermistor Calculator component ("myThermistor"). It calculates thermistor temperature from the resistance, similar to the Creator's stock Thermistor component. Calculated temperature returned as float-precision value with accuracy approx. 0.001 degC. Calculation speed is about 14-15x times faster than stock Thermistor component (formula-based) taking about 1100 CPU cycles.

     

The component was developed for fast TEC control, where accuracy, speed and wide temperature range were important. Attached archive contains the workspace bundle of the demo project, datasheet, screenshots and reference materials. Tested on PSoC5LP.

      

regards,  

odissey1

P.S. Updated link to SRS Thermistor Calculator:

https://www.thinksrs.com/downloads/programs/therm%20calc/ntccalibrator/ntccalculator.html

myThermistor demo.PNG

Parameters.PNG

SRS Thermistor Calculator.png

10 Replies
Praveen
Community Manager
Community Manager

 Thanks for sharing this with the community.

   

 

   

Praveen

Cheers
Praveen
0 Likes
urchc_1533771
New Contributor II

I opened this design and not see any connections to thermistor. How it`s work ?

   

Usually exist thermistor and normal resistor and ADC that calculate difference between ... 

0 Likes
JoMe_264151
Expert II

It is a pure software component that offers different ways to calculate the temperature from ADC values. See datasheet.

   

 

   

Bob

0 Likes
odissey1
Honored Contributor II
        chaplin.u, the Fast Thermistor Calculator is a replacement for Cypress stock Thermistor Calculator component and should be used same way the standard Thermistor Calculator is used. This component optimizes calculation speed (approx. 15x faster) by using log function approximation. Use Cypress standard Thermistor demo project and add/replace Thermistor Calculator.   
0 Likes
urchc_1533771
New Contributor II

Thanks, I tried it and it work fine. Just one problem. Instead of it`s "pure software component"  when I change my device to PROC Components tab is not visible and receive error :Component is not supported by this device...

0 Likes
odissey1
Honored Contributor II

I will take a look what is going on. But don't hold your breath...

0 Likes
odissey1
Honored Contributor II

Here is an answer. The custom component creation is not supported for PRoC family of devices. (?!)

The FastThermistorCalculator is indeed is just a piece of C code with component symbol attached to it. All you need is to copy *.h and *.c files into your project and set parameters in code like that.

Replace in *.h:

/***************************************

*           API Constants

***************************************/

#define `$INSTANCE_NAME`_REF_RESISTOR   ((float) `$ReferenceResistor`) //Reference resistor value [oHm]

#define `$INSTANCE_NAME`_K2C    (273.15f)                       //conversion degK to degC, deg: Tc = Tk - K2C

   

#define `$INSTANCE_NAME`_THA    ((float) `$SteinhartHart_THA`)  //Steinhart-Hart coeff A  

#define `$INSTANCE_NAME`_THB    ((float) `$SteinhartHart_THB`)  //Steinhart-Hart coeff B

#define `$INSTANCE_NAME`_THC    ((float) `$SteinhartHart_THC`)  //Steinhart-Hart coeff C

with something like (use your parameters!):

/***************************************

*           API Constants

***************************************/

#define `$INSTANCE_NAME`_REF_RESISTOR   ((float) 10000.0) //Reference resistor value [oHm]

#define `$INSTANCE_NAME`_K2C    (273.15f)                       //conversion degK to degC, deg: Tc = Tk - K2C

   

#define `$INSTANCE_NAME`_THA    ((float) 0.0011259)  //Steinhart-Hart coeff A  

#define `$INSTANCE_NAME`_THB    ((float) 0.0002346498)  //Steinhart-Hart coeff B

#define `$INSTANCE_NAME`_THC    ((float) 8.564001E-08)  //Steinhart-Hart coeff C

0 Likes
urchc_1533771
New Contributor II

Thanks ! I found second way. Just changed to PSOC device, compiled, copy generated code to my project and return to PROC.

Thanks for your code again !!!

0 Likes
urchc_1533771
New Contributor II

Hi !

What a range of temperatures this calculator ? In datasheet not exist this information.

0 Likes
odissey1
Honored Contributor II

Good question. The accuracy was tested using a set of A,B,C coefficients

for a 10k thermistor, which I typically use (TS-91), using the test demo

project provided.  The Datasheet clearly states that accuracy comparison

was done in Range 0-50C (from Rmin=3.602 k to Rmax=33.660 k)

You can run demo using your set of Steinhart coefficients to check the

accuracy of approximation in the range of interest.

0 Likes