Digital Communication PDF
Digital Communication PDF
Experiment No: 7
Title: CHANNEL CODING
Date of submission: 24/03/2024
BPSK Reciever
The BPSK receiver uses a detector of correlation type to demodulate the received signal.
Coherent detection requires knowledge of carrier frequency and phase at the end. This
information can be obtained through either the Costas loop or the Phase Lock Loop (PLL).
Here we assumed prior knowledge of the carrier signal.
Methodology
Function to get BPSK from input
def get_bpsk(arr):
samplerate = 441000; fs = 1.0; k=1/len(arr)
t = np.linspace(0., 10., samplerate)
data = np.cos(2. * np.pi * fs * t)
for i in range(len(arr)):
if arr[i]==0:
data[int(k*i*samplerate):int(k*(i+1)*samplerate)]=-data[int(k*i*samplerate
):int(k*(i+1)*samplerate)]
return data
#write("example.wav", samplerate, data.astype(np.int16))
error=error_bits/len(arr)
Finally Function to plot SNR vs error
def plot_err_snr(snr):
bpsk=add_noise(bpsk1,snr)
final=bpsk
final[:]=bpsk[:]*sin[:]
final2=np.zeros(len(final)+9)
final2[5:-4]=final
final1=np.convolve(final2, np.ones(10)/10, mode='valid')
final1=np.sign(final1)
farr=[]
i=0
while (i+0.5)*samplerate/len(arr)<len(final1):
farr.append(int((1+final1[int((i+0.5)*samplerate/len(arr))])/2))
i=i+1
error_bits=0
for i,j in zip(arr,farr):
if i != j:
error_bits += 1
error=error_bits/len(arr)
return error
Plotting
plt.plot(snrs, error_rate)
DIscussion
-In this experiment we were supposed to read an audio file,
encode it using -BPSK and then pass it through a hardware or
software channel to finally decode it.
-Using hardware channel was not possible for our group so we
decided to use a software channel.
-We were able to implement the modulation on hardware and see
the signal but were unable to take it as input to our laptops.
-I designed the channel to add white gaussian noise to the input.
-For reading and writing data I used a sample rate of 441000. I
decided to keep it high to prevent losing any data while reading
the audio file.
-BPSK is a modulation scheme where the phase of the carrier
signal is varied to represent binary data. In BPSK, the carrier
signal undergoes a 180-degree phase shift to represent the two
binary states (0 and 1).
-Demodulation was done by multiplying the signal after BPSK with
the sin wave used for modulation and taking its sign, which
happens using this operation:
int((1+final1[int((i+0.5)*samplerate/len(arr))])/2)
-I also sampled from the middle of each timestep corresponding
to each bit.
-The SNR vs error plot remains almost 0 while SNR is positive,
although it is not completely zero at SNR=0.
-The SNR then rises and saturates at 0.5 which is the error rate
that we would expect when guessing randomly indicating a
complete loss of data.
-This modulation technique is robust and relatively simple, making
it widely used in various communication systems.