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.

AD Result with Decimal Point

Status
Not open for further replies.

Suraj143

Active Member
Hi I have done a temperature display using LM35 & it worked.

I just right justify & read the ADRESL.

Ex: If the room temperature = 25C then it’s giving 51.2 steps.

So this is the ADRESL value, when I divide by 2 its showing the room temperature.

That’s fine it’s working.

What I need is I need to add a decimal point to this final temperature.
When I divide the AD result steps its always giving a round value.

I need temperatures like this 25.2, 25.3, and 25.4 etc……..not like 25, 26, and 27.
 
What value will you get from the ADC for different temperatures?

I.E.
25C = 500
26C = 520

Mike.
 
You don't have enough resolution to get a decimal point with your current setup. Can you change your reference voltage to something like 2V, this would give a reading around 125 for 25°C. Depending on which pic you are using you may be able to use the internal voltage reference to do this. With this setup you could simply multiply by 2 and convert to decimal - the decimal point would be placed before the last digit.

Mike.
 
Hi Mike

Depending on which pic you are using you may be able to use the internal voltage reference to do this.

That is the point mike.With just VDD & VSS reference you can't do this.So I need to make a reference about 2V.

Can I make my reference using two resistors?
Like 1.2K with 4.7K? (4.7K to GND side & 1.2K Vdd side, the resistor joint is going to AD input).

With this setup you could simply multiply by 2 and convert to decimal - the decimal point would be placed before the last digit.

So that means I have to work on whole 10 bit.The ADRESL is not enough
25C=125 steps
50C=250 steps
100C=500 steps
 
Why don't you go whole hog:
25C=250 steps
50C=500 steps
100C=1000 steps
Then there is no math to do and the increment will look natural. Just place the decimal point and display!
Use an OpAmp to scale the input if Vref can't go low enough.
 
Last edited:
Hi kchriste with reference VDD & VSS I'm getting results like this.

25C=51
26C=52
50C=102

What is hog?

How do you get 25C=250 steps?
 
I think you mean to make the Vref = 1V.Can I use two resistors to make this reference.I don't like opamps
 
Some pics have an internal voltage reference that can be set to around 2V. Which pic are you using.

Mike.
Edit, the minimum voltage allowed for Vref is 2V.
 
Last edited:
The 877 has an internal voltage reference that can be outputted on AN2, this could be connected to AN3 to use as a reference for the ADC. However, as this is just a resistive divider you may as well use a couple of resistors (put a cap across the bottom one to smooth it a little). Your accuracy will only be as good as your supply but the LM35 is only accurate to 0.5° anyway. Alternatively, a resistor/zener type reference with a pot across the zener for adjustment would be more accurate. As mentioned by kchriste, the most accurate solution would be an opamp.

Mike.
 
Hi kchriste with reference VDD & VSS I'm getting results like this.
25C=51
26C=52
50C=102
That would mean that 50C = 0.5V if you are using the full 1024 steps (10bit resolution) of the ADC.
Can I use two resistors to make this reference.I don't like opamps.
How do you get 25C=250 steps?
You use an OpAmp. :D
What's so bad about OpAmps? It will allow you to scale the voltage to take advantage of the full dynamic range of the ADC and add a calibration POT so you can adjust the accuracy of your thermometer.
What is hog?
It is a pig. The expression "go whole hog" means that you commit fully and do the full job without cutting corners. Probably comes from the days when the man brought home the bacon and cooked the "whole hog" on a spit over the fire. The meat would spoil, without refrigeration, if you didn't cook and eat it right away so there was no point in cooking half a hog.
A hog:
 

Attachments

  • single hog.jpg
    single hog.jpg
    45.5 KB · Views: 224
Last edited:
Hi for both of you thanks.

I'm dreaming what method to use Mikes or kchristie's method.

I don't like op amps because don't know how to configure it to make the reference.

kchriste can you tell whats the reference you telling me.:) I don't know anything about opamps.
 
Hi for both of you thanks.

I'm dreaming what method to use Mikes or kchristie's method.

I don't like op amps because don't know how to configure it to make the reference.

kchriste can you tell whats the reference you telling me.:) I don't know anything about opamps.


hi Suraj,
As you are using a LM35, use a simple opa, so that 5.12Vout gives 1023 adc value.
Use the PIC's internal +5Vref

When you convert this value to ascii for the display, just insert a 'dp' between the two lsd's
This will give a temperature range of +2C thru +100.0C with a 0.1Cdeg resolution.

As the LM35 give a +10mV change per Cdeg, at 102.3Cdeg its 1.023Vout.
A simple NI opa with again of approx 5 will raise this to 5.12V

If you only need to go as high as 60Cdeg, the opa can be powered from +5V,
for the full 102.3C the opa needs at least 9V on the power rail.

Do you follow OK.?:)

This is the method I use with a CA3140 opa, [goes close 0Vout]

EDIT:
added a clip from my drawing.
 

Attachments

  • esp01 Aug. 13.gif
    esp01 Aug. 13.gif
    4 KB · Views: 190
Last edited:
As the LM35 give a +10mV change per Cdeg, at 102.3Cdeg its 1.023Vout.
A simple NI opa with again of approx 5 will raise this to 5.12V

If you only need to go as high as 60Cdeg, the opa can be powered from +5V,
for the full 102.3C the opa needs at least 9V on the power rail.

Hi ericgibbs thanks for your input.

Actually that is the hardest part for me.I'll use an OP AMP CA3140.But I dont know how to configure that.
 
Hi ericgibbs thanks for your input.

Actually that is the hardest part for me.I'll use an OP AMP CA3140.But I dont know how to configure that.

hi Suraj,
Look at the EDIT for the drawing on my last post.:)
 
Eric's diagram shows what I had in mind. If you can't find the CA3140 then the TS912 or any other rail-to-rail OpAmp which works with a 5V supply will do. Make sure the OpAmp you choose has both rail-to-rail inputs AND outputs. The pin out will be different from the CA3140.
 
Whilst the opamp solution with give the greatest range of readings on the ADC it may not be the most accurate solution. The accuracy will be dependent on the stability of the 5V supply as this is what the ADC uses as its reference voltage. Using an accurate 2V reference will be more stable and supply independent but will only have half the resolution - 0.2°C. A combination of opamp and an accurate voltage reference would be the most accurate, however it's pretty academic as the LM35 is only accurate to 0.5°C.

Mike.
 
Hello thanks for that good points I'll use an op amp to give inputs.

And also I'll concentrate on a smoother power supply.I'll tell you the latest progress.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top