Hi everybody !
This code is a quick hack, I just happened to need a frequency counter and
so I wrote it. Feel free to use it, modify it, and send it back to me ;)
C sources included.
The directory "loop" contains a CPU-hog version, allowing for higher
frequency measures. Just click "GO" and it starts, press the left mouse
button and it returns control back to you.
The "int" directory contains an interrupt driven version, which is highly
affected in accuracy by system load, but lets you run it while still using
your machine. This program uses part of CIA_interval.c code, provided on the
RKRM Devices manual.
The operating principle is easy, I just set up a 1 sec window and count
zero crosses of the incoming signal, then divide by two and display.
The 1 sec window is calculated as an approximation.
A sample rate is defined, then the CIA divisor to get this rate is
calculated. As it often is not an integer number, then the real sample
rate is calculated by doing E/(this number). This is quite often also a
fractional number, so this is a source of inaccuracy, as the total number
of samples in a 1 sec window won't be an integer.
The E clock frequency is taken from SysBase, so this could be another
source of inaccuracy.
As I said before, this is a quick hack and I didn't pay much attention to
accuracy, it shows a 5-10 % accuracy and it works for me. If you write a
better code, please send it.
------------------------------------------------
AMIGA | Sergio R. Caprile, Bs. As., Argentina |
// | email: scaprile@geocities.com |
\X/ | DSP, Music, Electronics, Tai Chi Chuan |
------------------------------------------------
http://www.geocities.com/CapeCanaveral/Lab/2885|
------------------------------------------------
|