View previous topic :: View next topic |
Author |
Message |
SocMatt
Joined: 07 Jun 2004 Posts: 6
|
SocMatt |
Posted: Mon Jun 07, 2004 7:59 am |
|
|
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
|
|
Posted: Mon Jun 07, 2004 8:46 am |
|
|
You can use the capture module to get the pulse duration and then compute the frequency. |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 07, 2004 9:22 am |
|
|
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
|
|
Posted: Mon Jun 07, 2004 9:26 am |
|
|
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
|
|
Posted: Mon Jun 07, 2004 5:21 pm |
|
|
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. |
|
|
|