blueroomelectronics
Well-Known Member
I’m building a thermostat kit using a LM34 temperature sensor.
I requre the results in C or F
An LM34DZ is a Fahrenheit sensor and has an excellent range for direct A/D input on the PIC. -32C to 100C are possible (0F to 212F) or 0V to 2.12V at the A/D pin. The LM34 also offers more resolution per degree in this application.
The PICs 10bit ADRES is right justified (MSB --- LSB) and uses GND for the zero reference and 2.5V for the +Vref.
The math I’d like to simplify and avoid floating point, it would be nice but not necessary to convert the fractional part at this point.
So for F the formula is… (ADRES is the 10bit right justfied result) the result is a single byte integer (decimal)
F=(ADRES*125)/4096
C=(ADRES*125-32)*(5/9)/4096
Now F itself is very simple, *125 is easy and divide by 4096 (2^12) is super easy in binary. It’s the Celsius math I’d like some help with.
I requre the results in C or F
An LM34DZ is a Fahrenheit sensor and has an excellent range for direct A/D input on the PIC. -32C to 100C are possible (0F to 212F) or 0V to 2.12V at the A/D pin. The LM34 also offers more resolution per degree in this application.
The PICs 10bit ADRES is right justified (MSB --- LSB) and uses GND for the zero reference and 2.5V for the +Vref.
The math I’d like to simplify and avoid floating point, it would be nice but not necessary to convert the fractional part at this point.
So for F the formula is… (ADRES is the 10bit right justfied result) the result is a single byte integer (decimal)
F=(ADRES*125)/4096
C=(ADRES*125-32)*(5/9)/4096
Now F itself is very simple, *125 is easy and divide by 4096 (2^12) is super easy in binary. It’s the Celsius math I’d like some help with.