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

SocMatt

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



Joined: 07 Jun 2004
Posts: 6

View user's profile Send private message

SocMatt
PostPosted: Mon Jun 07, 2004 7:59 am     Reply with quote

Hi

Does anyone know a command for obtaining a frequency from an input squarewave??

Im using a PIC16F876

Cheers
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Mon Jun 07, 2004 8:46 am     Reply with quote

You can use the capture module to get the pulse duration and then compute the frequency.
Ttelmah
Guest







PostPosted: Mon Jun 07, 2004 9:22 am     Reply with quote

future wrote:
You can use the capture module to get the pulse duration and then compute the frequency.

I does depend rather on the frequency involved. If the frequency is very low, you can do the alternative to the above, which is to interrupt in the edges of the frequency itself, and record the values from one of the internal counters instead, effectively giving the 'interval' between edges.

Best Wishes
SocMatt



Joined: 07 Jun 2004
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 07, 2004 9:26 am     Reply with quote

The problem is the squarewave is an ouput of a sensor and can change from about 10Hz to 10Khz depending on the conditions
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Jun 07, 2004 5:21 pm     Reply with quote

By using a fast crystal (20MHz) and some careful programming you should be able to cover the whole range of 10Hz-10KHz. Take a look at the EX_CCPMP.C file in the \Examples directory.
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