Line codes are used to map binary information sequence into analog signal which has properties suitable for the physical media that is being utilized to send the data.

Consider the case of a networking equipment like a router or a switch. According to ISO-OSI ( “International Standard Organisation – Open System Interconnection”[1]) reference model , any communication device or network can be conceptualized into seven layers of protocols namely Application, Presentation, Session, Transport, Network, Data-Link, and Physical Layer. Physical Layer dictates the electrical, physical and mechanical properties of the communication network or device. It defines properties like voltage levels, timing , maximum data rate allowable through the media without data loss,bandwidth efficiency, power consumption, physical connectors ( details like 50Ω or 75Ω termination, SMA, SMC or BNC connectors etc…,).

Line codes are chosen in such a way that they are optimized for the media that is being used to transmit data. Some line codes provide excellent timing synchronization (Timing synchronization is important in the context of sampling and clock recovery at the receiver. Incorrect timing sync may cause unrecoverable errors at the receiver due to wrong sampling instants) but may posses an undesirable DC content ( Why ?? Desired operating frequency range for a particular application may be between 500KHz and 1MHz, presence of DC content in such an application causes wastage of power.)

Commonly used line codes are NRZ (Non Return to Zero), RZ (Return to Zero), AMI (Alternate Mark Inversion), Manchester code, 8b/10b code,2B1Q code, Miller code, etc..,

Power Spectrum Density (PSD) is a common method employed in choosing a line code suitable for the physical media under consideration. Lets discuss how to convert a bit stream into NRZ unipolar, NRZ polar and Manchester coded data and plot their PSD.

Procedure to plot Power Spectral Density of line codes in Matlab :

Step 1: Generate random binary sequence of sufficient length .Too small number of bits will give a poor PSD plot , whereas , too large number of bits consumes more computation time.

Step 2: Map the generated bits into NRZ unipolar or NRZ polar or Manchester line code (see Algorithm).

Step 3: Plot PSD using “psd” function in matlab.

 

Algorithm:

Manchester Coding:
NRZ Unipolar
NRZ Polar

First half of bit period :

signal = data

Second half of bit period:

signal = !data
For the entire bit period:

signal=0 { if data =0 }

signal=A volts { if data =1 }

For the entire bit period:

signal=-A volts { if data =0 }

signal=A volts { if data =1 }

 

Matlab Code:

File 1: %———Line_Encoder.m—————%

Check this ebook for the full Matlab code Simulation of Communication Systems using Matlab by Mathuranathan Viswanathan

File 2:———— Basic_Wave_gen.m——–>To generate line codes and plot them (optional file)

File 3:— PSD_of_Line_Codes.m—-> To generate PSD of Line codes

Sample Output :

Power Spectral Density of Line Codes

Power Spectral Density of Line Codes

Reference :

[1] – Cisco Systems, Inc – Internetworking Basics – click here

See also:

[1] Colored Noise Generation in Matlab
[2] Sampling Theorem – Baseband Sampling
[3] Sampling Theorem – Bandpass or Intermediate or Under Sampling
[4] Window Functions – An Analysis
[5] FFT and Spectral Leakage
[6] Raised Cosine Filter
[7] Moving Average Filter ( MA filter )

Recommended Books:

More Recommended Books at our Integrated Book Store