Simple Digital Thermometer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Simple Digital Thermometer

Post by JohnCrow »

Simple Digital Thermometer

Introduction

My earlier temperature projects have all used the LM35 device.
This is a 3 pin device in either a TO-92 or TO-202 style package.

The device comes in a few different accuracies, but all operate with the same basic 10 mV/°C output.

The main problem with the LM35 is it only reads positive temperatures
(without external signal conditioning circuitry.)

This project uses the LM335 type device.
It comes in the same TO-92 package, but it has an output of 10mV/K
This allows it to read negative temperatures.
The device selected here reads from -40°C to 100°C (233.15K to 373.15K)

K = Kelvin
This is the absolute thermodynamic temperature scale, where 0K = absolute zero = -273.15°C
It is not referred to as degrees Kelvin, as in degrees Celsius, but just Kelvin.

Therefore
0°C = 273.15 K
100°C = 373.15 K

The output from the device is converted to temperature as follows
Remember to use the floating point calculations in Flowcode and not the standard mathematical operators.

First Convert The ADC voltage to Kelvin (Read ADC as float)
Temp = fmul ( ADC_Voltage, 100)

Now convert to °C from Kelvin
Temp2 = fsub( Temp , 273.15)

Example ADC Voltage = 2.1115 V
Temp = 2.9818 * 100
Temp = 298.18

Temp2 = Temp - 273.15
Temp2 = 298.18 - 273.15
Temp2 = 25.03
Temp2 is then converted to a string to be displayed on the LCD

Equipment :

EB-006 Programmer with PIC 16F877A
EB-005 LCD Display
EB-016 Prototype Board

LM335Z Temperature Sensor - Connected to ADC5 (Port E Bit 0)
10k-ohm Preset Pot (Multi Turn preferred)
1k8 Resistor

The 10k-ohm pot is used to calibrated the sensor. It is adjusted until the display shows the ambient temperature in the room measured as close to the LM335 as possible.
Once set is should not need to be adjusted again.
LM335.jpg
LM335.jpg (119 KiB) Viewed 8808 times
Circuit.jpg
Circuit.jpg (39.95 KiB) Viewed 8807 times
LM335Z Local Temperature Display-PortE.fcf
(11 KiB) Downloaded 699 times
1 in 10 people understand binary, the other one doesn't !

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Simple Digital Thermometer

Post by medelec35 »

Hi John
This will be handy in a quiet a few applications

Thanks for sharing.

Martin
Martin

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Simple Digital Thermometer

Post by JohnCrow »

To simplfy the circuit even more the variable resistor can be left out and the adj pin left unconnected.
The output is then taken between the 1k8 resistor and the V+ connection on the device.
1 in 10 people understand binary, the other one doesn't !

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Simple Digital Thermometer

Post by kersing »

Hi John,

In your experience, what is the best device for calibration? I've tried digital thermometers but after having three of them within a couple of centimeters and all showing different temperatures (1.8 degree centigrade between highest and lowest) I've got reservations about using them as a reference.

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Simple Digital Thermometer

Post by JohnCrow »

Hi Jac
My thoughts on these semiconductor temperature sensors.

The LM35 can normally be between 0.5°C and 1.5°C depending on which version you are using.
Dont think any are highly accurate. If you look at my Touch Screen Temp Monitor, im using 4 LM35's in that one and they are all reading the same. I have the sensors in a matix protoboard, so they are all fairly close together.

Ive only just started to look at the LM335 device. Having the trim pot does seem to make it more accurate. Not tried seeing how it changes over a range. Want to wait till I can leave it in the sun for a while (quite a rare thing in England at the moment :) ) after setting it at about 20°C and compare it to an accurate thermometer.
Have just tried freezer spray and took it down to -40°C,although no way of knowing how accurate this is.

Even the LM335 only claims 0.5°C accuracy though.

Other options are the DS18S20 one wire bus device, or another device I have used in the past is the AD594/595 thermocouple amplifier, which gives a direct linear dc output from a thermopcouple, but again I seem to remember these dont allow negative temperatures.

They all work fairly well, just depends how much accuracy you need for you application. If you need more than 1 device you may need to select on test to get a couple of devices to read the same.
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Simple Digital Thermometer

Post by jgu1 »

Hi John!

Another good project from you. Nice of you to share with us. :D

Regard

Jorgen.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Simple Digital Thermometer

Post by jgu1 »

Hi John!
A question!

I have now tried to make your fine project with lm 335 but only with a potentiometer. I can see, depending on the voltage of the analog input, skips the decimals after the decimal between 0 and 3 decimal places. Is it not possible to keep it constant at 1 or 2 decimal places. If, how do you do it. :?:

Thank´s in advance.

Jorgen.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Simple Digital Thermometer

Post by JohnCrow »

Hi Jorgen
Is it not possible to keep it constant at 1 or 2 decimal places. If, how do you do it.
It is posible to fix the length of the decimals when converting a float to string for printing. See this thread.
It does need you to edit one of the flowcode files, so for this application Im happy with it changing between 2 & 3 places of decimals depending on how many digits are in the integer part. (Think it was set to a string length of 5 places)

http://www.matrixmultimedia.com/mmforum ... gth#p24361

I have now tried to make your fine project with lm 335 but only with a potentiometer
Do you mean you are not using the 1k8 resistor in the 5V line? Not sure what effect that will have on the operation.
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Simple Digital Thermometer

Post by jgu1 »

Hi John!

I will look at it,thank´s :D

Concerning the potentimeter. It was insted of LM335 the analog input. I am waiting for a LM335.


Regard

Jorgen

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Simple Digital Thermometer

Post by JohnCrow »

Ahh Ok I see what you mean now.
1 in 10 people understand binary, the other one doesn't !

Post Reply