Reading an LM35 sensor in minus degrees 16F690

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Reading an LM35 sensor in minus degrees 16F690

Post by TedO »

Hi all,

I have eventually finished my fridge controller which works perfectly well on a breadboard using 2 pots to simulate the LM35 sensors, but am having difficulty with the LM35 sensors (one for cabinet temp and the other for the evaporator temp)

When simulating the sensors on the breadboard, I used pots which I read to get an INT, then subtracted 512 to get 0 degrees midway on the pot setting which allowed me to simulate the minus side of the pot. Having now connected the LM35 sensors to the breadboard and placed the sensors inside a freezer, the temp goes down to 0 degrees and will not budge below that.

I read the LM35 sensors as Martin taught me in previous posts of mine, where: temp=temp *49/10 and then temp=temp/10 (having 10mV/degree C) to get a whole number on the degree of temperature, which is fine for any positive degree of temperature. The LM35 can read from -55 to 150 degrees according to the datasheet, how do I get the minus degree readings from the sensors? Have gone through the datasheet but has no clue.

Would appreciate some help please.

Thanks
Regards
Ted

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: Reading an LM35 sensor in minus degrees 16F690

Post by kersing »

Have you connected the lm35 as displayed in the right diagram of the datasheet first page? (Using negative voltage?)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Post by dazz »

HI

another way for a single power supply is shown in the attached datasheet (fig 18)

call vout + V1
Call vout - V2
connect each to an adc input and use this calculation temp=(v1-V2)*100 deg c
Hopefully it will work

Regards
Dazz

lm35.pdf
(1.3 MiB) Downloaded 503 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Post by QMESAR »

Well yes Kersing is correct the next question would be how do you measure negative voltages with the PIC ADC ?
would ne bice if some one can explain this
Attachments
1.jpg
1.jpg (16.5 KiB) Viewed 7813 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Post by QMESAR »

@dazz
We were posting at the same time your solution sounds good :D

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Post by TedO »

Thanks to all who responded to my request.

Dazz, I saw the figure 18 drawing but was totally confused with 2 outputs to the PIC instead of one, now that you have explained to me that I need to take both into ADC inputs and make the calculation, it makes a lot of sense!!!! I will try it and let you know how it went.

When I saw the sensor reading stop at 0 degrees on the LCD I realized that for me there was no way of reading the negative voltage......we live and learn new things every day.

Greatly appreciated
Regards
Ted

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Post by TedO »

Hi Dazz

Your advice on the LM35C sensors was spot on, only thing that I had to change was to remove the "*100" part of your formula. Following my program below gives you the temp accurately, no need to multiply by 100.
So to read the LM35C sensor for minus temperatures, follow the datasheet fig 18 to the letter, then write the program as follows:
You need 2 ADC inputs as Dazz has correctly mentioned per sensor, one for positive output from sensor the other the "negative" output which is slightly above ground due to the 2 1N914 diodes.

Get INT on both iputs ie tempPos and tempNeg
tempPos=tempPos*49/10
tempPos= tempPos/10
tempNeg=tempNeg*49/10
tempNeg=tempNeg/10
TempResult=(tempPos-tempNeg)

Now you can display TempResult on an LCD display with minus temperature readings.
Thanks to all for your valued input, this is how we all learn together.
Regards
Ted
Attachments
1.jpg
1.jpg (14.63 KiB) Viewed 7779 times

Post Reply