Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Wireless Channel with BPSK and Rayleigh fading

Subject: Wireless Channel with BPSK and Rayleigh fading

From: C?sar Ghali

Date: 28 Dec, 2008 14:58:01

Message: 1 of 3

Dear friends,

I am trying to simulate a Wireless Channel with Rayleigh fading and AWGN noise, and here is the problem:

I am using the following code which I found in MATLAB help:


modType = 'dpsk'; % 'dpsk' or 'bpsk'
chanType = 'fading'; % 'fading' or 'nofading'
 
chan = rayleighchan(1/10000,100);
 
M = 2;
if strcmp(modType, 'dpsk')
    hMod = modem.dpskmod('M', M);
    hDemod = modem.dpskdemod(hMod);
elseif strcmp(modType, 'bpsk')
    hMod = modem.pskmod('M', M);
    hDemod = modem.pskdemod(hMod);
end
 
 
tx = randint(50000,1,M);
dpskSig = modulate(hMod, tx);
 
% AWGN Only
if strcmp(chanType, 'nofading')
    fadedSig = dpskSig;
elseif strcmp(chanType, 'fading')
    fadedSig = filter(chan,dpskSig);
end
 
SNR = 0:1:20;
for n = 1:length(SNR)
   rxSig = awgn(fadedSig,SNR(n));
   rx = demodulate(hDemod, rxSig);
   %reset(hDemod);
 
   [nErrors, BER(n)] = biterr(tx,rx);
end
 
if strcmp(modType, 'dpsk')
    BERtheory = berfading(SNR,'dpsk',M,1);
elseif strcmp(modType, 'bpsk')
    BERtheory = berfading(SNR,'psk',M,1);
end
 
% Plot BER results.
semilogy(SNR,BERtheory,'b-',SNR,BER,'r*');
legend('Theoretical BER','Empirical BER','Location','Southwest');
xlabel('SNR (dB)'); ylabel('BER');
title('Binary DPSK over Rayleigh Fading Channel');


The following combinations of the modulation scheme and channel type works:
dpsk fading, dpsk nofading, bpsk nofading

By using the previous three combinations; the empirical curve matches the theoretical curve but by using bpsk modulation scheme with a fading channel results in a strange results.

If I try the following chunk of code:


modType = 'psk'; % 'dpsk' or 'bpsk'
chanType = 'fading'; % 'fading' or 'nofading'
 
chan = rayleighchan(1/10000,100);
 
M = 2;
if strcmp(modType, 'dpsk')
    hMod = modem.dpskmod('M', M);
    hDemod = modem.dpskdemod(hMod);
elseif strcmp(modType, 'bpsk')
    hMod = modem.pskmod('M', M);
    hDemod = modem.pskdemod(hMod);
end
 
message = randint(1,5,M)
signal = modulate(hMod, message)
rx = filter(chan, signal)
decode = demodulate(hDemod, rx)


I noticed that the decode vector have the exactly opposite value of the vector message (0s become ones and vice versa), this will of course lead to a approximately bit error rate equal to 0.5. In addition, I noticed also that the rx vector (after the effect of the channel) have the opposite sign of the vector signal.

My objective is to use bpsk with a fading channel.

Can anyone help me.

Thanks in advance for your help.


Cesar Ghali

Subject: Wireless Channel with BPSK and Rayleigh fading

From: Idin Motedayen-Aval

Date: 5 Jan, 2009 05:46:53

Message: 2 of 3

C?sar Ghali wrote:
> Dear friends,
>
> I am trying to simulate a Wireless Channel with Rayleigh fading and AWGN noise, and here is the problem:
>
> I am using the following code which I found in MATLAB help:
>
>
> modType = 'dpsk'; % 'dpsk' or 'bpsk'
> chanType = 'fading'; % 'fading' or 'nofading'
>
> chan = rayleighchan(1/10000,100);
>
> M = 2;
> if strcmp(modType, 'dpsk')
> hMod = modem.dpskmod('M', M);
> hDemod = modem.dpskdemod(hMod);
> elseif strcmp(modType, 'bpsk')
> hMod = modem.pskmod('M', M);
> hDemod = modem.pskdemod(hMod);
> end
>
>
> tx = randint(50000,1,M);
> dpskSig = modulate(hMod, tx);
>
> % AWGN Only
> if strcmp(chanType, 'nofading')
> fadedSig = dpskSig;
> elseif strcmp(chanType, 'fading')
> fadedSig = filter(chan,dpskSig);
> end
>
> SNR = 0:1:20;
> for n = 1:length(SNR)
> rxSig = awgn(fadedSig,SNR(n));
> rx = demodulate(hDemod, rxSig);
> %reset(hDemod);
>
> [nErrors, BER(n)] = biterr(tx,rx);
> end
>
> if strcmp(modType, 'dpsk')
> BERtheory = berfading(SNR,'dpsk',M,1);
> elseif strcmp(modType, 'bpsk')
> BERtheory = berfading(SNR,'psk',M,1);
> end
>
> % Plot BER results.
> semilogy(SNR,BERtheory,'b-',SNR,BER,'r*');
> legend('Theoretical BER','Empirical BER','Location','Southwest');
> xlabel('SNR (dB)'); ylabel('BER');
> title('Binary DPSK over Rayleigh Fading Channel');
>
>
> The following combinations of the modulation scheme and channel type works:
> dpsk fading, dpsk nofading, bpsk nofading
>
> By using the previous three combinations; the empirical curve matches the theoretical curve but by using bpsk modulation scheme with a fading channel results in a strange results.
>
> If I try the following chunk of code:
>
>
> modType = 'psk'; % 'dpsk' or 'bpsk'
> chanType = 'fading'; % 'fading' or 'nofading'
>
> chan = rayleighchan(1/10000,100);
>
> M = 2;
> if strcmp(modType, 'dpsk')
> hMod = modem.dpskmod('M', M);
> hDemod = modem.dpskdemod(hMod);
> elseif strcmp(modType, 'bpsk')
> hMod = modem.pskmod('M', M);
> hDemod = modem.pskdemod(hMod);
> end
>
> message = randint(1,5,M)
> signal = modulate(hMod, message)
> rx = filter(chan, signal)
> decode = demodulate(hDemod, rx)
>
>
> I noticed that the decode vector have the exactly opposite value of the vector message (0s become ones and vice versa), this will of course lead to a approximately bit error rate equal to 0.5. In addition, I noticed also that the rx vector (after the effect of the channel) have the opposite sign of the vector signal.
>
> My objective is to use bpsk with a fading channel.
>
> Can anyone help me.
>
> Thanks in advance for your help.
>
>
> Cesar Ghali

Cesar,
The above code looks like the example in the doc on using fading
channels, but that code uses differential encoding. The same code will
*not* work for non-differential encoded PSK. In the differential
encoded system, the information is transmitted in the phase *difference*
between consecutive channel symbols. In non-diff PSK, the information
is carried in the absolute phase of each symbol.

Thus, in the first case (DBPSK) one can demodulate the signal without an
equalizer (or any estimate of the channel phase). In the latter case
(BPSK), you must somehow undo the effect of the fading channel phase,
otherwise you can't demodulate (i.e. you need to use an equalizer, or
estimate the channel phase somehow).

For BPSK, you must also use pilot symbols. Otherwise you will not be
able to resolve the 180-degree ambiguity at the receiver (i.e. with no
noise, you will either detect your signal with zero errors or 100% errors).

You need to look at examples that do not use differential encoding, and
see how they account for the phase of the channel.

HTH,
Idin

Subject: Wireless Channel with BPSK and Rayleigh fading

From: C?sar Ghali

Date: 9 Jan, 2009 15:34:02

Message: 3 of 3

Dear Idin Motedayen-Aval,

Thanks for your help. Actually what you said was 100% right and it was the thing that I missed.

Thanks again.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us