/************************************************************************* * YSI44031_to_F * * Conversion routine: Thermistor reading (volts) to degF * Uses Steinhart and Hart approximation * Routine takes 1 argument: * psub->a - Voltage drop across thermistor (HacE_D1_NMR:SREG) * psub->val - returns calculated temperature in degrees Farenheight * ***************************************************************************/ #include #include #include #include #include #include #include #include float YSI44031_to_F(struct subRecord *psub) { /*constants for Steinhart and Hart equation for YSI44031*/ float A = 1.0284299584E-3; float B = 2.3927781009E-4; float C = 1.5591039659E-7; /*fixed resistor value in voltage divider*/ float RFIXED = 10000.0; /*voltage output of voltage reference used as source*/ float VREF = 10.0; float A1,B1,G1,R1,T1; /*voltage drop across thermistor*/ float VDROP; static unsigned char UDF = TRUE; if(UDF) { psub->udf = FALSE; UDF = FALSE; } VDROP = psub->a; psub->val = 0.; R1 = ((VDROP/VREF)*RFIXED)/(1-(VDROP/VREF)); B1=log(R1); G1=exp(3*log(B1)); A1=A+(B*B1)+(C*G1); T1=(1/A1)-273.15; /*now we have centigrade*/ T1=(T1*1.8)+32; /*now we have farenheight*/ psub->val = T1; return(0); };