View previous topic :: View next topic |
Author |
Message |
iso9001
Joined: 02 Dec 2003 Posts: 262
|
Erratic ADC Readings when switching channels |
Posted: Wed Jan 19, 2005 12:44 pm |
|
|
Hi,
I have a 16F872 part using A0_A1_A3 ADC setup, all the pins read just fine, but it seems that somtimes my A3 reading is actually reading the voltage on PIN_A2.... and vs
I have a delay_us(20); after the channel change, but maybe there is somthing I'm doing wrong ?
Is 20us enough ?
Is there a better way to prevent this ?
TIA |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Jan 19, 2005 12:51 pm |
|
|
Have you designed out as much noise as possible? Try things like ground planes, don't mix analog grounds with digital grounds, avoid AC power wires running next to analog lines, filter caps and so on.....
Ronald |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Jan 19, 2005 1:03 pm |
|
|
This is automotive so no AC. Traces are pretty big, no 90 degree angles or anything like that, I highly doubt its noise. I have 1 digital signal, but its really active and its pretty low power anyway.
I notices I can get it to mellow down a little by adding a switch channel statement to A3 right after I'm done using my A2 code. But it seems like a bandaid to a larger problem.
I'm pretty sure its not noise cause I can get unstable A3 readings when I play around with the voltage on A2 when its being read. |
|
|
iso9001
Joined: 02 Dec 2003 Posts: 262
|
|
Posted: Wed Jan 19, 2005 1:16 pm |
|
|
Oh yea, I forgot.
I monitored the whole deal on a scope and could not find anything wrong with any of the lines. Its a pic / software ADC problem, not my hardware. |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Wed Jan 19, 2005 1:48 pm |
|
|
Three quick thoughts:
1) delay_us(20) should be OK but check the data sheet for your PIC, especially the section on settling time. If you aren't allowing at least that much time from the set_adc_channel() call to the read_adc() call then the sample-and-hold cap inside the PIC isn't fully charged/discharged to the new level.
2) The input impedance of the PIC ADC pins is pretty high and so they should be driven by a low impedance source. Refer to the data sheet for the estimated input impedance. If you can spare the space/power/cost, drive them with op-amps.
3) There have been several problems over the years with the ADC setup code. Look at your LST file and confirm that your setup_adc() call is correct. Likewise set_adc_channel() and read_adc(). _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Wed Jan 19, 2005 2:45 pm |
|
|
Also make sure the conversion clock is configured properly. Per the datasheet it needs 12Tads, with a minumum Tad of 1.6uS. Table 11-1 provides limiting values. |
|
|
|