Strange Math Problem (Resolved)
Greg LaPolla
Posts: 323
I found this code in another thread for Steinhart Hart
It always returns a negative number.
I put the above problem in mathcad(see attachment) and it calculates properly. Using the same numbers in the prop yields an answer of
-9.549217
Edit - Forgot to attach picture
Post Edited (Greg LaPolla) : 4/2/2009 2:54:06 AM GMT
PRI Calc_StHart (A,B,C,Resistance) : Kelvin | B_x_Rlog , C_x_Rlog , Rcubed, Rlog, Addit G.start ' Start math32 Rlog := G.log(Resistance) ' Take the log of the Resistance B_x_Rlog := G.FMul(B,Rlog) ' Multiply B to log of R RCubed := G.FMul(Rlog,Rlog) ' Cube the log of R by R * R * R RCubed := G.FMul(Rlog,RCubed) ' Finish the Cube C_x_Rlog := G.FMul(RCubed,C) ' Multiply C to log the cubed log R Addit := G.Fadd(C_x_Rlog,B_x_Rlog) Addit := G.Fadd(Addit, A) ' Add all A,B,C together Kelvin := G.Fdiv(one,addit) ' Kelvin = 1/ all added G.stop
It always returns a negative number.
I put the above problem in mathcad(see attachment) and it calculates properly. Using the same numbers in the prop yields an answer of
-9.549217
Edit - Forgot to attach picture
Post Edited (Greg LaPolla) : 4/2/2009 2:54:06 AM GMT
Comments
R1_Float = 10000.0
R1_4095 = 4095.0 * R1_Float
and
ohms := FSub(FDiv(R1_4095,FFloat(ADC.GetData(0))),R1_Float)
Post Edited (Mike Green) : 4/1/2009 11:40:51 PM GMT
Thanks for the heads up!
Greg
The last calculation ( Fht := G.Fadd(Fht,32)) will not run.
Cheers!
Paul Rowntree