|
|
View previous topic :: View next topic |
Author |
Message |
jruibarroso
Joined: 07 Jan 2006 Posts: 64 Location: Braga
|
is it possible to output an analog voltage on an analog pin |
Posted: Thu Oct 12, 2006 5:32 am |
|
|
is it possible to output an analog voltage on an analog pin , eg >RA1 : 0...5 volts |
|
|
Storic
Joined: 03 Dec 2005 Posts: 182 Location: Australia SA
|
|
Posted: Thu Oct 12, 2006 5:45 am |
|
|
No,
I ask the same question a long time ago.
to get an analog output from a pin, you need to PWM the pin, filtered to get a DC voltage, an Op amp will help.
Andrew _________________ What has been learnt if you make the same mistake? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
|
Posted: Thu Oct 12, 2006 12:24 pm |
|
|
There is one exception to this: It *is* possible to output an analog voltage on an input pin on some devices that have a comparator voltage reference module. One such device is the 16F88.
On the PIC16F88, AN2 can be configured several ways, but these include not only as an analog input, but it may also be connected to the 4-bit resistor ladder of the comparator voltage reference (CVref) which is, in fact, a 4-bit R-2R D/A converter. Note that not all devices that have the CVref can be configured to output that voltage to a pin!!!
There *are* a number of caveats, however:
- It is quite high impedance. I can't drive much and it will probably need to be buffered. For a pin that is already being used as an A/D input, this may not be terribly helpful. In reading the Microchip data sheet, this "feature" (e.g. being able to route the reference to an output pin) was intended primarily to allow device testing, hence the lack of any on-chip buffering. I don't know what the impedance is, but I'd treat it as if it were in the 10k-50k region and be prepared for the effects of resistive and capacitive loading (e.g. voltage shift, slowed response, etc.)
- It has only 4 bits of resolution. This may or may not be too useful, depending on one's application. Even though it has only 4 bits, it has two, overlapping output voltage ranges.
I recently did a project (using a 16F88, in fact) where I used the Comparator Voltage reference module to generate a control voltage - I was already using the PWM for something else...
In that project, I was able to get about 8 bits of D/A resolution using software dithering in a timer ISR (it was 8 bits of resolution - but only about 7.5 bits of range - the top 16 codes were not usable in my simple algorithm, but so what...) and I was surprised to note that this 4 bit D/A had pretty good monotonicity even when stretched to 8 bits. In this case, I had an R/C network and op amp to filter/buffer the D/A output and it works nicely.
CT |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|