FreqMeasure.h not working

eivol

New member
Hi there!

We are working on a guitar tuner using Arduino. This was supposed to get the input frequency by means of FreqMeasure library but it's actually not working properly. The thing is, after having the entire code written, we realized that something was going wrong, so we decided to start using the "Serial Output" example given in the lines below:

#include <FreqMeasure.h>

void setup() {
Serial.begin(57600);
FreqMeasure.begin();
}

double sum=0;
int count=0;

void loop() {
if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
double frequency = F_CPU / (sum / count);
Serial.println(frequency);
sum = 0;
count = 0;
}
}
}

Our input frequency came from a function generation, but although we were changing the value of the input frequency, Serial displayed each the same one.
Any suggestion to fix it?
 
Hi there!
We are working on a guitar tuner using Arduino. This was supposed to get the input frequency by means of FreqMeasure library but it's actually not working properly.

Hi, it's hard to find, and as far as i know the only spot where it is mentioned is this page: If you're using a teensy 3.x, this lib is not working.
 
Would you believe I'm looking at (finally) porting FreqCount and FreqMeasure now...

But the question above might be on Teensy 2.0? I don't know. I do not understand what this means:

Our input frequency came from a function generation, but although we were changing the value of the input frequency, Serial displayed each the same one.
 
Thanks for replying!

If you're using a teensy 3.x, this lib is not working.

Actually we're using a kind of imitation of Arduino UNO R3... so I guess that if this library doesn't work with Teensy, won't work with this board either.

I do not understand what this means:

Our input frequency came from a function generation, but although we were changing the value of the input frequency, Serial displayed each the same one.

What I meant to say is, we were using a function generator to generate tones at some frequency but whatever the frequency we set, we always received the same one. For example, setting an input frequency of 80 Hz, we retrieved 300000. And though we decreased and increased this input frequency value, we were always receiving the same. I don't know if I've met myself clear... :/
 
If you're using the '328 chip, it should work.

My guess is you've not correctly connected the signal, or made some other hardware-related mistake. Since you've provided virtually zero information, it's impossible to even guess what's wrong.
 
Actually we're using a kind of imitation of Arduino UNO R3... so I guess that if this library doesn't work with Teensy, won't work with this board either.

It does work with AVR-based Teensies(Teensy 2.0 and Teensy++ 2.0) and AVR-basd Arduinos (including Uno).
It does not, currently, work on the ARM-based Teensy 3.0 or 3.1. But Paul is looking into that.

Once you have it working, its worth looking at the accuracy and precision of your Uno clone. Some of them use low-tolerance crystals (or even ceramic resonators). All the Teensy boards use a close-tolerance 5ppm crystal with low drift over time and with temperature and voltage.
 
Last edited:
Would you believe I'm looking at (finally) porting FreqCount and FreqMeasure now...

So what are the incantations to setup an external clock pin for the FTM? ALT4 for PTA18 and 19 have names FTM_CLKN0 and N1, but alas those are the 16mhz crystal pins.

inquiring minds ...
 
I'm working on FreqCount today, using LPTRM for counting, not FTM.

FreqMeasure only needs input capture mode, which is easily available on FTM. I'm going to do that one next....
 
Back
Top