how to understand one of the TS201 examples ----about the sampling!
hello, aces:
i am a TS201 beginner, and i am learning the examples that are included in the Visual DSP++ software, and one of them make me confused, it is placed here "D:\visual_dsp++\TS\Examples\ADSP-TS201 EZ-KIT Lite\Power_On_Self_Test\CoreA", i am learning it now, and the problems that confused me are:
(1). there are many main() functions in this project, i think that are not right, you can check it, in every .c file, there is a main() function.
(2). in the audio_test.c file, i can't understand the macro's meaning at the beginning of the file:
#define MAX_SAMPLES 256
#define REQUIRED_SAMPLES ((MAX_SAMPLES) * 250)
#define DESIRED_FREQ ((float)3000.0)
#define SAMPLE_RATE ((float)48000.0)
#define AMPLITUDE ((float)8388607)
#define PI ((float)3.141592765309)
#define ACCEPTABLE_DEVIATION_PCT ((float)0.015)
#define ACCEPTABLE_DEVIATION (DESIRED_FREQ * ACCEPTABLE_DEVIATION_PCT)
#define MAX_DESIRED_FREQ (DESIRED_FREQ + ACCEPTABLE_DEVIATION)
#define MIN_DESIRED_FREQ (DESIRED_FREQ - ACCEPTABLE_DEVIATION)
#define MIN_SIGNAL_STRENGTH (float)30.0
how do you understand the "REQUIRED_SAMPLES" and the "DESIRED_FREQ" and the "SAMPLE_RATE" ? i think the "DESIRED_FREQ" and the "SAMPLE_RATE" are the same defination, but it sames that i am wrong.
(3). in the audio_test.c file, i don't know what does the author want to do? especially this part in the "int Test_Channel(float* pfRealIn) " function, i don't understand :
twidfft(w, MAX_SAMPLES);
// Real input array fills from a converter or other source
rfft( pfRealIn, t, out, w, 1, MAX_SAMPLES);
// Arrays are filled with FFT data
// scan the output array for the highest real value
fTempFreq = (float)sqrt(out[0].re*out[0].re+out[0].im*out[0].im);
for (nSampleNumber=1; nSampleNumber < (MAX_SAMPLES / 2); nSampleNumber++)
{
if( ((float)sqrt(out[nSampleNumber].re*out[nSampleNumber].re+out[nSampleNumber].im*out[nSampleNumber].im)) > fTempFreq )
{
fTempFreq = (float)sqrt(out[nSampleNumber].re*out[nSampleNumber].re+out[nSampleNumber].im*out[nSampleNumber].im);
nHighestFreqIndex = nSampleNumber;
}
}
// multiply the index of the array of the highest value with the sample rate value
fSampledFrequency = nHighestFreqIndex * (SAMPLE_RATE / MAX_SAMPLES);
so, i don't understand this project, can anybody help me?? thank you~
test
audio
The main functions are all surrounded by #ifdef _STANDALONE_ so unless that is defined they are not being used. This was done so that users could just take the file they are interested in and define _STANDALONE_ and easily create a project for that one peripheral.
The basis of the audio test is to send out a 3kHz sine wave that we generate in code, loop it back to the input, do an FFT and make sure the frequency is 3kHz. Some of the defines are used to make sure we are not just capturing noise by checking the amplitude of the signal.
I think most of the defines there that are confusing you can be figured out by coming up to speed on how audio works and looking into what FFT's are all about. There are definitely plenty of books out there that would help.
hello, Chadw,
Thank you for your replay, but i am still confused with this example, and can you give me more explanation for what is the function of this function?
thanks again,
sheng ming
hello, Chadw,
you said that
"The basis of the audio test is to send out a 3kHz sine wave that we generate in code, loop it back to the input, do an FFT and make sure the frequency is 3kHz."
i think you are right, and what is the "SAMPLE_RATE"? it is equal to 48000, can you give me some example about how to distinguish the "DESIRED_FREQ" and the "SAMPLE_RATE"?
I have read some books about the FFT, but i can't understand this
best regards,
sheng ming
Hi,
the "SAMPLE RATE" is the sampling rate of the hardware - the AD1854 on the TS201 EZ-KIT Lite typically operates at 48kHz. The DESIRED_FREQUENCY in this example is the frequency of the generated "output" sine wave, and the frequency used to test the "input" sine wave to make sure it is in the acceptable range once it has been looped back.
Regards,
Craig.
thank you very much. this is the correct answer, i have solve this problem, i think understanding the FFT is great thing, maybe it changes my view of the world.
best regards,
sheng ming
Please log in to reply.