View previous topic :: View next topic |
Author |
Message |
Wohn
Joined: 25 Mar 2009 Posts: 6
|
16F887 Using 0.6v Vref for A/D, need help |
Posted: Fri May 21, 2010 12:59 pm |
|
|
Hi, I'm using a 16F887 and want to use the internal 0.6v Vref for Vref+ and I can't figure out how to have the device use it. The header file for the chip is uncommented for the most part and I am confused. I have setup the A/D to
Code: | setup_adc_ports(sAN0|sAN1|VSS_VREF); |
but can't figure out how to set Vref+ to the 0.6v internal reference.
Any help would be appreciated,
Thanks
John
Compiler version 4.057 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 21, 2010 1:29 pm |
|
|
Quote: | I can't figure out how to set Vref+ to the 0.6v internal reference. |
Look in this section of the 16F887 data sheet:
Quote: |
TABLE 17-10: PIC16F883/884/886/887 A/D CONVERTER (ADC) CHARACTERISTICS
|
It says the absolute minimum value allowed for Vref+ is 2.2v, and the
recommended minimum is 2.7 volts. |
|
|
Wohn
Joined: 25 Mar 2009 Posts: 6
|
|
Posted: Fri May 21, 2010 1:36 pm |
|
|
The 16f887 has a 0.6v reference on chip that can be used for the comparator or A/D module. It can be set to pin A3. I want to use that as the +Vref. The input has a max of 0.4v so even using a 2.5v refernce would limit the resolution, I need the best I can get. How would I enable the 0.6v reference. Sorry I'm not that good with setting individual bits in register.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 21, 2010 2:02 pm |
|
|
I don't think the Fixed Vref of 0.6v can be used by the A/D.
I looked at the block diagram for the A/D and there is no path for an
internal connection between the 0.6v and Vref+.
I think you could use the Comparator Voltage Reference module, and
configure it to put the CVref voltage on pin A2. Then you could put an
external jumper (a wire) between pin A2 and A3 (Vref+). Then you
could program CVref to setup your Vref+ voltage. I'm not certain that
this will work, because the 16F887 data sheet doesn't give the output
current from the CVref module when it's output on pin A2. The A/D
module requires up to 1 ma on the Vref+ pin to do the conversion.
But anyway, you still believe that you can use 0.6 volts for Vref+
even though the 16F887 data sheet says the minimum is 2.2 volts.
It's possible that you are confused by the A/D block diagram in
the data sheet. This one:
Quote: |
FIGURE 9-1: ADC BLOCK DIAGRAM
|
In the channel selection block diagram, it shows that CVref and the 0.6v
Fixed Vref can be selected as "channels". But that just allows you to
measure them with the A/D. They are not used for Vref+. |
|
|
Wohn
Joined: 25 Mar 2009 Posts: 6
|
|
Posted: Fri May 21, 2010 2:25 pm |
|
|
The 2.2v is the minimum to ensure 1LSB accuracy, not the minimum voltage for the input. I may be off 1 to 2 bits but better than a 2.5v refence voltage which would be equivilent to losing 3 bits.
How do I output the 0.6v reference on RA3, there isn't an option in the setup_vref(), how do I set it up in the register thru ccs without using asm code?
Thanks for your time pcm, I appreciate it. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 21, 2010 3:05 pm |
|
|
Quote: |
The 2.2v is the minimum to ensure 1LSB accuracy
|
That's not what the data sheet says. It says 2.7 volts is the
mimimum to ensure 1 lsb accuracy. It says the absolute minimum
is 2.2 volts.
Quote: |
How do I output the 0.6v reference on RA3
|
As I have said, the Fixed 0.6v does not appear to have any way to
be output on pin RA3 or RA2.
I don't think I can do anything more on this thread. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri May 21, 2010 3:07 pm |
|
|
why not amplify your signal and use a "normal" reference that is within the ADCs spec?
i think that way you wont lose much precision.... at least not as much as you will with the 0.6 vref....
gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Wohn
Joined: 25 Mar 2009 Posts: 6
|
|
Posted: Fri May 21, 2010 3:10 pm |
|
|
Thats what we may wind up doing, we were trying to keep parts count to a minimum tho. I was hoping we could get away without another IC and 2 resistors. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri May 21, 2010 3:15 pm |
|
|
The comparator Vref, is _not_ suitable to drive the ADC.
It is not rated to deliver the 1mA worst case, needed from Vref during acquisition.
You will gain nothing. The accuracy of the ADC, degrades slightly worse than linearly, as you drop Vref below 2.2v. The _best_ results, for each bit, will be with a 2.2v Vref. You may well find that going to something like 2.048v (commonly available), does not degrade the ADC significantly, and though not 'warranted', is likely to work well.
You will also find that other things start to go wrong. The ADC aquisition requirements, are based upon the minimum Vref. if you lower the Vref, you have to lengthen the acquisition time, and then leakage becomes more significant.
Realistically, the 'best' thing to do, is amplify your signal....
Best Wishes |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri May 21, 2010 3:21 pm |
|
|
you can use an instrumentation amplifier and set the gain with ONE resistor ;) .... you know... to save you that super expensive extra resistor.
just kidding..... but yeah... amplify, get a rail to rail single supply amp and a 4.096 Vref IC..... and 2 resistors.
Gabriel. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Wohn
Joined: 25 Mar 2009 Posts: 6
|
|
Posted: Fri May 21, 2010 3:43 pm |
|
|
Non inverting opamp will use 2 resistors, plus a feedback cap to prevent oscillations at such high gain. Its not the cost its just parts count and greater chance for the high impedence .006v to pickup noise. It can be done for less than 20 cents but that wasnt the point. We are using this to replace LM339's and was hoping to have almost no support circuitry.
I just assumed that the 0.6v reference on chip would be able to be used for the comparator and A/D. I realize now that thats not the case, the one diagram, Figure 8-8 shows the 0.6v outputing to "To Comparators
and ADC Module". I guess I incorrectly assumed that it meant it can be used as a voltage reference since it is listed in the "COMPARATOR VOLTAGE REFERENCE BLOCK DIAGRAM" stupid me. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri May 21, 2010 3:49 pm |
|
|
what is the range of you input signal? what is giving you this signal that needs such amplification?
"most" sensors are 0 - 100mv or 4 - 20mA.
just wondering..
Gabriel... _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Wohn
Joined: 25 Mar 2009 Posts: 6
|
|
Posted: Fri May 21, 2010 4:21 pm |
|
|
The input signal will be 0-.5v with about 100 steps, its a low impedence output from an opamp feeding a very high impedence fet input, we most likely will only be using about 30% of the range with a shunt diode to limit the input voltage to 5.1v. The problem is its not a sensor, its a analog control voltage for a VCA. Im using the pic as a bargraph to visually represent the amount of gain reduction via LED's. it works out to be .006v/dB and the most critical sonic diffences will be heard by the first .060v. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Sat May 22, 2010 5:57 am |
|
|
0 - 0.5 .... amp it x10 and you can use VDD as the ref, and you can use the full range of the ADC at 10 bits and you will have plenty more than you asked for....
I'm working on a project for my company where I get a signal from 0 - 0.07 from a water pressure sensor....I get more than 1 centimeter presicion.....I amp it x70 (0.07 x 70 = 4.9)
I don't see what your problem is.... _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
vinniewryan
Joined: 29 Jul 2009 Posts: 154 Location: at work
|
|
Posted: Sat May 22, 2010 8:46 pm |
|
|
If you're getting 0-.5v, a very simple but not very efficient fix, but one that may be all you need would be a PNP transistor where the Emitter is connected to V+, Collector is connected to the MCU ADC input pin, and the Base is connected to ground through a 2.2-10k resistor, and also to the output voltage of your output signal. This would give you a better range ADC range, but it would be backwards, which can be fixed with a simple function. Just a thought, I've been in similar situations and this method seems to do the job on some occasions.
Extra parts = 1 transistor ($0.3 cents) and 1 resistor ($0.004 cents) _________________ Vinnie Ryan |
|
|
|