Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error increases as frequency increases using FreqCount Library in Arduino Uno Board #22

Open
SumanTheBob opened this issue Aug 13, 2021 · 2 comments

Comments

@SumanTheBob
Copy link

SumanTheBob commented Aug 13, 2021

#include <FreqCount.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);

void setup() {
Serial.begin(9600);
lcd.begin(8, 2);
lcd.print("Freq:");
FreqCount.begin(1000);
}

void loop() {
if (FreqCount.available()) {
unsigned long count = FreqCount.read();
lcd.setCursor(0, 1);
lcd.print(count);
lcd.print(" ");
}
}
I am using this program for measuring the signal frequency of a square wave (8 v p-p) from a very good function generator with frequency varying from 2 kHz to 10 kHz. But the error increases as the frequency increases. (For 2 kHz the LCD output is 2003 Hz, for 5 kHz it is 5006 and for 10 kHz the LCD output is 10011: hence the error is always positive and it increases with frequency) Can you please guide me on why this is happening?

@colinluthier
Copy link

Are you feeding the clock of the Arduino with a calibrated source? Replacing the crystal with a TCXO will help with accuracy and stability.
Alternatively you can add a bit of code for an offset for your particular crystal.

@PaulStoffregen
Copy link
Owner

You say "the error increases as the frequency increases", but to my eyes the error looks like a pretty consistent percentage of the frequency measured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants