Projects STRLCPY wirelesscomm Commits 9ced758f
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    unit03_fading/partial/lab_chan_sounder.m
    1  -%% Lab: 5G Channel Sounding with Doppler
    2  -% Channel sounders are used to measure the channel response between a TX
    3  -% and RX. These are vital to study propagation and are also an excellent
    4  -% tool for debugging the front-end of a transceiver system. In this lab,
    5  -% we will simulate a simple channel sounder over a fading channel with
    6  -% time-variations and Doppler. The very same tools are used
    7  -% in radar.
    8  -%
    9  -% The digital communications class covered a simpler version of this lab
    10  -% with a static channel.
    11  -%
    12  -% In doing this lab, you will learn to:
    13  -%
    14  -% * Describe cluster-delay line (CDL) models
    15  -% * Get parameters for 5G CDL models using the
    16  -% <https://www.mathworks.com/products/5g.html 5G MATLAB toolbox>
    17  -% * Represent antenna orientations using global and local frames of
    18  -% reference.
    19  -% * Compute directional gains on paths from the angles
    20  -% * Implement multi-path fading channels
    21  -% * Perform simple time-frequency channel sounding
    22  -%
    23  -% *Submission*: Complete all the sections marked |TODO|, and run the cells
    24  -% to make sure your scipt is working. When you are satisfied with the
    25  -% results, <https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html
    26  -% publish your code> to generate an html file. Print the html file to
    27  -% PDF and submit the PDF.
    28  - 
    29  -%% Loading the 3GPP NR channel model
    30  -% In this lab, we will simulate a widely-used channel model from 3GPP,
    31  -% the organization that developed the 4G and 5G standards. Specifically,
    32  -% we will use the 5G New Radio cluster delay line model. In the CDL
    33  -% model, the channel is described by a set of path clusters. Each path
    34  -% cluster has various parameters such as an average gain, delay and angles
    35  -% of arrival and departure. The parameters for this model can be loaded
    36  -% with the following commands that are part of the 5G Toolbox.
    37  -fc = 28e9; % carrier in Hz
    38  -dlySpread = 50e-9; % delay spread in seconds
    39  -chan = nrCDLChannel('DelayProfile','CDL-C',...
    40  - 'DelaySpread',dlySpread, 'CarrierFrequency', fc, ...
    41  - 'NormalizePathGains', true);
    42  -chaninfo = info(chan);
    43  - 
    44  -%%
    45  -% After running the above commands, you will see that the chaninfo
    46  -% data structure has various vectors representing the paramters for each
    47  -% path cluster.
    48  - 
    49  -% TODO: Extract the parameters from chaninfo:
    50  -% gain = average path gain in dB
    51  -% aoaAz = azimuth angle of arrival
    52  -% aoaEl = elevation angle of arrival = 90 - ZoA
    53  -% aodAz = azimuth angle of departure
    54  -% aodEl = elevation angle of departure = 90 - ZoA
    55  -% dly = delay of each path
    56  - 
    57  -% TODO: Compute and print npath = number of paths
    58  - 
    59  -% TODO: Use the stem() command to plot the gain vs. delay.
    60  -% Each stem in this plot would represent one multi-path component.
    61  -% Set 'BaseValue' to -40 so that the stems are easier to see.
    62  -% Label the delay in ns.
    63  - 
    64  - 
    65  -%% Patch Element
    66  -% In this simulation, we will assume the TX and RX patch microstrip
    67  -% antennas. We use the code below to create the antenna element from the
    68  -% antenna demo.
    69  - 
    70  -% Constants
    71  -vp = physconst('lightspeed'); % speed of light
    72  -lambda = vp/fc; % wavelength
    73  - 
    74  -% Create a patch element
    75  -len = 0.49*lambda;
    76  -groundPlaneLen = lambda;
    77  -ant = patchMicrostrip(...
    78  - 'Length', len, 'Width', 1.5*len, ...
    79  - 'GroundPlaneLength', groundPlaneLen, ...
    80  - 'GroundPlaneWidth', groundPlaneLen, ...
    81  - 'Height', 0.01*lambda, ...
    82  - 'FeedOffset', [0.25*len 0]);
    83  - 
    84  -% Tilt the element so that the maximum energy is in the x-axis
    85  -ant.Tilt = 90;
    86  -ant.TiltAxis = [0 1 0];
    87  - 
    88  -%% Create UE and gNB antennas
    89  -% We will simulate a channel from a base station cell to a mobile device.
    90  -% In 5G terminology, the base station cell is called the gNB and the mobile
    91  -% device is called the UE (don't ask!). We first create a model for the
    92  -% antennas on each device. In reality, both would have an array of
    93  -% elements, but we will just assume one element for each now.
    94  -%
    95  -% To organize the code better, we have created a class |ElemWithAxes| to
    96  -% represent the antenna element. This class is basically a wrapper for
    97  -% the AntennaElement class to include a frame of reference and methods
    98  -% to compute gains relative to this frame of reference.
    99  - 
    100  -% TODO: Complete the code for the constructor in the ElemWithAxes class
    101  - 
    102  -% TODO: Create two instances, elemUE and elemgNB, of the ElemWithAxes
    103  -% class representing the elements at the UE and gNB.
    104  -% elemUE = ElemWithAxes(...);
    105  -% elemgNB = ElemWithAxes(...);
    106  - 
    107  -%% Rotate the UE and gNB antennas
    108  -% The response of the channel will depend on the orientation of the antenna
    109  -% elements. To make this simple, we will assume the UE and gNB elements
    110  -% are aligned to the strongest path. Note that when modifying a class
    111  -% you will need to re-run the constructor.
    112  - 
    113  -% TODO: Complete the code in the alignAxes() method of ElemWithAxes.
    114  - 
    115  -% TODO: Find the index of the path with the maximum gain.
    116  - 
    117  -% TODO: Call the elemUE.alignAxes() methods to align the UE antenna
    118  -% to the angle of arrival corresponding to the strongest path.
    119  - 
    120  -% TODO: Call the elemgNB.alignAxes() methods to align the gNB antenna
    121  -% to the angle of departure corresponding to the strongest path.
    122  - 
    123  - 
    124  -%% Get the directivity along the paths
    125  -% We next compute the directional gains along to the paths.
    126  -% The ElemWithAxes class is derived from a
    127  -%<https://www.mathworks.com/help/matlab/system-objects.html MATLAB system
    128  -% object>, which is MATLAB's base class for objects that can handle dynamic
    129  -% data. In constructing link-layer simulations, it is useful to build your
    130  -% classes as system objects. The key method in a system object is the
    131  -% step() method that is called in each chunk of data. In the derived
    132  -% class, you define the stepImpl() method which is in turn called in the
    133  -% step method. For the ElemWithAxes class, we will define the step method
    134  -% to take angles and return the directivity in dBi.
    135  - 
    136  -% TODO: Complete the code in the setupImpl() and
    137  -% stepImpl() method of ElemWithAxes.
    138  - 
    139  -% TODO: Call the elemUE.step() method with the angles of arrivals of the
    140  -% paths to get the directivity of the paths on the UE antenna.
    141  -% dirUE = elemUE.step(...);
    142  - 
    143  -% TODO: Call the elemgNB.step() method with the angles of departures of the
    144  -% paths to get the directivity of the paths on the gNB antenna.
    145  -% dirgNB = elemUE.step(...);
    146  - 
    147  -% TODO: Compute, gainDir, the vector of gains + UE and gNB directivity.
    148  -% gainDir = ...
    149  - 
    150  -% TODO: Use the stem plot as before to plot both the original gain and
    151  -% gainDir, the gain with directivity. Add a legend and label the axes.
    152  -% You will see that, with directivity, many of the paths are highly
    153  -% attenuated and a few are amplified.
    154  - 
    155  -%% Compute the Doppler
    156  -% We next compute the Doppler for each path.
    157  - 
    158  -% TODO: Complete the doppler method in the ElemWithAxes class
    159  - 
    160  -% TODO: Use the elemUE.set() method to set the mobile velocity to 100 km/h
    161  -% in the y-direction. Remember to convert from km/h to m/s.
    162  -vkmh = 100;
    163  - 
    164  -% TODO: Call the elemUE.doppler() method to find the doppler shifts of all
    165  -% the paths based on the angle of arrivals
    166  - 
    167  - 
    168  -%% Transmitting a channel sounding signal
    169  -% The code is based on the lab in digital communications. As described
    170  -% there, the TX simply repeated transmits a signal of length nfft. Each
    171  -% repetition is called a frame. We will use the following parameters.
    172  -fsamp = 4*120e3*1024; % sample rate in Hz
    173  -nfft = 1024; % number of samples per frame = FFT window
    174  -nframe = 512; % number of frames
    175  - 
    176  - 
    177  -%%
    178  -% In frequency-domain channel sounding we create the TX samples in
    179  -% frequency domain.
    180  - 
    181  -% TODO: Use the qammod function to create nfft random QPSK symbols.
    182  -% Store the results in x0Fd.
    183  - 
    184  -% TODO: Take the IFFT of the signal representing the time-domain samples.
    185  -% Store in x0.
    186  - 
    187  -% TODO: Repeat the data x0 nframe times to create a vector x of length
    188  -% nframe*nfft x 1.
    189  - 
    190  -%% Create a multi-path channel object
    191  -% To simulate the multi-path channel, we have started the creation of a
    192  -% class, |SISOMPChan|. The constructor of the object is already written in
    193  -% a way that you can call construct the channel with parameters with the
    194  -% syntax:
    195  -% chan = SISOMPChan('Prop1', Val1, 'Prop2', val2, ...);
    196  - 
    197  -% TODO: Use this syntax to construct a SISOMPChan object with the sample
    198  -% rate, path delays, path Doppler and directional gains for the channel
    199  - 
    200  -%% Implementing the channel
    201  -% The SIMOMPChan object derives from the matlab.System class and should
    202  -% implement:
    203  -% * setupImpl(): Called before the first step after the object is
    204  -% constructured
    205  -% * resetImpl(): Called when a simulation starts
    206  -% * releaseImpl(): Called on the first step after a reset() or release()
    207  -% * stepImpl(): Called on each step
    208  - 
    209  -% TODO: Complete the implementations of each of these meth
    210  - 
    211  -% TODO: Run the data through the step.
    212  - 
    213  -% TODO: Add noise 20 dB below the y
    214  - 
    215  - 
    216  -%% Estimating the channel in frequency domain
    217  -% We will now perform a simple channel estimate in frequency-domain
    218  - 
    219  -% TODO: Reshape ynoisy into a nfft x nframes matrix and take the FFT of
    220  -% each column. Store the results in yfd.
    221  - 
    222  - 
    223  -% TODO: Estimate the frequency domain channel by dividing each frame of
    224  -% yfd by the transmitted frequency domain symbols x0Fd. Store the results
    225  -% in hestFd
    226  - 
    227  -% TODO: Plot the estimated channel magnitude in dB. Label the axes in
    228  -% time and frequency
    229  - 
    230  -%% Estimating the channel in time-domain
    231  -% We next estimate the channel in time-domain
    232  - 
    233  -% TODO: Take the IFFT across the columns and store the results in a
    234  -% matrix hest
    235  - 
    236  -% TODO: Plot the magnitude of the samples of the impulse response
    237  -% in one of the symbols. You should see a few of the paths clearly.
    238  -% Label the axes in delay in ns.
    239  - 
    240  - 
    241  -%% Bonus: Viewing the channel in delay Doppler space
    242  -% Finally, we can estimate the channel in the delay-Doppler space.
    243  -% This is commonly done in radar and we will use the exactly same procedure
    244  -% here. In the frequency domain response, hestFd, each path results in:
    245  -% * Linear phase rotation across frequency due to delay of the path
    246  -% * Linear phase rotation across time due to Doppler
    247  -% Hence, we can see the paths in the delay-Doppler space with a 2D IFFT.
    248  - 
    249  -% TODO: Take a 2D ifft of hestFd and store in a matrix G.
    250  - 
    251  -% We can now extract the delay-Doppler components from G.
    252  -% Most of the interesting components in a small area:
    253  -%
    254  -% nrow = 64;
    255  -% ncol = 32;
    256  -% Gs = [G(1:nrow,nframe-ncol:nframe) G(1:nrow,1:ncol)];
    257  -%
    258  -% TODO: Plot the magnitude squared of Gs in dB using imagesc. Label the delay
    259  -% and doppler axes. You should see the components clearly.
    260  - 
    261  -% We can even compare the peaks in the matrix Gs with the delay and Doppler
    262  -% of the actual components.
    263  -% TODO: Find the indices of the paths with top 20 directional gains.
    264  - 
    265  -% TODO: On the same plot as above, plot a circle corresponding to the
    266  -% (doppler,delay) for each of the top components. You may have to reverse
    267  -% the doppler due to the sign conventions we have used.
    268  - 
  • unit03_fading/partial/lab_chan_sounder.mlx
    Binary file.
  • unit03_fading/partial/lab_chan_sounder.pdf
    Binary file.
Please wait...
Page is in error, reload to recover