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.
eblc1388 said:
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.
Yep and it's imposible to achieve such resolution in real life (and you are very limited by sensors resolution anyways...)
 
it looks like the LM35 is accurate to a tenth of a milli Volt
thats 0.0001V

so 2.5*1 /1024 =0.0024 V at its lowest reading .. and

2.5*1023/1024=2.4975 V
2.5*1024/1024 = 2.5000V at its maximum
question??
where are you going to be doing these calculations ...ie how are you going to be displaying the data ??
because if you are going to to be making decisions based on the temp reading .. there is no need to calculate the value returned , in volts..
 
williB said:
it looks like the LM35 is accurate to a tenth of a milli Volt
thats 0.0001V

I didn't see that in the datasheet?.

What I did see was it's guaranteed accurate within 0.5 of a degree centigrade at 25 degrees centigrade. Linearity is guaranteed to be no worse than 1.5% over it's full range.

A 10 bit A2D in a PIC is going to be fine for this, no problem at all, in theory exceeding the spec of the LM35 - and certainly exceeding the capability of calibrating it that accurately?.
 
i agree that the 10 bits available are plenty for the job..
why would they state the output as 10.0 mV and not 10mV if it wasnt accurate to a tenth of a milli volt.
 

Attachments

  • lm35_148.jpg
    lm35_148.jpg
    12.7 KB · Views: 1,023
williB said:
i agree that the 10 bits available are plenty for the job..
why would they state the output as 10.0 mV and not 10mV if it wasnt accurate to a tenth of a milli volt.

They could state it as 10.00000000mV, but it still means EXACTLY the same as 10mV - try reading the datasheet for details of the device!.
 
whoa cowboy.. calm down..lol
i did read the data sheet, but that was all i could find on the accuracyof the voltage output...
 
Does anyone have a good algorithm for displaying a decimal number on an LCD?
For example, if I want to display 25.1.
I'm thinking of multiplying it by 10 first, then dividing the number by 100 to get 2, then divide the remainder by 10 to get 5, then divide the remainder again to get 1.
Any better suggestions?
 
ptewright said:
Does anyone have a good algorithm for displaying a decimal number on an LCD?
For example, if I want to display 25.1.
I'm thinking of multiplying it by 10 first, then dividing the number by 100 to get 2, then divide the remainder by 10 to get 5, then divide the remainder again to get 1.
Any better suggestions?

If you have a decimal number then you just display it, by converting each digit to ASCII. If the number is hexadecimal you need a HEX to Decimal conversion routine. If you check various of my tutorials (including the analogue one), I provide just such a routine that's fast and easy to use - I didn't write it, I found it on the PICList. As for the decimal point, you just insert it where it needs to go!.
 
ptewright said:
Does anyone have a good algorithm for displaying a decimal number on an LCD?
For example, if I want to display 25.1.
I'm thinking of multiplying it by 10 first, then dividing the number by 100 to get 2, then divide the remainder by 10 to get 5, then divide the remainder again to get 1.
Any better suggestions?

This is the code I normally use to display a single byte number. The number to be displayed is in the W register.

Code:
WriteDec    clrf    Decimal100
Count100s   incf    Decimal100,F
            addlw   100h-100;   -100
            btfsc   STATUS, C
            GoTo    Count100s
            addlw   100
            clrf    Decimal10
Count10s    incf    Decimal10,F
            addlw   0f6h;       -10
            btfsc   STATUS, C
            GoTo    Count10s
            movwf   Units
            movfw   Decimal100
            addlw   2fh
            Call    WriteData
            movfw   Decimal10
            addlw   2fh
            Call    WriteData
            movfw   Units
            addlw   30h+0ah
WriteData
; here should be the code to write a 
; character to the LCD

HTH

Mike.
 
Jay.slovak said:
And I would replace R1 with serial combination of trimer and resistor, so it can be fine tuned.

Dumb question:
If I were to replace R1 with a trimer and resistor as you suggested, how would I connect the 3 leads of the trimer? :?
 
ptewright said:
Jay.slovak said:
And I would replace R1 with serial combination of trimer and resistor, so it can be fine tuned.

Dumb question:
If I were to replace R1 with a trimer and resistor as you suggested, how would I connect the 3 leads of the trimer? :?
lol no problem :lol:
Try this :D
 

Attachments

  • trimer_resistor.gif
    trimer_resistor.gif
    1.9 KB · Views: 321
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top