I am not very familiar with DSP techniques, and I am currently working on my research project to develop the firmware of a DSP processor, using C/Linux. It involves the modulation and demodulation of a dataset using Binary FSK and frequency hopping Tx and Rx algorithms. I am able to modulate the signals and have verified the output using MATLAB. However I an a little stuck at demodulation.

The technique that I am using for demodulation is to compare the amplitude of the FFT of the signal received at every hopping sequence and based on that, determine whether the bit received is 1 or 0. I have a predefined function which is used calculate the FFT of the signals. The function is as follows:

void fft(complex_float* in, complex_float* out, int N, int inv)
int i, j;
float a, f;
complex_float s, w;
f = inv ? 1.0/N : 1.0;
for (i = 0; i < N; i++) {
s.re = 0;
s.im = 0;
for (j = 0; j < N; j++) {
  a = -2*PI*i*j/N;
  if (inv) a = -a;
  w.re = cos(a);
  w.im = sin(a);
  s.re += in[j].re * w.re - in[j].im * w.im;
  s.im += in[j].im * w.re + in[j].re * w.im;
out[i].re = s.re*f;
out[i].im = s.im*f;

complex_float is a predefined struct :

typedef struct {
float re;
float im;

In the function fft() N defines the number of FFT points.

The problem that I am facing is how to determine the frequency points of the individual elements in the array returned by fft() function. In MATLAB, this was very easy to do the FFT function in MATLAB took the sampling frequency in account and plotted the power spectrum accordingly. However, In the fft() function defined above there is no frequency involved and hence I am confused as to how to find the power of the signal at any particular frequency, or how to determine the frequency point of any element of the retuned array.

  • 3
    $\begingroup$ Pedantic note: the code that you showed above is not an FFT. Instead, it's a basic implementation of the DFT. The FFT is just a fast, clever way to execute a DFT. $\endgroup$
    – Jason R
    Commented Jul 10, 2012 at 13:14

3 Answers 3


There are two different kinds of frequency-hopped BFSK systems.

  • In slow frequency-hopping, the center frequency or carrier frequency $f_c$ changes periodically at a fraction of the data rate. Thus, the carrier frequency hops to a particular value, say $f_1$ and stays there for some time (say $nT$ seconds, where the bit duration is $T$ seconds. During this epoch of duration $nT$ seconds, $n$ data bits are transmitted successively using BFSK. That is, one of two tones at frequencies $f_1 + \Delta f$ and $f_1 - \Delta f$ is transmitted for a duration of $T$ seconds depending on whether a $0$ or a $1$ is being transmitted. Usually, $\Delta f$ is chosen so that $(2\Delta f)T$ is an integer. Then, the next bit is transmitted over the next $T$ seconds, and so on till a total of $n$ bits have been transmitted. After $n$ bits have been transmitted, the carrier frequency hops to some other choice $f_2$, and tones at frequencies $f_2 + \Delta f$ and $f_2 - \Delta f$ are used.

  • In fast frequency-hopping systems, a single bis is transmitted over multiple hops, say $m$ hops. To transmit a $1$, a succession of tones of duration $T/m$ are transmitted at frequencies $f_1 - \Delta f$, $f_2 - \Delta f$, $f_3 - \Delta f$, and so on. Of course, if $0$ were to be transmitted, the tones would be at frequencies $f_1 + \Delta f$, $f_2 + \Delta f$, $f_3 + \Delta f$. Fast frequency hopping systems thus automatically provide both frequency diversity and time diversity.

It is easiest to demodulate a frequency-hopped BFSK signa; by first heterodyning it (see, for example, this answer on another stackexchange site) down to a fixed intermediate frequency $f_i$ (so that the tones are at $f_i + \Delta f$ and $f_i - \Delta f$ regardless of the original frequency of transmission. This requires a local tunable oscillator synchronized to the hopping pattern and offset from the carrier frequencies in the pattern by frequency $f_i$. After heterodyning, a standard BFSK receiver can be used, and as David Rick says in another answer, using a FFT is not a particularly good solution to the problem. A standard coherent or noncoherent FSK receiver will be much better to use.


At some point, before the fft() function is called, the sampling frequency must be known (from ADC? or other resampling functions?)... use that to find the frequencies of the bins as you would in Matlab.


The FFT is very inefficient for demodulating BFSK, because you are only using 2 of N bin values, and all the math for the rest is wasted. The Goertzel algorithm is a commonly-used alternative.

  • $\begingroup$ Thanks for the help David, that was really helpful and i can see a the performance improvement with the Goertzel algorithm. $\endgroup$
    – anshu
    Commented Jul 17, 2012 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.