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.

LM35 with PIC adc

Status
Not open for further replies.

ptewright

New Member
I'm planning on using the PIC's adc to read the analog output from the LM35 temperature sensor. This sensor has a 10mV sensitivity (ie. it outputs 0V at 0oC and 1V at 100oC) I read Nigel's a2d tutorial, but I don't quite understand it. If I use a 10-bit a2d, what is my minimum resolution? I'd like to be able to display the temperature in 0.1oC increments. Do I need an amplifier for that?

Oh and for those who have used the LM35 before, do I need a resistor between the output pin and ground? what is it for?

Thanks a bunch!
 
ptewright said:
I'm planning on using the PIC's adc to read the analog output from the LM35 temperature sensor. This sensor has a 10mV sensitivity (ie. it outputs 0V at 0oC and 1V at 100oC) I read Nigel's a2d tutorial, but I don't quite understand it. If I use a 10-bit a2d, what is my minimum resolution? I'd like to be able to display the temperature in 0.1oC increments. Do I need an amplifier for that?

Oh and for those who have used the LM35 before, do I need a resistor between the output pin and ground? what is it for?

Thanks a bunch!
You should use external reference of 2.5V (max resolution of PICs ADc). If you amplify it 2.5 times, with 10 bit resolution will give you 1024 steps, so you will have ~0.1C resolution. This is a very fine resolution, so try to make the wires short, to prevent noise...
 
cool thanks for the suggestions.
Is this how I connect the tl431 to get the 2.5 reference voltage?
How do I hook up the LM386 to amplify my 0-1V output to 0-2.5V?
Is there other methods? A little diagram would be very much appreciated :lol:
 
ptewright said:
cool thanks for the suggestions.
Is this how I connect the tl431 to get the 2.5 reference voltage?
How do I hook up the LM386 to amplify my 0-1V output to 0-2.5V?
Is there other methods? A little diagram would be very much appreciated :lol:
This will work fine, I will try to post you that 386 schematic.
 
OK, try this:

A=1+(R1/R2)

A - Amplification, should be 2.5 in your case
 

Attachments

  • 386_207.gif
    386_207.gif
    3.4 KB · Views: 1,747
Jay.slovak said:
OK, try this:

A=1+(R1/R2)

A - Amplification, should be 2.5 in your case

I'm gonna get some parts and try this circuit tomorrow!!
Just curious....Does it matter what values R1 and R2 are as long as R1 is 1.5 times bigger than R2? Let's say I use 15k and 10k, could I as well use 150k and 100k?
 
ptewright said:
Jay.slovak said:
OK, try this:

A=1+(R1/R2)

A - Amplification, should be 2.5 in your case

I'm gonna get some parts and try this circuit tomorrow!!
Just curious....Does it matter what values R1 and R2 are as long as R1 is 1.5 times bigger than R2? Let's say I use 15k and 10k, could I as well use 150k and 100k?
Oh, I ment LM358 not LM386 (Thanks eblc1388 !) LM386 is an Audio amplifier, LM358 is a rail-to-rail amplifier, it's suitable for your needs.

those resistors should be from 10K to 10M, it's not critical.
So R1=150K R2=100K will be fine.
 
While we are at the subject of A to D conversion, I have following question:

For a 10-bit AD converter on 16F877 with a Vref+ = 2.5V and Vref- =0V, what is the input voltage if the converter is giving out all high on its converted bit result?

answer 1: 2.5V

answer 2: 2.5V x 1023/1024 = 2.49756V

And if we get a converted result in between 0-1023, should we multiply it by (2.5V/1024) or (2.5V/1023)?

Thanks
 
eblc1388 said:
While we are at the subject of A to D conversion, I have following question:

For a 10-bit AD converter on 16F877 with a Vref+ = 2.5V and Vref- =0V, what is the input voltage if the converter is giving out all high on its converted bit result?

answer 1: 2.5V

answer 2: 2.5V x 1023/1024 = 2.49756V

And if we get a converted result in between 0-1023, should we multiply it by (2.5V/1024) or (2.5V/1023)?

Thanks
Certainly 2.5V will return full-scale result (all 1's). And you will multiply the result with "AD reference voltage/Number of steps"
 
Jay.slovak said:
Certainly 2.5V will return full-scale result (all 1's). And you will multiply the result with "AD reference voltage/Number of steps"

The number of steps is 1024 for a 10-bit converter, right?

So all '1' in the converted result means 1023 x 2.5V /1024 = 2.49756V, right?
 
eblc1388 said:
Jay.slovak said:
Certainly 2.5V will return full-scale result (all 1's). And you will multiply the result with "AD reference voltage/Number of steps"

The number of steps is 1024 for a 10-bit converter, right?

So all '1' in the converted result means 1023 x 2.5V /1024 = 2.49756V, right?

Yes, There are 1024 steps per 10bit AD (2^10+1). But now when I think about it, it should be like this:
Code:
2.5V 	 =	11 1111 1111b
1.248V	=	01 1111 1111b
=
=
=
=
0.00244	=	00 0000 0001b
0   	   =	00 0000 0000b


ADres*Uref/2^10=Voltage

Example:
511*2.5/1023=1.248V
 
ADCs always round down. A reading of zero can be any voltage up to (but less than) 2.5/1024. So for a more accurate value, you should add 2.5/2048 (I.E 1/2 a bit) to the result. In reality, the accuracy and linearity of the ADC make this rather academic.

Mike.
 
Jay.slovak said:
But now when I think about it, it should be like this:
Code:
2.5V 	 =	11 1111 1111b
1.248V	=	01 1111 1111b
=
0.00244	=	00 0000 0001b
0   	   =	00 0000 0000b
ADres*Uref/2^10=Voltage

Example:
511*2.5/1023=1.248V

I got it.

When you said 2.5V = 11 1111 1111b, this is a condition you want to achieve. In order to get his condition, you need to use a slightly higher reference voltage.

So using a reference of 2.5x1024/1023 = 2.5024V.. would be good.

But if you use a 2.5000V reference, I am afraid 11 1111 1111b would be 2.49756V and not 2.50000V. Of course, in real life, who cares.
 
Just an extra thought?, what is the specified accuracy of the temperature sensor?.

A 10 bit A2D is attempting to give 0.1% resolution, which is likely to be far more than the sensor provides?, so discussing half bits is rather pointless?.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top