This model, doc_gray_code, shows a communications link using Gray-coded 8-PSK modulation. Gray coding is a technique often used in multilevel modulation schemes to minimize the bit error rate by ordering modulation symbols so that the binary representations of adjacent symbols differ by only one bit.
The example model includes these blocks:
The Random Integer Generator block serves as the source, producing a sequence of integers.
The Integer to Bit Converter block converts each integer into a corresponding binary representation.
The AWGN Channel block adds white Gaussian noise to the modulated data.
The M-PSK Demodulator Baseband block demodulates the corrupted data.
The Bit to Integer Converter block converts each binary representation to a corresponding integer.
One copy of the Error Rate
Calculation block (labeled
Rate Calculation1 in this model)
compares the demodulated integer data with the
original source data, yielding symbol error
statistics. The output of the Error Rate
Calculation block is a three-element
vector containing the calculated error rate, the
number of errors observed, and the amount of data
Another copy of the Error Rate
Calculation library block (labeled
Error Rate Calculation2 in this
model) compares the demodulated binary data with the
binary representations of the source data, yielding
bit error statistics.
In this model, the M-PSK Modulator Baseband block:
Accepts binary-valued inputs that represent integers between 0 and M − 1, where M is the alphabet size
Maps binary representations to constellation points using a Gray-coded ordering
Produces unit-magnitude complex phasor outputs, with evenly spaced phases between 0 and 2π(M − 1)/M
The table indicates which binary representations in the input correspond to which phasors in the output. The second column of the table is an intermediate representation that the block uses in its computations.
|Modulator Input||Gray-Coded Ordering||Modulator Output|
The table below sorts the first two columns of the table above, according to the output values. This sorting makes it clearer that the overall effect of this subsystem is a Gray code mapping, as shown in the figure below. Notice that the numbers in the second column of the table below appear in counterclockwise order in the figure.
|Modulator Output||Modulator Input|
You can analyze the data that the example produces to compare theoretical performance with simulation performance.
The theoretical symbol error probability of MPSK is
erfc is the complementary error function,
is the ratio of energy in a symbol to noise power spectral density,
and M is the number of symbols.
To determine the bit error probability, the symbol error probability, PE, needs to be converted to its bit error equivalent. There is no general formula for the symbol to bit error conversion. Upper and lower limits are nevertheless easy to establish. The actual bit error probability, Pb, can be shown to be bounded by
The lower limit corresponds to the case where the symbols have undergone Gray coding. The upper limit corresponds to the case of pure binary coding.
To test the Gray code modulation scheme in this model, simulate the
graycode model for a range of
values. If you want to study bit error rates but not symbol error
rates, then you can use the
graphical user interface as described in BERTool.
The rest of this section studies both the bit and symbol error rates
and hence does not use
Because increasing the value of Eb/N0 lowers the number of errors produced, the length of each simulation must be increased to ensure that the statistics of the errors remain stable.
sim (Simulink) command to
run a Simulink® simulation
from the MATLAB® command
window, the following code generates data for symbol error rate and
bit error rate curves. It considers
values in the range 0 dB to 12 dB, in steps of 2 dB.
M = 8; Tsym = 0.2; BERVec = ; SERVec = ; EbNoVec = [0:2:12]; for n = 1:length(EbNoVec); EbNo = EbNoVec(n); sim('doc_gray_code') ; SERVec(n,:) = graySER; BERVec(n,:) = grayBER; end;
After simulating for the full set of Eb/N0 values, you can plot the results using these commands:
semilogy( EbNoVec,SERVec(:,1), 'o', EbNoVec, BERVec(:,1), '*' ); legend ( 'Symbol error rate', 'Bit error rate' ); xlabel ( 'Eb/No (dB)' ); ylabel( 'Error Probability' ); title ( 'Symbol and Bit Error Probability' );
As a further exercise, using data obtained from
berawgn, you can
plot the theoretical curves on the same axes with the simulation
results. You can also compare Gray coding with pure binary coding,
by modifying the M-PSK Modulator Baseband and
M-PSK Demodulator Baseband blocks so that
their Constellation ordering parameters are
Binary instead of