Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- frequency2temperature.comp.orig 2012-12-12 17:53:57.870992519 +0000
- +++ frequency2temperature.comp 2012-12-12 17:55:03.843331287 +0000
- @@ -11,6 +11,8 @@
- #include <rtapi_math.h> /* exp() and ln() */
- +extern double log(double);
- +
- /* see http://en.wikipedia.org/wiki/Thermistor
- The B-parameter equation is:
- 1/T = 1/T0 + 1/B * ln(R/R0)
- @@ -50,18 +52,20 @@
- const double R1 = 3500;
- float thermistor2temperature(float R) {
- + float T;
- if (R<=0)
- R=0.001; // avoid log(0)
- - float T = 1.0/ ( 1.0/T0 + (1.0/B) * log(R/R0) );
- + T = 1.0/ ( 1.0/T0 + (1.0/B) * log(R/R0) );
- return T;
- }
- float frequency2temperature(double f) {
- + float R, T;
- if (f<=0)
- f=1;
- - float R = 0.5 * ( (1.0/(f*0.6931*C1)) - R1);
- + R = 0.5 * ( (1.0/(f*0.6931*C1)) - R1);
- - float T = thermistor2temperature(R);
- + T = thermistor2temperature(R);
- return T;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement