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

16F648A comparator

 
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

16F648A comparator
PostPosted: Thu Oct 17, 2013 7:48 am     Reply with quote

Hi all! i have a question regarding the comparator in the 16F648A.

Is it possible to use only one pin to compare external battery voltage with an internal vref?

I have a circuit already working with a 16F88, that one of the functions is to monitor the battery voltage across a resistor divider. I use the ADC to do this.

The thing is that now i have to use the same hardware but with the 16F648A. The resistor divider is connected to one of the comparator inputs.

so it is possible to compare this voltage across the divider to the internal vref and let the user know when the battery is empty? i Only can use 1 pin, a comparator input.


thanks! (sorry for my inglish)
Ttelmah



Joined: 11 Mar 2010
Posts: 19343

View user's profile Send private message

PostPosted: Thu Oct 17, 2013 9:42 am     Reply with quote

It depends on what you want to do with one other pin....

The only comparator mode capable of what you want, is the one described in Figure 10-1 'comparator I/O modes', as 'four inputs multiplexed to two comparators'. With this the +ve inputs of both comparators are connected to the Vref, and the outputs of the comparators are 'internal' (so don't use any pins). The two comparator -ve inputs are connectable to RA0 or RA3 (comp 1), and RA1 or RA2 (comp 2).

These are selectable by the CCS modes:

A0_VR_A1_VR
A3_VR_A2_VR

So if you use 'A0', then A1 is also connected to a comparator. Use A3, the A2 is also connected to a comparator.

Now when a pin is setup as a comparator input, this defines it as an 'analog' pin, and it won't function as a 'logic' input. However it can still be used as a logic output OK.

So depending on which pin you use, the 'other' pin from the pair, needs to be used as an output.

Now there is a very obvious 'caveat' with using the comparator, that it gives no advance warning of approaching failure, and could be triggered by noise on the rail if there are things being switched.

Best Wishes
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