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

comparator basic understanding.

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



Joined: 22 Sep 2012
Posts: 37

View user's profile Send private message

comparator basic understanding.
PostPosted: Tue Oct 30, 2012 3:24 am     Reply with quote

Hi

We are using the pickit2 with pic16f690.

We use the internal comparator to call the interrupt routine.

We set the comparator positive pin(+) to be Vref .

We input some voltages in the negative pin(-) which is RC2 pin.

We can't understand the way this comparator works , and the data sheet doesn't say anything but "when comparator change its value=interrupt"

1. can we input negative voltages to the negative pin of comparator? like measuring a pure sin wave ? (it is working perfect but not sure if its ok).

2. if we set the Vref to be 1v, it has interrupt right when we turn the pic on, and if we set it to be lower than 1v, its not happening :
how is it work ? interrupt is happen only when there is a change that is bigger than 1v ?

3. when Vref is 0.4v , and v- is (-0.6v) we have an interrupt each time we input the -0.6 and also when we take it out. what is that ?

We can't understand, what is the rules, the exact rules for the comparator to turn the interrupt ? who has to be bigger ? can it be negative ?

Thanks a lot.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 8:11 am     Reply with quote

Quote:
1. can we input negative voltages to the negative pin of comparator? like measuring a pure sin wave ? (it is working perfect but not sure if its ok)

2. if we set the Vref to be 1v , it has interrupt right when we turn the pic on, and if we set it to be lower than 1v , its not happening :
how is it work ? interrupt is happen only when there is a change that is bigger than 1v ?

3. when vref is 0.4v , and v- is (-0.6v) we have an interrupt each time we input the -0.6 and also when we take it out . what is that ?

We cant understand, what is the rules, the exact rules for the comparator to turn the interrupt ? who has to be bigger ? can it be negative ?
Most of the answers ARE in the data sheet.

1) Do NOT apply voltages beyond the supply rails.

2) The common mode range is 0 to VDD - 1.5V. I would expect normal operation anywhere within that range. The offset is +/- 10mV at worst, so has to be allowed for.

3) Do not take an input to -0.6V. You are at risk of latch up, and other nasties.

The manual explains when interrupts occur. You can watch the output of the comparator, it's available on a pin. You can then watch what happens as you apply voltages to the input pins. In normal mode the output moves in the same direction as the V+ input pin and in the opposite direction to the V- input pin.

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 12:21 pm     Reply with quote

Example of comparator interrupt program:
http://www.ccsinfo.com/forum/viewtopic.php?t=44190&start=4
Notice how you have to read the CMCON register at the end of the
interrupt routine. This clears the interrupt condition, as described in
the 16F690 data sheet.

Also, just a reminder, do not try to single step through an interrupt
with the debugger, and preferably test the program in Release mode:
http://www.ccsinfo.com/forum/viewtopic.php?t=45859
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