Saed Dawoud wrote:
> Idin MotedayenAval <run.signature@MATLAB.for.email> wrote in message
> <hiq2nl$p6u$1@fred.mathworks.com>...
>> Saed Dawoud wrote:
>> > "Ethem Sozer" <esozer@mathworks.com> wrote in message >
>> <hiknu3$39j$1@fred.mathworks.com>...
>> >> Hi Saed,
>> >>
>> >> You are on the right track: the problem is phase recovery. You
>> need >> to correct the phase for the PSK demodulator to recover the
>> received >> bits.
>> >>
>> >> The Rayleigh channel object of the Communications Toolbox provides
>> the >> "PathGains" property where you can see the channel gain used to
>> >> generate the received signal. You can access this value using the
>> >> syntax: chan.PathGains, and use it to correct the fading effect of
>> the >> channel. By default, this property only shows the last channel
>> gain >> used. To store channel gain values for the whole frame, you
>> need to >> set the StorePathGains to 1 as follows:
>> >>
>> >> chan.StorePathGains = 1;
>> >>
>> >> Note that this will work for only flat fading channels. If you
>> have >> selective fading, then you will need an equalizer.
>> >>
>> >> By the way, to see the full effect of the fading, you need to put
>> the >> channel filter inside the for loop.
>> >>
>> >> Good luck,
>> >> Ethem
>> >>
>> >> "Saed Dawoud" <saed.dawoud@yahoo.com> wrote in message >>
>> news:hikkr8$cra$1@fred.mathworks.com...
>> >> > Hello,
>> >> >
>> >> > I am trying to simulate the Bit Error Rate (BER) for Binary Phase
>> >> Shift > Keying (BPSK) over Rayleigh fading channel, and I come up
>> with >> the > following code, which is a slightly modefied version of
>> the one >> in MATLAB > Communication Toolbox for DPSK:
>> >> >
>> >> > M=2;
>> >> > chan=rayleighchan(1/10000,100);
>> >> > tx=randint(50000,1,M);
>> >> > txSig=pskmod(tx,M);
>> >> > y=filter(chan,txSig);
>> >> >
>> >> > SNR=0:2:20;
>> >> > for n=1:length(SNR)
>> >> > rxSig=awgn(y,SNR(n));
>> >> > rx=pskdemod(rxSig,M);
>> >> > [nErrors,BER(n)]=biterr(tx,rx);
>> >> > end
>> >> >
>> >> > BERtheory = berfading(SNR,'psk',M,1);
>> >> > semilogy(SNR,BER,'k*',SNR,BERtheory,'r');
>> >> >
>> >> > As you noted, something is wrong in this code, since the
>> empirical >> result > is far away from the theoritical one, where it
>> is expected >> for both to be > almost the same. This situation is not
>> arised in the >> case of DPSK, so, I > think the reason is the phase
>> recovery, but I >> don't know how to solve this > problem. Can anyone
>> help me?
>> >> >
>> >> > Thanks in advance
>> > > Thank you for replying, but I still don't know how to use these >
>> properties in the code, can you show me this, please?
>> > > Thanks in advance
>>
>>
>> Saed,
>> The piece you're missing, I think, is the fact that the original code
>> uses DBPSK and you're using BPSK. The difference is more significant
>> than it appears. In the original DBPSK case, the information is
>> stored in the *phase difference* between consecutive symbols rather
>> than in the absolute phase. This basically means that in the DBPSK
>> case we can demodulate the signal even if we don't correct the phase
>> rotation introduced by the channel (provided that the channel phase
>> rotation is relatively constant over a few symbol periods, which is
>> true in this case).
>> For BPSK, the information is carried by the absolute phase of the
>> signal. So you *must* correct the phase of the received signal before
>> you can demodulate. For a flatfading channel you can do what Ethem
>> said and use the PathGains from the channel object to derotate your
>> signal. Or you can use an equalizer for the general case (flat or
>> frequencyselective fading).
>>
>> HTH,
>> Idin
>>
>> 
>> Idin MotedayenAval
>> The MathWorks, Inc.
>> zq=[4 2 5 15 1 3 24 57 45 12 19 12 15 8 3 7 8 69 53 12 2];
>> char(filter(1,[1,1],[105 zq])), clear zq
>
> Thanks Idin MotedayenAval for replying. Regarding the channel object
> proprties, I don't know where and how to use it in the code. I will try
> to read a little about equalization.
>
> Best regards
Hi Saed,
Perhaps we could make the example in the documentation more elaborate...
But in your case, after you have made the change that Ethem mentioned
(saving path gains), use these lines of code (I'll let you figure out
where):
rxSig = awgn(fadedSig,SNR(n)); % Add Gaussian noise
eqSig = rxSig .* conj(chan.PathGains);
rx = demodulate(hDemod, eqSig); % Demodulate
The second line is derotating the received signal to take out the
effect of phase rotation caused by the channel (this only works for a
flatfading or singlepath channel).
HTH,
Idin

Idin MotedayenAval
The MathWorks, Inc.
zq=[4 2 5 15 1 3 24 57 45 12 19 12 15 8 3 7 8 69 53 12 2];
char(filter(1,[1,1],[105 zq])), clear zq
