I’m using this library
(the 3 files I attached other than FC.h) to find the frequency of an input sin wave to pin 47 of Arduino mega 2560 for senior design project. The sin wave will be changing between roughly 340 kHz and 380kHz (0-5 V) at a rate of 20 thousand times per second. My Arduino needs to translate 340kHz into 0’s and 380kHz into 1’s.
I’ve tested it with a function generator and the frequency is accurate up to 8MHz! I need to sample the frequency several more times faster than the transmission bit rate (20kbits/sec) in order to reduce bit error rate and at least twice as fast (40kbits/sec) to get any accuracy at all.
BUT the frequency library, from what I can tell, can only update the frequency 1000 times a second. 40 times slower than the bare minimum sampling frequency…
When I look through the FreqCount.cpp and FreqCountTimers.h files I get lost.
Suggestions? Thanks in advance for any responses!
My code is FC
FC.h (1.09 KB)
FreqCount.cpp (2.77 KB)
FreqCount.h (260 Bytes)
FreqCountTimers.h (16.6 KB)