Advertisement
Guest User

Untitled

a guest
Dec 12th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. --- frequency2temperature.comp.orig 2012-12-12 17:53:57.870992519 +0000
  2. +++ frequency2temperature.comp 2012-12-12 17:55:03.843331287 +0000
  3. @@ -11,6 +11,8 @@
  4.  
  5. #include <rtapi_math.h> /* exp() and ln() */
  6.  
  7. +extern double log(double);
  8. +
  9. /* see http://en.wikipedia.org/wiki/Thermistor
  10. The B-parameter equation is:
  11. 1/T = 1/T0 + 1/B * ln(R/R0)
  12. @@ -50,18 +52,20 @@
  13. const double R1 = 3500;
  14.  
  15. float thermistor2temperature(float R) {
  16. + float T;
  17. if (R<=0)
  18. R=0.001; // avoid log(0)
  19. - float T = 1.0/ ( 1.0/T0 + (1.0/B) * log(R/R0) );
  20. + T = 1.0/ ( 1.0/T0 + (1.0/B) * log(R/R0) );
  21. return T;
  22. }
  23.  
  24. float frequency2temperature(double f) {
  25. + float R, T;
  26. if (f<=0)
  27. f=1;
  28. - float R = 0.5 * ( (1.0/(f*0.6931*C1)) - R1);
  29. + R = 0.5 * ( (1.0/(f*0.6931*C1)) - R1);
  30.  
  31. - float T = thermistor2temperature(R);
  32. + T = thermistor2temperature(R);
  33. return T;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement