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

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

Postby TedO » Sun Jul 17, 2016 12:17 pm

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: 1907
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1064 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Postby kersing » Sun Jul 17, 2016 1:33 pm

Have you connected the lm35 as displayed in the right diagram of the datasheet first page? (Using negative voltage?)
These users thanked the author kersing for the post:
TedO (Sun Jul 17, 2016 3:30 pm)
Rating: 5%
 
“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: 514 times
Been thanked: 467 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Postby dazz » Sun Jul 17, 2016 1:54 pm

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 232 times
These users thanked the author dazz for the post (total 4):
QMESAR (Sun Jul 17, 2016 2:01 pm) • TedO (Sun Jul 17, 2016 3:30 pm) • kersing (Sun Jul 17, 2016 8:51 pm) • medelec35 (Mon Jul 18, 2016 4:54 pm)
Rating: 20%
 
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: 1187
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 379 times
Been thanked: 604 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Postby QMESAR » Sun Jul 17, 2016 1:59 pm

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 3933 times
These users thanked the author QMESAR for the post:
TedO (Sun Jul 17, 2016 3:30 pm)
Rating: 5%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1187
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 379 times
Been thanked: 604 times
Contact:

Re: Reading an LM35 sensor in minus degrees 16F690

Postby QMESAR » Sun Jul 17, 2016 2:01 pm

@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

Postby TedO » Sun Jul 17, 2016 3:27 pm

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

Postby TedO » Mon Jul 18, 2016 3:55 pm

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 3899 times
These users thanked the author TedO for the post (total 2):
medelec35 (Mon Jul 18, 2016 4:54 pm) • dazz (Tue Jul 19, 2016 9:51 am)
Rating: 10%