From d137d01c8b8ad85dffefaf8ece889464a7302338 Mon Sep 17 00:00:00 2001 From: Nestor David Castillo Date: Sun, 3 Apr 2022 11:43:34 -0500 Subject: [PATCH 1/3] Remove prints unnecessary console prints --- main.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.m b/main.m index 7c2060e..c817ad3 100644 --- a/main.m +++ b/main.m @@ -24,7 +24,7 @@ wm = 2*pi*fm; % Frecquency in rad/s tm = 1./fm; % Time Period -factor = 100; % Sample Factor +factor = 75; % Sample Factor frecuenciaNyquist = 2*fm; % Nyquist Rate fs = factor*frecuenciaNyquist; % Sample Frequency ts = 1./fs; % Sample Period @@ -141,7 +141,7 @@ k=1; t_pam1 = 0:ts/numPeriodos:(d*numPeriodos-ts/numPeriodos); t_pam = 0:Tb_pam/(numPeriodos-1):numPeriodos*length(Fsample)*(Tb_pam/(numPeriodos-1)); -t_pam(end)=[] +t_pam(end)=[]; for i=1:1:length(Fsample) for j=1:1:numPeriodos @@ -244,7 +244,7 @@ grid minor; % BW_pcm -Y=fft(trama) +Y=fft(trama); P2 = abs(Y/length(trama)); P1 = P2(1:(length(trama))/2+1); P1(2:end-1) = 2*P1(2:end-1); @@ -270,14 +270,14 @@ title('PAM SIGNAL') % BW_pcm -Y_pam=fft(PAM) +Y_pam=fft(PAM); P2_pam = abs(Y_pam/length(PAM)); P1_pam = P2_pam(1:(length(PAM))/2+1); P1_pam(2:end-1) = 2*P1_pam(2:end-1); f_pam = B_pam*numPeriodos*(0:(length(PAM)/2))/length(PAM); -figurePamFrequency = figure('Name', 'PAM Signal - Frequency Domain') -plotPamFrequency = plot(f_pam, P1_pam) +figurePamFrequency = figure('Name', 'PAM Signal - Frequency Domain'); +plotPamFrequency = plot(f_pam, P1_pam); axis([0 12e3 0 0.5]); title('PAM Signal - Frequency Domain'); ylabel('Voltage [V]'); From eb10f3504f47e537bc09befde2e134f49bbb783b Mon Sep 17 00:00:00 2001 From: Nestor David Castillo Date: Sun, 3 Apr 2022 16:30:45 -0500 Subject: [PATCH 2/3] Add gif to readme --- README.md | 37 ++++-- css/main.css | 84 +++++++++++++ index.html | 41 ++++++- main.asv | 301 ----------------------------------------------- main.m | 2 +- pcmpamScript.rar | Bin 0 -> 2602 bytes 6 files changed, 151 insertions(+), 314 deletions(-) delete mode 100644 main.asv create mode 100644 pcmpamScript.rar diff --git a/README.md b/README.md index 2dcb2eb..5f859c0 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,42 @@ # Digital System Communication -![Pulse-Code-Modulation-1.png](https://live.staticflickr.com/65535/51974173526_ddd90b71e5_c.jpg) + + -By Voice Signal to 4kHz. +Exersise: + +To Voice's Signal Transmission with SNQ(Quatized) = 35db, Calculate: +a) Transmission Rate (PCM) +b) Bandwidth (PCM) in Hertz +c) Transmission Rate in 64-PAM +d) Bandwidth (PAM) in Hertz + +The encoder PCM is: + + +Construction of the Signal +Create parameters to overlap of sinusoidal +Voice Signal 4kHz + + + ### PAM Signal - + -### Quatized Signal +### BandWidth PAM Signal -![quatizedSignal.png](https://live.staticflickr.com/65535/51974460739_9985112b09_z.jpg) +![bwpam.png](https://live.staticflickr.com/65535/51980850675_ad9144ca80_k.jpg) -### Coded Signal +### Coded Signal PCM -![codedSignal.png](https://live.staticflickr.com/65535/51974173561_8eae686856_z.jpg) +![codedSignal.png](https://live.staticflickr.com/65535/51980364108_12be8daaa5_k.jpg) ### Digital Signal -![pcmSignal.png](https://live.staticflickr.com/65535/51974173536_7318ff024e_z.jpg) +![pcmSignal.png](https://live.staticflickr.com/65535/51980850620_6e4e3e58e0_h.jpg) + +### BW PCM Signal + +![bwpcmSignal.png](https://live.staticflickr.com/65535/51980850655_4b7275ca39_h.jpg) diff --git a/css/main.css b/css/main.css index e69de29..9d31423 100644 --- a/css/main.css +++ b/css/main.css @@ -0,0 +1,84 @@ +*{ + margin: 0; + padding: 0; + box-sizing: border-box; +} + +html{ + font-size: 62.5%; +} + +body{ + font-family: 'Inria Sans'; + font-size: 1.6rem; +} + +.container{ + display: flex; + width: 100vw; + height: 100vh; + flex-direction: column; + justify-content: center; + +} +.signalLetter{ + font-size: 2rem; + text-align: center; +} +.box-circle{ + height: 6rem; +} +.circle{ + width: 6rem; + height: 6rem; + margin: 0 auto; + border-radius: 100%; + border: 0.4rem #000 solid; + z-index: 2; + background-color: aliceblue; +} + +.line{ + margin: 0 auto; + height: 5rem; + width: 0.2rem; + background-color: #000; +} + +.half-line{ + margin: 0 auto; + height: 2.5rem; + width: 0.2rem; + background-color: #000; +} + +.box { + display: flex; + justify-content: center; + align-items: center; + color: aliceblue; + font-size: 2rem; + margin: 0 auto; + width:13.2rem; + height: 6rem; + background-color: blueviolet; + border-radius: 1rem; +} + +.box-blue{ + background-color: #003B4A; +} + +.box-green{ + background-color: #17E351; +} + +.box-orange{ + background-color: #FD6019; +} + +.container-extra{ + background-color: #CFFA25; + width: 22.5rem; + margin: 0 auto; +} \ No newline at end of file diff --git a/index.html b/index.html index 38018f3..9a564a4 100644 --- a/index.html +++ b/index.html @@ -8,11 +8,44 @@ - + + + -
- -
+
+
+
+

Voice Signal

+
+
+
+
+
+
+
+
+

Sampling

+
+
+
+

Quantizing

+
+
+
+

Encoding

+
+
+
+ +
+
+
+
+
+

Data Signal

+
+
+
\ No newline at end of file diff --git a/main.asv b/main.asv deleted file mode 100644 index 94969bb..0000000 --- a/main.asv +++ /dev/null @@ -1,301 +0,0 @@ -% PAM and PCM Script -% by David Castillo, Soledad Villegas - -% Delete Cache's Data -close all -clear all -clc - -% Exersise -% To Voice's Signal Transmission with SNQ(Quatized) = 35db, Calculate: -% a) Transmission Rate (PCM) -% b) Bandwidth (PCM) in Hertz -% c) Transmission Rate in 64-PAM -% d) Bandwidth (PAM) in Hertz - -% Construction of the Signal -% Create parameters to overlap of sinusoidal -% Voice Signal 4kHz - -% Signal Construction -% Signals that component a voice signal -A = [3 5 2 1.5]; % Signal's Signal -fm = [4e3 3.3e3 2.4e3 1.5e3]; % Frequency Signal -wm = 2*pi*fm; % Frecquency in rad/s -tm = 1./fm; % Time Period - -factor = 100; % Sample Factor -frecuenciaNyquist = 2*fm; % Nyquist Rate -fs = factor*frecuenciaNyquist; % Sample Frequency -ts = 1./fs; % Sample Period -rangoDinamico=5; % Dynamic Range - -% Level's Compute -snrQuatizationdB = 35; %***** SNR (QUATIZED - dB) ***** -snrQuatization = 10^(snrQuatizationdB/10); -L = sqrt(snrQuatization/3); % Levels - -if L==0 || L < 0 - disp('Fuera del Rango Establecido') -elseif L > 0 && L<=1 - L=1; -elseif L>1 && L<=2 - L=2; -elseif L>2 && L<=4 - L=4; -elseif L>4 && L<=8 - L=8; -elseif L>8 && L<=16 - L=16; -elseif L>16 && L<=32 - L=32; -elseif L>32 && L<=64 - L=64; -elseif L>64 && L<=128 - L=128; -elseif L>128 && L<=256 - L=256; -end - -n = log(L)/log(2); % Bits per Sample -fprintf('Exersise\n') -disp("Levels = "+L) % Print Levels -disp("n = "+n+" bits/sample") % Print Bits per Sample - -%% Graphic Voice Signal -numMuestras = min(tm)./min(ts); -numPeriodos = 10; -t = 0:ts:tm*numPeriodos; - -for i=1:1:length(A) - x(i,:) = A(i)*cos(2*pi*fm(i).*t); -end - -F = x(1,:); -figureSinosoides = figure('Name','Continue Signals'); -for i=1:1:length(A) - subplot(length(A),1,i); - plotsinusoides = plot(t,x(i,:)); - xlabel('t[s]') - ylabel('Voltage[V]') - title('Senoidal Signal') - hold on; - F = F + x(i,:); -end - -% Graphic Voice Signal -figureSignalVoice = figure('Name','Voice Signal'); -plotSignalVoice = plot(t, F); - plotSignalVoice.LineWidth = 1.5; - plotSignalVoice = 'red'; - xlabel('t[s]') - ylabel('Voltage[V]') - title('Voice Signal') - -% Signal Voice Configuration -ts = min(ts); -tm = min(tm); -d=tm; -fs = max(fs); -fm = max(fm); - -% Normalization -F = F/max(F); -F = F*rangoDinamico; - -% Square Signal -squareSignal = zeros(1,numPeriodos); -squareSignal(1:1)=1; -squareSignal = repmat(squareSignal,1,numMuestras); -F(end)=[]; -t(end)=[]; - -% Sampling -Fsample = F.*squareSignal; - -%% Computing Parameters - -% Transmission Rate -R_b = n*frecuenciaNyquist(1); -disp("a) Transmission Rate: R_s= "+R_b + " bps") - -% BandWidth PCM -Tb_pcm = 1/R_b; -B_pcm = 1/(2*Tb_pcm); -disp("b) BandWidth (PCM): B_pcm= "+B_pcm+" Hz") - - -% 64-PAM Rate -k = log(L)/log(2); -R_s = R_b/k; -disp("c) 64-PAM Rate: R_s= "+R_s + " baudios") - -% Ancho de banda PAM -Tb_pam = 1/R_s; -B_pam = 1/(2*Tb_pam); -disp("d) BandWidth (PAM): B_pam = "+ B_pam + " Hz") - - -%% PAM -PAM = []; -k=1; -t_pam1 = 0:ts/numPeriodos:(d*numPeriodos-ts/numPeriodos); -t_pam = 0:Tb_pam/(numPeriodos-1):numPeriodos*length(Fsample)*(Tb_pam/(numPeriodos-1)); -t_pam(end)=[] - -for i=1:1:length(Fsample) - for j=1:1:numPeriodos - PAM(k)= Fsample(i); - k=k+1; - end -end - -k=1; -% Retention -Fretention=reshape(Fsample,numPeriodos,[]); -FretentionSignal = []; -for i=1:1:length(Fretention) - for j=1:1:numPeriodos - FretentionSignal(k) = Fretention(1,i); - k=k+1; - end -end - - -%% PCM - -% Creo un Vector con los niveles de cuantificacion -a = rangoDinamico*2/L; -valoresCuatificacion = -5+a/2:a:5-a/2; - -% Quantizing -quatizedSignal = FretentionSignal; -vector = FretentionSignal; -for i=1:1:length(FretentionSignal) - if FretentionSignal(i) >= valoresCuatificacion(end) - quatizedSignal(i)= valoresCuatificacion(end); - vector(i) = L-1; - elseif FretentionSignal(i) <= valoresCuatificacion(1) - quatizedSignal(i)=valoresCuatificacion(1); - vector(i) = 0; - else - for j=1:1:L - if (FretentionSignal(i) > valoresCuatificacion(j) && FretentionSignal(i) < valoresCuatificacion(j) + a/2) || (FretentionSignal(i) < valoresCuatificacion(j) && FretentionSignal(i) > valoresCuatificacion(j) - a/2) - quatizedSignal(i) = valoresCuatificacion(j); - vector(i)=j-1; - end - end - end -end - -pcm =reshape(vector,numPeriodos,[]); -pcm_r = pcm(1,:); -pcm_r=dec2bin(pcm_r); - -trama=[]; -k=1; - -numSamplePoints=10; -for i=1:1:length(pcm_r) - for j=1:1:n - for d=1:1:numSamplePoints - trama(k) = string(pcm_r(i,j)); - k=k+1; - end - end - end - -tb=0:Tb_pcm/(numSamplePoints-1):n*numSamplePoints*length(pcm_r)*(Tb_pcm/(numSamplePoints-1)); -tb(end)=[]; - -%% Graphics PCM -% Digital Data -figureDigital = figure('Name','PCM Signal - Digital Data'); -plotDigital = plot(tb,trama); - plotDigital.LineWidth = 1.5; - plotDigital.Color='#0D00EB'; - yticks([0 1]) - axis([0 tb(1000) -2 2]); - title('PCM Signal - Digital Data'); - ylabel('Bit Value'); - xlabel('t[s]'); - grid on; - grid minor; - -% BW_pcm -Y=fft(trama) -P2 = abs(Y/length(trama)); -P1 = P2(1:(length(trama))/2+1); -P1(2:end-1) = 2*P1(2:end-1); -f = B_pcm*numPeriodos*(0:(length(trama)/2))/length(trama); - -% PCM Signal - Frequency Domain -figureDigitalFrequencyDomain = figure('Name','PCM Signal - Frequency Domain'); -plotDigitalFrequency = plot(f,P1); - axis([0 36e3 0 0.5]); - title('PCM Signal - Frequency Domain'); - ylabel('Voltage [V]'); - xlabel('frequency[Hz]'); - grid on; - grid minor; - -%% Graphics PAM - -%PAM signal -figurePAM = figure('Name','PAM SIGNAL'); -plotPAM = plot(t, F, t_pam, PAM,'LineWidth',1.5); - xlabel('t[s]') - ylabel('Voltage[V]') - title('PAM SIGNAL') - -% BW_pcm -Y_pam=fft(PAM) -P2_pam = abs(Y_pam/length(PAM)); -P1_pam = P2_pam(1:(length(PAM))/2+1); -P1_pam(2:end-1) = 2*P1_pam(2:end-1); -f_pam = B_pam*numPeriodos*(0:(length(PAM)/2))/length(PAM); - -figurePamFrequency = figure('Name', 'PAM Signal - Frequency Domain') -plot(f_pam, P1_pam) - -% Quantized Signal -figure('Name','QUANTIZED SIGNAL'); -plot(t,F,t,quatizedSignal, 'LineWidth',1.5); - yticks(valoresCuatificacion) - style = get(gca,'XTickLabel'); - set(gca,'XTickLabel',style,'fontsize',8) - set(gca,'XTickLabelMode','auto') - title('Quantized Signal') - ylabel('Levels of Quatization [V]') - xlabel('t[s]') - -% Tags for Coded -tagsDec=0:1:L-1; -tagsBin=dec2bin(tagsDec); -tagsBin=string(tagsBin); -tagsBin=num2cell(tagsBin); - -% Coded Signal -figure('Name','CODED SIGNAL'); -plot(t,F,t,quatizedSignal, 'LineWidth',1.5); - yticks(valoresCuatificacion) - yticklabels(tagsBin) - style = get(gca,'XTickLabel'); - set(gca,'XTickLabel',style,'fontsize',8) - set(gca,'XTickLabelMode','auto') - title('Coded Signal') - ylabel('Levels of Voltage [V]') - xlabel('t[s]') - grid on; - - -%% Digital Data Animation -%close all -% f1=figure('Name','Digital Data'); -% for i=1:1:length(tb) -% plot(tb(1:i),trama(1:i), 'LineWidth',1.5); -% axis([0 tb(1000) -2 2]) -% grid on; -% grid minor; -% pause(0.0001) -% end \ No newline at end of file diff --git a/main.m b/main.m index c817ad3..df63ded 100644 --- a/main.m +++ b/main.m @@ -24,7 +24,7 @@ wm = 2*pi*fm; % Frecquency in rad/s tm = 1./fm; % Time Period -factor = 75; % Sample Factor +factor = 50; % Sample Factor frecuenciaNyquist = 2*fm; % Nyquist Rate fs = factor*frecuenciaNyquist; % Sample Frequency ts = 1./fs; % Sample Period diff --git a/pcmpamScript.rar b/pcmpamScript.rar new file mode 100644 index 0000000000000000000000000000000000000000..e27796be9a3729704a0f32818b4e5367edce911f GIT binary patch literal 2602 zcmV+_3f1*eVR9iF2LS-{;ezW60R;yD1_1$pfPetshW6hi0s{--lK=#ZyZ|822KZ8d z0{{kXVQFqIZ3+VdF1xj>c}Lg*%|qP@Fm*&TGeq)NW&7wG;Pxhkh?LW7q4aDC#Q;sX z@?Z`gvn!y8aWD%KcO- ztP1;Igw{t!4^keB5;{1?-?jY^=a>8cU>6T!IUf4L19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mdLygt!yC=(3ThL|BHNMs0P zv{Xp(8^+?W^e!Xb25EwEG-6*3OiWLR>m(Z%qVE^LwJHE=7U={{j18$a68 zw~C=j7Fk~c0o1|H|1DkGx!gH+@ZMnF$@?8!^C7s%8T1NoF6$0kri~mGyGeGf#n6Pa z`($||1VP)SL=%os-x7=Uk(B7oq3WZ|c6t)&H#m2A2e{~cTioC9ruAB_xy3_e^rt2^ z9(4M9e+G89bvzSIV*6*j^)PI}>%x2d4m1MqD$nD&?$g))!ODg0*br9>bFs4xW@-^Ia*eX7-Taxo>cfZY11p M_#JmvQ3C}80CYtdD*ylh literal 0 HcmV?d00001 From c7503adc52cf3a2b17e09e16cf028ea35ff1d73c Mon Sep 17 00:00:00 2001 From: Nestor David Castillo Date: Sun, 3 Apr 2022 16:36:47 -0500 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5f859c0..2c93630 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Digital System Communication +Encoding Signal Exersise: