Read Microsoft Word - Codigos_de_linea_v1_EN.doc text version



Line codes


Redes de Computadores

Physical medium distortion analysis of baseband digital signal transmissions.

Spectral analysis is a basic concept required to understand the effects that take place when transmitting data through a physical medium, such as different cable types. The purpose of this lab session is that the student understands the process of transmitting baseband signals through guided media, and is capable of interpreting the effect of factors such as channel bandwidth, signal-to-noise ratio and transmission speed on the quality of the signal received at the destination. To do it we will use Matlab, which offers all the support required for this study.


In telecommunications a line code (baseband modulation) is a code picked for using in a communications system as a support for transmission. Line codes are frequently used for digital data transportation. These codes are formed by representing the amplitude of the digital signal with respect to time. The representation of the waveform is made through a certain number of impulses. These impulses represent digital "1"s and "0"s. The most well known line codes are NRZ, AMI and Manchester. The figures showed below offer examples of both polar NRZ and AMI modulation schemes.

Figure 1. Polar NRZ encoding example.

Figure 2. Bipolar AMI encoding example. After encoding the signal, it is transmitted through the physical layer. At times the characteristics of two channels apparently quite different are similar enough so that the same line code can be used. The encoded signal can be used in different ways, according to the field of application: · · · · · · It can be used directly for transmitting down a line, as voltage or current fluctuations. It is modulated enough so as to create a radiofrequency signal to be delivered through the open air. It can be used to turn on or off a light in Free Space Optics (FSO), usually infrared light. It can be converted into magnetic fields on a hard disk. It can be printed to generate bar codes. In can be converted into dots on optical disks (CD).

Strategies to eliminate the DC component Unfortunately, most of the long-distance communication channels can not carry a DC component. The simplest line code (unipolar), which does not limit the DC component, suffers from too many errors on most systems. Therefore, most line codes eliminate the DC component. There are two ways of eliminating the DC component: · To design each transmitted code so that it has the same number of positive and negative impulses, which would make the DC component null. An example of such type of codes is Manchester. · To use an alternating code, which is a code where some or all the symbols are represented by two sets of opposite parity, which are used in a sequence so that the total parity of a large sequence of symbols is minimized. Examples of this type of codes are AMI, 8B10T, 4B3T, etc.

Signal synchronization Line codes should allow the receiver to synchronize in phase with the received signal. If the synchronization is not ideal, then the decoded signal will not dispose of optimum


differences (in amplitude) between the consecutive symbols used by the line code. This increases the probability of error for the data received. In order to achieve a reliable clock recovery at the receiver, usually a maximum number of consecutive zeros or ones is imposed. The clock period is recovered by keeping track of the transitions perceived on the received sequence, until the maximum number of consecutive zeros and ones guarantees clock recovery. Sequences without these restrictions are prone to a poor code quality. It is also advisable that line codes have a synchronization structure so that errors may be detected.


For this lab session we will rely on a Matlab environment. Matlab is an application widely used in the telecommunications area (among others) which allows performing detailed analysis of communication systems, especially in what refers to signal processing. This lab session is divided into 3 parts, where the main changes between these parts are essentially the goals pursued. Hence, in the first part we seek that the student uses a short bit sequence to visually detect the impact of channel noise and bandwidth on the signal received at the destination, as well as the changes perceived in the frequency spectrum of the signal. In the second part the analysis focuses on the spectral analysis, where we propose a comparative study between different line codes. Finally, in the third part, we focus on the process of decoding with the goal of observing the variation in terms of Bit Error Rate (BER) as we change some of the channel's parameters.

Required material To complete this lab session the student must download a series of scripts in Matlab language which are available on the course's web site: ·

The material is on file that can be found together with this lab session guide. Please download this file and extract all .m files on a local folder or on disk W. Main scripts (to modify when told so): encoding.m: contains the main script for the first part spectral_analysis.m: contains the main script for the second part ber_calc.m: contains the main script for the third part

Auxiliary scripts (do no modify during the lab session): modulb.m: function that generates different line codes for any bit sequence of input. ideal_filter.m: function that models an ideal filter of any kind.


decode_seq.m: function that allows decoding of line codes. isodd.m: function that determines if a value is even or odd. The execution and interaction with the program is done in console mode, which means that Matlab must be started and the working directory modified so as to access these downloaded files.

Part I: Effect of the physical channel on the modulated signal A physical channel is characterized by a bandwidth, by the distance between sender and receiver and by the amount of noise. These two latter factors (distance and noise), together with a certain level of signal power at the source, allow us to calculate the Signal-to-Noise Ratio (SNR) at the receiver. Therefore, we can represent our communications system in the following manner: Noise

Binary input sequence (seq)

Line coding


y(t) yn(t) ynd(t)

Received signal (encoded)

By analyzing script encoding.m we can find the instructions that allow us to replicate the sequence of actions represented above. We now process to briefly comment the main commands: Initially we defined basic parameters, such as:

dr = 1000; % data rate, in bits/second fs = 25*dr; % since we are simulating the transmission process in Matlab, we must define a sampling rate that is significantly superior to dr (in this case, 25 times more) snr = 5; % signal-to-noise ratio at the destination (supposing Gaussian white noise) % Channel characterization (cut-off frequencies) fmin = 0; % value in Hz, 0 means that it is a low-pass filter fmax = 4000; % value in Hz, upper cut-off frequency

Afterwards we proceed to define the desired line-code, as well as the binary sequence used for testing:

% lncds is a vector contained all the lines codes already implemented lncds = {'unipolar_nrz'; ... %1 'bipolar_nrz'; ... '4level_nrz'; ... 'bipolar_rz'; ... 'unipolar_rz'; ... %5 'ami'; ... 'manchester'; ... 'miller'; ... 'unipolar_nyquist'; ...


'bipolar_nyquist'; ... % 10 'bipolar_nrzi'; ... 'b8zs'; ... 'hdb3'; ... '2b1q'}; %14 linecode = 1; % through this variable we will pick which line code we want to test (in this case 1 corresponds to unipolar NRZ). seq = [[1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 0 1 1]; % binary sequence used for testing this will be the

Finally, we obtain the modulated signal y(t), as well as the noisy signal yn(t) and the signal distorted by the filter representing the channel's bandwidth - ynd(t).

% % First we create the modulated signal y(t) % [y,t] = modulb(seq,dr,fs,lncds{linecode}); % % Afterward we add noise according to the SNR value set % sigrms = sqrt(mean(y.^2)); % Signal power in rms % scale power in noise relative to signal npow = sigrms*10^(-snr/20); % Noise power in rms yn = y+npow*randn(size(y)); % Add scaled noise to signal % % Finallly we distort we signal according to the channel defined, in this case using an ideal filter % ynd = idealfilter(yn,fmin*max(size(seq))/dr,fmax*max(size(seq))/dr);

Step 1: On Matlab's command line execute the instruction "encoding". You should obtain 6 figures, where the last 3 (4, 5 and 6) are the spectral representation of the first 3 (1, 2 and 3), respectively. Figure 1 shows the modulated signal as generated by the sender. Figure 2 allows observing the effect of noise on the signal, and figure 3 shows the effect of bandwidth. According to figure 6, what is the frequency range that the channel allows to pass? ____________________________________ Step 2: Mantaining the same line code, vary the signal-to-noise ratio (SNR). Test with values -10, -3, 0, 3, 10, 20 and 100. What is the value beyond which you think that the error rate will be high? ___________ What is the value beyond which you think it is meaningless to increase the power at the source? ___________________ Step 3: Reset the value of SNR to 5dB. Vary the maximum cut-off frequency of the channel, testing with values 100, 500, 1000, 2000 y 8000 Hz. For this case, what is the optimum cut-off frequency? _____________


Part II: Spectral analysis of different modulation techniques In this second part the objective is to characterize the different line codes in terms of their spectral efficiency. To do this the student must use the script spectral_analysis.m, and modify it when necessary. Begin by executing once the instruction spectral_analysis from the command line of Matlab. You shall obtain a graphic with the amplitude representation of the signal in the frequency domain. Below we show the spectral representation of the unipolar NRZ encoding after zooming and moving the figure obtained.

Single-Sided Amplitude Spectrum of y(t)












400 500 600 700 Frequency (Hz)




As can be observed, this line code requires a bandwidth of 1000 Hz, and has a very significant DC component. Repeat this same analysis for different line codes, and fill-in the following table: Modulation technique Unipolar NRZ (#1) Bipolar NRZ (#2) AMI (#6) Manchester (#7) Bipolar NRZI (#11) B8SZ (#12) HDB3 (#13) 2B1Q (#14) Bandwidth occupied1 (Hz) Null DC component (Yes/No)

Part III: Impact of the channel on the bit error rate (BER) In this section we will use the simulator to see visually how the bandwidth and the attenuation introduced by the channel affect the transmitted signal.


Until the first crossing by zero on the frequency spectrum.


For this analysis we will use script ber_calc.m. For the decoding process it calls script decode_seq.m which, as can be seen, only implements a subset of the line codes indexed by vector lncds. Step 1: Using line codes unipolar NRZ (#1) and AMI (#6), calculate the bit error rate when varying the signal-to-noise ratio, and complete the graphic shown below:

Note: Test with SNR values: -3, -1, 1, 3, 5 y 10 dB. Put both lines on the same figure. The bandwidth of the channel must be [0,4000] Hz.

Step 2: Again using line codes unipolar NRZ (#1) and AMI (#6), calculate the bit error rate as we vary the bandwidth supposing a low-pass channel (modelled in terms of frequencies by [0,fmax]) and complete the graphic shown below:

Note: Set the SNR value to 10 dB. Test with the values shown in the figure.

Step 3: Repeat the previous step changing the channel type to band-pass (modelled in terms of frequencies by [fmin, 1000]) and complete the graphic shown below:


Note: Set the value of SNR to 10 dB and the value of fmax to 1000 Hz. Test with the values shown in the figure. Which of these two line codes do you consider more adequate for transmitting over band-pass channels? __________________

Optional extensions of this lab session

1. Implement new line codes (not yet available in the scripts) and analyze their frequency spectrum. 2. Compare the results obtained with the ideal filter used against more realistic filters: Butterworth, Chebychev, etc. 3. Implement decoders for other lines codes (check decode_seq.m to confirm which are missing) and characterize them in terms of BER.



Microsoft Word - Codigos_de_linea_v1_EN.doc

8 pages

Report File (DMCA)

Our content is added by our users. We aim to remove reported files within 1 working day. Please use this link to notify us:

Report this file as copyright or inappropriate


Notice: fwrite(): send of 196 bytes failed with errno=104 Connection reset by peer in /home/ on line 531