C_Stottlemeyer_ECET375_WK3_lab
docx
keyboard_arrow_up
School
DeVry University, Chicago *
*We aren’t endorsed by this school
Course
375
Subject
Electrical Engineering
Date
Jun 4, 2024
Type
docx
Pages
16
Uploaded by cls8879
WEEK 3 LAB
ECET 375
MARCH 25, 2019
CHRIS STOTTLEMEYER
1
Experiments:
1)
The Matlab function dec2base(str,n,m) is very helpful in converting characters into a string of m digit string in base n. For example, dec2base(‘a’, 2, 8) will convert the ASCII code for ‘a’ into an 8 bit binary number expressed as a string of 8 bits.
Since we have four symbols, one for two bits, we use the dec2base(str,4,4) function.
The following sequence of commands (which are part of script file str2pam.m) is the basis for letters to symbol conversion.
What do you see when you run this script? What do you expect the binary code for the letter ‘n’ to be? What are its 4-PAM symbols?
A.) Binary code for the letter ‘a’ is 01100001
4-PAM symbols are [-1, 1, -3, -1]
1)
Change the str variable in the script to ‘Pay $200’. Run the code and record the output. What is the output? How many symbols are there? What is the code for $ sign? What is the relationship between the number of symbols and the number of letters?
A.) 01010000
01100001
01111001
00100000
00100100
00110010
00110000
00110000
4 digits base 4 for ‘Pay $200’ are 1100
1201
1321
0200
0210
0302
0300
0300
Multiply by 2 98
98
96
96
98
100
96
98
98
102
100
98
96
100
96
96
96
100
98
96
96
102
96
100
96
102
96
96
96
102
96
96
2
4-PAM symbols are -1
-1
-3
-3
-1
1
-3
-1
-1
3
1
-1
-3
1
-3
-3
-3
1
-1
-3
-3
3
-3
1
-3
3
-3
-3
-3
3
-3
-3
1.
Transforming Symbols to Signals
In this step, we convert the symbols into signals for transmission. Ideally we want to choose such signals that: i)
cause no inter-symbol interference (ISI; i.e., the value of the message at a given time does not interfere with the value of the message at other times)
ii)
are efficient in terms of bandwidth usage
iii)
are not adversely affected by noise that is invariably present in transmission systems
The program given below generates and displays rectangular, Hamming, sync, and square-root raised
cosign (SRRC) pulse shapes and their spectrum.
The following program illustrates the example pulse shapes:
%% ECET-375 Lab-2: pulseShapes.m %%generate symbols % Create a random +/- L-PAM source symbol sequence with
% length N and variance 'Var'
L=4; Var=5; N=1000;
s=2*floor(L*rand(1,N))-L+1;
s=s*sqrt(3*Var/(L^2-1));
%oversample by M points to simulate analog system
M=20; ovrSampled=zeros(1,N*M); ovrSampled(1:M:end)=s % oversampling by factor of M
pulseChoice = 'srrc'
% 'Rectangle' 'Hamming' 'Sync' 'rc, 'srrc'
switch (lower(pulseChoice))
case 'hamming'
% Generate hamming pulse
extent = 1;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
3
pulseSig=hamming(extent*M);
pulseShapeTitle = 'Hamming Pulse'
;
case 'rectangle'
%generate pulses used to convert symbols into signals
pulseSig=ones(1,M); % rectangular/square pulse width M
pulseShapeTitle = 'Rectangular Pulse'
;
case 'sync'
f6db=10; % 6db width of the sync pulse
beta=1e-8;
%zero for beta in raised cosine signal yields sinc pulse
indx=-4/(2*f6db)+1e-8:1/(10*2*f6db):4/(2*f6db)+1e-8; % sampling indices
pulseSig=(sin(2*pi*f6db*indx)./(2*pi*f6db*indx)).*(cos(2*pi*beta*f6db*indx)./(1-
(4*beta*f6db*indx).^2));
pulseShapeTitle=
'Sync Pulse'
case 'srrc'
% Generate a Square-Root Raised Cosine Pulse
beta=0.3;
% try different values for the roll-off factor; a value of 0 yields the sinc pulse
f6db=10; % 6db width of the sync pulse
indx=-4/(2*f6db)+1e-8:1/(10*2*f6db):4/(2*f6db)+1e-8; % sampling indices
pulseSig=(sin(2*pi*f6db*indx)./(2*pi*f6db*indx)).*(cos(2*pi*beta*f6db*indx)./(1-
(4*beta*f6db*indx).^2));
pulseShapeTitle=
'SRRC Pulse'
otherwise
% Generate hamming pulse
extent = 1;
pulseSig=hamming(extent*M) %ones(1,M);
pulseShapeTitle = 'Hamming Pulse'
;
end
%Simulate the received signal
recSig=filter(pulseSig,1,ovrSampled); % convolve pulse shape with oversampled signal
tt=1/M:1/M:length(pulseSig)/M;
figure(1)
4
subplot(3,1,1), plot(tt,pulseSig)
ylabel(
'Pulse shape'
)
xlabel(
'one sample period'
)
title(pulseShapeTitle)
[h,w]=freqz(pulseSig);
subplot(3,1,2), semilogy(w/pi,abs(h))
ylabel(
'Pulse spectrum'
)
xlabel(
'normalized frequency'
)
fftx=abs(fft(recSig));
subplot(3,1,3), semilogy(2*(1:length(fftx)/2)/length(fftx),fftx(1:length(fftx)/2))
ylabel(
'Waveform spectrum'
)
xlabel(
'normalized frequency'
)
Experiments:
The pulseShapes.m
program shown above has capability to display one of the four pulse shapes (Hamming, rectangle, Sync, or SRRC) and its spectrum. 1)
Make the choice of one of Hamming, Rectangle, Sync, or SRRC one at a time. Save the graphs you obtain for each in your lab report. Which pulse shape produces the smallest bandwidth? Which pulse shape has the widest bandwidth?
5
SRRC has the smallest pulse. Hamming has the widest.
2)
Which pulse shape has widest span in the time-domain? Which pulse shape has the narrowest
span in the time-domain?
A.) Hamming pulse has widest span in the time domain and Rectangular has the narrowest span. 2.
Eye Diagrams
The inter-symbol interference (ISI) occurs when signals of adjacent symbols interfere with each other. This may occur when the pulse shapes used for symbols are wider than the time allocated for one symbol. It is like a radio program that continues beyond its allotted time and into the next program’s time slot. Another reason for ISI is that a noisy channel impairs the signals (for example, causes unequal phase delays for different input frequencies) so much that they spill over to adjacent channels. The ISI may cause the receiver to incorrectly decode the bits from the signals. The eye diagram is a visual tool that can be used to understand the extent of impairments to the transmitted signal.
If you overlay the traces of received signal for every n symbols (that is, if you restart the trace on an oscilloscope every nT seconds) without erasing the previous traces, the picture you see is the eye diagram. The abscissa displays the time for n symbols, and the ordinate displays the received
signal amplitude. As the number of overlaid traces increases, the eye diagram becomes thicker and can show how the effects of noise, channel impairments, and other detrimental factors contribute to the difficulty of correctly determining the transmitted message.
The following Matlab program illustrates the generation of eye diagrams for different pulse shapes.
%% ECET-375 Lab-3: eyeDiagrams.m %%generate symbols
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
6
% Create a random +/- L-PAM source symbol sequence with length N and variance 'Var'
%%%%%%%%%%%%%%%%%%%%%%%%%
L=4; %Change this to try out different L-PAM symbols:e.g. 4, 6
Var=5; %Change this to try out different variances for random symbols e,g. 5, 35/6
%%%%%%%%%%%%%%%%%%%%%%%%%
N=1000;
s=2*floor(L*rand(1,N))-L+1;
s=s*sqrt(3*Var/(L^2-1));
%oversample by M points to simulate analog system
M=20; ovrSampled=zeros(1,N*M); ovrSampled(1:M:end)=s; % oversampling by factor of M
%%%%%%%%%%%%%%%%%%%%%%%%%%
%generate pulse used to convert symbols into signals
pulseChoice = 'srrc'
% 'Rectangle' 'Hamming' 'Sync' 'srrc'
%%%%%%%%%%%%%%%%%%%%%%%%%%
switch (lower(pulseChoice))
case 'hamming'
%%%%%%%%%%%%%%%%%%%%%%%%%%
extent = 1; % Change this value to try out different length hamming pulses. e.g. 2, 3, 4
%%%%%%%%%%%%%%%%%%%%%%%%%%
offset = -3;
bias = 1;
pulseSig=hamming(extent*M);
eyeDiagTitle=
'Eye diagram for hamming pulse shape'
case 'rectangle'
pulseSig=ones(1,M); % rectangular/square pulse width M
eyeDiagTitle = 'Eye diagram for rectangular pulse shape'
7
offset = -3;
bias = 1;
case 'sync'
f6db=10; % 6db width of the sync pulse
beta=1e-8;
%zero for beta in raised cosine signal yields sinc pulse
indx=-4/(2*f6db)+1e-8:1/(10*2*f6db):4/(2*f6db)+1e-8; % sampling indices
pulseSig=(sin(2*pi*f6db*indx)./(2*pi*f6db*indx)).*(cos(2*pi*beta*f6db*indx)./(1-
(4*beta*f6db*indx).^2));
pulseSig=pulseSig/max(pulseSig);
eyeDiagTitle=
'Eye diagram for sync pulse shape'
offset = -3;
bias = 1;
case 'srrc'
%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generate a Square-Root Raised Cosine Pulse
beta=0.3;
% try different values for the roll-off factor; a value of 0 yields the sinc pulse
%%%%%%%%%%%%%%%%%%%%%%%%%%
f6db=10; % 6db width of the sync pulse
indx=-4/(2*f6db)+1e-8:1/(10*2*f6db):4/(2*f6db)+1e-8; % sampling indices
pulseSig=(sin(2*pi*f6db*indx)./(2*pi*f6db*indx)).*(cos(2*pi*beta*f6db*indx)./(1-
(4*beta*f6db*indx).^2));
pulseSig=pulseSig/max(pulseSig);
eyeDiagTitle=
'Eye diagram for srrc pulse shape'
offset = -3;
bias = 1;
otherwise
pulseSig=hamming(M);
8
eyeDiagTitle=
'Eye diagram for hamming pulse shape'
offset = -3;
bias = 1;
end
%Simulate the received signal
recSig=filter(pulseSig,1,ovrSampled); % convolve pulse shape with oversampled signal
%Split signal at the receiver into traces.
nEyes=5; %number of eyes to plot
nTr=floor(length(recSig)/(nEyes*M)) % number of sample per trace
adjRecSig=recSig(end-nEyes*M*(nTr + offset)+bias:end); % dont plot transients at start
TrMatrix=reshape(adjRecSig,nEyes*M,(nTr + offset)); % Trace data arranged as rows of a matrix
absis=(1:nEyes*M)/M;
%displayed simultaneously to create an eye diagram
plot(absis, TrMatrix), title(eyeDiagTitle)
Experiments:
The eyeDiagrams.m
program shown above has several parameters that you can change and then explore the corresponding eye diagrams. 1)
To start off, you can change the pulse choice to one of Hamming, Rectangle, Sync, or SRRC one at a time. Save the graphs you obtain for these in your lab report. Which pulse shape produces the widest eyed diagram?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
9
Sync pulse has the widest eye diagram. 2)
Now set the pulse choice as Hamming. Then, keeping this choice unchanged, try different values for the extent (e.g. 1, 2, 3, and 4) and save the eye diagram graphs you obtain. Describe what is happening in the ‘eye’ as you increase the extent. What do you conclude about the effect of extent of the Hamming pulse on the errors at the receiver?
10
The increase in extent shows a greater error rate and means that the message will likely transmit incorrectly. 3.
A Receiver
We have seen before that the transmitted signal is generated using pulse shapes corresponding to symbols which, in turn, are coded messages. The receiver needs to undo all these operations to recover the message that was transmitted. First, the receiver needs to figure out where in the received
signal the pulse shapes occur. The following Matlab script (xmtRec.m) combines the transmitter and receiver functions: %ECET-375 Lab-3 xmtRev.m script
%TRANSMITTER
% encode text string as 4-PAM (-1, +1, -3, +3)
str=
'ECET-375 is a fun course.'
;
Nm=length(str); % length of message
base=4;
sym=zeros(1,base*Nm); % provide space for 4-PAM code
for i=0:Nm-1 % generate 4-PAM using base 4
sym(base*i+1:base*i+base)=2*(dec2base(str(i+1),base,4))-99;
end
Ns=length(sym); % number of symbols
% zero pad symbol array to create oversampled samples.
11
% sequence of scaled T-spaced pulses (with T = 1 time unit)
M=100; ovrSampld=zeros(1,Ns*M); ovrSampld(1:M:end)=sym; % oversampling factor
% Hamming pulse filter impulse response
pulseSig=hamming(M); % pulse of width M
basBndSig=filter(pulseSig,1,ovrSampld); % convolve pulse shape with symbols
%Plot BasebandSig spectrum
Ts=1/M;
N=length(basBndSig); % length of the signal x
t=Ts*(1:N); % define a time vector ssf=(-N/2:N/2-1)/(Ts*N); % frequency vector
fx=fft(basBndSig(1:N)); % do DFT/FFT
fxs=fftshift(fx); % shift it for plotting
subplot(2,1,1), plot(t,basBndSig) % plot the waveform
xlabel(
'seconds'
); ylabel(
'amplitude'
) % label the axes
subplot(2,1,2), plot(ssf,abs(fxs)) % plot magnitude spectrum
xlabel(
'frequency'
); ylabel(
'magnitude'
) % label the axes
% am modulation
tt=1/M:1/M:length(basBndSig)/M; % T/M-spaced time vector
fc=20; % carrier frequency
carSig=cos(2*pi*fc*tt); % carrier
recSig=carSig.*basBndSig; % modulate message with carrier
%RECEIVER
% am demodulation of received signal sequence r
syncCosine=cos(2*pi*fc*tt); % synchronized cosine for mixing
demSig=recSig.*syncCosine; % demod received signal
firLen=50; % LPF length
fPoints=[0 0.1 0.2 1]; magPoints=[1 1 0 0 ]; % design of LPF parameters
b=firpm(firLen,fPoints,magPoints); % create LPF impulse response
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
12
recScSig=2*filter(b,1,demSig); % LPF and scale downconverted signal
% extract upsampled pulses using correlation implemented as a convolving filter
pwr=(sum(pulseSig.^2)/length(pulseSig)); %calculate power in the pulse signal.
recSigPulse=filter(fliplr(pulseSig)/(pwr*M),1,recScSig); % filter rec'd sig with pulse; normalize
% set delay to first symbol-sample and increment by M
dn2Sym=recSigPulse(0.5*firLen+M:M:end); % downsample to symbol rate
figure(2), plot([1:length(dn2Sym)],dn2Sym,
'.'
) % % Convert signals to symbols : -1, +1, -3, +3
% using nearest neighbor method
% alphabet - vector of discrete values that y can take on % sorted in ascending order
% y - quantized vector
alphabet=[-3,-1,1,3];
x=dn2Sym;
[r c] = size(alphabet); if c>r, alphabet=alphabet'; end
[r c] = size(x); if c>r, x=x'; end
alpha=alphabet(:,ones(size(x)))';
dist=(x(:,ones(size(alphabet)))-alpha).^2;
[v,i]=min(dist,[],2);
y=alphabet(i);
% decode decision device output to text string
%reconstruct message
seq=y';
clusterVariance=(seq-dn2Sym)*(seq-dn2Sym)'/length(seq), % cluster variance
lmp=length(seq);
percentageVsymbolErrors=100*sum(abs(sign(seq-sym(1:lmp))))/lmp, % symb err
13
S = length(seq);
off = mod(S,base);
if off ~= 0
sprintf(
'ignoring last %i PAM symbols'
,off)
seq = seq(1:S-off);
end
N = length(seq)/base;
for i = 0:N-1
f(i+1) = base2dec(char((seq(base*i+1:base*i+4)+99)/2),base); end
reconstructedMmessage = char(f)
Experiments:
The xmtRec.m
program shown above displays two figures. 1)
What message is the transmitter sending? What is the corresponding 4-PAM code?
The message is “ECET-375 is a fun course”. And the corresponding 4-PAM code are -1
-3
-1
-1
-1
-3
-3
3
-1
-3
-1
-1
-1
-1
-1
-3
-3
1
3
-1
-3
3
-3
3
-3
3
-1
3
-3
3
-1
-1
-3
1
-3
-3
-1
1
1
-1
-1
3
-3
3
-3
1
-3
-3
-1
1
-3
-1
-3
1
-3
-3
-1
1
-1
1
-1
3
-1
-1
-1
1
3
1
-3
1
-3
-3
-1
1
-3
3
14
-1
1
3
3
-1
3
-1
-1
-1
3
-3
1
-1
3
-3
3
-1
1
-1
-1
-3
1
3
1
2)
Which type of pulse shape is the transmitter using?
A.) hamming pulse
3)
Run the script and save the two figures it produces. Determine the nature of the figures
first shows the amplitude of a 4-PAM code with string “Pay $200”
4)
Figure 2 shows the history of reconstructed symbols estimates made by the receiver. This diagram is called the time history of a constellation diagram. In this figure, all the dots, if everything goes well, occur near the expected symbol values (i.e. -3, -1, +1, +3). The closer they cluster around the defined symbols, the less likely the errors in reconstruction of the messages. Cluster variance, which is the average of the square of the difference between the decoded symbol values (these are called soft
decisions) and the nearest member of the alphabet (these are called hard
decisions), measures how close the clusters occur. What is the cluster variance for the message used in the script?
Cluster variance = 2.8637 e^-5
5)
Is the original message completely recovered? If not, what are the errors?
The message is recovered
6)
Try your own message and see if it is reconstructed correctly.
The message is recovered
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
15
Related Documents
Related Questions
b) There are five binary or hexadecimal numbers and six decimal conversions. Draw a line to
connect each binary/hexadecimal to decimal number.
Binary/Hexadecimal
Decimal
4E
78
11011010
157
10011101
167
A7
25
19
218
arrow_forward
Digital Electronics
Are these complete answers? I want complete
arrow_forward
20. Suppose we have just found yet another representation for floating point numbers. Using this
representation, a li2-bit floating point number has 1 bit for the sign of the number, 4 bits for
the exponent and 7 bits for the mantissa, which is normalized as in the Simple Model so that
the first digit to the right of the radix points must be a 1. Numbers in the exponent are in signed
2's complement representation. No bias is used and there are no implied bits. Show the
representation for the smallest positive number this machine can represent using the following
format (simply fill in the squares provided). What decimal number does this equate to? :
SIGN
EXPONENT
MANTISSA
arrow_forward
a) Convert the decimal number - 239 into a
signed binary number using
(1) sign-magnitude method (2) 1's
complement method (3) 2's complement
method
b) If the above decimal number is positive ,
that is + 239, then convert it to a signed
binary number using 1 's complement
method
c) Do the following binary subtraction:
101111111.01111-
001011010.10110
d)Explain Types of RAM?
arrow_forward
1) What is the biggest binary number (decimal value) you can write with 6 bits?
What is the biggest binary number (decimal value and in terms of n) you can write
with n bits?
If you want to represent the decimal numbers from 0-16, what is the minimum
number of bits you will need?
Convert the decimal number 238 to binary number. (ZERO point if not showing
steps/calculation!)
arrow_forward
convert decimal number 4932 to:
(a) BCD
(b) excess-3 code
(c) ASCII
(d) ASCII with odd parity
(e) hex-coded binary
plz show steps. but you don't need to show steps to ascii. Thanks.
arrow_forward
Answer the D, E and F part
arrow_forward
Question iii please help......
arrow_forward
To convert the decimal number 30 to an 8-bit binary number, use the following representation methods: a) the inverse of its complement: b) Excess-M:?
arrow_forward
2) Perform the following conversions:
dont use others answers
show yiur work step by step
arrow_forward
(i) Convert decimal number 567 to Octal
(ii) Convert decimal number 39 to binary
(iii) Convert decimal number 644 to hexadecimal
(iv) Convert hexadecimal value C9 to binary.
Convert (0.677)10 into an octal number
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you

Related Questions
- b) There are five binary or hexadecimal numbers and six decimal conversions. Draw a line to connect each binary/hexadecimal to decimal number. Binary/Hexadecimal Decimal 4E 78 11011010 157 10011101 167 A7 25 19 218arrow_forwardDigital Electronics Are these complete answers? I want completearrow_forward20. Suppose we have just found yet another representation for floating point numbers. Using this representation, a li2-bit floating point number has 1 bit for the sign of the number, 4 bits for the exponent and 7 bits for the mantissa, which is normalized as in the Simple Model so that the first digit to the right of the radix points must be a 1. Numbers in the exponent are in signed 2's complement representation. No bias is used and there are no implied bits. Show the representation for the smallest positive number this machine can represent using the following format (simply fill in the squares provided). What decimal number does this equate to? : SIGN EXPONENT MANTISSAarrow_forward
- a) Convert the decimal number - 239 into a signed binary number using (1) sign-magnitude method (2) 1's complement method (3) 2's complement method b) If the above decimal number is positive , that is + 239, then convert it to a signed binary number using 1 's complement method c) Do the following binary subtraction: 101111111.01111- 001011010.10110 d)Explain Types of RAM?arrow_forward1) What is the biggest binary number (decimal value) you can write with 6 bits? What is the biggest binary number (decimal value and in terms of n) you can write with n bits? If you want to represent the decimal numbers from 0-16, what is the minimum number of bits you will need? Convert the decimal number 238 to binary number. (ZERO point if not showing steps/calculation!)arrow_forwardconvert decimal number 4932 to: (a) BCD (b) excess-3 code (c) ASCII (d) ASCII with odd parity (e) hex-coded binary plz show steps. but you don't need to show steps to ascii. Thanks.arrow_forward
- 2) Perform the following conversions: dont use others answers show yiur work step by steparrow_forward(i) Convert decimal number 567 to Octal (ii) Convert decimal number 39 to binary (iii) Convert decimal number 644 to hexadecimal (iv) Convert hexadecimal value C9 to binary. Convert (0.677)10 into an octal numberarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
