# Re: Calculating the variable sampling frenquecy.....

Started by May 21, 2004
 Ng- This is a good news group question. Are you saying that the PCM3003 daughtercard is not providing 16 kHz, but actually something else? Clearly if your sampling frequency is off then measured delay will not match your MATLAB results. O ya. Did you carefully measure sampling rate? Put in a nice 1 kHz sine wave and look at some waveform plots? -Jeff > Could you check on this....is't this part is use to > calculating the variable sampling frequency???????? > > Because i am try to calculation the sampling frequency > base on the book.... > Ex: FskHz is specified in the program, the actual > sampling frequency is calculated is 14,648.438Hz. > > Actually i have tryed to calculate by used below > fomula > but the results given is same as 16kHz... > > float SampleRate(float freq) { /* freq is desired > sample freq */ > unsigned int divider; > float clock_freq = 37500000.0; > float clocks_per_sample = 256.0; > > *(volatile unsigned int *)TIMER0_CTRL = 0; /* stop > timer */ > if(freq == 0) > freq = 1; > divider = (clock_freq / (2 * clocks_per_sample)) / > freq + (float)0.5; > if(divider == 0) //* minimum divider in clock mode is > 1 */ > divider = 1; > freq = (clock_freq / (2 * clocks_per_sample)) / > divider; > *(volatile unsigned int *)TIMER0_PRD = divider; /* > set period */ > *(volatile unsigned int *)TIMER0_CTRL = 0x3D1; /* > clock mode, int clock */ > /* TOUT = timer pin, PWID = 1 */ > return freq; > } > > Thanks for your time > > From > Hsiung > > --- Jeff Brower <> wrote: > > Ng- > > > > Yes, I think the maximum cross-correlation value is > > what you want. That should get > > you delay between mics. You can also estimate > > relative amplitude to confirm which > > quadrant. > > > > -Jeff
 Ng- > Actually i am try to find the time delay of the Cross > Correlation from my C program....but the problem is i > couldn't get the right time delay same as matlab > program? > why? I have check the cross-correlation data with > Matlab corr....it show that the data are > approximately > the same. Could you give me some suggestion on this? This is a debug issue, not DSP. First, just ignore DSK for a while and feed the same exact .wav file to MATLAB routine as to a PC version of your C code. Do get you get identical results? Second, try to understand exactly what MATLAB does "under the hood". Calling an intrinsic cross-correlation function may make some assumptions. For example, what happens at the end of the waveform -- are zeros appended to x[n] in order to consume all points? Or does it stop at x[n-M] ? -Jeff > --- Jeff Brower <> wrote: > > Ng- > > > > This is a good news group question. Are you saying > > that the PCM3003 daughtercard is > > not providing 16 kHz, but actually something else? > > > > Clearly if your sampling frequency is off then > > measured delay will not match your > > MATLAB results. O ya. > > > > Did you carefully measure sampling rate? Put in a > > nice 1 kHz sine wave and look at > > some waveform plots? > > > > -Jeff > > > > > > > Could you check on this....is't this part is use > > to > > > calculating the variable sampling > > frequency???????? > > > > > > Because i am try to calculation the sampling > > frequency > > > base on the book.... > > > Ex: FskHz is specified in the program, the > > actual > > > sampling frequency is calculated is 14,648.438Hz. > > > > > > Actually i have tryed to calculate by used below > > > fomula > > > but the results given is same as 16kHz... > > > > > > float SampleRate(float freq) { /* freq is desired > > > sample freq */ > > > unsigned int divider; > > > float clock_freq = 37500000.0; > > > float clocks_per_sample = 256.0; > > > > > > *(volatile unsigned int *)TIMER0_CTRL = 0; > > /* stop > > > timer */ > > > if(freq == 0) > > > freq = 1; > > > divider = (clock_freq / (2 * > > clocks_per_sample)) / > > > freq + (float)0.5; > > > if(divider == 0) //* minimum divider in > > clock mode is > > > 1 */ > > > divider = 1; > > > freq = (clock_freq / (2 * > > clocks_per_sample)) / > > > divider; > > > *(volatile unsigned int *)TIMER0_PRD = > > divider; /* > > > set period */ > > > *(volatile unsigned int *)TIMER0_CTRL = > > 0x3D1; /* > > > clock mode, int clock */ > > > > > /* TOUT = timer pin, PWID = 1 > > */ > > > return freq; > > > } > > > > > > Thanks for your time > > > > > > From > > > Hsiung > > > > > > --- Jeff Brower <> wrote: > > > > Ng- > > > > > > > > Yes, I think the maximum cross-correlation value > > is > > > > what you want. That should get > > > > you delay between mics. You can also estimate > > > > relative amplitude to confirm which > > > > quadrant. > > > > > > > > -Jeff