# assignment

4063/7080 Communications
Assignment #2
The assignment is to determine the probability of error for a binary FSK system using Monte Carlo
simulation. The binary FSK signal will be generated in complex baseband form (ie. as a phasor), noise
added and then filtered by a matched filter. The filter output will be sampled and a decision made as to
whether the digital data is +1 or
1. By comparing the decision with the original data we can count errors.
If the probability is estimated from a count nerrs, the 90% confidence limits for the estimated probability of
error are approximately exp[
± 1.645/(nerrs)] times the estimated probability. To get a reasonably accurate
estimate we therefore need nerrs
10, which for a probability of error of 104 means a data length of 105
symbols is required. For nerrs = 10 the exact 90% confidence limits are 1.68 and 0.59 times the estimate.
To avoid large data arrays in MATLAB, the data is to be processed in segments and once processed the data
will be discarded. This will enable the program to run on versions of MATLAB which restrict array sizes.
While the simulation can be run in one go using large array sizes, for this assignment you are required to use
the data segmentation technique.
If you wish to make use of Python this is a possible alternative.
The FSK signal will be sampled with m = 8 samples per symbol and each segment will contain n = 32
symbols, giving a data segment of N = m
x n = 256 samples.
The amount of noise added will be determined by a factor
γ = 2Eb/No, and we will compare our simulation
result with the theoretical result.
1. Specified Parameters

 Symbol (bit) rate Symbol period Modulation index Sampling frequency Sampling interval fb T h fs ts 1000 bits/sec 1 ms (f1–f2)T = 1 8000 Hz 125 µs 32 Symbols per segment n Samples per symbol m 8 Samples per segment N 256 20 and 2000 0 to 14 dB in steps of 1 dB. gaussian Number of segments R “Signal to noise ratio” γ Noise distribution

2. FSK Signal
The FSK signal with modulation index h = 1 can be represented as:
[ ] c +ω= φ )t(tcosA)t(s
where d
φ/dt = ±hπ/T and φ(t) is continuous to avoid discontinuities in the signal (which cause spectral
spreading). With a modulation index h = 1, the phase increment is
±π for each symbol. Hence the phasor
representation is:
1
~ = eA)t(s φ )t(j
In the interval kT t (k+1)T, the phasor is:
~
k { } λ= + λ )tsin()k(aj)tcos(A)t(s
where
λ = π/T and a(k) = ±1 is the digital data. This corresponds to a carrier frequency shift of ±1/2T Hz.
The in-phase and quadrature noise components nc(t) and ns(t) are generated as in Assignment #1. The RF
noise is assumed white of power spectral density N
o/2 V2/Hz and hence the phasor components have power
spectral density N
o V2/Hz. In sampled form, the samples should have variance σ2 such that σ2 = Nofs, where
f
s
is the sampling frequency. Use the randn function and set the initial seed (once only) to ensure repeatable
results.
The received phasor signal is then:
~ )t(v ~
+= + sc )t(nj)t(n)t(s
4. Data Generation
We will generate independent data samples using the random number generator in MATLAB. To generate n
samples of a(k) first use
a1 = rand(1,n) to generate n uniformly distributed random variables in the range 0
to 1, then obtain the desired binary data from
a2 = 2 x (a1>=0.5) 1. Set the initial seed (once only) to
ensure repeatable results.
The signal segment can be generated by generating a sequence of n values of a2 and replicating it a total
of m times for each symbol, giving N = m
x n samples. This sequence can then used to generate the FSK
5. Demodulation
At the receiver, a clock recovery circuit (not implemented in this exercise) is used to determine where a
symbol begins and ends and is used to generate local signals
±cos(λt) and ±sin(λt) (ie. there is a sign
ambiguity, both + or both
). These are used to demodulate the FSK signal by multiplying the received
signal phasor by
±cos(λt) and ±sin(λt) and integrating over one symbol period.
∫ ∫

 ∫ λ ±= λ 2 s c dt)tcos()t(n )k(n, n dt)tcos()t( ±= 1 )k(n + T)1k( T)1k( kT kT

∫ ∫
+ +
+ + +
±= λ ±= λ

 ±= s )k(v λ ±= ++ 3 4 kT )k(jn)k(n)k(aAT 1 ~ dt)tsin()t(v j

 ±= c (v )k λ ++±= 1 2 kT )k(jn)k(nAT ~ dt)tcos()t(v

T)1k(
kT
4 s
T)1k(
kT
3 c
T)1k(
T)1k(
)k(n dt)tsin()t(n )k(n, n dt)tsin()t(
2
12
2
Note that vc and vs are complex. The correct sign can be determined from Re{vc), so demodulation is
achieved by comparing the signs of Re{v
c} and Im{vs}. In practice, the other two demodulation parameters
Im(v
c} and Re{vs} are used for carrier and clock recovery (which we are not doing here).
With a discrete time simulation the integrations are approximated by summations over m samples.
6. Counting Errors
By comparing the original data signal with the demodulated signal, an error count for each segment can be
made. This is added to a running count of errors and all other quantities can be discarded and overwritten by
values which apply to the next segment.
7. Theoretical Probability of Error
Using the integral forms for vc and vs above, prove that the probability of Im{vs} being the wrong sign is p =
Q{
(γ/2)} and similarly for Re{vc}, and hence the probability of error for the demodulation method used is
P
e = 2pq where q = (1p).
Your submission should contain a detailed description of your procedures, theoretical analysis, the
graphical plots required and your MATLAB code with plenty of comments. The assignment is expected to
be your own work, copies of another person’s work will not be favourably received.
1. Plot the real and imaginary parts of the signal phasor (without noise) for one segment.
2. Do steps 3 and 4 for number of segments R = 20 and R = 2000.
3. For each value of
γ, determine the error probability as determined by the simulation and also calculate the
theoretical value.
4. Plot the measured and theoretical probabilities of error against
γ in dB on the one graph. Plot the
theoretical values as a line and the measured values as an “*”. Probabilities should be plotted on a
logarithmic scale in the range 10
5 to 100.
Comment briefly on the significance of your results.
3