Go Down

Topic: frequency count with high accuracy (Read 5668 times) previous topic - next topic

john12345

Hello all.

I'm am very new to arduino, so please forgive dumb questions. I have been reading page after page of data on using arduino as a freq counter but still can't seem to get anywhere.

Let's start at the beginning. I want to build a combo frequency counter and generator. The range will need to be between 10hz and 25khz. The generator will be piped out to a Bluetooth speaker and the counter will use a microphone.as a pickup an will also monitor output frequency of generator. The counter will tie to gps for its accuracy and I would like 8 to 12 digit display. (No sense of accuracy with out seeing it).

So, which Arduino board should I be looking at? Uno, mega?

Eventually I will use a 5 or 7 in display.

Thank you for any guidance.

TomGeorge

Hi,

Welcome to the forum.

What is your electronics, programming, arduino, hardware experience?

What sort of accuracy do you require, what is the application?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

jackrae

If you want an accurate 12 segment display then you are going to need a super accurate crystal located within a stable oven.  Or an atomic clock because that's what you are asking for.

On the other-hand, if you want to be realistic and have a display that offers say 0.1% accuracy ( 1 part in 1,000) then you are looking for a device that can display say 0.01% or 1 part in 10,000 ie a 5 or 6 segment display.

Even then you are going to be looking at a pretty good crystal to act as a reference source driving a phase locked loop circuit

MarkT

Hello all.

I'm am very new to arduino, so please forgive dumb questions. I have been reading page after page of data on using arduino as a freq counter but still can't seem to get anywhere.

Let's start at the beginning. I want to build a combo frequency counter and generator. The range will need to be between 10hz and 25khz. The generator will be piped out to a Bluetooth speaker and the counter will use a microphone.as a pickup an will also monitor output frequency of generator. The counter will tie to gps for its accuracy and I would like 8 to 12 digit display. (No sense of accuracy with out seeing it).

So, which Arduino board should I be looking at? Uno, mega?

Eventually I will use a 5 or 7 in display.

Thank you for any guidance.
Now tell us what you actually want to do.

xyproblem.info
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

john12345

Thanks all for responding.

Tomgeorge: I am a pmel tech trained through the usaf. I've been in calibration for over 20 years mainly working on low freq, torque, force and pressure. I have some programing, but in vb and object pascal. I have no experiance with arduino.

I want to obtain accuracy that is easily e x 10-10 and the uncertainty can be calculated without major studies. I am planing to add a gps receiver that has a 1pps timing that a 10 MHZ reference can be derived (there's already  a few out there).

I want to make a cal standard for audio level freqencys.



Jackrae, please see above about the gps.




Markt, I hope I clarified things.

Thanks all for responding.

raschemmel

Let me see if I understand this correctly.

You want to generate an audio sound , but you want to transmit the frequency for the sound via bluetooth. because the frequency transmitter is  inside the "package" . The Bluetooth will receive the frequency (through the plastic wrapped around the package) and send it to the audio amplifier which will send the frequency to the speaker. A separate device will then search for the audio frequency , sending GPS coordinates as it does. When the "package" that was "dropped off" is located, the GPS coordinates are transmitted to the recovery team that dispatch the recovery vehicle to pickup the "package".


Does that sound about right ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

#6
May 15, 2016, 08:45 pm Last Edit: May 15, 2016, 11:20 pm by raschemmel
Quote
I want to make a cal standard for audio level freqencys.
Oh, my bad.

I found a sketch in Reply#11 of this post.

But for reasons I can't figure, it doesn't work. It compiles (with the timerone lib installed) but it doesn't do anything.

This one works.
The Timer1 initialize parameter:
Code: [Select]
Timer1.initialize(30);
 (30 uS period) produces a frequency of 33.333 kHz.


Code: [Select]
/*
 *  Timer1 library example
 *  June 2008 | jesse dot tane at gmail dot com
 */

#include "TimerOne.h"

void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(30);         // initialize timer1, and set a 1/2 second period
  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
}

void callback()
{
  digitalWrite(10, digitalRead(10) ^ 1);
}

void loop()
{
  // your program here...
}
  



I found a frequency counter sketch here:

And this one works:
Code: [Select]
// Arduino UNO DDS

#include <PWM.h>

int32_t frequency_9 = 4000; //frequency (in Hz)
int32_t frequency_3 = 3000; //frequency (in Hz)
 

void setup()
{

InitTimersSafe();

SetPinFrequencySafe(9, frequency_9);
SetPinFrequencySafe(3, frequency_3);
 
}

void loop()
{
 
 int dutyC =512; // Duty Cycle 0 (0%) - 1023(100%)
 pwmWrite(9, dutyC / 4);
 pwmWrite(3, dutyC / 4);
 delay(30);
 
 }
 


Code: [Select]
Frequency Counter
0
4000
3996
3996
3996
3996
3996
3996
3995
3995
3996
3996
3996
3996
3996 


Frequency Counter
Code: [Select]
#include <FreqCounter.h>

void setup() {
  Serial.begin(57600);                    // connect to the serial port
  Serial.println("Frequency Counter");
}

long int frq =0;
void
loop() {

 FreqCounter::f_comp= 8;             // Set compensation to 12
 FreqCounter::start(1000);            // Start counting with gatetime of 100ms
 while (FreqCounter::f_ready == 0)         // wait until counter ready
 
 frq=FreqCounter::f_freq;            // read result
 Serial.println(frq);                // print result
 delay(20);
}  


See attached scope screenshot.
Note, the filename of the Frequency generator is based on the period parameter of 30 uS, which equates to 33,333 Hz.

The attached serial terminal capture file using Clear Terminal shows a frequency of 33,298 (35 Hz lower than scope reading and period parameter.

Frequency Counter
Code: [Select]

33332
33298
33298
33298
33298
33298
33297
33298
33298
33298
33297
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33299
33298
33299
33298
33298
33298
33298
33298
33298
33298
33298
33298
33298
33299
33298
33298
33298
33298
33298
33298
33298
33298
33298
33299
33298
33298
33298
33299
33298

 

It's only 5 digits accuracy and it's off by 0.1060 %.
NOTE: The very FIRST reading is right on the money. All the rest are off by 35 Hz.
When I changed the frequency to 9900 Hz T = (101 us), the reading was 9891 (10 Hz off). (again 0.1 % error)
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

john12345

Raschemmel, no problem. It's nothing like that. I gotta check one device with a freq counter and another with an audio tone generator that will be sent to a speaked via bluetooth. I'll achieve high accuracy with a gps receiver. Hopefully one unit. All controlled through a touch screen display.

raschemmel

#8
May 15, 2016, 10:30 pm Last Edit: May 15, 2016, 10:32 pm by raschemmel
Quote
I'll achieve high accuracy with a gps receiver
How so ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

john12345

Gps single is timed to an accuracy E x 10 to the -13. It is THE most accurate frequency source there is. Anyone can read that signal and use the timing signal. (1 pps). There are Senegal projects doing that now so I know it can be done.

raschemmel

#10
May 15, 2016, 11:15 pm Last Edit: May 15, 2016, 11:18 pm by raschemmel
Quote
Gps single is timed to an accuracy E x 10 to the -13. It is THE most accurate frequency source there is. Anyone can read that signal and use the timing signal. (1 pps). There are Senegal projects doing that now so I know it can be done.
I understand that GPS by it's very nature, is timing accuracy based technology because it works by triangulating the timing signals. Based on your wording, it sounds like this is something you have never yet done. So if I understand you correctly , the GPS doesn't check anything, but rather is the reference source and knowing it's frequency, you can compare a measured frequency and calibrate the measuring device until it returns the correct frequency sent by the GPS ?

On a side note, I was USAF , (659th Tac Wing) stationed in Tachikawa , Japan during the Vietnam War.
(69-71) as a Medical Service Specialist (SGT) (Hospital Corpsman, assigned to ICU WARD)
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

MarkT

1 part in 10^10 for a 10kHz tone is about 30 degrees of phase change per day.  That's nothing to do
with audio, the human ear is not that sensitive (!).

Phase lags/leads in an audio path are dominated by the Q of the speaker resonances, delays due
to the slow speed of sound in air, and similar.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

MrMark

Gps single is timed to an accuracy E x 10 to the -13. It is THE most accurate frequency source there is. Anyone can read that signal and use the timing signal. (1 pps). There are Senegal projects doing that now so I know it can be done.
The 1 PPS from a GPS has a long term drift rate on the order of 10E-13, but there is a great deal of short term jitter in GPS time measurement so one needs to use the GPS signal to discipline a clock with good short term stability.  A GPS Rubidum disciplined oscillator will get you in the neighborhood of 10E-11.  10E-13 instantaneous is Cesium Beam lab standard territory, thus, while it is possible to do this, it requires (last time I looked) a ~$70k instrument.  

The question still is why you think you need this kind of accuracy in measuring an audio signal.  Even if your receiver/frequency counter were that good, you'd need another precision reference at the audio transmit end because the bluetooth link is going to corrupt your source signal to maybe 10e-6 at best.

john12345

That is how I'm gonna use the gps. As a 10 MHz reference for the couner.

Raschelle, thank you for your service.

I know the human ear can not tell the difference between 5001.0004 Hz and 5001.0006, but the equipment I need to test does. And it is designed to work from about 800 Hz to 8 khz. (Audio range)


There are a lot of possible sources of a reference signal, but calculating their uncertainty of the signal is hard to calculate in lab conditions, and this project must be portable. The gps signals uncertainty will not change because of things like outside temp.

All of the frequency counters that are portable do not have the accuracy or resolution . And any counter with accuracy is not portable or cost thousands.

I can use a mic and the counter to monitor the output of the generator. I have the needed equipment to certify the entire system. I know gps is a bit overkill like a bazooka flyswatter, but it solves many issues for me.

Thanks for all the great discussion.

raschemmel

Is this for calibrating USAF equipment ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up