CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Erratic ADC Readings when switching channels

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

Erratic ADC Readings when switching channels
PostPosted: Wed Jan 19, 2005 12:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 19, 2005 12:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 19, 2005 1:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 19, 2005 1:16 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 19, 2005 1:48 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 19, 2005 2:45 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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