Got Questions? Get Answers.
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:
BER for BPSK

Subject: BER for BPSK

From: Saed Dawoud

Date: 13 Jan, 2010 14:20:24

Message: 1 of 8

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

Subject: BER for BPSK

From: Ethem Sozer

Date: 13 Jan, 2010 15:13:05

Message: 2 of 8

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

Subject: BER for BPSK

From: Saed Dawoud

Date: 13 Jan, 2010 21:17:25

Message: 3 of 8

"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

Subject: BER for BPSK

From: Saed Dawoud

Date: 15 Jan, 2010 10:39:03

Message: 4 of 8

Any help will be highly appreciated. I just want to understand the concept to build upon for more complicated codes.

Subject: BER for BPSK

From: Idin Motedayen-Aval

Date: 15 Jan, 2010 15:48:03

Message: 5 of 8

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 flat-fading channel you can do what Ethem
said and use the PathGains from the channel object to de-rotate your
signal. Or you can use an equalizer for the general case (flat or
frequency-selective fading).

HTH,
Idin

--
Idin Motedayen-Aval
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

Subject: BER for BPSK

From: Saed Dawoud

Date: 15 Jan, 2010 17:36:21

Message: 6 of 8

Idin Motedayen-Aval <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 flat-fading channel you can do what Ethem
> said and use the PathGains from the channel object to de-rotate your
> signal. Or you can use an equalizer for the general case (flat or
> frequency-selective fading).
>
> HTH,
> Idin
>
> --
> Idin Motedayen-Aval
> 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 Motedayen-Aval 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

Subject: BER for BPSK

From: Idin Motedayen-Aval

Date: 18 Jan, 2010 16:22:31

Message: 7 of 8

Saed Dawoud wrote:
> Idin Motedayen-Aval <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 flat-fading channel you can do what Ethem
>> said and use the PathGains from the channel object to de-rotate your
>> signal. Or you can use an equalizer for the general case (flat or
>> frequency-selective fading).
>>
>> HTH,
>> Idin
>>
>> --
>> Idin Motedayen-Aval
>> 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 Motedayen-Aval 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 de-rotating the received signal to take out the
effect of phase rotation caused by the channel (this only works for a
flat-fading or single-path channel).

HTH,
Idin

--
Idin Motedayen-Aval
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

Subject: BER for BPSK

From: mahmud_dbm

Date: 5 Mar, 2010 08:54:22

Message: 8 of 8

Dear Sir..

I asked this questions to you in others posts also, I'm repeating my question here,

 I'm using reyleighchan, say for 1000 bits of 100 parallel streams. now i set my channel with chan=rayleighchan and some required parameters, then coeff=chan.PathGain; wud give me the channel status and at the receiver i simply divide received streams by "coeff" ; and i'm getting exact performance.

Now my question is:
"What kind of Equalization is this.?" , i think it is somewhat more than adaptive equalization, because i'm getting 100 different Coeffs for 100 different streams and i'm simply dividing by the status very easily, now in practice "which kind of Equalization" wud give me this Performance..????

Practically how would i get this status directly like this. ? or is it possible at all.?
Note: My System doesn't have pilot or anything to get CSI from the channel. what "kind of equalization" does something smartly exactly like this...??

Thank You

Mahmud

Tags for 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