/************************************************************************* * vishay_NTCLE100E3103_to_F * * Conversion routine: Thermistor reading (volts) to degF * Uses extended Steinhart and Hart approximation * Routine takes 1 argument: * psub->a - Voltage drop across thermistor (some_PV_name) * psub->val - returns calculated temperature in degrees Farenheight * ***************************************************************************/ #include #include #include #include #include #include #include #include float vishay_NTCLE100E3103_to_F(struct subRecord *psub) { /*constants for extended Steinhart and Hart equation for Vishay NTCLE100E3103*/ float A = 3.354016E-3; float B = 2.569850E-4; float C = 2.620131E-6; float D = 6.383091E-8; /*fixed resistor value in voltage divider*/ float RFIXED = 10000.0; /*voltage output of voltage reference used as source*/ float VREF = 10.0; float Inv_Temperature,G1,G2,G3,R1,Temperature; /*voltage drop across thermistor*/ float VDROP; static unsigned char UDF = TRUE; if(UDF) { psub->udf = FALSE; UDF = FALSE; } VDROP = psub->a; psub->val = 0.; /*The constants from Vishay use the ratio R1/RFIXED in the equation. So, we can simplify the equation R1 = (RFIXED)/((VREF/VDROP)-1) to be...*/ R1 = 1/((VREF/VDROP)-1); G1=log(R1); G2=exp(2*log(B1)); G3=exp(3*log(B1)); Inv_Temperature=A+(B*G1)+(C*G2)+(D*G3); Temperature=(1/Inv_Temperature)-273.15; /*now we have centigrade*/ Temperature=(Temperature*1.8)+32; /*now we have farenheight*/ psub->val = Temperature; return(0); };