Thursday, January 05, 2006

3 - Finding an Unknown Frequency (The Number Game)

Aim

To find the frequency of a signal.

Apparatus / Setup

There are 2 parts to this experiment.

  • Part 1 : Setting up the circuit and executing the algorithm on DSP. Setup same as Experiment 1.
  • Part 2 : Exchanging values between DSP and PC. Setup same as Experiment 2.

Theory

Remember the game in which you asked your friend to think of of any number between 1 and 100? Then you would ask him a few questions relating to the number. After a few such questions, you would tell him his secret number. And he would say, “Yes, that was the number I had thought of. But how did you know?”

Well now we can are going to do a similar thing using our DSP board. Ask your friend to tune the Signal generator to generate a sine wave of any frequency between 500 and 1000 Hz. Then, feed this signal of unknown frequency into the DSP through its' Audio In port. Execute your algorithm on the DSP board. Then ask your friend to check whether a number popping up on your PC’s monitor is the same as his secret frequency. He will be quite amazed when the numbers match his secret frequency!!

There are quite a few ways to find the time-period / frequency of an unknown signal. We shall show the DSP implementation of one such technique.

Suppose we have kept our guessing range within 500 to 1000 Hz. This would correspond to a range in time-period (1/fs) of (1/1000 = ) 1 msec to ( 1/500 = ) 2 msec. Since DSK 6711 supports a sampling frequency of 8000 Hz, the range in time-period would correspond to: -

  • 1 msec corresponds to ( 8000/1000 * 1 ) = 8 samples
  • 2 msec corresponds to ( 8000/1000 * 2) = 16 samples

Now, Auto-correlation function (ACF) gives values of the correlation at different values of lag (τ). So if we have a signal of unknown frequency, and we find that its’ ACF plot looks like Figure below, we can make a safe venture on the value of the unknown frequency.

Figure 1 : Plot of Auto-Correlation Function

In the above diagram, the maxima within our range of interest lies at 10 samples. If you do some mental maths, you can quickly say what the value of the unknown frequency was.

Procedure

Part 1 - Circuit

This process of guessing the unknown time-period / frequency by using the signal’s ACF is exactly what we would like to do using the DSP. I will draw below the basic block diagram of a Simulink circuit for achieving the same.

Note that the Sub-Matrix block is required to override the presence of a maxima at lag = 0. The maxima within the range of 8 to 16 samples is what interests us the most.

Part 2 - RTDX

By the above process, the value of the unknown frequency is calculated. The value remains calculated and sits pretty within the DSP. However, as the DSP does not have a monitor/output screen, we have no way of accessing the calculated value!

Unless of course we use RTDX (Real Time Data Exchange). RTDX, as shown in Experiment 2, allows the PC and the DSP to exchange values/data. And as our good-old PC is equipped with a monitor, we can easily see the values calculated on the DSP popping up on the PC screen via RTDX. Follow the procedure enumerated in Experiment 2 to do the same.

Discussion

  1. You can try out different dynamic ranges (other than 500 – 1000 Hz) to check the performance of the DSP and your algorithm.
  2. There are other methods apart from ACF to find an unknown frequency. Does FFT ring a bell here?

3 comments:

Anonymous said...

hello
iam working on a WiMAX project and iam a beginner using RTDX and CCS , i have a problem using to/From RTDX as i generate code from simulink and when i make enable for ochan1 there is error of HOST buffer Size and whatever i change it the problem still the same .
plz if any one can help me or listen to me online as i can not explain the problem here
contact me on :
eng_mkasiem@yahoo.com

thanks alot

kriti said...

@anonymous
i don't remember experiencing the problem... so cannot help directly.

however if u r a beginner, i would suggest you try simpler experiments on the board first (maybe experiments 1 and 2 of my site).

then maybe u would be better equipped to solve the present problem.

Akash said...

Check here you can configure the latest version of DSP Processor