View previous topic :: View next topic |
Author |
Message |
mkuang
Joined: 14 Dec 2007 Posts: 257
|
How to configure 18F2525 for bipolar A/D inputs |
Posted: Mon Feb 11, 2008 11:31 am |
|
|
Hi all,
I am trying to use the A/D function on the 18F2525 for a bipolar input from -5V to +5V. I am reading the datasheet and it says:
The analog reference voltage is software selectable to be either the device's positive and negative supply voltage (VDD and Vss), or the voltage level on the Vref+ and Vref- pins.
But then I read the device file (18f2525.h) and it says:
#define VSS_VDD 0x00 // Range 0-Vdd
#define VREF_VREF 0x30 // Range VrefL-VrefH
#define VREF_VDD 0x20 // Range VrefL-Vdd
#define VSS_VREF 0x10 // Range 0-VrefH
There doesn't seem to be an option for a range of -Vss to Vdd. The option:
#define VSS-Vdd
seems to give a range of 0 - Vdd according to the comments.
So what is the correct #define statement to use if I want to use -Vss and Vdd supply voltages on the PIC to be my A/D lower and upper limits?
Thanks
MK |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Mon Feb 11, 2008 11:35 am |
|
|
You can't. The analog - reference can't be below Vss (ground). You'll have to add some analog signal conditioning prior to the PIC to turn the double-ended inputs into single-ended inputs. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Feb 11, 2008 11:39 am |
|
|
newguy wrote: | You can't. The analog - reference can't be below Vss (ground). You'll have to add some analog signal conditioning prior to the PIC to turn the double-ended inputs into single-ended inputs. |
Thanks for the reply.
So this line from the datasheet is wrong?
The analog reference voltage is software selectable to be either the device's positive and negative supply voltage (VDD and Vss), or the voltage level on the Vref+ and Vref- pins. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Mon Feb 11, 2008 12:08 pm |
|
|
No, that line is correct. The caveat is that Vref- must be greater than or equal to Vss, and less than Vdd. Somewhere in the "electrical specifications" or similar at the back of the datasheet you'll find the note regarding Vref-. It will specify the acceptable voltage input range for this pin. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Feb 11, 2008 12:31 pm |
|
|
newguy wrote: | No, that line is correct. The caveat is that Vref- must be greater than or equal to Vss, and less than Vdd. Somewhere in the "electrical specifications" or similar at the back of the datasheet you'll find the note regarding Vref-. It will specify the acceptable voltage input range for this pin. |
I see. Looks like Vdd - Vss is a maximum of 7Volts so there is no way you can use +5V for Vdd and -5V for Vss. Which also means the most range you can get between Vref+ and Vref- is less than about 7volts. I think I am better off inverting the negative signal with an opamp buffer. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 11, 2008 1:39 pm |
|
|
See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=25005
In the diagram that I posted, if you set the voltage on the bottom
resistor to +5v, then it would convert a signal with an input range
of +/- 5v to a range of 0v to 5v.
In other words, it would reduce the amplitude from 10v p/p down
to 5v p/p, and it would shift the level so it's referenced to 0v. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Tue Feb 12, 2008 8:57 am |
|
|
Thanks PCM Programmer. I am familiar with that circuit but not exactly what I want to do. My signal is coming from a particular sensor and there are two types of sensors: one with a signal from 0-5V and the other from 0 to -5V. So depending on the sensor I plug in the signal is either all positive or all negative so no I wouldn't want to shift the level. |
|
|
|