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

16F88 comparator and ADC

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



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

16F88 comparator and ADC
PostPosted: Mon May 26, 2014 9:49 pm     Reply with quote

Hi all! i have a simple question about this pic. It is possible to use some analog inputs (ADC channels) and the comparator module?

I need to trigger from a very fast signal (small signal) and I'm planning to do it with the comparator module setting a Vref externally. I already tested it on a 16F648A and it works great. But now i need an analog signal too.

I know this pic has ADCs and comparator modules, but.. can i use them at the same time?

thanks!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue May 27, 2014 12:51 am     Reply with quote

Yes.

They are completely separate modules, except some of the pins can be used for functions on both.

A little depends on what accuracy you want to use from the ADC?.

The 'VREF+' pin for the comparator, is shared by C2OUT. So this is the first decision. Realistically to use the 12bit accuracy of the ADC, _requires_ using an external Vref. You are unlikely to get anything beyond perhaps 7bits of useable/repeatable accuracy using the supply rail as the reference. Now provided you are happy to use this lower accuracy, 'no problem'.
Now you talk about setting the Vref for the comparator externally. If you look at Figure 13-1 (comparator operating modes), then the bottom left diagram shows the mode that will suit you the best. Here only comparator 2 is enabled, and uses just three pins. RA1, RA2 & RA4. You can put the reference you use for the comparator on the +ve or -ve input, and the signal on the other pin. This then leaves the RA3 pin clear to use for the ADC Vref if required (otherwise you can use the supply rail, with the accuracy limits mentioned), and AN0, AN5 & AN6 available for use as inputs to the ADC.
If required, you can use both comparators, but then you are stuck with using the supply for Vref, and only AN5 & AN6 are available as ADC inputs.

Best Wishes
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Tue May 27, 2014 6:27 am     Reply with quote

wow! thanks Ttelmah!

I didnt know that the 16F88 had 12 bit adc. I though that was 8 or 10 bits.

I just want it to measure the battery voltage, so i dont need high accuracy.

For high accuracy conversions i use the AD7705.

thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue May 27, 2014 10:38 am     Reply with quote

Apologies. There is another PIC with a short number like this that has a 12bit rather than 10bit ADC. Trying now to remember the number!....
It's an 'oldie'. Something like 16C88.
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