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 support@ccsinfo.com

Bad A/D Conversion

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



Joined: 15 Apr 2006
Posts: 12

View user's profile Send private message

Bad A/D Conversion
PostPosted: Thu Mar 25, 2010 8:03 pm     Reply with quote

In one version of code, my 10-bit A/D readings were correct and stable. In the next version of code, the readings are erratic (+/-100). The code for A/D setup is the same and the code for reading is the same. I have tried auto acquisition times of 16 and 20 Tad and I have set auto to 000 and then manually waited 20us. Tad is 8xFosc but I have tried 16x, too. Osc. is 8MHz internal. I have verified my hardware by putting old code in the same hardware with good results. ADCON2 = 0x85, ADCON1 = 0x07, ADCON0 = 0x05 (selects channel and turns on at same time). After 10 to 20us acq. time, I set the go/done bit, poll that bit, then read ADRESH/L. I've checked all my variable types, which also haven't changed between versions. There is at least 50us between taking a reading and switching channels. I am using an 18F4550, but the A/D chapter reads pretty much the same as for other uChip parts with A/D.

What else could cause this erratic behavior? Thanks! CJ
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 25, 2010 8:29 pm     Reply with quote

1. Post your test program. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=42090&start=1
Make the test program be very short and compilable, just like that one.
Don't include any CCS Wizard code that disables timers that are already
disabled, etc. Test it before you post it.

2. Describe the circuit that provides the analog signal to the PIC.

3. Give the PIC a constant analog voltage (if possible) from your circuit.
Post the voltage, as measured with a scope or voltmeter. Also post
some of the ADC output values for this voltage that appear on your
terminal window.

4. Post your compiler version.
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