|
|
View previous topic :: View next topic |
Author |
Message |
zzattack
Joined: 22 Dec 2010 Posts: 5
|
Analog port pulls down |
Posted: Fri Dec 24, 2010 4:56 am |
|
|
I'm trying to do an AD conversion on a pic16f88. I split the value I wish to measure in 1/60 using a 59k and 1k resistor and this seems to work: the input voltage on the AD port is 1/60th of the battery (0.14V in my case). However, as soon as I hook it up to the PIC (port RA0), the voltage gets pulled up. Using output_low() on this port results in a pull down to 0.07V. Why is this?
Code: |
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(sAN0 | VSS_VREF);
|
I also have a Vref of 2.5V split into 1/11th on port RA3 which does not get pulled up. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Fri Dec 24, 2010 5:52 am |
|
|
As a comment, if your clock is faster than 1Mhz, look in the data sheet, and select the right ADC clock.....
On the pull down, when you do output_low, as soon as you do this, the TRIS will be programmed to 'output', and the pin will be pulled down.
Now, a question. Are you using, fast_io on this port?. If so, you have the TRIS set wrong. The pin needs to be set as an input. If not, are you are any time, using 'port wide' output instructions on the port (OUTPUT_A). If so, again the TRIS will be overridden and set incorrectly, but I'd have expected RA3 to also be affected.
Now another comment. Look at the _minimum_ Vref span for your chip. 0.227v (2.5/11), is _not_ suitable. Table 18-13, A20. If you use less than the specified span, accuracy just disappears.
Best Wishes |
|
|
zzattack
Joined: 22 Dec 2010 Posts: 5
|
|
Posted: Fri Dec 24, 2010 6:14 am |
|
|
Thanks for your comment, I'm running the PIC at 8MHz,
I do not use any output_* or fast_io on this (or any other) port. Does the setup_adc_ports() command set the port to input itself, or do I need to do this manually myself too? I will no longer split the Vref. Anyway, I'm still measuring a high on the analog ports :( |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Dec 24, 2010 9:56 am |
|
|
All port pins are set to input by default. If you don't perform any port operations on RA0, there's no reason why it should change to high output state. |
|
|
|
|
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
|