{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 9: Spread Spectrum Modulation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 9.1: PN_sequence_generation.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:PN sequence generation\n", "//Example9.1 and Figure9.1: Maximum-length sequence generator\n", "//Program to generate Maximum Length Pseudo Noise Sequence\n", "//Period of PN Sequence N = 7\n", "clc;\n", "//Assign Initial value for PN generator\n", "x0= 1;\n", "x1= 0;\n", "x2 =0;\n", "x3 =0;\n", "N = input('Enter the period of the signal')\n", "for i =1:N\n", " x3 =x2;\n", " x2 =x1;\n", " x1 = x0;\n", " x0 =xor(x1,x3);\n", " disp(i,'The PN sequence at step')\n", " x = [x1 x2 x3];\n", " disp(x,'x=')\n", "end\n", "m = [7,8,9,10,11,12,13,17,19];\n", "N = 2^m-1;\n", "disp('Table 9.1 Range of PN Sequence lengths')\n", "disp('_________________________________________________________')\n", "disp('Length of shift register (m)')\n", "disp(m)\n", "disp('PN sequence Length (N)')\n", "disp(N)\n", "disp('_________________________________________________________')\n", "//RESULTEnter the period of the signal 7\n", "// The PN sequence at step 1. \n", "// x= 1. 0. 0. \n", "// The PN sequence at step 2. \n", "// x= 1. 1. 0. \n", "// The PN sequence at step 3. \n", "// x= 1. 1. 1. \n", "// The PN sequence at step 4. \n", "// x= 0. 1. 1. \n", "// The PN sequence at step 5. \n", "// x= 1. 0. 1. \n", "// The PN sequence at step 6. \n", "// x= 0. 1. 0. \n", "// The PN sequence at step 7. \n", "// x= 0. 0. 1. " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 9.2: Maximum_length_sequence_property.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Maximum length sequence property\n", "//Example9.2 and Figure 9.2: Maximum-length sequence \n", "//Period of PN Sequence N = 7\n", "//Properites of maximum-length sequence\n", "clc;\n", "//Assign Initial value for PN generator\n", "x0= 1;\n", "x1= 0;\n", "x2 =0;\n", "x3 =0;\n", "N = input('Enter the period of the signal')\n", "one_count = 0;\n", "zero_count = 0;\n", "for i =1:N\n", " x3 =x2;\n", " x2 =x1;\n", " x1 = x0;\n", " x0 =xor(x1,x3);\n", " disp(i,'The PN sequence at step')\n", " x = [x1 x2 x3];\n", " disp(x,'x=')\n", " C(i) = x3;\n", " if(C(i)==1)\n", " C_level(i)=1;\n", " one_count = one_count+1;\n", " elseif(C(i)==0)\n", " C_level(i)=-1;\n", " zero_count = zero_count+1;\n", " end\n", "end\n", "disp(C,'Output Sequence')//refer equation 9.4\n", "disp(C_level,'Output Sequence levels')//refer equation 9.5\n", "if(zero_count < one_count)\n", " disp(one_count,'Number of 1s in the given PN sequence')\n", " disp(zero_count,'Number of 0s in the given PN sequence')\n", " disp('Property 1 (Balance property) is satisified')\n", "end\n", "Rc_tuo = corr(C_level,N);\n", "t = 1:2*length(C_level);\n", "//\n", "figure\n", "a =gca();\n", "a.x_location = 'origin';\n", "plot2d(t,[C_level; C_level])\n", "xlabel(' t')\n", "title('Waveform of maximum-length sequence [0 0 1 1 1 0 1 0 0 1 1 1 0 1]')\n", "//\n", "figure\n", "a =gca();\n", "a.x_location ='origin';\n", "a.y_location ='origin';\n", "plot2d([-length(Rc_tuo)+1:-1,0:length(Rc_tuo)-1],[Rc_tuo($:-1:2),Rc_tuo],5)\n", "xlabel(' tuo')\n", "ylabel(' Rc(tuo)')\n", "title('Autocorrelation of maximum-length sequence')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 9.3: Processing_gain.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Processing gain, PN sequence length, Jamming margin in dB\n", "//Example9.3: Processing gain and Jamming Margin\n", "clear;\n", "clc;\n", "close;\n", "Tb = 4.095*10^-3;//Information bit duration\n", "Tc = 1*10^-6;//PN chip duration\n", "PG = Tb/Tc;//Processing gain\n", "disp(PG,'The processing gain is:')\n", "N = PG; //PN sequence length\n", "m = log2(N+1);//feedback shift register length\n", "disp(N,'The required PN sequence is:')\n", "disp(m,'The feedback shift register length:')\n", "Eb_No = 10;//Energy to noise density ratio\n", "J_P = PG/Eb_No;//Jamming Margin\n", "disp(10*log10(J_P),'Jamming Margin in dB:')\n", "//Result\n", "//The processing gain is: 4095. \n", "//The required PN sequence is: 4095. \n", "//The feedback shift register length: 12. \n", "//Jamming Margin in dB: 26.122539 " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 9.4_9_5: Slow_and_Fast_Frequency_hopping_FH_MFSK.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Slow and Fast Frequency hopping: FH/MFSK\n", "//Example9.4 and Example9.5: Parameters of FH/MFSK signal\n", "//Slow and Fast Frequency Hopping\n", "clear;\n", "close;\n", "clc;\n", "K =2; //number of bits per symbol\n", "M = 2^K; //Number of MFSK tones\n", "N = 2^M-1;//Period of the PN sequence\n", "k = 3; //length of PN sequence per hop\n", "disp(K,'number of bits per symbol K =')\n", "disp(M,'Number of MFSK tones M=')\n", "disp(N,'Period of the PN sequence N =')\n", "disp(k,'length of PN sequence per hop k =')\n", "disp(2^k,'Total number of frequency hops =')\n", "//Result\n", "//number of bits per symbol K = 2. \n", "//Number of MFSK tones M = 4. \n", "//Period of the PN sequence N = 15. \n", "//length of PN sequence per hop k = 3. \n", "//Total number of frequency hops = 8. " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 9.4_96: Direct_Sequence_Spread_Coherent_BPSK.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//clear//\n", "//Caption:Direct Sequence Spread Coherent BPSK\n", "//Figure 9.4:Generation of waveforms in DS/BPSK spread spectrum transmitter\n", "clear;\n", "close;\n", "clc;\n", "t = 0:13;\n", "N = 7;\n", "wt = 0:0.01:1;\n", "bt = [1*ones(1,N) -1*ones(1,N)];\n", "ct = [0,0,1,1,1,0,1,0,0,1,1,1,0,1];\n", "ct_polar = [-1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,1];\n", "mt = bt.*ct_polar;\n", "Carrier = 2*sin(wt*2*%pi);\n", "st = [];\n", "for i = 1:length(mt)\n", " st = [st mt(i)*Carrier];\n", "end\n", "//\n", "figure\n", "subplot(3,1,1)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot2d2(t,bt,5)\n", "xlabel(' t')\n", "title('Data b(t)')\n", "subplot(3,1,2)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot2d2(t,ct_polar,5)\n", "xlabel(' t')\n", "title('Spreading code c(t)')\n", "subplot(3,1,3)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot2d2(t,mt,5)\n", "xlabel(' t')\n", "title('Product Signal m(t)')\n", "//\n", "figure\n", "subplot(3,1,1)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot2d2(t,mt,5)\n", "xlabel(' t')\n", "title('Product Signal m(t)')\n", "subplot(3,1,2)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot(Carrier)\n", "xlabel(' t')\n", "title('Carrier Signal')\n", "subplot(3,1,3)\n", "a =gca();\n", "a.x_location = 'origin';\n", "a.y_location = 'origin';\n", "a.data_bounds = [0,-2;20,2];\n", "plot(st)\n", "xlabel(' t')\n", "title('DS/BPSK signal s(t)')\n", "//" ] } ], "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 }