Community
cancel
Showing results for
Did you mean:
Beginner
1,699 Views

## How to verify sample rate on Intel Galileo?

'm sampling a guitar signal as part of a guitar tuning project. The sampling (2048 Hz) is done in software using the arduino IDE on Galileo. I have concerns that because the sampling isn't real-time , it may be fluctuating and creating bad data for the FFT that runs later in the program.

How would i go about checking the exact frequency of the samples to check if it is indeed causing the FFT to give back inconsistent data? And how would i fix this problem ? (it currently has an accuracy of +/- 2Hz which is unacceptable for a tuner)

Here's how i'm sampling incoming guitar signal:

`for (n = 0; n < 100; n++) // capture 100 data points `

{

start = micros();

while (finish < start + (489)) //gives approx 2K Hz sample rate

{

finish = micros();

}

x[n] = (SigAmplitude - 512); //get rid of DC bias

y[n] = 0; // no imaginary part

}
3 Replies
Honored Contributor I
91 Views

Hi flicky ,

Yocto is not a real time OS, so I suggest you sample at the maximum rate. i.e. no delay. i.e. no

` `

while (finish < start + (489)) //gives approx 2K Hz sample rate

{

finish = micros();

` }`

and save the time with each of the samples for the time equivalent to 100 samples. Later, just downsample at the times you need and interpolate if needed (which does not seem to be necessary right now, but given that yocto is not a RT OS there may be some extra-large jitter somewhere.

HTH,

Fernando.

Community Manager
91 Views

Hi,

Measuring the sample rate via software is not very effective due to the sketch is also measuring the time that takes running of other instructions, for example, in your sketch, it will also measure how it takes to run the condition in the while function. You can create a file that saves the analogRead and the micros() after every reading, at the end you can manually do the subtraction using the time measurements.

Which is the sample rate you need for your project?

Regards,

Charlie

Community Manager
91 Views

Hi flicky,

I would like to know if you have been able to read the sample rate on the pins, please let us know the sample rate you are looking for.

Regards,

Charlie