Comm Matlab(1 6)

13
1 DIGITAL COMMUNICATION LAB Submitted By ANKIT GOEL 14/EC/09

description

code for communication lab experiments

Transcript of Comm Matlab(1 6)

Page 1: Comm Matlab(1 6)

1

DIGITAL COMMUNICATION LAB

Submitted By

ANKIT GOEL

14/EC/09

Page 2: Comm Matlab(1 6)

2

EXPERIMENT 1

Aim: - To evaluate the performance and compute the SNR of Uniform and µ-law companding

quantizer

[I] Uniform Quantizer MATLAB Code: -

clear all; clc; N=2000; a=rand(1,N)-0.5; b=a; for L=3:80 Linv=1/L; for n=1:N c(n)=0; d(n)=0; for j=0:L-1 if ( ( a(n)>(j*Linv-0.5) ) & ( a(n)<((j+1)*Linv-0.5) ) ) b(n)= ((j*Linv-0.5)+((j+1)*Linv-0.5))/2; end; end; end; for n=1:N c(n)=(b(n)-a(n))*(b(n)-a(n)); d(n)=a(n)*a(n); end; v(L-2)=mean(c); e(L-2)=mean(d); snr(L-2)=e(L-2)/v(L-2); end; plot(3:L,snr,'k') xlabel('Quantisation Levels---->'); ylabel('SNR---->'); title('Uniform Quantizer');

Page 3: Comm Matlab(1 6)

3

Output: -

0 10 20 30 40 50 60 70 800

1000

2000

3000

4000

5000

6000

7000

Quantisation Levels---->

SN

R--

-->

Uniform Quantizer

Page 4: Comm Matlab(1 6)

4

EXPERIMENT 2 Aim: Evaluate the performance of non uniform quantizer µ-Law Companding Quantizer MATLAB Code: -

clear all; clc; A = 10000; %Number of values Max =256; %Maximum value with minimum = 0 DATA = Max*rand(1,A); Power=0; for i=1:length(DATA) Power = Power + DATA(i).^2; end Power; u=1; for i=1:length(DATA) b(i)=Max*((log10((DATA(i)/Max)*u+1)) / (log10(1+u))); end T = 100;%Number of maximum levels N = zeros(1,T); for z = 2:T L = z;%Number of levels d = zeros(1,length(b)); Diff = zeros(1,length(b)); M = (max(b))/L; %Interval for i=1:length(b), j=1; while b(i) > (j*M) d(i) = d(i) + M; j = j+1; end end Diff = DATA-d; Noise = 0; for i=1:length(Diff) Noise = Noise + Diff(i).^2; end N(z)=Noise; SNR(z) = Power/N(z); end plot(SNR,'k') xlabel('Number of levels---->'); ylabel('SNR'); title('u Law quantizating');

Page 5: Comm Matlab(1 6)

5

Output: -

0 10 20 30 40 50 60 70 80 90 1000

50

100

150

200

250

Number of levels---->

SN

R

u Law quantizating

Page 6: Comm Matlab(1 6)

6

EXPERIMENT 3

Aim: - To sample a signal of given amplitude and frequency using Flat top and natural sampling and reconstruct it back at the receiver

Apparatus: Emona Telecoms Kit 101, BNC Connectors, Digital Storage Oscillicope, Patch leads

Theory: The sampling process is described in time domain. As such it is an operation that is basic to digital signal processing and digital communications. Through use if the sampling process, an analog signal is converted into a corresponding sequence of samples that are usually spaced uniformly in time. Clearly, for such a procedure to have practical utility, it is necessary that we choose the sampling rate properly, so that the sequence of samples uniquely defines the original analog signal. For an analog signal g(t),

Naturally Sampled version

In Pulse Amplitude Modulation, the amplitudes of regularly spaced pulses are varied in proportion to the corresponding sample of values of a continuous message signal; the pulses can be of a rectangular form or some other appropriate shape. PAM is similar to natural sampling where the signal is multiplied by a periodic train of rectangular pulses.

Flat Top Sampling

1. Instantaneous sampling of the message signal m(t) every Ts seconds, where the

sampling rate fs = 1/Ts is chosen in accordance with the sampling theorem. 2. Lengthening the duration of each sample of each sample so obtained o some constant

value T

Process of Flat Top Sampling

Page 7: Comm Matlab(1 6)

7

Observations:

Natural sampling of Sine Wave Flat top sampling of Sine Wave

Natural Sampling at higher sampling frequency Reconstruction of message signal

Input Signal and the Reconstructed Signal

Page 8: Comm Matlab(1 6)

8

EXPERIMENT 4

Aim: - Convert a sine wave to a PCM data stream using PCM encoder and reconstruct the message at the receiver using PCM decoder

Apparatus: Emona Telecoms Kit 101, BNC Connectors, Digital Storage Oscillicope, Patch leads

Theory: In Pulse Code Modulation, a message signal is represented by a sequence of coded pulses, which is accomplished by representing in discrete form in both time and amplitude. The basic operations performed in the transmitter of a PCM system are sampling, quantizing and encoding, the low pass filter before sampling the signal is used for preventing aliasing of the message signal. The quantizing and encoding operations are usually performed in the same circuit, which is called an analog-to-digital converter. The basic operations in the receiver are regeneration of impaired signals, decoding and reconstruction of the train of quantized samples. When TDM is used, it becomes necessary to synchronize the receiver to the transmitter for the overall system to operate satisfactorily.

Pulse Code Encoding

Pulse Code Decoding

In combining the processes of sampling and quantization, the specification of a continuous message baseband signal becomes limited to a discrete set of values, but not in the form best suited to transmission over a telephone line or radio path. To exploit the advantages of sampling and quantizing for the purpose of making the transmitted signal more robust to noise, interference and other channel impairments, we require use of encoding process to translate the discrete set of values to a more appropriate form of digital signal. Maximum advantage over the effects of noise in a medium is obtained by using a binary code because a binary symbol withstands high level of noise and is easy to regenerate.

Page 9: Comm Matlab(1 6)

9

Observations:

Sampling frequency for PCM Encoder

PCM Encoded Sine Wave

PCM Decoded Sine wave at the receiver and the input sine wave

Page 10: Comm Matlab(1 6)

10

EXPERIMENT 5

Aim: - To observe the effect of limited bandwidth on the transmission of digital data

Apparatus: Emona Telecoms Kit 101, BNC Connectors, Digital Storage Oscillicope, Patch leads

Theory: In classical model, intelligence moves from transmitter to a receiver over a channel. A number of transmission media can be used for the channel including metal conductors. Regardless of the medium used, all channels have a bandwidth. That is, the medium lets a range of signal frequencies pass relatively unaffected while frequencies outside the range are mode smaller. The issue has important implications. If the medium’s bandwidth isn’t wide enough some of the sine waves are attenuated and others are lost completely.

Square Wave through a channel through a band limited channel

Bandwidth limiting in a channel can distort digital signals and upset the operation of the receiver. A solution to the problem of limited bandwidth of the channel is to use a transmission medium that has a sufficiently wide bandwidth for the digital data. As digital technology spreads there are demands to push more data down existing channels. To do so without slowing things down requires that the transmission bit rate be increased. This ends up having the same basic effect as reducing the channel’s bandwidth. Eye diagrams give us idea about the signal’s quality and the channel’s bandwidth. As bandwidth limiting degrades the signal’s quality the eyes begin to close.

Eye Diagram

Page 11: Comm Matlab(1 6)

11

Observations:

PCM Data with full bandwidth PCM Data with restricted bandwidth using a LPF

Eye Diagram

Restored Digital Signal using Comparator

Page 12: Comm Matlab(1 6)

12

EXPERIMENT 6

Aim: - To generate binary ASK signal and evaluate its performance in the presence of Additive White Gaussian Noise Apparatus: Emona Telecoms Kit 101, BNC Connectors, Digital Storage Oscillicope, Patch leads

Theory:

Amplitude-shift keying is a form of modulation that represents digital data as variations in the amplitude of a carrier wave. The amplitude of an analog carrier signal varies in accordance with the bit stream (modulating signal), keeping frequency and phase constant. The level of amplitude can be used to represent binary logic 0s and 1s.

The simplest and most common form of ASK operates as a switch, using the presence of a carrier wave to indicate a binary one and its absence to indicate a binary zero. This type of modulation is called on-off keying, and is used at radio frequencies to transmit Morse code (referred to as continuous wave operation).

More sophisticated encoding schemes have been developed which represent data in groups using additional amplitude levels. For instance, a four-level encoding scheme can represent two bits with each shift in amplitude; an eight-level scheme can represent three bits; and so on. These forms of amplitude-shift keying require a high signal-to-noise ratio for their recovery, as by their nature much of the signal is transmitted at reduced power.

Page 13: Comm Matlab(1 6)

13

Observations:

Digital Signal and its ASK Signal

Input Signal and its Regenerated signal after ASK