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.

A/D, value for Vref on PICs for best accuracy.

Status
Not open for further replies.

Odin

Member
How low Vref can a PIC use without sacrificing accuracy? Wich method should I use to read a signal from ex. LM35, wich give 10mV pr. deg. Celsius --> approx. 250 mV for room temperature.
Generally, to convert a low voltage signal, should I attenuate the reference, or should I amplify the signal?
At the moment I'm using a 16F684 reading a LM35, with just a normal diode as a 0,7 V reference to the Vref pin. Displaying the result on a LCD. No particulary project really, just fiddling on the lab to learn more.
I have two different voltage reference circuits at hand; TL431 and LM385-2,5 . Both giving 2,5 V reference. I'm thinking of dividing the voltage with two resistors, then feeding the Vref pin. Are there any max/min values for the resistors I should be aware of? Any minimum impedance for the Vref, as for the A/D input?

Btw. How do I get the degree character on the LCD? The "little o" in degrees Celsius.
 
Use an opamp to amplify the output of the LM35 - you can't use the Vref like that - use a TL341 (or similar) for Vref, and scale the input accordingly (with either opamps or attenuators).
 
hi,
The nearest ready made 'deg' symbol in the controller is character DFh.
Also you have the option to create your own symbols IIRC , 8 symbols.

If you want to use the LM35 you will get better results if you amplify the output of the LM35, by a factor of about *5 and use the full 10 bits.
Use the PICs internal default +5Vref.

The PIC data sheets usually quote a +Vref minimum of +2.5V.
 
ericgibbs said:
hi,
The nearest ready made 'deg' symbol in the controller is character DFh.
Also you have the option to create your own symbols IIRC , 8 symbols.

Thank you! I'll try that.


If you want to use the LM35 you will get better results if you amplify the output of the LM35, by a factor of about *5 and use the full 10 bits.
Use the PICs internal default +5Vref.

The PIC data sheets usually quote a +Vref minimum of +2.5V.

I found the numbers in the datasheets now, page 147 for the 16F684. Vref min = 2,2 V (absolute minimum to ensure 1 LSB accuracy)

I'm not so keen on using Vdd as reference, as I think it varies to much. I usually feed the PIC from a 7805. Their voltage varies often +/- 0,1 V The one I'm using now is 4,924 V
That's 1,5% error. Maybe not that bad, but I prefer a "real" reference.
The 16F684 can use Vdd from 2,0 - 5,5 V. Guess it means less than full accuracy on the A/D when run at 2 V?
I will hook up an opamp to the LM35 and test. I'm using the full 10 bits, btw. Working with PICC lite. Biggest concern now is that I've already used 94% of the code space, just to read a temp. sensor and displaying the value on a LCD :)

For the record: I'm actually using a diode now, as a 0,7 V reference, and it works. So I know it can be done, but with reduced accuracy I guess.
 
Odin said:
I'm not so keen on using Vdd as reference, as I think it varies to much. I usually feed the PIC from a 7805. Their voltage varies often +/- 0,1 V The one I'm using now is 4,924 V

Like I said above, use a 2.5V reference (like the TL341).

That's 1,5% error. Maybe not that bad, but I prefer a "real" reference.
The 16F684 can use Vdd from 2,0 - 5,5 V. Guess it means less than full accuracy on the A/D when run at 2 V?
I will hook up an opamp to the LM35 and test. I'm using the full 10 bits, btw. Working with PICC lite. Biggest concern now is that I've already used 94% of the code space, just to read a temp. sensor and displaying the value on a LCD :)

You must be writing some pretty poor code! (or the compiler is?), it shouldn't take much just to read an LM35 and display on an LCD.
 
Nigel Goodwin said:
Like I said above, use a 2.5V reference (like the TL341).

I have quite a few of those, so I'll give it a try. Think I even sorted some of them a while ago. Don't remember the exact numbers, but they were pretty accurate, with very little variation between them.

You must be writing some pretty poor code! (or the compiler is?), it shouldn't take much just to read an LM35 and display on an LCD.

He, he :) I've just started out with C. Bought a book on Amazon; "123 PIC Microcontroller Experiments for the Evil Genius" by Myke Predko. I like the book a lot. It's based on using the 16F684, wich I was already used to. And the PICC lite compiler from HTsoft. It's limited code space, and probably not optimized to well.
I'm so lucky that I have the C18 compiler from Microchip at work. I will use it at a later point. Have some 18-series PICs as well. For my hobby use, it doesen't matter if the price is a bit higher.

I started out with 16C84 and assembler, must be close to ten years ago. Never believed I would be even close to spending all the code space in a PIC.
I've learned a lot from your site btw. Got my first program for LCD there, and copy and pasted a lot from the different tutorials. Can't remember how much space it took with assembler to do the same, but I think 5 or 10% maybe.

So thanks a lot for that nice site of yours! :)
 
hi odin,
The basic range of the LM35 is +2 thru +150 degC, this relates to 0mV thru +1.5Vout.

With a +5Vref, the ADC value is (1.5/5)* 1023 =306.9, which is an ADC value of about 2/degC, so the best resolution is about 0.5degC.

With a +2.5Vref its an ADC value range of 613.8, which is about 4/degC, so the best resolution is about 0.25degC.

I would suggest that you decide over what range temperatures you want to measure.

If its say, a domestic/house room, I would limit my tempr range to say 0degC thru 50degC,
which is a LM35 Vout range of 0 thru +0.5V.

Use a +2.5Vref and amplify the LM35 output by about *5, [+2.5V max], this will give an ADC value of about 20/degC,
which can be processed to give a tempr resolution of 0.1degC.

But remember the stated non-linearity of the LM35 is +/-0.25degC.

I have found that some PIC's will work at lower than their recommended Vref min, but others of the same type will not,
its best to stay within the recommended Vref if you require consistant results from one PIC to another.

If you make the amplifier gain adjustable, you will be able to normalise the ADC value to the tempr in degC,
this will simplify the program.

Hope this helps.
 
Hey guys, wouldn't a 2.56 volt reference actually be better than a 2.50 volt reference? With 10 bit resolution that works out to exactly 2.5 millivolts per step (1024 steps) instead of 2.4414025 millivolts per step.
 
Mike said:
Hey guys, wouldn't a 2.56 volt reference actually be better than a 2.50 volt reference? With 10 bit resolution that works out to exactly 2.5 millivolts per step (1024 steps) instead of 2.4414025 millivolts per step.

Doesn't really matter - you stick a pot on the input and tweak it to be accurate. The TL341 is an ajustable reference, so you could adjust it to 2.56 if you wanted?.
 
Nigel Goodwin said:
Doesn't really matter - you stick a pot on the input and tweak it to be accurate. The TL341 is an ajustable reference, so you could adjust it to 2.56 if you wanted?.

It does matter, the point is that adjusting it for 2.56V gives you accuracy with simple maths. Your statement of "if you wanted?" makes it appear that you don't understand (or question) the significance of adjusting for 2.56V.

I suggested the same thing just last week in this thread.

Mike.
 
Pommie said:
It does matter, the point is that adjusting it for 2.56V gives you accuracy with simple maths. Your statement of "if you wanted?" makes it appear that you don't understand (or question) the significance of adjusting for 2.56V.

Quite the opposite, I'm fully aware of the reasons for it, and in fact my tutorial does the same thing for the same reason (except it displays 0-10.23V, so no maths is required at all).

You appear to be missing the point though?, using a 2.56V reference is no different to using a 2.5V one - you simply adjust the input attenuator so the output of the A2D reads exactly correct, no maths required, EXACTLY the same as using a 2.56V reference. As it would be VERY unusual not to have some kind of input processing, and probably an adjustment, it completely negates the need for a 2.56V reference.

BTW - all of this discussion is wrong anyway :p it should be a 2.55V reference, NOT 2.56V :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top