diff options
Diffstat (limited to 'Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling')
15 files changed, 4172 insertions, 0 deletions
diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/1-Introduction_of_Signals_and_Spectra.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/1-Introduction_of_Signals_and_Spectra.ipynb new file mode 100644 index 0000000..b1b88db --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/1-Introduction_of_Signals_and_Spectra.ipynb @@ -0,0 +1,338 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Introduction of Signals and Spectra" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1: Calculation_of_Energy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 12\n", +"//problem 1.1\n", +"\n", +"//Given signal u = 2*exp(-3*t) \n", +"\n", +"//Since the function integral does not accept %inf as limit we need to use approximation by changing variables.\n", +"\n", +"//First the signal is to be expressed in terms of 'x'.\n", +"\n", +"function y=Signal(x); \n", +"y=2*exp(-3*x); \n", +"endfunction;\n", +"\n", +"//We then substitute x = tan(z), and then express the given signal wrt 'z' and not 'x'.\n", +"\n", +"function y=Gmodified(z); \n", +"x=tan(z); \n", +"y=(Signal(x))^2/(cos(z))^2; \n", +"endfunction;\n", +"\n", +"E = intg(0,atan(10),Gmodified)\n", +"\n", +"disp(E,'The energy of this signal is ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2: Calculation_of_Power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 12\n", +"//problem 1.2\n", +"\n", +"//Given signal u = 2*sin(0.5*%pi*t) \n", +"\n", +"//Since u is periodic, averaging over -infinity to + infinity will give the same result as averaging over -2 to 2, where 4 is the time period.\n", +"\n", +"t0 = -2;\n", +"t1 = 2;\n", +"E = integrate('(2*sin(0.5*%pi*t))^2','t',t0,t1)/4;\n", +"\n", +"disp(E,'The power of the signal is ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3: Time_shifting.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 18\n", +"//problem 1.3\n", +"\n", +"//u1(T) vs T\n", +"T = [-5:0.0082:5];\n", +"u1(T<=0) = 0;\n", +"u1(T>0) = 1;\n", +"xlabel('T');\n", +"ylabel('u(T)')\n", +"\n", +"subplot(131);\n", +"plot2d(T,u1);\n", +"\n", +"//u2(T-t) vs T\n", +"//Shifting the given signal by t units to the right, we get\n", +"//Let us assume the amount of time to be shited is 3 units \n", +"t = 3;\n", +"\n", +"T = [-5:0.0082:5];\n", +"u2(T<=t) = 0;\n", +"u2(T>t) = 1;\n", +"xlabel('T');\n", +"ylabel('u(T - t)')\n", +"\n", +"subplot(132);\n", +"plot2d(T,u2);\n", +"\n", +"//u(t - T) = u(-(T - t))\n", +"\n", +"T = [-5:0.0082:5];\n", +"u3(T>=t) = 0;\n", +"u3(T<t) = 1;\n", +"xlabel('T');\n", +"ylabel('u(t - T)')\n", +"\n", +"subplot(133);\n", +"plot2d(T,u3);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.4: Time_shifting.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 18\n", +"//problem 1.4\n", +"\n", +"//u1(t)\n", +"t = [-5:0.0082:5];\n", +"u1(t<=0) = 0;\n", +"u1(t>0) = 1;\n", +"\n", +"xlabel('t');\n", +"ylabel('u(t)')\n", +"\n", +"subplot(131);\n", +"plot2d(t,u1);\n", +"\n", +"//u2(t-T)\n", +"//Shifting the given signal by t units to the right, we get\n", +"//Let us assume the amount of time to be shited is 3 units \n", +"T = 3;\n", +"\n", +"t = [-5:0.0082:5];\n", +"u2(t<=T) = 0;\n", +"u2(t>T) = 1;\n", +"\n", +"xlabel('t');\n", +"ylabel('u(t-T)')\n", +"\n", +"subplot(132);\n", +"plot2d(t,u2);\n", +"\n", +"\n", +"//u(t) - u(t - T)\n", +"\n", +"t = [-5:0.0082:5];\n", +"u3 = u1 - u2;\n", +"\n", +"xlabel('t');\n", +"ylabel('u(t) - u(t-T)')\n", +"\n", +"subplot(133);\n", +"plot2d(t,u3);\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.5: Crosscorrelation_and_Autocorrelation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 18\n", +"//problem 1.5\n", +"\n", +"//V1(t) = u(t) - u(t - 5)\n", +"t = [-5:0.1:5];\n", +"V1(t<=0) = 0;\n", +"V1(t>0) = 1;\n", +"\n", +"xlabel('t');\n", +"ylabel('V1(t)')\n", +"subplot(121);\n", +"plot2d(t,V1);\n", +"\n", +"\n", +"//V2(t) = 2*t*(u(t) - u(t - 3))\n", +"t = [0:0.1:3];\n", +"V2 = 2*t;\n", +"\n", +"xlabel('t');\n", +"ylabel('V2(t)')\n", +"subplot(122);\n", +"plot2d(t,V2);\n", +"\n", +"//Autocorrelation R12(0) = R\n", +"\n", +"R = integrate('2*t','t',0,3);\n", +"\n", +"E1 = integrate('1','t',0,5);\n", +"\n", +"//In the textbook, E2 has been computed as 18 instead of 36\n", +"E2 = integrate('4*t^2','t',0,3);\n", +"\n", +"c = R/(E1*E2)^0.5;\n", +"\n", +"disp(R,'The correlation term R12(0) is ');\n", +"disp(E1,'The autocorrelation term R1(0) is ');\n", +"disp(E2,'The autocorrelation term R2(0) is ');\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.6: Autocorrelatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 19\n", +"//problem 1.6\n", +"\n", +"//V1(t) = u(t) - u(t - 5)\n", +"t = [-5:0.1:5];\n", +"V1(t<=0) = 0;\n", +"V1(t>0) = 1;\n", +"\n", +"xlabel('t');\n", +"ylabel('V1(t)')\n", +"subplot(121);\n", +"plot2d(t,V1);\n", +"\n", +"\n", +"//V2(t) = 2*t*(u(t) - u(t - 3))\n", +"t = [0:0.1:3];\n", +"V2 = 2*t;\n", +"\n", +"xlabel('t');\n", +"ylabel('V2(t)')\n", +"subplot(122);\n", +"plot2d(t,V2);\n", +"\n", +"//Autocorrelation R12(1) = Ra\n", +"//The range is t = 0 to 2, as signal V2(t) has been shifted left by one unit, V2(t-1)\n", +"\n", +"Ra = integrate('2*(t+1)','t',0,2);\n", +"\n", +"disp(Ra,'The correlation term R12(1) is ');\n", +"\n", +"//Autocorrelation R12(-1) = Rb\n", +"//The range is t = 1 to 4, as signal V2(t) has been shifted right by one unit, V2(t+1)\n", +"\n", +"Rb = integrate('2*(t-1)','t',1,4);\n", +"\n", +"disp(Rb,'The correlation term R12(-1) is ');\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/10-Phase_Locked_Loops.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/10-Phase_Locked_Loops.ipynb new file mode 100644 index 0000000..33667ea --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/10-Phase_Locked_Loops.ipynb @@ -0,0 +1,168 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 10: Phase Locked Loops" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.3: SNR_of_Phase_Discriminator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 520\n", +"//problem 10.3\n", +"\n", +"// Part (a)\n", +"\n", +"//Input SNR SNR_ip\n", +"SNR_ip = 1000;\n", +"\n", +"//Beta B\n", +"B = 10;\n", +"\n", +"//Output SNR SNR_op\n", +"SNR_op = (1.5*(B^2)*SNR_ip)/(1 + (12*B/%pi)*(SNR_ip)*exp(-0.5*(1/(B+1))*(SNR_ip)));\n", +"\n", +"disp('Output SNR is '+string(10*log10(SNR_op))+' dB');\n", +"\n", +"// Part (b)\n", +"\n", +"//Input SNR SNR_ip\n", +"SNR_ip = 10;\n", +"\n", +"//Output SNR SNR_op\n", +"SNR_op = (1.5*(B^2)*SNR_ip)/(1 + (12*B/%pi)*(SNR_ip)*exp(-0.5*(1/(B+1))*(SNR_ip)));\n", +"\n", +"disp('Output SNR is '+string(10*log10(SNR_op))+' dB');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.5: Channel_Spacing.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 533\n", +"//problem 10.5\n", +"\n", +"//Given reference frequency is fref = 10 MHz\n", +"fref = 10 * 10^6;\n", +"\n", +"//Given step frequency is fstep = 100 KHz\n", +"fstep = 100 * 10^3;\n", +"\n", +"//Division ratio M\n", +"M = fref/fstep;\n", +"\n", +"//Required output frequency F = 100.6 MHz\n", +"F = 100.6 * 10^6;\n", +"\n", +"N = F/fstep;\n", +"\n", +"//Given P = 64\n", +"P = 64;\n", +"\n", +"//Truncating value B = 15\n", +"B = 15;\n", +"\n", +"A = N - P*B;\n", +"\n", +"disp('The value of A is '+string(A));\n", +"disp('The value of B is '+string(B));\n", +"disp('The value of M is '+string(M));\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.7: Phase_Locked_Loops.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 534\n", +"//problem 10.7\n", +"\n", +"//Given reference frequency for PLL is fref = 0.48 MHz\n", +"fref = 0.48 * 10^6;\n", +"\n", +"//Frequency divider N = 2000\n", +"N = 2000;\n", +"\n", +"//Output Frequency fout\n", +"fout = fref*N;\n", +"\n", +"//Output Frequency favg\n", +"favg = (2000*15 + 2001*1)*(0.48/16) * 10^6;\n", +"\n", +"disp('Output frequency is '+string(fout)+' Hz');\n", +"\n", +"//Reference frequency is not subdivided before going to comparator and it is an integer divider in the feedback path the frequency resolution fres = 0.48 * 10^6;\n", +"fres = 0.48 * 10^6;\n", +"\n", +"disp('Frequency resolution is '+string(fres)+' Hz');\n", +"\n", +"disp('Output frequency resolution is '+string(favg - fout)+' Hz');\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/11-Optimal_Reception_of_Digital_Signal.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/11-Optimal_Reception_of_Digital_Signal.ipynb new file mode 100644 index 0000000..7d44c03 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/11-Optimal_Reception_of_Digital_Signal.ipynb @@ -0,0 +1,415 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 11: Optimal Reception of Digital Signal" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.3: Optimal_threshold_and_probability_of_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 558\n", +"//problem 11.3\n", +"\n", +"//Prior probability of s1 P_s1 = 0.4\n", +"P_s1 = 0.4;\n", +"\n", +"//Prior probability of s2 P_s2 = 1 - P_s1\n", +"P_s2 = 1 - P_s1;\n", +"\n", +"//Voltage level V1 = 1\n", +"V1 = 1;\n", +"\n", +"//Voltage level V2 = -1\n", +"V2 = -1;\n", +"\n", +"//Part a\n", +"\n", +"//Noise Variance sigma1 = 10^-3\n", +"sigma1 = 10^-3;\n", +"\n", +"//Descision Threshold lambda1 \n", +"lambda1 = (V1+V2)/2 + (sigma1)*log(P_s2/P_s1)/(V1-V2);\n", +"\n", +"//Probability of error Pe\n", +"Pe = 0.5*(2*P_s1 - P_s1*erfc(((V2-V1)/(2*sigma1*2^0.5)) + (sigma1)*log(P_s2/P_s1)/((V1-V2)*2^0.5)));\n", +"\n", +"disp('The decision threshold is '+string(lambda1)+' V');\n", +"disp('The probability of error is approximately '+string(Pe));\n", +"\n", +"//Part b\n", +"\n", +"//Noise Variance sigma2 = 10^-1\n", +"sigma2 = 10^-1;\n", +"\n", +"//Descision Threshold lambda2\n", +"lambda2 = (V1+V2)/2 + (sigma2)*log(P_s2/P_s1)/(V1-V2);\n", +"\n", +"//Probability of error Pe\n", +"Pe1 = 0.5*(2*P_s1 - P_s1*erfc(((V2-V1)/(2*sigma2*2^0.5)) + (sigma2)*log(P_s2/P_s1)/((V1-V2)*2^0.5)));\n", +"\n", +"//In the textbook Pe has been calulated to be 0.0021 because of the use of a very high precision calculator, unfortunately in scilab the function erfc approximates the output value to a larger extent due to which an exact value cannot be obtained.\n", +"\n", +"disp('The decision threshold is '+string(lambda2)+' V');\n", +"disp('The probability of error is approximately '+string(Pe1));\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.4: Decision_threshold.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 559\n", +"//problem 11.4\n", +"\n", +"//Part b\n", +"\n", +"//Voltage level V1 = 1\n", +"V1 = 1;\n", +"\n", +"//Voltage level V2 = -1\n", +"V2 = -1;\n", +"\n", +"//Prior probability of s1 P_s1 = 0.4\n", +"P_s1 = 0.4;\n", +"\n", +"//Prior probability of s2 P_s2 = 1 - P_s1\n", +"P_s2 = 1 - P_s1;\n", +"\n", +"//Cost of selecting s1 when s2 is transmitted C12 = 0.7\n", +"C12 = 0.7;\n", +"\n", +"//Cost of selecting s2 when s1 is transmitted C21 = 1 - C12\n", +"C21 = 1 - C12;\n", +"\n", +"//Noise Variance sigma = 10^-3\n", +"sigma = 10^-3;\n", +"\n", +"//Descision Threshold lambda\n", +"lambda = (V1+V2)/2 + (sigma)*log((C12*P_s2)/(C21*P_s1))/(V1-V2);\n", +"\n", +"disp('The decision threshold is '+string(lambda)+' V');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.5: Probability_of_error_of_optimum_filter.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 567\n", +"//problem 11.5\n", +"\n", +"//The voltage level of reciever is V = 5 mV\n", +"V = 5*10^-3;\n", +"\n", +"//The time required to transfer one bit is T = 1/9600 sec\n", +"T = 9600^-1;\n", +"\n", +"//the signal energy of a bit be Es\n", +"Es = (V^2)*T;\n", +"\n", +"//The power spectral density is n/2 = 10^-9 Watt/hertz\n", +"n = 2*10^-9;\n", +"\n", +"//Probability error for optimal reciever is Pe\n", +"Pe = 0.5*erfc((Es/n)^0.5);\n", +"\n", +"disp('The probability of error is '+string(Pe));\n", +"\n", +"//When the data rate is doubled, the new effective energy per bit is Es_new\n", +"Es_new = (V^2)*(T/2);\n", +"\n", +"//The new probability of error is Pe_new\n", +"Pe_new = 0.5*erfc((Es_new/n)^0.5);\n", +"\n", +"//Percentage increase in error rate is P\n", +"P = 100*(Pe_new - Pe)/Pe;\n", +"\n", +"disp('Percentage increase in error rate is '+string(P));\n", +"\n", +"//Voltage required to restore probability levels, V_new\n", +"V_new = V*2^0.5;\n", +"\n", +"disp('Voltage required to restore the probability levels is '+string(V_new)+' Volts');\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.6: Error_probability_of_BPSK_signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 575\n", +"//problem 11.6\n", +"\n", +"//Amplitude of signal is A = 10 mV\n", +"A = 10*10^-3;\n", +"\n", +"//Power Spectral Density n = 2 * 10^(-9) W/Hz\n", +"n = 2 * 10^(-9);\n", +"\n", +"//Frequency is f = 1 MHz\n", +"f = 1*10^6;\n", +"\n", +"//Data rate is D = 10^4 bps;\n", +"D = 10^4;\n", +"\n", +"//Time taken for a bit to traverse\n", +"T = 1/D;\n", +"\n", +"//Energy per signal element is Es\n", +"Es = A^2/(2*D);\n", +"\n", +"//Probability of error Pe\n", +"Pe = 0.5*erfc((Es/n)^0.5);\n", +"\n", +"disp('Probability of error is '+string(Pe));\n", +"\n", +"//Phase shift phi = %pi/6\n", +"phi = %pi/6;\n", +"\n", +"//Probability of error Pe_local_oscillator\n", +"Pe_local_oscillator = 0.5*erfc(((Es/n)^0.5)*cos(phi));\n", +"\n", +"disp('Probability of error of local oscillator with phase shift is '+string(Pe_local_oscillator));\n", +"\n", +"//Timing error t\n", +"t = 0.1*T;\n", +"\n", +"//Probability of error when there is a synchronization fault Pe_timing_error\n", +"Pe_timing_error = 0.5*erfc(((Es/n)*(1 - 2*(t/T))^2)^0.5);\n", +"\n", +"disp('Probability of error with synchronization fault is '+string(Pe_timing_error));\n", +"\n", +"//Probability of error when both faults occur Pe_both\n", +"Pe_both = 0.5*erfc(((Es/n)*(cos(phi)^2)*(1 - 2*(t/T))^2)^0.5);\n", +"\n", +"disp('Probability of error when both faults occur '+string(Pe_both));\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.7: Error_probability_of_coherent_FSK_signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 575\n", +"//problem 11.7\n", +"\n", +"//Amplitude of signal is A = 10 mV\n", +"A = 10*10^-3;\n", +"\n", +"//Power Spectral Density n = 2 * 10^(-9) W/Hz\n", +"n = 2 * 10^(-9);\n", +"\n", +"//Data rate is D = 10^4 bps;\n", +"D = 10^4;\n", +"\n", +"//Time taken for a bit to traverse\n", +"T = 1/D;\n", +"\n", +"//Energy per signal element is Es\n", +"Es = A^2/(2*D);\n", +"\n", +"//Probability of error Pe_a\n", +"Pe_a = 0.5*erfc((0.6*Es/n)^0.5);\n", +"disp('Probability of error when offset is small is '+string(Pe_a));\n", +"\n", +"//Probability of error Pe_b\n", +"Pe_b = 0.5*erfc((Es/(2*n))^0.5);\n", +"disp('Probability of error when frequencies used are orthogonal is '+string(Pe_b));\n", +"\n", +"//Probability of error Pe_c\n", +"Pe_c = 0.5*exp(-(Es/(2*n)));\n", +"disp('Probability of error for non coherent detection is '+string(Pe_c));\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.8: Error_probability_in_Optimal_Reception.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 588\n", +"//problem 11.8\n", +"\n", +"//Energy aasosciated with each bit Eb = 5 * 10^(-8) J\n", +"Eb = 5 * 10^(-8);\n", +"\n", +"//Power Spectral Density n = 2 * 10^(-9) W/Hz\n", +"n = 2 * 10^(-9);\n", +"\n", +"//No of symbols M\n", +"M = 16\n", +"\n", +"//No of bits N\n", +"N = log2(M);\n", +"\n", +"//Error limit for 16-PSK is P_16_PSK\n", +"P_16_PSK = erfc(((N*Eb*(%pi)^2)/(((M)^2)*n))^0.5);\n", +"\n", +"disp('Upper limit of error probability of 16 PSK system is '+string(P_16_PSK));\n", +"\n", +"//Error limit for 16-QASK is P_16_QASK\n", +"P_16_QASK = 2*erfc(((0.4*Eb)/(n))^0.5);\n", +"\n", +"disp('Upper limit of error probability of 16 QASK system is '+string(P_16_QASK));\n", +"\n", +"//Error limit for 16-FSK is P_16_FSK\n", +"P_16_FSK = ((2^4 - 1)/2)*erfc(((N*Eb)/(2*n))^0.5);\n", +"\n", +"disp('Upper limit of error probability of 16 FSK system is '+string(P_16_FSK)+', negligibly small');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.9: Probability_of_error_of_QPR_System.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 595\n", +"//problem 11.9\n", +"\n", +"//Energy aasosciated with each bit Eb = 5 * 10^(-8) J\n", +"Eb = 5 * 10^(-8);\n", +"\n", +"//Power Spectral Density n = 2 * 10^(-9) W/Hz\n", +"n = 2 * 10^(-9);\n", +"\n", +"//Probability of error Pe\n", +"Pe = 0.5*erfc(((Eb*(%pi)^2)/(16*n))^0.5);\n", +"\n", +"disp('Probability of error of QPR system is '+string(Pe));\n", +"\n", +"//Given Bandwidth of channel is BW\n", +"BW = 10*10^3;\n", +"\n", +"D = 2*BW;\n", +"\n", +"disp('Data rate is '+string(D)+' bps');\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/12-Noise_in_Pulse_Code_Modulation_and_Delta_Modulation_Systems.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/12-Noise_in_Pulse_Code_Modulation_and_Delta_Modulation_Systems.ipynb new file mode 100644 index 0000000..56064f7 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/12-Noise_in_Pulse_Code_Modulation_and_Delta_Modulation_Systems.ipynb @@ -0,0 +1,258 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 12: Noise in Pulse Code Modulation and Delta Modulation Systems" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.2: SNR_Optimal_receiver.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 608\n", +"//problem 12.2\n", +"\n", +"//Baseband cutoff signal fM = 4 kHz\n", +"fM = 4 * 10^3;\n", +"\n", +"//White noise power spectral density n\n", +"n = 2*10^(-9);\n", +"\n", +"// Part (a)\n", +"\n", +"//Input Signal energy Si = 0.001\n", +"Si_a = 0.001;\n", +"\n", +"//No of levels used for PCM Coding M = 8\n", +"M_a = 8;\n", +"\n", +"N_a = log2(M_a);\n", +"\n", +"//Input SNR is SNR_ip\n", +"SNR_ip = Si_a/(n*fM);\n", +"\n", +"//Output SNR is SNR_op\n", +"SNR_op = (2^(2*N_a))/(1 + (2^(2*N_a + 1))*erfc((SNR_ip*(1/(2*N_a))))^0.5);\n", +"\n", +"disp('Input SNR for (a) is '+string(10*log10(SNR_ip))+' dB');\n", +"disp('Output SNR (a) is '+string(10*log10(SNR_op))+' dB');\n", +"\n", +"// Part (b)\n", +"\n", +"//Input Signal energy Si = 0.001\n", +"Si_b = 0.001;\n", +"\n", +"//No of levels used for PCM Coding M = 256\n", +"M_b = 256;\n", +"\n", +"N_b = log2(M_b);\n", +"\n", +"//Input SNR is SNR_ip_b\n", +"SNR_ip_b = Si_b/(n*fM);\n", +"\n", +"//Output SNR is SNR_op_b\n", +"SNR_op_b = (2^(2*N_b))/(1 + (2^(2*N_b + 1))*erfc((SNR_ip_b*(1/(2*N_b))))^0.5);\n", +"\n", +"//Unfortunately in scilab the function erfc approximates the output value to a larger extent due to which an exact value cannot be obtained.\n", +"//The difference in the textbook answer and obatined answer is significant because of converting the answer into dB.\n", +"\n", +"disp('Input SNR for (b) is '+string(10*log10(SNR_ip_b))+' dB');\n", +"disp('Output SNR for (b) is '+string(10*log10(SNR_op_b))+' dB');\n", +"\n", +"// Part (c)\n", +"\n", +"//Input Signal energy Si = 0.01\n", +"Si_c = 0.01;\n", +"\n", +"//No of levels used for PCM Coding M = 256\n", +"M_c = 256;\n", +"\n", +"N_c = log2(M_c);\n", +"\n", +"//Input SNR is SNR_ip_c\n", +"SNR_ip_c = Si_c/(n*fM);\n", +"\n", +"//Output SNR is SNR_op_c\n", +"SNR_op_c = (2^(2*N_c))/(1 + (2^(2*N_c + 1))*erfc((SNR_ip_c*(1/(2*N_c))))^0.5);\n", +"\n", +"disp('Input SNR for (c) is '+string(10*log10(SNR_ip_c))+' dB');\n", +"disp('Output SNR for (c) is '+string(10*log10(SNR_op_c))+' dB');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.3: SNR_of_Optimal_reciver.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 609\n", +"//problem 12.3\n", +"\n", +"//Baseband cutoff signal fM = 4 kHz\n", +"fM = 4 * 10^3;\n", +"\n", +"//White noise power spectral density n\n", +"n = 2*10^(-9);\n", +"\n", +"// Part (a)\n", +"\n", +"//Input Signal energy Si = 0.001\n", +"Si = 0.001;\n", +"\n", +"//No of levels used for PCM Coding M = 8\n", +"M = 8;\n", +"\n", +"N = log2(M);\n", +"\n", +"//Input SNR is SNR_ip\n", +"SNR_ip = Si/(n*fM);\n", +"\n", +"//Output SNR is SNR_op\n", +"SNR_op = (2^(2*N))/(1 + (2^(2*N + 1))*erfc((SNR_ip*(3/(10*N))))^0.5);\n", +"\n", +"disp('Input SNR for (a) is '+string(10*log10(SNR_ip))+' dB');\n", +"disp('Output SNR (a) is '+string(10*log10(SNR_op))+' dB');\n", +"\n", +"// Part (b)\n", +"\n", +"//Input Signal energy Si = 0.001\n", +"Si = 0.001;\n", +"\n", +"//No of levels used for PCM Coding M = 256\n", +"M_b = 256;\n", +"\n", +"N_b = log2(M_b);\n", +"\n", +"//Input SNR is SNR_ip_b\n", +"SNR_ip_b = Si/(n*fM);\n", +"\n", +"//Output SNR is SNR_op_b\n", +"SNR_op_b = (2^(2*N_b))/(1 + (2^(2*N_b + 1))*erfc((SNR_ip_b*(3/(10*N_b))))^0.5);\n", +"\n", +"//Unfortunately in scilab the function erfc approximates the output value to a larger extent due to which an exact value cannot be obtained.\n", +"//The difference in the textbook answer and obatined answer is significant because of converting the answer into dB.\n", +"\n", +"disp('Input SNR for (b) is '+string(10*log10(SNR_ip_b))+' dB');\n", +"disp('Output SNR for (b) is '+string(10*log10(SNR_op_b))+' dB');\n", +"\n", +"// Part (c)\n", +"\n", +"//Input Signal energy Si = 0.01\n", +"Si = 0.01;\n", +"\n", +"//No of levels used for PCM Coding M = 256\n", +"M = 256;\n", +"\n", +"N = log2(M);\n", +"\n", +"//Input SNR is SNR_ip_c\n", +"SNR_ip_c = Si/(n*fM);\n", +"\n", +"//Output SNR is SNR_op_c\n", +"SNR_op_c = (2^(2*N))/(1 + (2^(2*N + 1))*erfc((SNR_ip_c*(3/(10*N))))^0.5);\n", +"\n", +"disp('Input SNR for (c) is '+string(10*log10(SNR_ip_c))+' dB');\n", +"disp('Output SNR for (c) is '+string(10*log10(SNR_op_c))+' dB');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.4: Output_SNR_in_DM_including_Thermal_Noise.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 618\n", +"//problem 12.4\n", +"\n", +"//Upper cut off frequecny fb = 3200 Hz\n", +"fM = 3200;\n", +"\n", +"//Lower cut off frequecny fl = 300 Hz\n", +"fl = 300;\n", +"\n", +"//Data rate fb = 32000 bps\n", +"fb = 32000;\n", +"\n", +"//White noise power spectral density n\n", +"n = 2*10^(-9);\n", +"\n", +"//Input Signal energy Si = 0.001\n", +"Si = 0.001;\n", +"\n", +"//Output SNR is SNR_op\n", +"SNR_op = (0.6*(fb/fM)^3)/(1 + (0.3*(fb^2/(fl*fM)))*erfc(Si/(n*fb)));\n", +"\n", +"disp('Output SNR is '+string(10*log10(SNR_op))+'dB');\n", +"\n", +"//Data rate fb_n = 32000 bps\n", +"fb_n = 2*32000;\n", +"\n", +"//Output SNR is SNR_op_n\n", +"SNR_op_n = (0.6*(fb_n/fM)^3)/(1 + (0.3*(fb_n^2/(fl*fM)))*erfc(Si/(n*fb_n)));\n", +"\n", +"disp('Output SNR when data rate is doubled is '+string(10*log10(SNR_op_n))+'dB');" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/13-Information_Theory_and_Coding.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/13-Information_Theory_and_Coding.ipynb new file mode 100644 index 0000000..6543ae2 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/13-Information_Theory_and_Coding.ipynb @@ -0,0 +1,406 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 13: Information Theory and Coding" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.11: Turbo_code.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 696\n", +"//problem 13.11\n", +"\n", +"//The output equations are as follows v1 = s1 xor s2 xor s3 & v2 = s1 xor s3\n", +"//the no of bits in output mode(bits_out) is v*(L+K), v = no of outputs for commutatot = 2, L = length of input = 3 & K = no of memeory elements = 3\n", +"v = 2\n", +"L = 3\n", +"K = 3\n", +"bits_out = v*(L+K)\n", +"\n", +"//Taking in, s1, s2 , s3, v1 & v2 as row matrix where each column represents its corresponding input or output, in means input\n", +"in = [0 1 0 1 0 0 0]\n", +"\n", +"s1 = zeros(1,7)\n", +"s2 = zeros(1,7)\n", +"s3 = zeros(1,7)\n", +"v1 = zeros(1,7)\n", +"v2 = zeros(1,7)\n", +"\n", +"\n", +"for i = 2:7\n", +" s3(i) = s2(i-1)\n", +" s2(i) = s1(i-1)\n", +" s1(i) = in(i-1)\n", +" v1(i-1) = bitxor(s1(i),bitxor(s2(i),s3(i)))\n", +" v2(i-1) = bitxor(s1(i),s3(i))\n", +"end\n", +"\n", +"//Output matrix is out\n", +"out = zeros(1,12)\n", +"for i = [1 3 5 7 9 11]\n", +" out(i) = v1((i+3)/2)\n", +" out(i+1) = v2((i+3)/2)\n", +"end\n", +"\n", +"disp('output is')\n", +"disp(out)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.12: Turbo_code.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 697\n", +"//problem 13.12\n", +"\n", +"//The qeneratr matrix requires impulse response of the coder.\n", +"//This is the ourput generated when the initially reset coder is fed with a single 1.\n", +"//The no of bits in the output code = 2(1+3) = 8\n", +"\n", +"//Taking in, s1, s2 , s3, v1 & v2 as row matrix where each column represents its corresponding input or output, in means input\n", +"in = [0 1 0 0 0]\n", +"\n", +"s1 = zeros(1,5)\n", +"s2 = zeros(1,5)\n", +"s3 = zeros(1,5)\n", +"v1 = zeros(1,5)\n", +"v2 = zeros(1,5)\n", +"\n", +"\n", +"for i = 2:5\n", +" s3(i) = s2(i-1)\n", +" s2(i) = s1(i-1)\n", +" s1(i) = in(i-1)\n", +" v1(i-1) = bitxor(s1(i),bitxor(s2(i),s3(i)))\n", +" v2(i-1) = bitxor(s1(i),s3(i))\n", +"end\n", +"\n", +"//Output matrix is out\n", +"out = zeros(1,8)\n", +"for i = [1 3 5 7]\n", +" out(i) = v1((i+3)/2)\n", +" out(i+1) = v2((i+3)/2)\n", +"end\n", +"\n", +"disp('impulse response is')\n", +"disp(out)\n", +"\n", +"//Then generator matrix is G\n", +"G = [1 1 1 0 1 1 0 0 0 0 0 0;0 0 1 1 1 0 1 1 0 0 0 0;0 0 0 0 1 1 1 0 1 1 0 0]\n", +"\n", +"//Note that, in G, impulse responses appear in staggered apper in a staggered manner in each row while the rest of the elements are 0.\n", +"\n", +"//Now, output is b_o = b_i*G where input b_i =[1 0 1] \n", +"b_i = [1 0 1]\n", +"\n", +"b_o = b_i*G\n", +"\n", +"//Here multiplication means Exor operation so whereever two occurs it should be changed to 1\n", +"\n", +"for i = 1:12\n", +" if b_o(i) > 1 then\n", +" b_o(i) = 0;\n", +" end\n", +"end\n", +"\n", +"disp('output is ')\n", +"disp(b_o)\n", +"disp('The output obtained is exactly same as example 13.1')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.14: GO_back_N_algorithm.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 701\n", +"//problem 13.14\n", +"\n", +"//Given, Tw = 10microsec, BCH(1023973) code is used implies k as 973 & n as 1023, P_A = 0.99, T1 = 40microsec & N = 4\n", +"Tw = 10*10^-6\n", +"k = 973\n", +"n = 1023\n", +"P_A = 0.99\n", +"T1 = 40*10^-6\n", +"N = 4\n", +"\n", +"//efficiency of Stop-and-Wait ARQ(n_SandW) = (k/n)*(P_A/(1+(T1/Tw)))\n", +"n_SandW = (k/n)*(P_A/(1+(T1/Tw)))\n", +"\n", +"//efficiency of Go-Back-N ARQ(n_GBN) = (k/n)*(1/(1+(N*(1-P_A)/P_A)))\n", +"n_GBN = (k/n)*(1/(1+(N*(1-P_A)/P_A)))\n", +"\n", +"//efficiency of Selective Repeat ARQ(n_SR) = (k/n)*P_A\n", +"n_SR = (k/n)*P_A\n", +"\n", +"disp('efficiency of Stop-and-Wait ARQ is '+string(n_SandW))\n", +"disp('efficiency of Go-Back-N ARQ is '+string(n_GBN))\n", +"disp('efficiency of Selective Repeat ARQ is '+string(n_SR))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.15: Power_of_a_Transmitter.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 718\n", +"//problem 13.15\n", +"\n", +"//Bit interval T = 1/10^6 = 10^-6 sec \n", +"T = 10^-6\n", +"\n", +"//White Noise Power Spectral Density n/2 = 10^-9 W/Hz\n", +"n = 2*10^-9\n", +"\n", +"//Power required Ps = Eb/T, where Eb = energy per bit\n", +"\n", +"//For information system feedback system Eb = n\n", +"Ps = n/T\n", +"\n", +"disp('power required for information system feedback system is '+string(Ps)+' Watt')\n", +"\n", +"//For optimal system Ps = (0.69 * n)/T\n", +"Ps = (0.69 * n)/T;\n", +"\n", +"disp('power required for optimal system is '+string(Ps)+' Watt')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.16: Probability_of_error_for_Trellis_decoded_modulatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 719\n", +"//problem 13.16\n", +"\n", +"//Given, Eb = 10^-9Joule, n/2 = 10^-9 Watt/Hertz\n", +"Eb = 10^-8\n", +"n = 2*10^-9\n", +"\n", +"//Probability of error for trellis-decoded modulation(Pe) = (1/2)*erfc(sqrt(1.5*Eb/n))\n", +"Pe = (1/2)*erfc(sqrt(1.5*Eb/n))\n", +"\n", +"disp('Probability of error for trellis-decoded modulation is '+string(Pe))\n", +"\n", +"//Probability of error for Qpsk modulation(Pe) = (1/2)*erfc(sqrt(Eb/n))\n", +"Pe = (1/2)*erfc(sqrt(Eb/n))\n", +"\n", +"disp('Probability of error for Qpsk modulation is '+string(Pe))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.1: Information_rate_of_source.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 631\n", +"//problem 13.1\n", +"\n", +"//Given probabilities p1 = p4 = 1/8 & p2 = p3 = 3/8\n", +"p1 = 1/8\n", +"p4 = 1/8\n", +"p2 = 3/8\n", +"p3 = 3/8\n", +"\n", +"//The average information H is p1*log2 (1/p1)+p2*log2 (1/p2)+p3*log2 (1/p3)+p4*log2 (1/p4) bits/message\n", +"H = p1*log2 (1/p1)+p2*log2 (1/p2)+p3*log2 (1/p3)+p4*log2 (1/p4)\n", +"\n", +"//information rate R is r*H bits/sec where r is 2*B\n", +"//R1 = R/B\n", +"R1 = 2*H\n", +"\n", +"disp('The average information is '+string(H)+' bits/message')\n", +"disp('Information rate '+string(R1)+'*B bits/sec')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.4: Channel_Capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 649\n", +"//problem 13.4\n", +"\n", +"//Given bandwidth(B) = 4000Hertz & Noise PSD(n/2) = 10^-9 Watt/Hertz\n", +"B = 4000\n", +"n = 2*10^-9\n", +"\n", +"//Chanel capacity(C) = B*log2 (1+S/(n*B))\n", +"\n", +"//case 1\n", +"//Signal energy(S) = 0.1Joule\n", +"S = 0.1\n", +"\n", +"C = B*log2 (1+S/(n*B))\n", +"\n", +"disp('Channel capacity for bandwidth = 4000Hertz, Noise PSD = 10^-9 Watt/Hertz & Signal energy(S) = 0.1Joule is '+string(C)+' bits/sec')\n", +"\n", +"//case 2\n", +"//Signal energy(S) = 0.001Joule\n", +"S = 0.001\n", +"\n", +"C = B*log2 (1+S/(n*B))\n", +"\n", +"disp('Channel capacity for bandwidth = 4000Hertz, Noise PSD = 10^-9 Watt/Hertz & Signal energy(S) = 0.001Joule is '+string(C)+' bits/sec')\n", +"\n", +"//case 3\n", +"//Signal energy(S) = 0.001Joule & incresed bandwidth(B) = 10000Hertz\n", +"B = 10000\n", +"S = 0.001\n", +"\n", +"C = B*log2 (1+S/(n*B))\n", +"\n", +"disp('Channel capacity for bandwidth = 10000Hertz, Noise PSD = 10^-9 Watt/Hertz & Signal energy(S) = 0.001Joule is '+string(C)+' bits/sec')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.8: Probability_of_error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 675\n", +"//problem 13.8\n", +"\n", +"//With single parity bit added, the code size = 4. An error evades parity check if any 2 or all symbols ofthe code arrives are erroneous.\n", +"//Probability of any symbol from n are erroneous = nCm*(p^m)*(1-p)^(n-m)\n", +"\n", +"//Thus, the probability of error undetected, P_undeterr = (4C2*(p^2)*(1-p)^2)+4C4*(p^4) = 6*(p^2)*(1-p)^2)+(p^4)\n", +"\n", +"//Probability of error in detection(P_undeterr1) for p = 0.1\n", +"p = 0.1\n", +"P_undeterr1 = 6*(p^2)*((1-p)^2)+(p^4)\n", +"\n", +"disp('Probability of error in detection for p = 0.1 is '+string(P_undeterr1))\n", +"\n", +"//Probability of error in detection(P_undeterr2) for p = 0.01\n", +"p = 0.01\n", +"P_undeterr2 = 6*(p^2)*((1-p)^2)+(p^4)\n", +"\n", +"disp('Probability of error in detection for p = 0.01 is '+string(P_undeterr2))" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/14-Communication_Systems_and_Component_Noises.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/14-Communication_Systems_and_Component_Noises.ipynb new file mode 100644 index 0000000..aebb8bd --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/14-Communication_Systems_and_Component_Noises.ipynb @@ -0,0 +1,199 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 14: Communication Systems and Component Noises" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.1: Thermal_noise_voltage.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 738\n", +"//problem 14.1\n", +"\n", +"//Boltzman constant k = 1.3806488 × 10-23 m2 kg s-2 K-1\n", +"k = 1.3806488 * 10^-23; \n", +"\n", +"//Let room temperature be 27 C\n", +"T = 27 + 273; \n", +"\n", +"//Bandwidth BW = 10 MHz\n", +"BW = 10 * 10 ^6;\n", +"\n", +"//For (a)\n", +"//Let the equivalent resistance be Ra\n", +"Ra = 10 + 10;\n", +"\n", +"//RMS Noise Voltage be Va\n", +"Va = (4*k*T*Ra*BW)^0.5;\n", +"\n", +"disp('The rms voltage at output a is '+string(Va)+' Volt');\n", +"\n", +"//For (b)\n", +"//Let the equivalent resistance be Rb\n", +"Rb = (10 * 10)/(10+10);\n", +"\n", +"//RMS Noise Voltage be Vb\n", +"Vb = (4*k*T*Rb*BW)^0.5;\n", +"\n", +"disp('The rms voltage at output b is '+string(Vb)+' Volt');\n", +"\n", +"//For (c)\n", +"\n", +"Rc = 10;\n", +"C = 1*10^-9;\n", +"\n", +"//In the textbook, the author has forgotten to multiply the result with T, hence has obtained an erroneous result.\n", +"//The given answer is 28.01uV but the correct answer is found out to be 1.2uV\n", +"\n", +"Vc_square = 2*k*integrate('Rc/(1 + (2*%pi*Rc*C*f)^2)','f',-10^7,10^7);\n", +"Vc = Vc_square^0.5;\n", +"\n", +"disp('The rms voltage at output c is '+string(Vc)+' Volt');\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.2: Output_Noise_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 741\n", +"//problem 14.2\n", +"\n", +"//The Antenna noise temperature is T_ant = 10 K\n", +"T_ant = 10;\n", +"\n", +"//The reciever noise temperature is Te = 140 K\n", +"Te = 140;\n", +"\n", +"//Midband available gain of reciever gao = 10^10\n", +"gao = 10^10;\n", +"\n", +"//Noise bandwidth is BN = 1.5 * 10^5 Hz\n", +"BN = 1.5 * 10^5;\n", +"\n", +"//Boltzman constant k = 1.3806488 × 10-23 m2 kg s-2 K-1\n", +"k = 1.3806488 * 10^-23; \n", +"\n", +"//Available noise power at output is pao\n", +"\n", +"pao = gao*k*(T_ant + Te)*BN;\n", +"\n", +"disp('The available output noise power is '+string(pao)+' Watts');\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.3: Transmitted_power_of_antenna.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 748\n", +"//problem 14.3\n", +"\n", +"//The distance d = 30 * 1.6 * 10^3 m;\n", +"d = 30 * 1.6 * 10^3;\n", +"\n", +"//Frequency f = 4 * 10^9 Hz\n", +"f = 4 * 10^9;\n", +"\n", +"//Wavelength w = c/f m \n", +"w = 3*10^8 / f;\n", +"\n", +"//Transmitter gain KT = 40 dB\n", +"KT = 10^4;\n", +"\n", +"//Reciever gain KT = 40 dB\n", +"KR = 10^4;\n", +"\n", +"//Reciever power PR = 10^-6 Watt\n", +"PR = 10^-6;\n", +"\n", +"//Transmitter power PT\n", +"PT = PR*(4*%pi*d/w)^2/ (KT*KR);\n", +"\n", +"disp('The transmitter output is '+string(PT)+' Watt')\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/15-Spread_Spectrum_Modulation.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/15-Spread_Spectrum_Modulation.ipynb new file mode 100644 index 0000000..ee8f896 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/15-Spread_Spectrum_Modulation.ipynb @@ -0,0 +1,162 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 15: Spread Spectrum Modulation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 15.1: Jamming.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 764\n", +"//problem 15.1\n", +"\n", +"//Signal Power data rate fb = 100 Kbps\n", +"fb = 10^5;\n", +"\n", +"//Signal Strength Ps = 1 mW\n", +"Ps = 1*10^(-3);\n", +"\n", +"//Chip frequency fs = 100 MHz\n", +"fs = 10^8;\n", +"\n", +"//Noise Spectral Density n = 2*10^(-9) W/Hz\n", +"n = 2*10^(-9);\n", +"\n", +"//Jamming Signal power is Pj = 1 W\n", +"Pj = 1;\n", +"\n", +"//Processing Gain P\n", +"P = fs/fb;\n", +"disp('Processing Gain is '+string(P));\n", +"\n", +"//Bit Interval T\n", +"T = 1/fb;\n", +"disp('Bit Interval is '+string(T)+'s');\n", +"\n", +"//Energy per bit Eb\n", +"Eb = Ps*T;\n", +"disp('Energy per bit is '+string(Eb));\n", +"\n", +"//Error Probability without jamming E_without_jamming\n", +"E_without_jamming = 0.5*erfc((Eb/(n))^0.5);\n", +"disp('Error probability without jamming is '+string(E_without_jamming));\n", +"\n", +"//Error Probability with jamming E_jamming\n", +"E_jamming = 0.5*erfc(((2*Ps*P)/(Pj))^0.5);\n", +"disp('Error probability jamming is '+string(E_jamming));\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 15.2: Ranging_using_DS_spread_spectrum.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 764\n", +"//problem 15.2\n", +"\n", +"//Chip Rate fc = 110 MHz\n", +"fc = 10*10^6;\n", +"Tc = 1/fc;\n", +"\n", +"//Delay D = 0.1 ms\n", +"D = 0.1*10^-3;\n", +"\n", +"//Speed of light c = 3*10^8 Kmps\n", +"c = 3*10^8;\n", +"\n", +"//Estimated Distance d\n", +"d = 0.5*c*D;\n", +"\n", +"//Tolerance Tol\n", +"Tol = 0.5*c*Tc;\n", +"\n", +"disp('The target is between '+string(d-Tol)+' metres and '+string(d+Tol)+' metres of the source.');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 15.3: Sequence_length.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 769\n", +"//problem 15.3\n", +"\n", +"//Number of Flip Flops N\n", +"N = 13;\n", +"\n", +"//Maximal length of sequence L\n", +"L = 2^N - 1;\n", +"\n", +"//Upper Bound S\n", +"S = (L - 1)/N;\n", +"\n", +"//No of basic sequences and mirror images\n", +"disp('No of basic sequences and mirror images is '+string(S/2)');\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/2-Random_Variables_and_Processes.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/2-Random_Variables_and_Processes.ipynb new file mode 100644 index 0000000..fd3bf64 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/2-Random_Variables_and_Processes.ipynb @@ -0,0 +1,475 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2: Random Variables and Processes" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.10: Probability_of_Error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 105\n", +"//problem 2.10\n", +"\n", +"//We know that, Probabilty of error(P_error) for the signal correpted by Gaussian channel variance sigma^2 where signal having voltage levels as 0&V is (1/2)*erfc(V/(2*sqrt(2)*sigma))\n", +"\n", +"//P_error for V = 4 & sigma^2 =2\n", +"V = 4\n", +"sigma = sqrt(2)\n", +"P_error = (1/2)*erfc(V/(2*sqrt(2)*sigma))\n", +"\n", +"disp('Probabilty of error for V = 4 & sigma^2 =2 is '+string(P_error))\n", +"\n", +"//P_error for V = 2 & sigma^2 =2\n", +"V = 2\n", +"sigma = sqrt(2)\n", +"P_error = (1/2)*erfc(V/(2*sqrt(2)*sigma))\n", +"\n", +"disp('Probabilty of error for V = 2 & sigma^2 =2 is '+string(P_error))\n", +"\n", +"//P_error for V = 4 & sigma^2 =4\n", +"V = 4\n", +"sigma = sqrt(4)\n", +"P_error = (1/2)*erfc(V/(2*sqrt(2)*sigma))\n", +"\n", +"disp('Probabilty of error for V = 4 & sigma^2 =4 is '+string(P_error))\n", +"\n", +"//P_error for V = 8 & sigma^2 =2\n", +"V = 8\n", +"sigma = sqrt(2)\n", +"P_error = (1/2)*erfc(V/(2*sqrt(2)*sigma))\n", +"\n", +"disp('Probabilty of error for V = 8 & sigma^2 =2 is '+string(P_error))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.11: Probability_of_Error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 106\n", +"//problem 2.11\n", +"\n", +"//(a)\n", +"//out of n attempts the probability of message reaching correctly for k times is given by binomial distribution pX(k) = nCk*(q^k)*(1-q)^(n-k) where q is probability of correctly reaching\n", +"\n", +"//Here n = 10, k = 1, q = 0.001\n", +"n = 10\n", +"k = 1\n", +"q = 0.001\n", +"\n", +"//pX(k) is denoted as p_X_1\n", +"//10C1 =10\n", +"p_X_1 = 10*(q^k)*(1-q)^(n-k)\n", +"\n", +"disp('The probability that out of 10 transmissions 9 are corrent and 1 is incorrect is '+string(p_X_1))\n", +"\n", +"//probability that more than two erroneous out of 100 transmissions(p_100_2) = 1-probability of less than or equal to two error in transmission\n", +"//p_100_2 = 1-pX(0)-pX(1)-pX(2)\n", +"//p_100_2 =1-100C0*((0.001)^0)*((1-0.001)^100)-100C1*((0.001)^1)*((1-0.001)^99)-100C0*((0.001)^2)*((1-0.001)^98)\n", +"\n", +"//Since, calculation of above is cumbersome we may use Poisson ditribution to approximate above\n", +"//Poisson distribution = pX(k) = (alfa^k)*(e^-alfa)/k!, where alfa = n*T\n", +"\n", +"//Here n = 100 & q = 0.001\n", +"n = 100\n", +"q = 0.001\n", +"\n", +"alfa = n*q\n", +"\n", +"p_100_2 = 1-(alfa^0)*(%e^-0.1)/factorial(0)-(alfa^1)*(%e^-0.1)/factorial(1)-(alfa^2)*(%e^-0.1)/factorial(2)\n", +"\n", +"disp('probability that more than two erroneous out of 100 transmissions is '+string(p_100_2))\n", +"\n", +"//(c)\n", +"//from(b), required probability i.e probability of more than one are erroneous out of 100 transmission(p_100_1) is\n", +"p_100_1 = 1-(alfa^0)*(%e^-0.1)/factorial(0)-(alfa^1)*(%e^-0.1)/factorial(1)\n", +"\n", +"disp('probability that more than one erroneous out of 100 transmissions is '+string(p_100_1))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.13: Probability_of_Error.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 115\n", +"//problem 2.13\n", +"\n", +"//Given, Error probability is 10^-4 = P_e, no of ecperiments conducted = N = 4*10^5 & estimated probability of error p does not differ from P_e by more than 50%\n", +"P_e = 10^-4\n", +"N = 4*10^5\n", +"\n", +"//Tchebycheff's inequality is P(|p-Pe|>=E)<=P_e/(N*E^2)\n", +"//From given values we can find that E = 50*10^-4\n", +"E = 50*10^-4\n", +"\n", +"//Here R.H.S of Tchebycheff's inequality is denoted as Tc_RHS\n", +"Tc_RHS = P_e/(N*E^2)\n", +"\n", +"//Tc_RHS in persentage is Tc_RHSper\n", +"Tc_RHSper = Tc_RHS/100\n", +"\n", +"//disp(Tc_RHSper,Tc_RHS,'or P(|p-10^-4|>=0.5*10^-2)<=',Tc_RHS,'The probability of estimated probability of error p does not differ from P_e by more than 50% is less than equal to')\n", +"\n", +"//given solution has been computed wrong, obtaines solution is 10^-7\n", +"disp('The probability of estimated probability of error p does not differ from P_e by more than 50% is less than equal to '+string(Tc_RHS)+'or P(|p-10^-4|>=0.5*10^-2)<='+string(Tc_RHS)+' = '+string(Tc_RHSper)+'%')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1: Probability_of_two_Events.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 85\n", +"//problem 2.1\n", +"\n", +"//A & B are two events occured in sample space S, where P(A) & P(B) are their corresponding probability\n", +"P_S=1\n", +"\n", +"//Given A&B are not mutually exclusive events, \n", +"//Probability of A is 0.2 = P_A\n", +"//Probability of B is 0.4 = P_B\n", +"//Probability of either A or B is 0.5 = P_AUB\n", +"P_A = 0.2\n", +"P_B = 0.4\n", +"P_AUB = 0.5\n", +"\n", +"//Probability of both of A&B jointly occur is P_AinterB = P_A+P_B-P_AUB where inter is intersection\n", +"P_AinterB = P_A+P_B-P_AUB\n", +"\n", +"disp('Probability of both of A&B jointly occur is '+string(P_AinterB))\n", +"\n", +"//Probability of none of AorB are occur is P_NOAB = Total occurence(P_S) - Probability of either AorB(P_AUB)\n", +"P_NOAB = P_S-P_AUB\n", +"\n", +"disp('Probability of none of AorB are occur is '+string(P_NOAB))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2: Bayes_Theorem.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 86\n", +"//problem 2.2\n", +"\n", +"//Probability that A will occur if B has already occurred(P_AB) = ratio of Probability of joint occurence of A&B (P_A_B) & Probability of B(P_B)\n", +"//P_A_B(robability of joint occurence) = Probability that A&B both occur(P_AinterB)\n", +"\n", +"//From given values P_AinterB = 0.1 implies P_A_B = 0.1 & P_B = 0.4\n", +"P_AinterB = 0.1\n", +"P_A_B = P_AinterB \n", +"P_B = 0.4\n", +"\n", +"P_AB = P_A_B/P_B\n", +"\n", +"//Similarly\n", +"//Probability that B will occur if A has already occurred(P_BA) = ratio of Probability of joint occurence of A&B (P_A_B) & Probability of B(P_A)\n", +"\n", +"//From given values P_A = 0.2\n", +"P_A = 0.2\n", +"\n", +"P_BA = P_A_B/P_A\n", +"\n", +"//Bayes theorem says that P_AB = (P_A/P_B)*P_BA\n", +"//After Calculating LHS & RHS if both are equal then bayes theorem is satisfying\n", +"\n", +"//Calculating LHS\n", +"LHS = P_AB\n", +"\n", +"//Calculating RHS\n", +"RHS = (P_A/P_B)*P_BA\n", +"\n", +"disp('P(A/B) = '+string(P_AB) );\n", +"\n", +"if LHS == RHS then\n", +" disp('LHS = RHS, Hence Bayes theorem is verified' );\n", +"end\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5: Optimum_Receiver_Algorithm.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 95\n", +"//problem 2.5\n", +"\n", +"//Given, The probability that m0 is sent is 0.7 = P_m0\n", +"P_m0 = 0.7\n", +"\n", +"//The probability that m0 is sent is 0.3 = P_m1\n", +"P_m1 = 0.3\n", +"\n", +"//The probability that r0 is received given that m0 is sent is 0.9 = P_r0m0 where r is voltage & m is message\n", +"P_r0m0 = 0.9\n", +"\n", +"//the probability that r1 is received given that m0 is sent is 0.1 = P_r1m0 where r is voltage & m is message\n", +"P_r1m0 = 0.1\n", +"\n", +"//The probability that r1 is received given that m1 is sent is 0.6 = P_r1m1\n", +"P_r1m1 = 0.6\n", +"\n", +"//the probability that r0 is received given that m1 is sent is 0.4 = P_r0m1 where r is voltage & m is message\n", +"P_r0m1 = 0.4\n", +"\n", +"//With the given values check eqations P_r0m0*P_m0(P00) > P_r0m1*P_m1(P01)\n", +"P00 = P_r0m0*P_m0\n", +"P01 = P_r0m1*P_m1\n", +"\n", +"if P00>P01 then\n", +" disp('as P(r0|m0)*P(m0) > P(r0|m1)*P(m1) is valid, we whould select m0 whenever r0 is received')\n", +"end\n", +"\n", +"//With the given values check eqations P_r1m1*P_m1(P11) > P_r1m0*P_m0(P10)\n", +"P11 = P_r1m1*P_m1\n", +"P10 = P_r1m0*P_m0\n", +"\n", +"if P11>P10 then\n", +" disp('as P(r1|m1)*P(m1) > P(r1|m0)*P(m0) is valid, we whould select m1 whenever r1 is received')\n", +"end" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6: Optimum_Receiver_Algorithm.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 96\n", +"//problem 2.6\n", +"\n", +"//Given, the probability that r0 is received given that m0 is sent is 0.9 = P_r0m0 where r is voltage & m is message\n", +"P_r0m0 = 0.9\n", +"\n", +"//The probability that m0 is sent is 0.7 = P_m0\n", +"P_m0 = 0.7\n", +"\n", +"//The probability that r1 is received given that m1 is sent is 0.6 = P_r1m1\n", +"P_r1m1 = 0.6\n", +"\n", +"//The probability that m0 is sent is 0.3 = P_m1\n", +"P_m1 = 0.3\n", +"\n", +"//The probability that the transmitted signal is correctly read at receiver is P(c)(P_c) = the probability that m0 was sent when r0 was read(P_r0m0*P_m0) + the probability that m1 was sent when r1 was read(P_r1m1*P_m1)\n", +"\n", +"P_c = P_r0m0*P_m0+P_r1m1*P_m1\n", +"\n", +"//P(e)(P_e) = 1-P(c)\n", +"P_e = 1-P_c\n", +"\n", +"disp('P(e) = '+string(P_e))\n", +"disp('P(c) = '+string(P_c))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7: Optimum_Receiver.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 96\n", +"//problem 2.7\n", +"\n", +"//Here P(ra|mb) is denoted as P_ramb where a is 0,1,2 & b is 0,1\n", +"//P(X) is denoted as P_X where X is m0, m1, C & E\n", +"\n", +"//From given values P_m0 = 0.6, P_m1 = 0.4, P_r0m0 =0.6, P_r1m1 = 0.7, P_r0m1 = 0, P_r1m0 = 0.2, P_r2m0 = 0.2 & P_r2m1 = 0.3\n", +"P_m0 = 0.6\n", +"P_m1 = 0.4\n", +"P_r0m0 =0.6\n", +"P_r1m1 = 0.7\n", +"P_r0m1 = 0\n", +"P_r1m0 = 0.2\n", +"P_r2m0 = 0.2\n", +"P_r2m1 = 0.3\n", +"\n", +"//(a)\n", +"//Comaparing P(r0|m0)*P(m0) & P(r0|m1)*P(m1) gives result\n", +"LHS = P_r0m0*P_m0\n", +"RHS = P_r0m1*P_m1\n", +"\n", +"disp('As P(r0|m0)*P(m0)['+string(LHS)+'] > P(r0|m1)*P(m1)['+string(RHS)+']')\n", +"disp('we select m0 whenever r0 is received')\n", +"\n", +"//Similarly compare P(r1|m1)*P(m1) & P(r1|m0)*P(m0)\n", +"LHS = P_r1m1*P_m1\n", +"RHS = P_r1m0*P_m0\n", +"\n", +"disp('As P(r1|m1)*P(m1)['+string(LHS)+'] > P(r1|m0)*P(m0)['+string(RHS)+']')\n", +"disp('we select m1 whenever r1 is received')\n", +"\n", +"//compare P(r2|m0)*P(m0) & P(r2|m1)*P(m1)\n", +"LHS = P_r2m0*P_m0\n", +"RHS = P_r2m1*P_m1\n", +"\n", +"disp('As P(r2|m0)*P(m0)['+string(LHS)+'] = P(r2|m1)*P(m1)['+string(RHS)+']')\n", +"disp('We can accordingly make either assignment and we arbitrarily associate r2 with m0')\n", +"\n", +"//(b)\n", +"//The probability of being correct is P(C) = P(r0|m0)*P(m0)+P(r1|m1)*P(m1)+P(r2|m0)*P(m0)\n", +"P_C = P_r0m0*P_m0+P_r1m1*P_m1+P_r2m0*P_m0\n", +"\n", +"//The probability of error is P(E) = 1-P(C)\n", +"P_E = 1 - P_C;\n", +"\n", +"disp('Probability of being correct is P(C) = '+string(P_C)')\n", +"disp('Probability of error is P(E) = '+string(P_E)')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8: Probability_Distribution_Function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 99\n", +"//problem 2.8\n", +"\n", +"//Given, probability density function of X is fX_x where fX_x = a*e^(-0.2*x) for x greater than & equal to 0 & = 0 eleswhere\n", +"\n", +"//a = fX_x/(a*e^(-0.2*x))\n", +"//from definition integration of fX_x with limits -infinity to +infinity is 1\n", +"//As per given fX_x, integration of a*e^(-0.2*x) with limits 0 & +inffinity and obtained value be P\n", +"//a = 1/p\n", +"\n", +"P = integrate('%e^(-0.2*x)','x',0,100)\n", +"a = 1/P\n", +"\n", +"disp('a = '+string(a))" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/3-Amplitude_Modulation_Systems.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/3-Amplitude_Modulation_Systems.ipynb new file mode 100644 index 0000000..ba4e552 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/3-Amplitude_Modulation_Systems.ipynb @@ -0,0 +1,172 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: Amplitude Modulation Systems" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.4: Transmission_Power_Efficiency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 163\n", +"//problem 3.4\n", +"\n", +"//Transmission power effiency n = {(m^2)/[2+(m^2)]}*100% where m is modulated index\n", +"\n", +"//Given modulated indices are m1 = 0.25, m2 = 0.5 & m3 = 0.75\n", +"\n", +"//Transmission power effiencies are n1, n2 & n3 respectively for m1, m2 & m3\n", +"n1 = {(0.25^2)/[2+(0.25^2)]}*100\n", +"n2 = {(0.5^2)/[2+(0.5^2)]}*100\n", +"n3 = {(0.75^2)/[2+(0.75^2)]}*100\n", +"\n", +"disp('Transmission power effiency for modulated index 0.25 is '+string(n1)+ '%')\n", +"disp('Transmission power effiency for modulated index 0.5 is '+string(n2)+ '%')\n", +"disp('Transmission power effiency for modulated index 0.75 is '+string(n3)+ '%')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.7: Calculation_of_L_and_C_of_Power_Amplifier.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 185\n", +"//problem 3.7\n", +"\n", +"//Given input inmedance of matching networkis R1 = 10 ohm & output impedance of matching networ is R2 = 50 ohm & carrier frequency is fc = 500 KHz\n", +"R1 = 10\n", +"R2 = 50\n", +"fc = 500000\n", +"\n", +"//Wc = 2*pi*fc\n", +"Wc = 2*%pi*fc\n", +"\n", +"//AS R1 = R2*(X2^2)/[(R2^2)+(X2^2)], X2 = 25ohm\n", +"X2 = 25\n", +"\n", +"//AS X1 = (R2^2)*X2/[(R2^2)+(X2^2)] & R1>R2, X1 = -20ohm\n", +"X1 = -20\n", +"\n", +"//|X1| = |jwL| = wL = 20 & |X2| = |1/jwC| = 1/wC = 25, so |X1*X2| = L/C = 500 denotes as LC_div\n", +"LC_div = 500\n", +"\n", +"//Wc^2 = 1/(L*C). LC is denoted as LC_prod\n", +"LC_prod = 1/(Wc^2)\n", +"\n", +"//In the textbook the calculated LC = 10^-3, in reality the value of LC = 1.013D-13\n", +" \n", +"L = sqrt(LC_div*LC_prod)\n", +"\n", +"//In the textbook the calculated L^2 = 50*10^-14, in reality the value of L^2 = 5.066D-11 \n", +" \n", +"C = L/500\n", +"\n", +"//In the textbook the calculated C = 1.4*10^-9, in reality the value of C = 1.424D-08 \n", +"\n", +"disp('Inductance '+string(L)+' H')\n", +"disp('Capacitance '+string(C)+' F')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.8: Calculation_of_Gain_and_Power_radiated_of_Antenna.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 185\n", +"//problem 3.8\n", +"\n", +"//Given ohmnic loss resistance is Ro = 12 Ohm, \n", +"Ro = 12\n", +"\n", +"//radiation resistance is Rr = 48 Ohm,\n", +"Rr = 48\n", +"\n", +"//directivity is D = 2\n", +"D = 2\n", +"\n", +"//Input current = 0.1*cos[2*pi*(10^6)*t], Amplitude of input current is A = 0.1 Amp\n", +"A = 0.1\n", +"\n", +"//Equivalent resistance = Re = Ro+Rr\n", +"Re = Ro+Rr\n", +"\n", +"//Total power used in antenna = Pin = (A^2)*Re/2\n", +"Pin = (A^2)*Re/2\n", +"\n", +"//Power used in radiation = Prad = (A^2)*Rr/2\n", +"Prad = (A^2)*Rr/2\n", +"\n", +"//Efficiency of the antenna = n = Prad/Pin\n", +"n = Prad/Pin\n", +"\n", +"//Gain of antenna = Ga = efficiency*directivity\n", +"Ga = n*D\n", +"\n", +"disp('Total power used in antenna '+string(Pin)+' Watt')\n", +"disp('Power used in radiation '+string(Prad)+' Watt')\n", +"disp('Efficiency of the antenna '+string(n))\n", +"disp('Gain of antenna '+string(Ga))" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/4-Angle_Modulation.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/4-Angle_Modulation.ipynb new file mode 100644 index 0000000..989b10d --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/4-Angle_Modulation.ipynb @@ -0,0 +1,169 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4: Angle Modulation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2: Calculation_of_frequency_parameters.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 199\n", +"//problem 4.2\n", +"\n", +"//Given angle modulated signal is x = 3*cos[2*pi*(10^6)*t+2*sin(2*pi*10^3*t)]\n", +"\n", +"//So, phase of the angle modulates signal is Q = 2*pi*(10^6*t)+2*sin(2*pi*(10^3)*t)\n", +"\n", +"//Instantaneous frequency = dQ/dt = 2*pi*(10^6)+ 4*pi*(10^3)*sin(2*pi*(10^3)*t)\n", +"\n", +"//For Instantaneous frequency at 0.25ms, Substituting t = 0.25ms in Instantaneous frequency\n", +"//Instantaneous frequency is expressed as f1_rad for frequency in radians per second\n", +"f1_rad = 2*%pi*(10^6)+ 4*%pi*(10^3)*sin(2*%pi*(10^3)*0.00025)\n", +"\n", +"//Instantaneous frequency is expressed as f1_hz for frequency in hertz\n", +"f1_hz = f1_rad/(2*%pi)\n", +"\n", +"disp('the Instantaneous frequency at time t=0.25ms is '+string(f1_rad)+' rad/sec = '+string(f1_hz)+' Hz')\n", +"\n", +"//For Instantaneous frequency at 0.25ms, Substituting t = 0.5ms in Instantaneous frequency \n", +"//Instantaneous frequency is expressed as f2rad for frequency in radians per second\n", +"f2_rad = 2*%pi*(10^6)+ 4*%pi*(10^3)*sin(2*%pi*(10^3)*0.0005)\n", +"\n", +"//Instantaneous frequency is expressed as f2hz for frequency in hertz\n", +"f2_hz = f2_rad/(2*%pi)\n", +"\n", +"disp('the Instantaneous frequency at time t=0.5ms is '+string(f2_rad)+' rad/sec = '+string(f2_hz)+' Hz')\n", +"\n", +"//Maximum phase deviation = max[2*sin(2*pi*(10^3)*t)] = 2*1\n", +"maxDp = 2;\n", +"\n", +"disp('Maximum phase deviation is '+string(maxDp)+' rad')\n", +"\n", +"//Maximum frequency deviation = max[4*pi*(10^3)*sin(2*pi*(10^3)*t)] = 4*pi*(10^3)*1\n", +"maxDf = 4*%pi*(10^3)*1;\n", +"\n", +"disp('Maximum frequency deviation is '+string(maxDf)+' Hz')\n", +"//disp('in rad',maxDf,'Maximum frequency deviation is')\n", +"\n", +"//In the textbook the calculated value of max frequency devaition is = 2000 Hz, in reality the value = 12566.371 Hz " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.4: Calculation_of_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 208\n", +"//problem 4.4\n", +"\n", +"//Given modulating signal m(t) = 2*sin(2*pi*(10^3)*t), B for phase modulation Bp = 10 & for fequency modulation Bf = 10\n", +"Bp = 10\n", +"Bf = 10\n", +"\n", +"//So Amplitude of modulating signal is Am=2 metres\n", +"Am = 2\n", +"\n", +"//Frequency of modulating signal is fm = 1000 hertz\n", +"fm=1000\n", +"\n", +"//Bandwidth = 2*(1+B)*fm\n", +"\n", +"//Bandwidth for phase modulation with modulating signal m(t) is bw_pm = 2*(1+Bp)*fm\n", +"bw_pm = 2*(1+10)*1000\n", +"\n", +"//Bandwidth for frequency modulation with modulating signal m(t) is bw_fm = 2*(1+Bf)*fm\n", +"bw_fm = 2*(1+10)*1000\n", +"\n", +"disp('Bandwidth for phase modulation '+string(bw_pm)+' Hz')\n", +"disp('Bandwidth for frequency modulation '+string(bw_fm)+' Hz')\n", +"\n", +"//Bandwidth for phase & frequency modulation if frequency of modulating signal is doubled i.e fm = 2000 hertz\n", +"\n", +"//Bp & Bf after frequency of modulating signal is doubled\n", +"\n", +"//Bp = kp*Am, observing the equation as there is no change in amplitude Bp = 10\n", +"Bp = 10\n", +"\n", +"//Bf = kf*Am/fm, observing the equation as there is change in frequency Bf = 10/2 = 5\n", +"Bf = 5\n", +"\n", +"//Bandwidth for phase modulation if frequency of modulating signal is doubled is bw_double_pm = 2*(1+Bp)*fm\n", +"bw_double_pm = 2*(1+10)*2000\n", +"\n", +"//Bandwidth for frequency modulation if frequency of modulating signal is doubled is bw_double_fm = 2*(1+Bf)*fm\n", +"bw_double_fm = 2*(1+5)*2000\n", +"\n", +"disp('Bandwidth for phase modulation for doubled frequency '+string(bw_double_pm)+' Hz')\n", +"disp('bandwidth for frequency modulation for doubled frequency '+string(bw_double_fm)+' Hz')\n", +"\n", +"//Bandwidth for phase & frequency modulation if amplitude of modulating signal is halfed i.e Am = 1 metre\n", +"\n", +"//Bp & Bf after amplitude of modulating signal is halfed\n", +"\n", +"//Bp = kp*Am, observing the equation as there is change in amplitude Bp = 10/2 = 5\n", +"Bp = 5\n", +"\n", +"//Bf = kf*Am/fm, observing the equation as there is change in amplitude Bf = 5/2 = 2.5\n", +"Bf = 2.5\n", +"\n", +"//Bandwidth for phase modulation if frequency of modulating signal is doubled is bw_halfed_pm = 2*(1+Bp)*fm\n", +"bw_halfed_pm = 2*(1+5)*2000\n", +"\n", +"//Bandwidth for frequency modulation if frequency of modulating signal is doubled is bw_halfed_fm = 2*(1+Bf)*fm\n", +"bw_halfed_fm = 2*(1+2.5)*2000\n", +"\n", +"disp('Bandwidth for phase modulation for halfed amplitude '+string(bw_halfed_pm)+' Hz')\n", +"disp('Bandwidth for frequency modulation for halfed amplitude '+string(bw_halfed_fm)+' Hz')" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/5-Pulse_Modulation_and_Digital_Transmission_of_Analog_Signal.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/5-Pulse_Modulation_and_Digital_Transmission_of_Analog_Signal.ipynb new file mode 100644 index 0000000..78e6288 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/5-Pulse_Modulation_and_Digital_Transmission_of_Analog_Signal.ipynb @@ -0,0 +1,330 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5: Pulse Modulation and Digital Transmission of Analog Signal" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.11: SNR_of_a_DM_system.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 296\n", +"//problem 5.11\n", +"\n", +"//case 1(a)\n", +"//f = 400Hertz, fs = 8000Hertz\n", +"f = 400\n", +"fs = 8000\n", +"\n", +"//We know that maximum signal to noise ratio(SNR_max) = 3*(fs^2)/(8*(pi^2)*(f^2))\n", +"SNR_max = 3*(fs^2)/(8*(%pi^2)*(f^2))\n", +"//SNR_max in decibels is SNR_max_db\n", +"SNR_max_db = 10*log10 (SNR_max)\n", +"\n", +"disp('Maximum signal to noise ratio for f = 400 & fs = 8000 is '+string(SNR_max)+' = '+string(SNR_max_db)+' db')\n", +"\n", +"//case 1(b)\n", +"//f = 400Hertz, fs = 16000Hertz\n", +"f = 400\n", +"fs = 16000\n", +"\n", +"//We know that maximum signal to noise ratio(SNR_max) = 3*(fs^2)/(8*(pi^2)*(f^2))\n", +"SNR_max = 3*(fs^2)/(8*(%pi^2)*(f^2))\n", +"\n", +"//SNR_max in decibels is SNR_max_db\n", +"SNR_max_db = 10*log10 (SNR_max)\n", +"\n", +"//Given solution is 13.8385 dB obtained solution is 17.838515 dB\n", +"\n", +"disp('Maximum signal to noise ratio for f = 400 & fs = 16000 is '+string(SNR_max)+' = '+string(SNR_max_db)+' db')\n", +"\n", +"//case 2(a)\n", +"//f = 400Hertz, fs = 8000Hertz & fc = 1000Hertz\n", +"f = 400\n", +"fs = 8000\n", +"fc = 1000\n", +"\n", +"//If a 1kHz low pass post reconstruction filter is used then maximum signal to noise ratio(SNR_max) = 3*(fs^3)/(8*(pi^2)*(f^2)*fc)\n", +"SNR_max = 3*(fs^3)/(8*(%pi^2)*(f^2)*fc)\n", +"//SNR_max in decibels is SNR_max_db\n", +"SNR_max_db = 10*log10 (SNR_max)\n", +"\n", +"disp('If a 1kHz low pass post reconstruction filter is used then')\n", +"\n", +"disp('Maximum signal to noise ratio for f = 400, fs = 8000 & fc = 1000 is '+string(SNR_max)+' = '+string(SNR_max_db)+' db')\n", +"\n", +"//case 2(b)\n", +"//f = 400Hertz, fs = 16000Hertz & fc = 1000Hertz\n", +"f = 400\n", +"fs = 16000\n", +"fc = 1000\n", +"\n", +"//If a 1kHz low pass post reconstruction filter is used then maximum signal to noise ratio(SNR_max) = 3*(fs^3)/(8*(pi^2)*(f^2)*fc)\n", +"SNR_max = 3*(fs^3)/(8*(%pi^2)*(f^2)*fc)\n", +"//SNR_max in decibels is SNR_max_db\n", +"SNR_max_db = 10*log10 (SNR_max)\n", +"\n", +"disp('Maximum signal to noise ratio for f = 400, fs = 16000 & fc = 1000 is '+string(SNR_max)+' = '+string(SNR_max_db)+' db')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.2: Minimum_sampling_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 247\n", +"//problem 5.2\n", +"\n", +"//Highest frequency(fH) = 10000/2 = 5000 Hz \n", +"fH = 5000\n", +"\n", +"//Lowest frequency(fL) = 6000/2 = 3000 Hz\n", +"fL = 3000\n", +"\n", +"//Minimum sampling frequency from low pass consideration(S_LOW) = 2*fH\n", +"S_LOW = 2*fH\n", +"\n", +"disp('Minimum sampling frequency from low pass consideration is '+string(S_LOW)+' Hz')\n", +"\n", +"//B = fH-fL = 2000 Hz\n", +"B = fH-fL\n", +"\n", +"//k = floor(fH/B) = 2, where floor(x) gives the largest integer that does not exceed x\n", +"k = floor(fH/B)\n", +"\n", +"//The required sampling frequency from band pass consideration(S_BAND) = 2*fH/k\n", +"S_BAND = 2*fH/k\n", +"\n", +"disp('Minimum sampling frequency from band pass consideration is '+string(S_BAND)+' Hz')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.3: Calculation_of_Guard_time.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 259\n", +"//problem 5.3\n", +"\n", +"//Given width of each pulse W = 150 us\n", +"W = 150 * 10^-6\n", +"\n", +"//One cycle is a period,T = 1ms\n", +"T = 1000 * 10^-6\n", +"\n", +"//There are 5 messages multiplexed each utilizeallocated time pulse width = s(T_5) = T/5\n", +"T_5 = T/5\n", +"\n", +"//Gaurd time(GT_5) = allocated time-pulse width = T_5-W\n", +"GT_5 = T_5-W\n", +"\n", +"disp('Gaurd time where 5 messages multiplexed is '+string(GT_5)+' seconds')\n", +"\n", +"//Here there are 10 messages multiplexed each utilizeallocated time pulse width = s(T_10) = T/10\n", +"T_10 = T/10\n", +"\n", +"//Gaurd time(GT_10) = allocated time-pulse width = T_10-norrow pulses width = T_10 -50* 10^-6\n", +"GT_10 = T_10 - 50 * 10^-6\n", +"\n", +"disp('Gaurd time where 10 messages multiplexed is '+string(GT_10)+' seconds')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.5: Calculation_of_minimum_number_of_Binary_digits.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 272\n", +"//problem 5.5\n", +"\n", +"//Let Abe the maximum value of the discrete samples.\n", +"//Error tolerated is 0.1% i.e. 0.001A\n", +"//If D is step size then possible maximum error is D/2\n", +"//Thus D/2 = 0.001A or A/D = 500 = no of levels required(Levels)\n", +"Levels = 500\n", +"\n", +"//minimum no of binary digits required(B) = rounded value to the next higher integer of log2 (Levels)\n", +"B = round(log2 (Levels))\n", +"\n", +"disp('Minimum no of binary digits required '+string(B))" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.6: Companding.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 273\n", +"//problem 5.6\n", +"\n", +"//The y axis is uniformly quantized with step size(step_size) = 1/[(2^8)/(2-1)] in both +ve & -ve direction between 1 & -1 when peak of input varies between 1 & -1.\n", +"//The smallest step in x direction occurs nearest to x=0 i.e between y1 = 0 & y2 = step_size\n", +"step_size = 1/[(2^8)/2-1]\n", +"y1 = 0\n", +"y2 = step_size\n", +"\n", +"//Then, y1 = [ln(1+255*x1)]/[ln(1+255)]\n", +"\n", +"x1 = (%e^(y1*log(256)) - 1)/255;\n", +"\n", +"//y2 = [ln(1+255*x2)]/[ln(1+255)]\n", +"x2 = (%e^(y2*log(256)) - 1)/255;\n", +"\n", +"//The smallest step size is 10*(x2-x1)\n", +"disp('The smallest step size is '+string(10*(x2-x1))+' Volts')\n", +"\n", +"//The largest step size occurs when x is at its extreme between y1 = 1-1/127 = 126/127 & y2 = 1\n", +"y1 = 1-1/127\n", +"y2 = 1\n", +"\n", +"//Then, y1 = [ln(1+255*x1)]/[ln(1+255)]\n", +"\n", +"x1 = (%e^(y1*log(256)) - 1)/255;\n", +"\n", +"//y2 = [ln(1+255*x2)]/[ln(1+255)]\n", +"x2 = (%e^(y2*log(256)) - 1)/255;\n", +"\n", +"//The largest step size is 10*(x2-x1)\n", +"disp('The largest step size is '+string(10*(x2-x1))+' Volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.9: LMS_Algorithm.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 296\n", +"//problem 5.9\n", +"\n", +"//for error calculation e(n) = m(n) - [^hj(n)*m(n-1)+^hj(n)*m(n-2)+^hj(n)*m(n-3)+ ........+^hj(n)*m(n-N)]\n", +"\n", +"//for coefficient upgradation ^hj(n+1) = ^hj(n)+um(n-j)e(n) where u = learning parameter = 0.1.\n", +"u = 0.1\n", +"\n", +"//Assign m values taking from m = -3 to 5\n", +"//Denoting m(x) as matrix m where each element repesents from n = -3 to 5 \n", +"m = [0 0 0 1 2 3 4 5 6]\n", +"\n", +"//taking e(n) as matrix e, ^hj(n) as matrises h_j\n", +"e = zeros(1,5)\n", +"h_1 = zeros(1,6)\n", +"h_2 = zeros(1,6)\n", +"\n", +"//given ^h1(0)= ^h2(0) = 0\n", +"h_1(1) = 0\n", +"h_2(1) = 0\n", +"\n", +"for i = 1:5\n", +" e(i) = m(i+3) - h_1(i)*m(i+2) - h_2(i)*m(i+1)\n", +" h_1(i+1) = h_1(i) + u*m(i+2)*e(i)\n", +" h_2(i+1) = h_2(i) + u*m(i+1)*e(i)\n", +"end\n", +"\n", +"//here e(3) is given as 1.32 but it is displaying 0.92\n", +"//here ^h2(3) is given as 0.26 but it is displaying 0.46\n", +"\n", +"for i = 1:5\n", +" disp('e('+string(i-1)+') = '+string(e(i)))\n", +" disp('^h1('+string(i)+') = '+string(h_1(i+1)))\n", +" disp('^h2('+string(i)+') = '+string(h_2(i+1)))\n", +"end" + ] + } +], +"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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/6-Digital_Modulation_and_Transmission.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/6-Digital_Modulation_and_Transmission.ipynb new file mode 100644 index 0000000..95c0c5a --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/6-Digital_Modulation_and_Transmission.ipynb @@ -0,0 +1,475 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6: Digital Modulation and Transmission" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.1: Carrier_phase_variatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 341\n", +"//problem 6.1\n", +"\n", +"//Given messages signal m = [1,0,1,1,0,1]\n", +"m = [1,0,1,1,0,1];\n", +"\n", +"//Logical 0 corrsponds to pi i.e %pi and Logical 1 corresponds to 0\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//For BPSK, from the above deduction let the carrier phase be Carrier_Phase_BPSK\n", +"for i = 1:5\n", +" if m(i)==1 then\n", +" Carrier_Phase_BPSK(i) = 0;\n", +" else\n", +" Carrier_Phase_BPSK(i) = %pi;\n", +" end\n", +"end\n", +"\n", +"disp(Carrier_Phase_BPSK,'The Phase of the carrier signal for BPSK varies as ');\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//For DPSK\n", +"//Let b represent the input to balance modulator\n", +"\n", +"//If the initial value of b be 0\n", +"b = 0;\n", +"\n", +"for i = 2:5\n", +" b(i) = bitxor(m(i),b(i-1)) \n", +"end\n", +"\n", +"//Now the carrier phase, Carrier_Phase_DPSK\n", +"for i = 1:5\n", +" if b(i)==1 then\n", +" Carrier_Phase_DPSK(i) = 0;\n", +" else\n", +" Carrier_Phase_DPSK(i) = %pi;\n", +" end\n", +"end\n", +"\n", +"//Now the carrier amplitude, Carrier_Amplitude_DPSK\n", +"for i = 1:5\n", +" Carrier_Amplitude_DPSK(i) = cos(Carrier_Phase_DPSK(i));\n", +"end\n", +"\n", +"disp(Carrier_Phase_DPSK,'The Phase of the carrier signal for DPSK varies as follows, '+'when the initial value of b is 1');\n", +"disp(Carrier_Amplitude_DPSK,'The Amplitude of the carrier signal for DPSK varies as follows, '+'when the initial value of b is 1');\n", +"\n", +"//If the initial value of b be 1\n", +"b = 1;\n", +"\n", +"for i = 2:5\n", +" b(i) = bitxor(m(i),b(i-1)) \n", +"end\n", +"\n", +"//Now the carrier phase, Carrier_Phase_DPSK\n", +"for i = 1:5\n", +" if b(i)==1 then\n", +" Carrier_Phase_DPSK(i) = 0;\n", +" else\n", +" Carrier_Phase_DPSK(i) = %pi;\n", +" end\n", +"end\n", +"\n", +"//Now the carrier amplitude, Carrier_Amplitude_DPSK\n", +"for i = 1:5\n", +" Carrier_Amplitude_DPSK(i) = cos(Carrier_Phase_DPSK(i));\n", +"end\n", +"\n", +"disp(Carrier_Phase_DPSK,'The Phase of the carrier signal for DPSK varies as follows, '+'when the initial value of b is 0');\n", +"disp(Carrier_Amplitude_DPSK,'The Amplitude of the carrier signal for DPSK varies as follows, '+'when the initial value of b is 0');\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//For DEPSK\n", +"//The DEPSK transmitter output is same as that of DPSK\n", +"\n", +"//If the initial value of b be 0\n", +"b = 0;\n", +"\n", +"for i = 2:5\n", +" b(i) = bitxor(m(i),b(i-1)) \n", +"end\n", +"\n", +"//Now the carrier phase, Carrier_Phase_DPSK\n", +"for i = 1:5\n", +" if b(i)==1 then\n", +" Carrier_Phase_DEPSK(i) = 0;\n", +" else\n", +" Carrier_Phase_DEPSK(i) = %pi;\n", +" end\n", +"end\n", +"\n", +"disp(Carrier_Phase_DEPSK,'The Phase of the carrier signal for DEPSK varies as follows, '+'when the initial value of b is 1');\n", +"\n", +"//If the initial value of b be 1\n", +"b = 1;\n", +"\n", +"for i = 2:5\n", +" b(i) = bitxor(m(i),b(i-1)) \n", +"end\n", +"\n", +"//Now the carrier phase, Carrier_Phase_DPSK\n", +"for i = 1:5\n", +" if b(i)==1 then\n", +" Carrier_Phase_DEPSK(i) = 0;\n", +" else\n", +" Carrier_Phase_DEPSK(i) = %pi;\n", +" end\n", +"end\n", +"\n", +"disp(Carrier_Phase_DEPSK,'The Phase of the carrier signal for DEPSK varies as, '+'when the initial value of b is 0');\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.2: DPSK_and_DEPSK.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 341\n", +"//problem 6.2\n", +"\n", +"//From Ex6_1 the obtained carrier amplitude is c\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//For DPSK\n", +"//Considering the initial value of the storage element to be 0 in polar and -1 in biploar\n", +"c = [1,1,-1,1,1];\n", +"y = -1;\n", +"//Let the output be y\n", +"for i = 2:5\n", +" y(i) = c(i)*c(i-1);\n", +"end\n", +"\n", +"//Converting back to binary data\n", +"for i = 1:5\n", +" if y(i)== -1 then\n", +" output_binary(i) = 0;\n", +" else\n", +" output_binary(i) = 1;\n", +" end\n", +"end\n", +"\n", +"//Now inverting the output we get:\n", +"for i = 1:5\n", +" output_binary(i) = ~output_binary(i);\n", +"end\n", +"\n", +"disp(output_binary,'The DPSK output is');\n", +"\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//For DEPSK\n", +"\n", +"//From example Ex6_1, we have b when initial storage value is assumed to be 1\n", +"b = [1,1,0,1,1]; \n", +"\n", +"//Output y \n", +"y = 1;\n", +"for i = 2:5\n", +" y(i) = bitxor(b(i),b(i-1));\n", +"end\n", +"\n", +"disp(y,'The DEPSK output is');\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.4: Bandwidth_and_Noise_susceptibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 365\n", +"//problem 6.4\n", +"\n", +"//Given energy per bit Eb = 0.01\n", +"Eb = 0.01;\n", +"\n", +"//Given fundamental frequency is fb = 8 KHz \n", +"fb = 8*10^3;\n", +"\n", +"//No of symbols M = 16\n", +"M = 16;\n", +"\n", +"N = log2(M);\n", +"\n", +"BW_BPSK = 2*fb;\n", +"disp('Bandwidth for BPSK is '+string(BW_BPSK)+'Hz');\n", +"\n", +"BW_QPSK = fb;\n", +"disp('Bandwidth for QPSK is '+string(BW_QPSK)+'Hz');\n", +"\n", +"BW_16MPSK = fb/2;\n", +"disp('Bandwidth for 16 MPSK is '+string(BW_16MPSK)+'Hz');\n", +"\n", +"BW_BFSK = 4*fb;\n", +"disp('Bandwidth for BFSK is '+string(BW_BFSK)+'Hz');\n", +"\n", +"BW_MSK = 1.5*fb;\n", +"disp('Bandwidth for MSK is '+string(BW_MSK)+'Hz');\n", +"\n", +"BW_16MFSK = 2*M*fb;\n", +"disp('Bandwidth for 16 MFSK is '+string(BW_16MFSK)+'Hz');\n", +"\n", +"\n", +"Min_dist_BPSK = 2*(Eb)^0.5;\n", +"disp('Minimum distance in signal space in BPSK is '+string(Min_dist_BPSK));\n", +"\n", +"Min_dist_QPSK = 2*(Eb)^0.5;\n", +"disp('Minimum distance in signal space in QPSK is '+string(Min_dist_QPSK));\n", +"\n", +"//The given answer in the textbook is 0.0152, which appears to be wrong. The correct answer is 0.078\n", +"Min_dist_16MPSK = (4*N*Eb*(sin(%pi/16))^2)^0.5;\n", +"disp('Minimum distance in signal space in 16 MPSK is '+string(Min_dist_16MPSK));\n", +"\n", +"Min_dist_BFSK = (2*Eb)^0.5;\n", +"disp('Minimum distance in signal space in ortho BFSK is '+string(Min_dist_BFSK));\n", +"\n", +"Min_dist_MSK = 2*(Eb)^0.5;\n", +"disp('Minimum distance in signal space in MSK is '+string(Min_dist_MSK));\n", +"\n", +"Min_dist_16MFSK = (2*N*Eb)^0.5;\n", +"disp('Minimum distance in signal space in ortho 16 MFSK is '+string(Min_dist_16MFSK));\n", +"\n", +"disp('The best method that provides least noise susceptibility is 16 MFSK, then BPSK, then QPSK, then comes MSK, then orthogonal BFSK and finally 16 MPSK')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.5: Duobinary_decoding.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 381\n", +"//problem 6.5\n", +"\n", +"//Given input signal is d\n", +"d = [0,1,1,1,0,1,0,1,1];\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"//The answers obtained here are different from the ones mentioned in the textbook.\n", +"//The given answers have been checked rigorously and have been found out to be true.\n", +"\n", +"//When precoded\n", +"\n", +"//Signal b is initially assumed to be 0 \n", +"b = 0;\n", +"\n", +"for i = 2:9\n", +" b(i) = bitxor(b(i-1),d(i));\n", +"end\n", +"\n", +"//Changing bit code to polar signal we get, 0 --> -1, 1 --> +1\n", +"for i = 1:9\n", +" if b(i)==1 then\n", +" bp(i) = 1;\n", +" else\n", +" bp(i) = -1;\n", +" end\n", +"end\n", +"\n", +"//Let initial value of Vd be 0\n", +"//Vd = 0;\n", +"\n", +"for i = 2:9\n", +" Vd(i) = bp(i) + bp(i-1);\n", +"end\n", +"\n", +"//Converting polar signal to bit code we get, -2 --> 0, 0 --> 1, 2 --> 0\n", +"for i = 1:9\n", +" if Vd(i)== -2 then\n", +" da(i) = 0;\n", +" elseif Vd(i)== 2 then\n", +" da(i) = 0;\n", +" else\n", +" da(i) = 1;\n", +" end\n", +"end\n", +"\n", +"disp(da,'Decoded output when precoded is ')\n", +"\n", +"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//When not precoded exor gate is not there\n", +"\n", +"//Changing bit code to polar signal we get, 0 --> -1, 1 --> +1\n", +"for i = 1:9\n", +" if d(i)==1 then\n", +" dp(i) = 1;\n", +" else\n", +" dp(i) = -1;\n", +" end\n", +"end\n", +"\n", +"for i = 2:9\n", +" Vd(i) = dp(i) + dp(i-1);\n", +"end\n", +"\n", +"//Converting polar signal to bit code we get, -2 --> 0, 0 --> 1, 2 --> 1\n", +"for i = 2:9\n", +" if Vd(i)== -2 then\n", +" da(i) = 0;\n", +" elseif Vd(i)== 2 then\n", +" da(i) = 0;\n", +" else\n", +" da(i)= ~da(i-1);\n", +" end\n", +"end\n", +"\n", +"disp(da,'Decoded output when not precoded is ')\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.6: Roll_off_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 381\n", +"//problem 6.6\n", +"\n", +"//Given Bandwidth BW = 4 kHz\n", +"BW = 4*10^3;\n", +"\n", +"//Given data rate is fb = 6 kbps\n", +"fb = 6*10^3;\n", +"\n", +"//The roll off factor alpha is \n", +"alpha = ((2*BW)/fb) - 1;\n", +"\n", +"disp('The roll off factor is '+string(alpha));\n", +"\n", +"///////////////////////////////////////////////////////////////////////////////\n", +"\n", +"//The required data rate supported at alpha = 0.25 is D\n", +"alpha = 0.25\n", +"\n", +"//The corresponding expression for D is\n", +"D = (2*BW)/(1+alpha);\n", +"\n", +"disp('The supported data rate is '+string(D)+' kbps');\n", +"\n", +"//For full roll-off alpha = 1.0, \n", +"alpha = 1;\n", +"\n", +"fb = 2*BW/(1+alpha);\n", +"\n", +"disp('The data rate is '+string(fb)+' kbps');\n", +"\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/7-Mathematical_Representation_of_Noise.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/7-Mathematical_Representation_of_Noise.ipynb new file mode 100644 index 0000000..27052f4 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/7-Mathematical_Representation_of_Noise.ipynb @@ -0,0 +1,136 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7: Mathematical Representation of Noise" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.3: Noise_Power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 413 \n", +"//problem 7.3\n", +"\n", +"//The resistance R = 1000 Ohm \n", +"R = 10^3;\n", +"\n", +"//The capacitance C = 0.5*10^-6 F\n", +"C = 0.1*10^-6;\n", +"\n", +"//Cutoff frequency for RC filter is f\n", +"f = 1/(2*%pi*R*C)\n", +"\n", +"//White noise power spectral density n\n", +"n = 10^(-9);\n", +"\n", +"//Noise power at filter output P\n", +"P = (%pi/2)*n*f;\n", +"\n", +"disp('Noise power at output filter is '+string(P)+' Watt');\n", +"\n", +"//Noise power at filter output P_new when cutoff frequency is doubled\n", +"P_new = (%pi/2)*n*2*f;\n", +"\n", +"disp('Noise power at output filter when cutoff frequency is doubled is '+string(P_new)+' Watt');\n", +"\n", +"//Ideal Low Pass filter Bandwidth B = 1000 Hz\n", +"B = 1000;\n", +"\n", +"disp('Output Noise Power is '+string(n*B)+' Watt');\n", +"\n", +"disp('Output Noise Power when cut-off frequency is doubled is '+string(2*n*B)+' Watt');\n", +"\n", +"//Proportionality constant T = 0.01\n", +"T = 0.01;\n", +"\n", +"//Output noise power O\n", +"O = n*(B^3)*(T^2)*(4/3)*(%pi)^2;\n", +"\n", +"disp('Output Noise Power when signal is passed through a differentiator passed through ideal low pass filter '+string(O)+' Watt');\n", +"\n", +"O_new = 8*n*(B^3)*(T^2)*(4/3)*(%pi)^2;\n", +"\n", +"disp('Output Noise Power when signal is passed through a differentiator passed through ideal low pass filter and when cut-off frequency is doubled is '+string(O_new)+' Watt');\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.4: SNR_at_output_of_equalizer.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 413\n", +"//problem 7.4\n", +"\n", +"//Given signal strength S = 0.001 W\n", +"S = 0.001;\n", +"\n", +"//Gaussian Noise Magnitude n \n", +"n = 10^(-8);\n", +"\n", +"//Frequency of signal f = 4000 Hz\n", +"F = 4000;\n", +"\n", +"//Noise at equalizer output N\n", +"N = integrate('n*(1+(f^2)/F^2)','f',-F,F);\n", +"\n", +"//Signal to Noise Ratio value is SNR\n", +"SNR = S/N;\n", +"\n", +"disp('SNR value is '+string(10*log10(SNR))+' dB');\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/8-Noise_in_Amplitude_Modulation_System.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/8-Noise_in_Amplitude_Modulation_System.ipynb new file mode 100644 index 0000000..d47bc67 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/8-Noise_in_Amplitude_Modulation_System.ipynb @@ -0,0 +1,233 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 8: Noise in Amplitude Modulation System" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.1: SNR_of_SSB_signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 436\n", +"//problem 8.1\n", +"\n", +"//Given frequency range fc= 1MHz to fc = 1.0005Mhz\n", +"//Single side message bandwidth is fM\n", +"fM= (1.0005 - 1)*10^6;\n", +"disp('Message bandwidth is '+string(fM)+' Hz');\n", +"//The textbook contains a calculation error here. The calculated fM in the textbook is 500kHz instead of 5kHz, following which all the solutions are erroneous \n", +"\n", +"//Given input signal strength Si= 1mW\n", +"//Let output signal strength be So\n", +"//So=Si/4\n", +"Si= 10^(-3);\n", +"So= Si/4;\n", +"disp('Signal output strength is '+string(So)+' dB');\n", +"\n", +"//Given Power Spectral Density n = 10^-9 W/Hz\n", +"//Let output noise strength be No\n", +"n= 10^-9;\n", +"No= (n*fM)/4;\n", +"disp('Output Noise Strength is '+string(No)+' dB');\n", +"\n", +"//Let SNR at filter output be SNR\n", +"SNR= So / No;\n", +"disp('Output SNR is '+string(SNR)+' dB');\n", +"\n", +"//By reduction of message signal Bandwidth the Output Noise strength changes\n", +"//Let the new output noise strength, bandwidth and SNR be be No_new, fM_new and SNR_new respectively\n", +"fM_new = 75/100*fM;\n", +"No_new = n*fM_new/4;\n", +"SNR_new = So / No_new;\n", +"\n", +"disp('Changed SNR is '+string(SNR_new)+' dB');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2: Signal_strength_and_noise_power_density.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 436\n", +"//problem 8.2\n", +"\n", +"//Given frequency range fc - fm = 0.995MHz to fc + fm = 1.005Mhz\n", +"//Double side message bandwidth is fM\n", +"fM= (1.005 - 0.995)*10^6 / 2;\n", +"disp('Message bandwidth is '+string(fM)+' Hz');\n", +"//The textbook contains a calculation error here.\n", +"//The calculated fM in the textbook is 500kHz instead of 5kHz,\n", +"//Following which all the solutions obtained here are erroneous.\n", +"\n", +"//Given input signal strength Si= 1mW\n", +"//Let output signal strength be So\n", +"//So=Si/2\n", +"Si= 10^(-3);\n", +"So= Si/2;\n", +"disp('Signal output strength is '+string(So)+' dB');\n", +"\n", +"//Given Power Spectral Density n = 10^-9 W/Hz\n", +"//Let output noise strength be No\n", +"n= 10^-9;\n", +"No= (n*fM)/2;\n", +"disp('Output Noise Strength is '+string(No)+' dB');\n", +"\n", +"//Let SNR at filter output be SNR\n", +"SNR= So / No;\n", +"disp('Output SNR of the DSB-SC wave is '+string(SNR)+' dB');\n", +"\n", +"//By reduction of message signal Bandwidth the Output Noise strength changes\n", +"//Let the new output noise strength, bandwidth and SNR be be No_new, fM_new and SNR_new respectively\n", +"fM_new = 75/100*fM;\n", +"No_new = n*fM_new/4;\n", +"SNR_new = So / No_new;\n", +"disp('Changed SNR is '+string(SNR_new)+' dB');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3: Minimum_transmitter_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 446\n", +"//problem 8.3\n", +"\n", +"//Given bandwidth of signal is fM = 4kHZ\n", +"fM = 4*10^3;\n", +"//Given power spectral density of white noise n = 2*10^-9 W/Hz\n", +"n = 2*10^-9;\n", +"//Also given that minimum output SNR is 40dB\n", +"//Signal undergoes a loss of 30dB\n", +"\n", +"//For SSB:\n", +"// Required minimum output SNR = Si_min_SSB / (n*fM) = 40 dB = 10^4\n", +"Si_min_SSB = (10^4)*n*fM;\n", +"// Required minimum signal strength at transmitter output Si_tran = Si_min * 30 dB\n", +"Si_tran_SSB = Si_min_SSB * 10^3;\n", +"disp('Required minimum SSB signal strength at transmitter output is'+string(Si_tran_SSB)+' W');\n", +"\n", +"//For DSB-SC:\n", +"// Required minimum output SNR = (Si_min_DSB/3) / (n*fM) = 40 dB = 10^4\n", +"Si_min_DSB = 3*(10^4)*n*fM;\n", +"// Required minimum signal strength at transmitter output Si_tran = Si_min * 30 dB\n", +"Si_tran_DSB = Si_min_DSB * 10^3;\n", +"disp('Required minimum DSB signal strength at transmitter output is'+string(Si_tran_DSB)+' W');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.4: SNR_of_a_Square_Demodulator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 447\n", +"//problem 8.4\n", +"\n", +"//Given bandwidth of signal is fM = 60 kHZ\n", +"fM = 60*10^3;\n", +"\n", +"//Given power spectral density of white noise n = 2*10^-6 W/Hz\n", +"n = 2*10^-6;\n", +"\n", +"//Given time average of square of mssg signal P = 0.1W\n", +"P = 0.1;\n", +"\n", +"//Noise power at input baseband range NM\n", +"NM = n * fM;\n", +"\n", +"//Threshold occurs at carrier power Pc = 2.9 * NM\n", +"Pc_Threshold = 2.9 * NM;\n", +"\n", +"//For carrier power Pc = 10W, output SNR\n", +"Pc = 10;\n", +"SNRo = Pc * P / NM ;\n", +"disp('Output SNR is '+string(SNRo)+' dB');\n", +"\n", +"//Carrier power is reduced by 100 times making the new power Pc_new\n", +"Pc_new = Pc / 100;\n", +"\n", +"//In the given solutions the NM value is 1.2W instead of 0.12W\n", +"//The corect answer is 0.0925926 instead of 0.000926\n", +"SNR_new = (4/3) * P * (Pc_new/NM)^2;\n", +"disp('Output SNR when carrier power is reduced is '+string(SNR_new)+' dB');\n", +"\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 +} diff --git a/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/9-Noise_in_Frequency_Modulation_Systems.ipynb b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/9-Noise_in_Frequency_Modulation_Systems.ipynb new file mode 100644 index 0000000..b795a00 --- /dev/null +++ b/Principles_of_Communication_Systems_by_H_Taub_and_D_L_Schilling/9-Noise_in_Frequency_Modulation_Systems.ipynb @@ -0,0 +1,236 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 9: Noise in Frequency Modulation Systems" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.1: SNR_of_an_FM_Limiter_Discriminator_Demodulator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 463\n", +"//problem 9.1\n", +"\n", +"//Input signal strength Si = 0.5 W\n", +"Si = 0.5;\n", +"\n", +"//Gaussian Power Spectral Density n = 10^(-10) W/Hz\n", +"n = 10^(-10);\n", +"\n", +"//Baseband cutoff signal fM = 15 kHz\n", +"fM = 15 * 10^3;\n", +"\n", +"//Maximum frequency deviation Df = 60 kHz\n", +"Df = 60 * 10^3;\n", +"\n", +"//Average power of the modulating signal mt = 0.1 W\n", +"mt = 0.1;\n", +"\n", +"SNR = (3/(4*%pi^2))*((Df/fM)^2)*mt^2*(Si/(n*fM));\n", +"\n", +"disp('SNR is '+string(10*log10(SNR))+' dB');\n", +"\n", +"//Part b\n", +"\n", +"//Required SNR at output>40 dB = 10000\n", +"\n", +"//From (a), required Si/0.5 > 10000/4052.8 \n", +"//Or, required Si > 1.2337 W\n", +"//Since, channel loss is 20 dB (=100), \n", +"//Required transmitter power > 1.2337*100 = 123.37 \n", +"\n", +"disp('Required transmitter power > 1.2337 x 100 = 123.37 ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.2: FM_Limiter_Discriminator_Demodulator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 464\n", +"//problem 9.2\n", +"\n", +"//Baseband cutoff signal fM = 15 kHz\n", +"fM = 15 * 10^3;\n", +"\n", +"//Maximum frequency deviation Df = 60 kHz\n", +"Df = 60 * 10^3;\n", +"\n", +"//Figure of Merit for FM is G_FM\n", +"G_FM = (3/2)*(Df/fM)^2;\n", +"\n", +"disp('Figure of Merit for FM system is '+string(G_FM));\n", +"\n", +"//Ratio of Figure of Merits of FM and AM systems is R\n", +"R = G_FM/(1/3);\n", +"\n", +"disp('Ratio of Figure of Merits for FM and AM systems is '+string(R));\n", +"\n", +"Df_new = 2*Df;\n", +"\n", +"//Figure of Merit for FM when bandwidth is doubled is G_FM_new\n", +"G_FM_new = (3/2)*(Df_new/fM)^2;\n", +"\n", +"//Ratio of Figure of Merits of FM and AM systems when bandwidth is doubled is R_new\n", +"R_new = G_FM_new/(1/3);\n", +"\n", +"disp('Ratio of Figure of Merits for FM and AM systems when bandwidth is doubled is '+string(R_new));\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.3: RC_Filter_Preemphasis_Deemphasis.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 475\n", +"//problem 9.3\n", +"\n", +"//Resistance R = 1000 Ohm\n", +"R = 10^3;\n", +"\n", +"//Capacitance C = 0.1 * 10^-6 F\n", +"C = 0.1*10^-6;\n", +"\n", +"//Break point for RC filter is f1\n", +"f1 = 1/(2*%pi*R*C)\n", +"\n", +"//Baseband bandwidth of signal fM = 15 kHz\n", +"fM = 15 * 10^3;\n", +"\n", +"Gain = atan(fM/f1)/(3*(f1/fM)*[1 - (f1/fM)*atan(fM/f1)]);\n", +"\n", +"disp('Initial Gain is '+string(10*log10(Gain))+' dB');\n", +"\n", +"//New Baseband bandwidth of signal fM_new = 15 kHz\n", +"fM_new = 2*15 * 10^3;\n", +"\n", +"Gain_new = atan(fM_new/f1)/(3*(f1/fM_new)*[1 - (f1/fM_new)*atan(fM_new/f1)]);\n", +"\n", +"disp('Final Gain is '+string(10*log10(Gain_new))+' dB');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.6: SNR_at_Input.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"//page 495\n", +"//problem 9.6\n", +"\n", +"//Baseband cutoff signal fM = 15 kHz\n", +"fM = 15 * 10^3;\n", +"\n", +"//Carrier filter bandwidth is B = 60 kHz\n", +"B = 60 * 10^3;\n", +"\n", +"//RMS frequency division Df_RMS = 30 kHz\n", +"Df_RMS = 30 * 10^3;\n", +"\n", +"//Let a = Df_RMS/fM for substitution \n", +"a = Df_RMS/fM;\n", +"\n", +"//Let b = fM/B for substitution \n", +"b = fM/B;\n", +"\n", +"//Let input SNR 1 be I_SNR1 = 10 dB = 10\n", +"I_SNR1 = 10;\n", +"\n", +"//Output SNR is O_SNR1\n", +"O_SNR1 = (3*(a^2)*I_SNR1)/(1+6*((2/%pi)^0.5)*I_SNR1*exp(-(b)*I_SNR1));\n", +"\n", +"disp('Output SNR is '+string(10*log10(O_SNR1))+' dB');\n", +"\n", +"//Let input SNR 2 be I_SNR2 = 20 dB = 100\n", +"I_SNR2 = 100;\n", +"\n", +"//Output SNR is O_SNR2\n", +"O_SNR2 = (3*(a^2)*I_SNR2)/(1+6*((2/%pi)^0.5)*I_SNR2*exp(-(b)*I_SNR2));\n", +"\n", +"//Solution given in the book is 13.5431 which is fallacious, the correct answer is 24.32444\n", +"disp('Output SNR is '+string(10*log10(O_SNR2))+' dB');\n", +"\n", +"//Let input SNR 3 be I_SNR3 = 30 dB = 1000\n", +"I_SNR3 = 1000;\n", +"\n", +"//Output SNR is O_SNR3\n", +"O_SNR3 = (3*(a^2)*I_SNR3)/(1+6*((2/%pi)^0.5)*I_SNR3*exp(-(b)*I_SNR3));\n", +"\n", +"disp('Output SNR is '+string(10*log10(O_SNR3))+' dB');" + ] + } +], +"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 +} |