4
$\begingroup$

I'm trying to implement a software audio modem with FSK to transmit and receive short digital data between two devices (e.g. a PC and an iPhone) so I'm simulating simple cases study using Scilab/MATLAB.

While I can reconstruct the original signal when no noise nor background sound is present, problems arise when playing the afsk in presence of normal ambient background sounds: trying to reconstruct the digital data reading from the PC microphone is extremely difficult.

To generate the AFSK signal I use this simple script below, then I save the wav file to disk for the next steps.

function s = fsk (bit, f1, f2, fs, T)
% bit : Array of bit
% f1: Frequency 1
% f2: Frequency 2
% fs: Sampling frequency
% T : Tramsision period for 1 bit
    t=0:1/fs:T-1/fs;
    s=[];
    for i=1:length(x)
        s=[s (bit(i)==0)*sin(2*pi*t*f1)+(bit(i)==1)*sin(2*pi*t*f2)];
    end    
end
  • The frequency f1, f2 I choose can vary: $3000\textrm{ Hz}$ and $4000\textrm{ Hz}$ or $3000\textrm{ Hz}$ and $5000\textrm{ Hz}$.
  • The frequency sampling is $44100\textrm{ Hz}$ and the period of transmission is $0.01\textrm{ sec}$ (for the moment I don't bother with higher trasmission rate).
  • The bit array is a very simple $[\textrm{0 1 0 1 0...}]$ sequence.

When I read-back the wav file I decode it using a simply coherent demodulation in these 3 step scheme:

  1. Pass-band the signal with a FIR filter around $5000\textrm{ Hz}$ created using the command fir1(91,[2*4900/fs 2*5100/fs])

  2. Multiply the filtered signal by the f2 (mark) carrier sin(2*pi*f2*t) (or multiply the signal with a 1 sample-delayed version of itself)

  3. Low-pass the multiplied signal obtained in step 2 to isolate the low frequency component of the original digital signal using LP FIR filter generated with fir1(61, 2*500/fs)

The original sequence of bit is now almost perfectly reconstructed. I've played a bit around with the filters parameters to obtain a good recontruction.

Reconstructed bit stream

Then I decided to play the wav file on my stereo with normal background noise present (actually very low), I recorded it with the pc microphone and saved with Audacity, read it back with MATLAB/scilab and I tried to reconstruct the original bit sequence with the 3 steps above but the signal is a bit different from what I expected and I can't see the original pattern and I don't know I to recontruct the bit sequence using any treshold value.

Noisy bit-stream

I suppose the cause is the SNR is awesome but I don't know where I'm wrong and I don't understand why the results are so different than the previous case.

How could I reconstruct the correct bit stream sequence in presence of background noise ?

UPDATE: Do I have to low-pass filter the modulated signal before send it to the receiver ?

Any suggestion will be very appreciated.


Well...it seems that my recording system was buggy ,as Jim pointed out ! I played and recorded the sound using the speakers and mic on the same PC so this introduced some indesiderable feedback or filtering or something else I suppose. Now I'm using an external device to play the sound (a smartphone) and the recorded signal is much better. This is the signal transmitted

Hello world !

and this is the decoded signal

fsk decoded

I'm using a bandpass filter centered around the mark and space frequency before transmit it. The decoding steps are the same as before but in step 2 I'm using the slicing method correlating the signal with the delayed version of itself.

The reconstructed FSK signal has now a much better SNR than before. Now should be easy to recover the exact bit sequence....

$\endgroup$
7
  • 1
    $\begingroup$ Your pass-band filter destroys the f1 portions of the signal. How do you recover f1? $\endgroup$
    – Jim Clay
    Commented Aug 28, 2012 at 16:37
  • 2
    $\begingroup$ Your synthesis script makes a signal with phase jumps between symbols (you stitch together 2 incoherent sine waves). Normally AFSK signals have continuous phase. Your case will generate a wider spectrum and will be probably more difficult to decode. $\endgroup$
    – Juancho
    Commented Aug 28, 2012 at 17:50
  • $\begingroup$ I've also made a bandpass FIR filter centered on the mark and space frequencies (about 100/200 Hz width) to let them pass both while stopping out-of-band noise but with the same discouraging results. How could I build a continuous phase AFSK signal in practice ? Please keep in mind that these scheme works perfectly in absence of noise while it's seriously degraded with some low-level background noise. $\endgroup$
    – Yozek
    Commented Aug 31, 2012 at 8:51
  • $\begingroup$ Actually for restoring the bit stream I have to transmit a bit for a period of 0.1/0.05 seconds (symbol rate). If I try to transmit with a faster rate (<0.01 sec) I recover just a lot of garbage. $\endgroup$
    – Yozek
    Commented Aug 31, 2012 at 14:11
  • $\begingroup$ @Randagio How do you know that your recording setup works? That looks like a garbage recording. $\endgroup$
    – Jim Clay
    Commented Sep 3, 2012 at 15:14

0

Your Answer

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

Browse other questions tagged or ask your own question.