If it can be done, what would be the equivalent digital representation, say for -2V? |
|
Can the ADC module of the PIC16F87 accept a negative analog input?
Started by ●February 9, 2004
Reply by ●February 9, 20042004-02-09
--- nibnewux <> wrote: > If it can be done, what would be the equivalent digital > representation, say for -2V? It can not, directly, if it could, the output would depend on a lot of things, references, bipolar AtoD, or single run at a lower supply. Chad. ===== My software has no bugs. Only undocumented features. __________________________________ |
Reply by ●February 9, 20042004-02-09
The A/D of a PIC can easily measure a negative voltage. Simply build a 2-resistor voltage divider that is connected to Vref at one end, the A/D input at the middle and your voltage to be measured at the other end. For example: If you connect a 7.5K resistor between Vref the A/D channel, and another 7.5K resistor between the A/D channel and your voltage to be measured, then at 0 volts in, the A/D will read Vref/2. As the voltage gets more negative, the A/D will produce a smaller and smaller result, and will read 0 volts at -Vref. The math can get a little messy, but I have done it many times. Contact me off-list if you need more information. Charles Linquist -----Original Message----- From: nibnewux [mailto:] Sent: Sunday, February 08, 2004 9:20 PM To: Subject: [piclist] Can the ADC module of the PIC16F87 accept a negative analog input? If it can be done, what would be the equivalent digital representation, say for -2V? to unsubscribe, go to http://www.yahoogroups.com and follow the instructions Yahoo! Groups Links |
|
Reply by ●February 9, 20042004-02-09
--- In , "Charles Linquist" <Charles@L...> wrote: > > The A/D of a PIC can easily measure a negative voltage. Simply build a > 2-resistor voltage divider that is connected to Vref at one end, the A/D > input at the middle and your voltage to be measured at the other end. > > For example: If you connect a 7.5K resistor between Vref the A/D channel, > and another 7.5K resistor between the A/D channel and your voltage to be > measured, then at 0 volts in, the A/D will read Vref/2. As the voltage gets > more negative, the A/D will produce a smaller and smaller result, and will > read 0 volts at -Vref. > > The math can get a little messy, but I have done it many times. Contact me > off-list if you need more information. > > Charles Linquist > Charles@L... Hi Charles, Please keep this on-list. This is the great type of creative use that makes this list so useful. Dave |
|
Reply by ●February 9, 20042004-02-09
Good idea, just keep in mind that the accuracy is degraded by the ratio and tolerance of the resistors. Chad --- Dave Mucha <> wrote: > --- In , "Charles Linquist" <Charles@L...> > wrote: > > > > The A/D of a PIC can easily measure a negative voltage. Simply > build a > > 2-resistor voltage divider that is connected to Vref at one end, > the A/D > > input at the middle and your voltage to be measured at the other > end. > > > > For example: If you connect a 7.5K resistor between Vref the A/D > channel, > > and another 7.5K resistor between the A/D channel and your voltage > to be > > measured, then at 0 volts in, the A/D will read Vref/2. As the > voltage gets > > more negative, the A/D will produce a smaller and smaller result, > and will > > read 0 volts at -Vref. > > > > The math can get a little messy, but I have done it many times. > Contact me > > off-list if you need more information. > > > > Charles Linquist > > Charles@L... > > Hi Charles, > > Please keep this on-list. This is the great type of creative use > that makes this list so useful. > Dave > > ===== My software has no bugs. Only undocumented features. __________________________________ |
|
Reply by ●February 9, 20042004-02-09
the data sheet pinout for the F87 implies the the 87 doesn't have VRef+ and Vref-. It appears its brother the F88 does, though. Also, you lose AN2 and AN3 when using Vref+/- although the data sheet is not explicit on this point. Phil --- In , Chad Russel <chadrussel@y...> wrote: > Good idea, just keep in mind that the accuracy is degraded by the ratio > and tolerance of the resistors. > > Chad > > --- Dave Mucha <davemucha@j...> wrote: > > --- In , "Charles Linquist" <Charles@L...> > > wrote: > > > > > > The A/D of a PIC can easily measure a negative voltage. Simply > > build a > > > 2-resistor voltage divider that is connected to Vref at one end, > > the A/D > > > input at the middle and your voltage to be measured at the other > > end. > > > > > > For example: If you connect a 7.5K resistor between Vref the A/D > > channel, > > > and another 7.5K resistor between the A/D channel and your voltage > > to be > > > measured, then at 0 volts in, the A/D will read Vref/2. As the > > voltage gets > > > more negative, the A/D will produce a smaller and smaller result, > > and will > > > read 0 volts at -Vref. > > > > > > The math can get a little messy, but I have done it many times. > > Contact me > > > off-list if you need more information. > > > > > > Charles Linquist > > > Charles@L... > > > > Hi Charles, > > > > Please keep this on-list. This is the great type of creative use > > that makes this list so useful. > > > > > > Dave > > > > > > > > ===== > My software has no bugs. Only undocumented features. > > __________________________________ > |
Reply by ●February 9, 20042004-02-09
No. When I mentioned "-Vref", I didn't mean the -VREF on the
PIC. I simply meant a negative voltage equal to VREF. Using the technique that I described, you don't need -VREF. You use the A/D as you normally would. Use GND for -Vref. I use a 2K from 4.096 V reference to the A/D input, and a 7.5K resistor from the A/D input to the measured voltage (-12V in my case). You then have to subtract the A/D reading from a constant to obtain the correct reading, since the greater the negative voltage, the smaller the A/D output. Using 1% resistors and the 10bit converter in most of the PICs, I find that my accuracy is usually within 15mV when reading a nom -12V level. I should mention that I'm using a .2% tolerance part for my 4.096V reference. Charles Linquist the data sheet pinout for the F87 implies the the 87 doesn't have VRef+ and Vref-. It appears its brother the F88 does, though. Also, you lose AN2 and AN3 when using Vref+/- although the data sheet is not explicit on this point. Phil --- In , Chad Russel <chadrussel@y...> wrote: > Good idea, just keep in mind that the accuracy is degraded by the ratio > and tolerance of the resistors. > > Chad > > --- Dave Mucha <davemucha@j...> wrote: > > --- In , "Charles Linquist" <Charles@L...> > > wrote: > > > > > > The A/D of a PIC can easily measure a negative voltage. Simply > > build a > > > 2-resistor voltage divider that is connected to Vref at one end, > > the A/D > > > input at the middle and your voltage to be measured at the other > > end. > > > > > > For example: If you connect a 7.5K resistor between Vref the A/D > > channel, > > > and another 7.5K resistor between the A/D channel and your voltage > > to be |