{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 6: Baseband Shaping for Data Transmission" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 06.01: Nonreturn_to_zero_bipolar_format.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Nonreturn-to-zero bipolar format\n", "//Figure 6.1(c):Discrete PAM Signals Generation\n", "// [3].BiPolar NRZ\n", "//page 235\n", "clear;\n", "close;\n", "clc;\n", "x = [0 1 1 0 0 1 0 0 1 1];\n", "binary_negative = [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1];\n", "binary_zero = [0 0 0 0 0 0 0 0 0 0];\n", "binary_positive = [1 1 1 1 1 1 1 1 1 1];\n", "L = length(x);\n", "L1 = length(binary_negative);\n", "total_duration = L*L1;\n", "//plotting\n", "a =gca();\n", "a.data_bounds =[0 -2;L*L1 2];\n", "for i =1:L\n", " if(x(i)==0)\n", " plot([i*L-L+1:i*L],binary_zero);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " elseif((x(i)==1)&(x(i-1)~=1))\n", " plot([i*L-L+1:i*L],binary_positive);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " else\n", " plot([i*L-L+1:i*L],binary_negative);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " end\n", "end\n", "xgrid(1)\n", "title('BiPolar NRZ')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 06.1: Nonreturn_to_zero_polar_format.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Nonreturn-to-zero polar format\n", "//Figure 6.1(b): Discrete PAM Signals Generation\n", "// [2].Polar NRZ\n", "//page 235\n", "clear;\n", "close;\n", "clc;\n", "x = [0 1 0 0 0 1 0 0 1 1];\n", "binary_negative = [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1];\n", "binary_positive = [1 1 1 1 1 1 1 1 1 1];\n", "L = length(x);\n", "L1 = length(binary_negative);\n", "total_duration = L*L1;\n", "//plotting\n", "a =gca();\n", "a.data_bounds =[0 -2;L*L1 2];\n", "for i =1:L\n", " if(x(i)==0)\n", " plot([i*L-L+1:i*L],binary_negative);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " else\n", " plot([i*L-L+1:i*L],binary_positive);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " end\n", "end\n", "xgrid(1)\n", "title('Polar NRZ')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.01: Nonreturn_to_zero_unipolar_format.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Nonreturn-to-zero unipolar format\n", "//Figure 6.1(a): Discrete PAM Signals Generation\n", "//[1].Unipolar NRZ \n", "//page 235 \n", "clear;\n", "close;\n", "clc;\n", "x = [0 1 0 0 0 1 0 0 1 1];\n", "binary_zero = [0 0 0 0 0 0 0 0 0 0];\n", "binary_one = [1 1 1 1 1 1 1 1 1 1];\n", "L = length(x);\n", "L1 = length(binary_zero);\n", "total_duration = L*L;\n", "//plotting\n", "a =gca();\n", "a.data_bounds =[0 -2;L*L1 2];\n", "for i =1:L\n", " if(x(i)==0)\n", " plot([i*L-L+1:i*L],binary_zero);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " else\n", " plot([i*L-L+1:i*L],binary_one);\n", " poly1= a.children(1).children(1);\n", " poly1.thickness =3;\n", " end\n", "end\n", "xgrid(1)\n", "title('Unipolar NRZ')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.15: Frequency_response_of_modified_duobinary_conversion_filter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Frequency response of modified duobinary conversion filter\n", "//Figure 6.15: Frequency Response of Modified duobinary conversion filter\n", "//(a)Amplitude Response\n", "//(b)Phase Response\n", "//page 259\n", "clear;\n", "close;\n", "clc;\n", "rb = input('Enter the bit rate=');\n", "Tb =1/rb; //Bit duration\n", "f = -rb/2:1/100:rb/2;\n", "Amplitude_Response = abs(2*sin(2*%pi*f.*Tb));\n", "Phase_Response = -(2*%pi*f.*Tb);\n", "subplot(2,1,1)\n", "a=gca();\n", "a.x_location ='origin';\n", "a.y_location ='origin';\n", "plot2d(f,Amplitude_Response,2)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "xlabel('Frequency f---->')\n", "ylabel('|H(f)| ----->')\n", "title('Amplitude Repsonse of Modified Duobinary Singaling')\n", "xgrid(1)\n", "subplot(2,1,2)\n", "a=gca();\n", "a.x_location ='origin';\n", "a.y_location ='origin';\n", "plot2d(f,Phase_Response,5)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "xlabel(' Frequency f---->')\n", "ylabel(' ')\n", "title('Phase Repsonse of Modified Duobinary Singaling')\n", "xgrid(1)\n", "//Result\n", "//Enter the bit rate=8 " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.1: Bandwidth_Requirements_of_the_T1_carrier.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Bandwidth Requirements of the T1 carrier\n", "//Example6.1:Bandwidth Requirements of the T1 Carrier\n", "//Page 251\n", "clear;\n", "clc;\n", "Tb = input('Enter the bit duration of the TDM signal:')\n", "Bo = 1/(2*Tb);//minimum transmission bandwidth of T1 system\n", "//Transmission bandwidth for raised cosine spectrum 'B'\n", "alpha = 1;//cosine roll-off factor\n", "f1 = Bo*(1-alpha);\n", "B = 2*Bo-f1;\n", "disp(B,'Transmission bandwidth for raised cosine spectrum in Hz:')\n", "//Result\n", "//Enter the bit duration of the TDM signal:0.647*10^-6\n", "//Transmission bandwidth for raised cosine spectrum in Hz:1545595.1 " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.2: Frequency_response_of_modified_duobinary_conversion_filter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Duobinary Encoding\n", "//Example6.2: Precoded Duobinary coder and decoder\n", "//Page 256\n", "clc;\n", "b = [0,0,1,0,1,1,0];//input binary sequence:precoder input\n", "a(1) = xor(1,b(1));\n", "if(a(1)==1)\n", " a_volts(1) = 1;\n", "end\n", "for k =2:length(b)\n", " a(k) = xor(a(k-1),b(k));\n", " if(a(k)==1)\n", " a_volts(k)=1;\n", " else\n", " a_volts(k)=-1;\n", " end\n", "end\n", "a = a';\n", "a_volts = a_volts';\n", "disp(a,'Precoder output in binary form:')\n", "disp(a_volts,'Precoder output in volts:')\n", "//Duobinary coder output in volts\n", "c(1) = 1+ a_volts(1);\n", "for k =2:length(a)\n", " c(k) = a_volts(k-1)+a_volts(k);\n", "end\n", "c = c';\n", "disp(c,'Duobinary coder output in volts:')\n", "//Duobinary decoder output by applying decision rule\n", "for k =1:length(c)\n", " if(abs(c(k))>1)\n", " b_r(k) = 0;\n", " else\n", " b_r(k) = 1;\n", " end\n", "end\n", "b_r = b_r';\n", "disp(b_r,'Recovered original sequence at detector oupupt:')\n", "//Result\n", "//Precoder output in binary form: \n", "// \n", "// 1. 1. 0. 0. 1. 0. 0. \n", "// \n", "// Precoder output in volts: \n", "// \n", "// 1. 1. - 1. - 1. 1. - 1. - 1. \n", "// \n", "// Duobinary coder output in volts: \n", "//\n", "// 2. 2. 0. - 2. 0. 0. - 2. \n", "// \n", "// Recovered original sequence at detector oupupt: \n", "// \n", "// 0. 0. 1. 0. 1. 1. 0. " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.3: Generation_of_bipolar_output_for_duobinary_coder.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Generation of bipolar output for duobinary coder\n", "//Example6.3:Operation of Circuit in figure 6.13\n", "//for generating bipolar format\n", "//page 256 and page 257\n", "//Refer Table 6.4\n", "clc;\n", "x = [0,1,1,0,1,0,0,0,1,1];//input binary sequence:precoder input\n", "y(1) = 1;\n", "for k =2:length(x)+1\n", " y(k) = xor(x(k-1),y(k-1));\n", "end\n", "y_delay = y(1:$-1);\n", "y = y';\n", "y_delay = y_delay';\n", "disp(y,'Modulo-2 adder output:')\n", "disp(y_delay,'Delay element output:')\n", "for k = 1:length(y_delay)\n", " z(k) = y(k+1)-y_delay(k);\n", "end\n", "z = z';\n", "disp(z,'differential encoder bipolar output in volts:')\n", "//Result\n", "//Modulo-2 adder output: \n", "// 1. 1. 0. 1. 1. 0. 0. 0. 0. 1. 0. \n", "// Delay element output: \n", "// 1. 1. 0. 1. 1. 0. 0. 0. 0. 1. \n", "// differential encoder bipolar output in volts: \n", "// 0. - 1. 1. 0. - 1. 0. 0. 0. 1. - 1. " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.4: Power_Spectra_of_different_binary_data_formats.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Power Spectra of different binary data formats\n", "//Figure 6.4: Power Spectal Densities of \n", "//Different Line Coding Techniques\n", "//[1].NRZ Polar Format [2].NRZ Bipolar format\n", "//[3].NRZ Unipolar format [4]. Manchester format\n", "//Page 241\n", "close;\n", "clc;\n", "//[1]. NRZ Polar format\n", "a = input('Enter the Amplitude value:');\n", "fb = input('Enter the bit rate:');\n", "Tb = 1/fb; //bit duration\n", "f = 0:1/(100*Tb):2/Tb;\n", "for i = 1:length(f)\n", " Sxxf_NRZ_P(i) = (a^2)*Tb*(sinc_new(f(i)*Tb)^2);\n", " Sxxf_NRZ_BP(i) = (a^2)*Tb*((sinc_new(f(i)*Tb))^2)*((sin(%pi*f(i)*Tb))^2);\n", " if (i==1)\n", " Sxxf_NRZ_UP(i) = (a^2)*(Tb/4)*((sinc_new(f(i)*Tb))^2)+(a^2)/4;\n", " else\n", " Sxxf_NRZ_UP(i) = (a^2)*(Tb/4)*((sinc_new(f(i)*Tb))^2);\n", " end\n", " Sxxf_Manch(i) = (a^2)*Tb*(sinc_new(f(i)*Tb/2)^2)*(sin(%pi*f(i)*Tb/2)^2);\n", "end\n", "//Plotting\n", "a = gca();\n", "plot2d(f,Sxxf_NRZ_P)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "plot2d(f,Sxxf_NRZ_BP,2)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "plot2d(f,Sxxf_NRZ_UP,5)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "plot2d(f,Sxxf_Manch,9)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "xlabel('f*Tb------->')\n", "ylabel('Sxx(f)------->')\n", "title('Power Spectral Densities of Different Line Codinig Techniques')\n", "xgrid(1)\n", "legend(['NRZ Polar Format','NRZ Bipolar format','NRZ Unipolar format','Manchester format']);\n", "//Result\n", "//Enter the Amplitude value:1\n", "//Enter the bit rate:1 " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.6: Ideal_solution_for_zero_ISI.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Ideal solution for zero ISI\n", "//Figure 6.6(b): Ideal Solution for Intersymbol Interference\n", "//SINC pulse\n", "//page 249\n", "rb = input('Enter the bit rate:');\n", "Bo = rb/2;\n", "t =-3:1/100:3;\n", "x = sinc_new(2*Bo*t);\n", "plot(t,x)\n", "xlabel('t------>');\n", "ylabel('p(t)------->');\n", "title('SINC Pulse for zero ISI')\n", "xgrid(1)\n", "//Result\n", "//Enter the bit rate:1" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.7: Practical_solution_Raised_Cosine.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Practical solution: Raised Cosine \n", "//Figure6.7(b):Practical Solution for Intersymbol Interference\n", "//Raised Cosine Spectrum\n", "//page 250\n", "close;\n", "clc;\n", "rb = input('Enter the bit rate:');\n", "Tb =1/rb;\n", "t =-3:1/100:3;\n", "Bo = rb/2;\n", "Alpha =0; //Intialized to zero\n", "x =t/Tb;\n", "for j =1:3\n", " for i =1:length(t)\n", " if((j==3)&((t(i)==0.5)|(t(i)==-0.5)))\n", " p(j,i) = sinc_new(2*Bo*t(i));\n", " else\n", " num = sinc_new(2*Bo*t(i))*cos(2*%pi*Alpha*Bo*t(i));\n", " den = 1-16*(Alpha^2)*(Bo^2)*(t(i)^2)+0.01; \n", " p(j,i)= num/den;\n", " end\n", " end\n", " Alpha = Alpha+0.5;\n", "end\n", "a =gca();\n", "plot2d(t,p(1,:))\n", "plot2d(t,p(2,:))\n", "poly1= a.children(1).children(1);\n", "poly1.foreground=2;\n", "plot2d(t,p(3,:))\n", "poly2= a.children(1).children(1);\n", "po1y2.foreground=4;\n", "poly2.line_style = 3;\n", "xlabel('t/Tb------>');\n", "ylabel('p(t)------->');\n", "title('RAISED COSINE SPECTRUM - Practical Solution for ISI')\n", "legend(['ROlloff Factor =0','ROlloff Factor =0.5','ROlloff Factor =1'])\n", "xgrid(1)\n", "//Result\n", "//Enter the bit rate:1" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.9: Frequency_response_of_duobinary_conversion_filte.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Frequency response of duobinary conversion filter\n", "//Figure6.9:Frequency Response of Duobinary Conversion filter\n", "//(a)Amplitude Response\n", "//(b)Phase Response\n", "//Page 254\n", "clear;\n", "close;\n", "clc;\n", "rb = input('Enter the bit rate=');\n", "Tb =1/rb; //Bit duration\n", "f = -rb/2:1/100:rb/2;\n", "Amplitude_Response = abs(2*cos(%pi*f.*Tb));\n", "Phase_Response = -(%pi*f.*Tb);\n", "subplot(2,1,1)\n", "a=gca();\n", "a.x_location ='origin';\n", "a.y_location ='origin';\n", "plot2d(f,Amplitude_Response,2)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "xlabel('Frequency f---->')\n", "ylabel('|H(f)| ----->')\n", "title('Amplitude Repsonse of Duobinary Singaling')\n", "subplot(2,1,2)\n", "a=gca();\n", "a.x_location ='origin';\n", "a.y_location ='origin';\n", "plot2d(f,Phase_Response,5)\n", "poly1= a.children(1).children(1); \n", "poly1.thickness = 2; // the tickness of a curve.\n", "xlabel(' Frequency f---->')\n", "ylabel(' ')\n", "title('Phase Repsonse of Duobinary Singaling')\n", "//Result\n", "//Enter the bit rate=8 " ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }