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

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







Comparator
PostPosted: Tue Feb 13, 2007 10:28 am     Reply with quote

Does anyone know how to use the comparator of pic 16f877?. I need a zero crossing detector , for when a sine wave cross the zero , the Pic starts counting and when another sine wave cross the zero , the pic stops the counter.
Thanks.
Ttelmah
Guest







PostPosted: Tue Feb 13, 2007 11:07 am     Reply with quote

The PIC16F877, doesn't have a comparator module....
The 16F877A does.
The easiest way to do what you want, is probably to wire the output to load a flip-flop, and the output of the second compator to clear it. Then use the output of the flip flop, to gate the sigal to count.

Best Wishes
Rick
Guest







PostPosted: Tue Feb 13, 2007 1:00 pm     Reply with quote

How do I use the comparator as a zero crossing detector in C , using PIC16f877A?.
Ttelmah
Guest







PostPosted: Tue Feb 13, 2007 3:36 pm     Reply with quote

The same way as any comparator. You would need to have the AC voltage 'biased' so that the 'zero' point represents a voltage inside the comparator's range, and then feed this voltage into one input, and the DC voltgae corresponding to the 'zero' level into the other.

Best Wishes
Rick
Guest







PostPosted: Tue Feb 13, 2007 5:50 pm     Reply with quote

I've never use a comparator before , could you please explain me how it works. I need fist to setup the comparator , using setup_comparator() function . when I choose wich pins are gonna be the input of comparators , is that righ? So how it works , Where do I choose that the comparison is gonna be with 0?. And when the Sine cross the zero , is a output pin(where do I choose it?) gonna turn logic 1?

Thanks so much for you Attention.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 13, 2007 6:04 pm     Reply with quote

Look at the CCS example file, EX_COMP.c for sample code.
It's in this directory:
c:\program files\picc\examples\Ex_Comp.c

Also study this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=26861
Rick
Guest







PostPosted: Wed Feb 14, 2007 5:32 pm     Reply with quote

Which simulator do u guys use to simulate a comparator? I can't find PIC16f877A or other PIC who has a comparator at Proteus.
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Fri Feb 16, 2007 9:42 am     Reply with quote

Should not a schmitt trigger and a small inexpensive PIC do a zero crossing detector just fine ?
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