I need the equation for calculating the temperature... (by marzook)
I use LM35 for temperature measurement ....
I need the equation for calculating the temperature ... Someone Can help or give an example in ladder logic?
Welcome
marzook
(no subject) (by Jonathan Westhues)
We note that the LM35 puts out a voltage proportional (with no offset) to the temperature T in degrees Celsius. Since your micro's A/D can't convert negative values, this means your circuit will work only for temperatures above freezing.
As mentioned, the scale is 10 mV/degree. So
Vout = 0.010*T
Then for a 10-bit A/D converter with a 5 V reference,
code = 1023*V/5 = 1023*0.010*T/5 = 2.046*T
so
T = code/2.046
If we want to evaluate this using only integer math, then we might write T = (code*22)/45. That doesn't overflow with 16-bit math, since 22*1023 = 22507 < 32768. I chose that approximation by truncating the continued fraction, so there's a sense in which it's optimal. This doesn't really matter, as long as it's much better than other sources of error (for example, the tolerance on the voltage reference, often around 1%) in the system.