Resistance Thermometer - The Function For Temperature Value Acquisition (C++)

The Function For Temperature Value Acquisition (C++)

The following code estimates a Pt100 or Pt1000 sensor's temperature from its current resistance (input parameter r).

float GetPt100Temperature(float r) { float const Pt100 = { 80.31, 82.29, 84.27, 86.25, 88.22, 90.19, 92.16, 94.12, 96.09, 98.04, 100.0, 101.95, 103.9, 105.85, 107.79, 109.73, 111.67, 113.61, 115.54, 117.47, 119.4, 121.32, 123.24, 125.16, 127.07, 128.98, 130.89, 132.8, 134.7, 136.6, 138.5, 140.39, 142.29, 157.31, 175.84, 195.84 }; int t = -50, i = 0, dt = 0; if (r > Pt100) while (250 > t) { dt = (t < 110) ? 5 : (t > 110) ? 50 : 40; if (r < Pt100) return t + (r - Pt100) * dt / (Pt100 - Pt100); t += dt; }; return t; } float GetPt1000Temperature(float r) { return GetPt100Temperature(r / 10); }

Read more about this topic:  Resistance Thermometer

Famous quotes containing the words function, temperature and/or acquisition:

    “... The state’s one function is to give.
    The bud must bloom till blowsy blown
    Its petals loosen and are strown;
    And that’s a fate it can’t evade
    Unless ‘twould rather wilt than fade.”
    Robert Frost (1874–1963)

    The siren south is well enough, but New York, at the beginning of March, is a hoyden we would not care to miss—a drafty wench, her temperature up and down, full of bold promises and dust in the eye.
    —E.B. (Elwyn Brooks)

    Whatever may be our just grievances in the southern states, it is fitting that we acknowledge that, considering their poverty and past relationship to the Negro race, they have done remarkably well for the cause of education among us. That the whole South should commit itself to the principle that the colored people have a right to be educated is an immense acquisition to the cause of popular education.
    Fannie Barrier Williams (1855–1944)