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

18F87K22 A/D

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



Joined: 19 May 2018
Posts: 27

View user's profile Send private message

18F87K22 A/D
PostPosted: Wed Jun 26, 2019 5:18 am     Reply with quote

Do I have to disable something to get a/d inputs on PortA to work ? I’m getting erroneous readings on all PortA a/d inputs. Rest of a/d inputs ok, temp sensor, voltage ref, PortF all work fine. TrisA programmed as inputs! a/d inputs programmed as well.

Thanks in advance.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jun 26, 2019 6:31 am     Reply with quote

You need to post a small, compilable program for us to see and run. It's probably something simple BUT until we see your code.....

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 26, 2019 9:46 am     Reply with quote

Sample A/D program for the 18F87K22:
http://www.ccsinfo.com/forum/viewtopic.php?t=57941&start=18

If it doesn't work, post your CCS compiler version.
gtx15



Joined: 19 May 2018
Posts: 27

View user's profile Send private message

18F87K22 A/D
PostPosted: Sat Jun 29, 2019 2:03 pm     Reply with quote

It appears that if my A/D input goes slightly below VSS (Vref-). My A/D results Go negative. I'm getting results like FFEF. Any solution besides better pcb layout?
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jun 30, 2019 4:48 am     Reply with quote

Most ( if not all ?) PICs have ADCs that ONLY read positive voltages. So it s important to ensure no negative volts get to the ADC section. Hard to advise you what to do, other than general comments hardware... proper ground planes, shielded cabling, clamping inputs, etc. Software bodges would be multiple sampling, like 'Olympic' averaging as you should never rely upon one reading, especially for control purposes.
Microchip have several 'apnotes' about using the ADC section. Getting analog to work correctly, especially more than 8 bits is 1/2 design, 1/2 layout and 1/2 luck.
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