0

I am doing phase shift keying of binary data.

This is what I am doing,

 f=10;
 m=[];
 b = [1 0 0 1 1 1 0]
    for i=1:1:length(b)
        if (b(i)==1)
            Modulated=10*cos(2*pi*f*t2);
        else
            Modulated=10*cos(2*pi*f*t2 + pi);
        end
        m=[m Modulated];
    end

The phase is not changing when there is a difference from last bit to present bit or present bit to future bit.

How can I change the phase when there is a difference in the bit value?

Edit: The pic with complete system. I am using equiripple filter. enter image description here

cppiscute
  • 707
  • 2
  • 10
  • 33

1 Answers1

0

Your code works fine. Maybe frequency is too high and a plot is too dense so that you can't notice it. Try with lower frequency.

Here is a code for (simplified) full modulation and demodulation:

%% modulation
f=0.5;
t2 = 0:0.01:1;
m=[];
b = [1 0 0 1 1 1 0];
for i=1:1:length(b)
    if (b(i)==1)
        Modulated=10*cos(2*pi*f*t2);
    else
        Modulated=10*cos(2*pi*f*t2 + pi);
    end
    m=[m Modulated];
end
subplot(3, 1, 1)
plot(m)
title('Modulated')

%% downconversion
oscillator = cos(2*pi*f*t2);
demod = m .* repmat(oscillator, 1, length(b));
subplot(3, 1, 2)
plot(demod)
title('Downconverted')

%% demodulation
d = [];
for i = 1:1:length(b)
    idx_start = (i - 1) * length(t2) + 1;
    idx_end = i * length(t2);
    Demodulated = mean(demod(idx_start:idx_end));
    d = [d Demodulated];
end
subplot(3, 1, 3)
plot(d, 'x')
title('Demodulated (LPF)')

enter image description here

And please be noted that, even though signal 1 and signal 0 are continuous, it does not mean that they have the same phase.

Jeon
  • 4,000
  • 4
  • 28
  • 73
  • I understood the point you are making. My whole question is based on me trying to write the detection/demodulation algorithm for this modulated waveform. I just want to know, how can we detect the transmitted bits if the received signal phase is same but they represent different bits? – cppiscute Sep 25 '16 at 14:46
  • I can't get your point. I showed that different bits are mapped to different phase. But why do you keep telling that different bits with same phases? – Jeon Sep 25 '16 at 14:48
  • If you want to build a demodulator, multiply a carrier signal `cos(2*pi*f*t2)` to a received signal and pass it to a low pass filter (e.g., moving average is the simpliest one) – Jeon Sep 25 '16 at 14:49
  • I found out that my problem is because of the channel. The channel is acting like inverter/something like that. So the demodulator output is completely wrong. [PS: I am using the same method as yours, i,e Gram-schmidt orthogonalization] – cppiscute Sep 25 '16 at 15:04
  • Well, channel is another issue. You need to estimate a channel matrix by sending a *known to both tx/rx* signal. – Jeon Sep 25 '16 at 15:06
  • Or, for quick experiment, you can just hard code that inverting channel. – Jeon Sep 25 '16 at 15:07