0
$\begingroup$

I am trying to demodulate a PPM signal in MATLAB. My signal is constructed using 2 base functions :

% Base function for bit 1 (centered around Tb/4 and has a width Tb/2) : g1 = @(t) Ag * rectpuls(t - (1/4)*Tb, Tb/2); % Base function for bit 0 (centered around 3/4*Tb, width Tb/2) : g0 = @(t) Ag * rectpuls(t - (3/4)*Tb, Tb/2); 

Which looks like this :

Base functions for PPM modulation

My signal is composed of many of these pulses according to a data vector. Everything is passed through a AWGN channel and then comes the demodulation part. Matched filters should be time reversed complex conjugate of my basis fonctions, which I created in my code like this :

% Matched filter for g0 h0 = @(t) conj(flip(g0(t))); % Matched filter for g1 h1 = @(t) conj(flip(g1(t))); 

I then convolve my signal with theses matched filters and compare the output to retrieve my original data vector.

% Matched filter outputs output_h0 = conv(r, h0(t), 'same'); output_h1 = conv(r, h1(t), 'same'); % Demodulate based on the maximum matched filter output rb = zeros(1, N); for k = 1:N % Decide which bit was transmitted based on the maximum output if output_h1(k * Fs) > output_h0(k * Fs) rb(k) = 1; else rb(k) = 0; end end 

My retrieved data looked wrong so I plotted the matched filters output and saw that it is completely wrong. What did I get wrong with matched filtering ?

Matched filters output

Thanks for your help !

$\endgroup$

1 Answer 1

3
$\begingroup$

Your approach looks correct to me. but your results seem wrong: for example, the output of the second matched filter (g1) starts at 3000; also, the output of both filters goes to zero when the input is still present. I suspect there's a few bugs in your code.

I reproduced your setup in Julia, transmitting the sequence g1 g1 g0 g0 g1, and this is the output of each of the matched filters:

enter image description here

Note that it is not enough to sample the peaks! You need to sample once per second and choose the largest output. Sampling at times t = 1, 2, 3, 4, 5, we obtain the following sequence out of each filter:

g0: 0, 0, 1, 1, 0 g1: 1, 1, 0, 0, 1 

which is exactly what one would expect.

For completeness, here's the matched filter output for the input signal described in the question (g1 g0 g1 g0 g0 g0 g0 g1 g0 g1):

enter image description here

Here is my code:

using DSP Tp = 1.0 # pulse interval # Define pulse functions g0(t) = Tp/2 <= t < Tp ? 1.0 : 0.0 g1(t) = 0 <= t < Tp/2 ? 1.0 : 0.0 # received signal r(t) = g1(t) + g1(t - Tp) + g0(t - 2Tp) + g0(t - 3Tp) + g1(t - 4Tp) rx = r.(range(-0.5, 6, step = 1/20)) g0p = g0.(range(0, length=20, step = 1/20)) g1p = g1.(range(0, length=20, step = 1/20)) # matched filtering mf0 = conv(rx, reverse(g0p)) mf1 = conv(rx, reverse(g1p)) 
$\endgroup$
16
  • 1
    $\begingroup$ @PeterK. :-) The good news is, Julia is likely to be the last language you'll need to learn! (Yes, I'm a big fan) $\endgroup$ Commented Jan 14, 2024 at 20:17
  • 1
    $\begingroup$ @DanBoschen No, I used a shorter sequence for simplicity. The OP sequence is g1 g0 g1 g0 g0 g0 g0 g1 g0 g1, which I've tested with my code and works fine. $\endgroup$ Commented Jan 14, 2024 at 23:54
  • 1
    $\begingroup$ @DanBoschen I think the OP's received sequence is g1 g1 g0 g1 g0, and then the output stops. $\endgroup$ Commented Jan 15, 2024 at 0:05
  • 1
    $\begingroup$ @MBaz ok I suspect my g1 and g0 correlation outputs are time reversed as if I reverse those it appears to match what you did and confirmed via simulation (which I didn't do). I think this is the correct answer....indeed g0 is zero first so can't start ramping at t=0 as I show. I ama going to delete my answer to not confuse. $\endgroup$ Commented Jan 15, 2024 at 2:19
  • 1
    $\begingroup$ @MBaz my code is now working I think it was a bug in the convulotion function or I might not understand how it works but by using the 'full' argument and cuting the zeros myself I got the original data back. Thank you for your help ! $\endgroup$ Commented Jan 15, 2024 at 20:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.