Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

temperature sensor LM35

Status
Not open for further replies.
Good morning,

I was reading about the LM35 and saw that it does not work under the terminal 4V + Vs therefore believe
that the configuration that I mentioned above, putting the LM35 + Vs to 2.5 volts should not be correct!

The friend advised me Ericgibbs: "Use of a reference voltage of +2.5 to adjust itself to a conversion
ADC, 8 bit "

I ask: How? I change the hardware or software? and how to change?

I appreciate any help!

Cabral

hi,
You are correct that the LM35 requires 4V minimum, I use +5V.

The Vref I explained in my previous posts was for the +Vref pin of the PIC.

Get a 2.5V ref ic and connect the 2.5V output to the +Vref of the PIC.

This will set the PIC's adc conversion so that for a 2.5V input voltage onto the adc inputs, it will give a conversion value of 1023 decimal [3FFh]

Connect the LM35 Vs to +5V and the LM35 output to an adc input pin on the PIC.

So if the temperature is say, 100Cdeg, the 1,0V output from the LM35 will give a conversion value of [1.0V/2.5Vref] * 1023 = 409

This value has to be multiplied within the program to make it equivalent to 100Cdeg.


I prefer to use the PIC's internal +Vref [5v] and use an amplifier with a gain of five.
This means the output from the LM35 at 100Cdeg = 5V, so the adc converts this to 1023, the maximum possible value.

Do you understand this OK.?
 
Got it!
But in the original circuit pin 5 of the pic 16F73, +Vref ( RA3 ) is not connected to anything! I need to stabilize a voltage of 2.5 V and connect this pin? Is this?

I appreciate the help and patience!

Cabral
 
Got it!
But in the original circuit pin 5 of the pic 16F73, +Vref ( RA3 ) is not connected to anything! I need to stabilize a voltage of 2.5 V and connect this pin? Is this?

I appreciate the help and patience!

Cabral

hi,
Do you have a circuit diagram you could post.?

If you use a 2.5V ref, you must alter the program to make RA3 a Vref pin...
 
hi,
Do you have a circuit diagram you could post.?

If you use a 2.5V ref, you must alter the program to make RA3 a Vref pin...

I will post the circuit diagram, and you can analyze it and make changes that will need to be made in
program and the hardware, ok? (The entire program I posted earlier)

Thank you again!

Cabral
 

Attachments

  • termometro.JPG
    termometro.JPG
    38.9 KB · Views: 766
Last edited:
hi,
Look at this image.
Change ADCON1 configuration to set AN3 as a +Vref pin
 

Attachments

  • termometro.JPG
    termometro.JPG
    39.9 KB · Views: 1,630
DEFINE osc 20

Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

define ADC_BITS 10
define ADC_CLOCK 3
define ADC_SAMPLEUS 50

temp var word
temperature var word
quanta con 1250

TRISA = %11111111
ADCON1= %10001110

Pause 500
Lcdout $fe, 1

loop:
ADCIN 0, temp
pause 5

temperature= (temp*10) */ quanta
lcdout $fe,2
lcdout $fe,$80,"Temp ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C"
Pause 200

Goto loop
End

OK. Now I have this code of displaying temperature on LCD, I need to improve it where I need to use a keypad to enter a value of temperature, when the air temperature equal of greater than the temperature being set, PIC will ON a LED. I am wondering how to insert the keypad part. I'll be using a 4*3 keypad.
 
hi,
Look at this image.
Change ADCON1 configuration to set AN3 as a +Vref pin

Ericgibbs,

:confused:

How is the first time you use a PIC with ADC input, just not with literature on the internet to help me configure AN3 as voltage reference.
Make time I tried to not need to ask, but really is not an answer here, give the projeto.Agradeço if you can analyze the source code as posted above and make the necessary changes ...

Thank you already,

Cabral
 
Ericgibbs,

:confused:

How is the first time you use a PIC with ADC input, just not with literature on the internet to help me configure AN3 as voltage reference.
Make time I tried to not need to ask, but really is not an answer here, give the projeto.Agradeço if you can analyze the source code as posted above and make the necessary changes ...

Thank you already,

Cabral

hi,
Do you mean this code.???, please confirm.:)

I understand you require RA3 as a +Vref for the ADC.?

Code:
DEFINE osc 20

Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

define ADC_BITS 10
define ADC_CLOCK 3
define ADC_SAMPLEUS 50

temp var word
temperature var word
quanta con 1250

TRISA = %11111111
ADCON1= %10001110

Pause 500
Lcdout $fe, 1

loop:
ADCIN 0, temp
pause 5

temperature= (temp*10) */ quanta
lcdout $fe,2
lcdout $fe,$80,"Temp ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C"
Pause 200

Goto loop
End
 
The pic is a 16F73 and this is the code below. You showed me to a reference voltage of 2.56v on pin 5 (AN3), so I did, but to configure, document RA3 + Vref for the ADC, I can not!




DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB
DEFINE LCD_DBIT 0 ' PORTB starting address
DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB
DEFINE LCD_RSBIT 5 ' LCD RS bit address
DEFINE LCD_EREG PORTB ' LCD E bit on PORTB
DEFINE LCD_EBIT 4 ' LCD E bit address
DEFINE LCD_BITS 4 ' LCD in 4-bit mode
DEFINE LCD_LINES 2 ' LCD has 2 rows
'
' Define A/D converter parameters
'
DEFINE ADC_BITS 8 ' A/D number of bits
DEFINE ADC_CLOCK 3 ' Use A/D internal RC clock
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
DEG CON 223
'
' Variables
'
Res Var Word ' A/D converter result
Temp1 Var Byte ' Temperature in degrees C
quatro var byte
TRISA = 1 ' RA0 (AN0) is input
TRISB = 0 ' PORTB is output
PAUSE 500 ' Wait 0.5sec for LCD to initialize
'
' Initialize the A/D converter
'
ADCON1 = 0 ' Make AN0 to AN4 as analog inputs,
' make reference voltage = VDD
ADCON0 = %11000001 ' A/D clock is internal RC, select AN0
' Turn on A/D converter
LCDOUT $FE, 1 ' Clear LCD
AGAIN:
'
' Start A/D conversion
'
ADCIN 0, Res ' Read Channel 0 data

Temp1 = Res * 2' Convert to degrees C
LCDOUT $FE,2,"TEMP = ",DEC Temp1, deg,"C"
PAUSE 1000 ' Wait 1 second
GOTO AGAIN ' Repeat
END ' End of program
 
hi,
your code.
Code:
ADCON1= %10001110

change to
ADCON1= %10000101; AD3 = +Vref

Look at this image.
 

Attachments

  • AAAimage01.gif
    AAAimage01.gif
    32.3 KB · Views: 442
Unfortunately it did not work ... The LCD shows 254 degrees and does not change if not heat or cool the LM35
 
Unfortunately it did not work ... The LCD shows 254 degrees and does not change if not heat or cool the LM35

What voltage do have connected to AN3, it should be +2.5V, thats the reference voltage that you have to apply to the AN3 pin.
 

Attachments

  • termometro.JPG
    termometro.JPG
    41.7 KB · Views: 898
Last edited:
You are not setiing the ADCON1 correctly!!!!!

ADCON1 = 0 ' Make AN0 to AN4 as analog inputs,

Its not correct if you want to use a external +2.5V ref.

Please post a circuit diagram showing how you have the analog pins connected.
 
Ericgibbs,

I put a reference of 2.56 volts on pin 5 (AN3) as you guided me in the drawing in
Annex, and the software I replace the ADCON1 = 0
by ADCON1= %10000101
as you guided me ...

Cabral
 

Attachments

  • termometro.JPG
    termometro.JPG
    39.9 KB · Views: 862
hi,
This is your program, I have had to modify it so that it will run in the Oshonsoft simulator.

Its uses the same pins as your circuit, with ADCON1 set and it works OK.

Look at this image.:)
 

Attachments

  • AAAimage03.gif
    AAAimage03.gif
    77.8 KB · Views: 520
Last edited:
Ericgibbs,

It worked! Now worked! :D:D

I used ADCON1 = 10000101% as you had suggested
and 2.56 V on pin 5 (AN3) and not more variable Temp1 multiply by two (res = temp1 * 2) and
worked very well!

Thank you very much for your help and patience friend!

Big hug,

Cabral
 
Hi
is it possible to build a simpler version (without the PIC) of a lm35 based thermometer? all I want it to do is to measure and disply. if there is, could you please direct me to where I can find the diagram?
Thanks.
 
Hi
is it possible to build a simpler version (without the PIC) of a lm35 based thermometer? all I want it to do is to measure and disply. if there is, could you please direct me to where I can find the diagram?
Thanks.

hi,
Look at the datasheet for the ICL7106, with a simple amplifier and a LM35 you can make a temperature display.:)
 

Attachments

  • ICL71067.pdf
    219.5 KB · Views: 443
Hi, I need to boost the output voltage of LM35 to 4 ~ 7V. How do i go about building the circuit? Please kindly include circuit diagrams as I'm a noob in circuit designs. Thanks and your help is greatly appreciated.
 
Hi, i am new here :)
i need some help. i need to build a thermometer..
i am ask to design a circuit using LM35 and ampilfied by a op-amp MCP602 to 5v..
then connected to PIC16F876..
but i have no idea how to start with >.<
can anyone help??
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top