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:

    As a medium of exchange,... worrying regulates intimacy, and it is often an appropriate response to ordinary demands that begin to feel excessive. But from a modernized Freudian view, worrying—as a reflex response to demand—never puts the self or the objects of its interest into question, and that is precisely its function in psychic life. It domesticates self-doubt.
    Adam Phillips, British child psychoanalyst. “Worrying and Its Discontents,” in On Kissing, Tickling, and Being Bored, p. 58, Harvard University Press (1993)

    This pond never breaks up so soon as the others in this neighborhood, on account both of its greater depth and its having no stream passing through it to melt or wear away the ice.... It indicates better than any water hereabouts the absolute progress of the season, being least affected by transient changes of temperature. A severe cold of a few days’ duration in March may very much retard the opening of the former ponds, while the temperature of Walden increases almost uninterruptedly.
    Henry David Thoreau (1817–1862)

    Wars and revolutions and battles are due simply and solely to the body and its desires. All wars are undertaken for the acquisition of wealth; and the reason why we have to acquire wealth is the body, because we are slaves in its service.
    Socrates (469–399 B.C.)