1 | | - | %% Simulating a 28 GHz antenna for a UAV |
2 | | - | % |
3 | | - | % For complex antennas, it is often necessary to perform detailed EM |
4 | | - | % simulations in third-party software such as HFSS and then import |
5 | | - | % the results into MATLAB for analysis. In this lab, we will import HFSS |
6 | | - | % simulation data for a 28 GHz antenna designed for a UAV (unmanned aerial |
7 | | - | % vehicle or drone). Antenna modeling is particularly important for mmWave |
8 | | - | % aerial links since the directivity gain is necessary to overcome the |
9 | | - | % high isotropic path loss of mmWave frequencies. Also, UAVs can be |
10 | | - | % an arbitrary orientation and it is important to model the cases when |
11 | | - | % the UAV is out of the beamwidth of the antenna. |
12 | | - | % |
13 | | - | % In going through this lab, you will learn to: |
14 | | - | % |
15 | | - | % * Import data from an EM simulation data given as a |
16 | | - | % <https://www.mathworks.com/help/matlab/ref/table.html MATLAB table object>. |
17 | | - | % * Compute directivity from E-field values |
18 | | - | % * Create custom arrays in MATLAB's phased array toolbox |
19 | | - | % * Display 2D and 3D antenna patterns |
20 | | - | % * Compute the half-power beamwidth (HPBW) of an antenna |
21 | | - | % * Compute fractions of power in angular areas |
22 | | - | % * Estimate the path loss along a path |
23 | | - | % |
24 | | - | % *Submission*: Complete all the sections marked |TODO|, and run the cells |
25 | | - | % to make sure your scipt is working. When you are satisfied with the |
26 | | - | % results, <https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html |
27 | | - | % publish your code> to generate an html file. Print the html file to |
28 | | - | % PDF and submit the PDF. |
29 | | - | |
30 | | - | |
31 | | - | %% Load the data |
32 | | - | % The data for this lab was generously donated by Vasilii |
33 | | - | % Semkin of VTT and taken from the paper: |
34 | | - | % |
35 | | - | % * W Xia,V. Semkin, M. Mezzavilla, G. Loianno, S. Rangan, |
36 | | - | % Multi-array Designs for MmWave and Sub-THzCommunication to UAVs, |
37 | | - | % 2020 |
38 | | - | % |
39 | | - | % The paper performs EM simulations on a ciccularly polarized |
40 | | - | % 28 GHz antenna mounted to the bottom of a commercial DJI Matrice 100 |
41 | | - | % quadrocopter. An image of the drone with the antenna and its pattern |
42 | | - | % is shown in the following picture. |
43 | | - | A = imread('CP_patch_downwards_m100_3D_coord.png'); |
44 | | - | imshow(A, 'InitialMagnification', 40); |
45 | | - | |
46 | | - | %% |
47 | | - | % We will first load the data with the following command. |
48 | | - | load patch_bottom_data.mat |
49 | | - | |
50 | | - | %% |
51 | | - | % Running the above command should create an object, |data_table|, in |
52 | | - | % your workspace. The |data_table| object is a MATLAB table, |
53 | | - | % which is like a SQL table. Run the following command to see the first |
54 | | - | % five rows. You should see the fields in each table entry including |
55 | | - | % the azimuth and elevation and the corresponding V and H fields. |
56 | | - | data_table(1:5,:) |
57 | | - | |
58 | | - | %% Reading and the data table |
59 | | - | % We can read the table columns into MATLAB arrays with commands such as, |
60 | | - | % |
61 | | - | % col = data_table(:,{column_name}).Variables; |
62 | | - | |
63 | | - | % TODO: Read the 'Elevation' and 'Azimuth' columns into matlab arrays |
64 | | - | % el and az. |
65 | | - | |
66 | | - | |
67 | | - | %% |
68 | | - | % In this simulation, the antenna was pointed upwards, meaning that the |
69 | | - | % boresight is at an elevation of 90 degrees. But, since we want to |
70 | | - | % simulate antenna pointing downwards, we need to switch the signs of the |
71 | | - | % elevation angles. |
72 | | - | |
73 | | - | % TODO: Switch the elevation angles with el = -el; |
74 | | - | |
75 | | - | %% Getting the E-field |
76 | | - | % Most EM simulations prodcuce outputs as E-field at some distance from the |
77 | | - | % antenna. The E-field is represented by two complex values, one for |
78 | | - | % the H polarization and for the V polarization. |
79 | | - | |
80 | | - | % TODO: Read the complex E-fields from the data_table object. Store them |
81 | | - | % in variables EH and EV. |
82 | | - | |
83 | | - | |
84 | | - | %% |
85 | | - | % Recall that the radiation intensity and any point is proportional to |
86 | | - | % the E-field power, |
87 | | - | % |
88 | | - | % W = Epow/eta, Epow = |EH|^2 + |EV|^2. |
89 | | - | % |
90 | | - | % where eta is characteristic impedance. This is the power flux |
91 | | - | % that can be received by an antenna exactly aligned in polarization |
92 | | - | % with the E-field. |
93 | | - | |
94 | | - | % TODO: Compute the E-field power, Epow = |EH|^2 + |EV|^2. |
95 | | - | % Remember to use the MATLAB abs() command. |
96 | | - | |
97 | | - | |
98 | | - | %% Compute the directivity |
99 | | - | % We next compute the directivity of the antenna. The directivity |
100 | | - | % of the antenna is given by, |
101 | | - | % |
102 | | - | % dir = U / Ptot |
103 | | - | % |
104 | | - | % where Ptot is the total radiated power and U is the far-field |
105 | | - | % radiation density |
106 | | - | % |
107 | | - | % U = r^2 W = r^2 Epow / eta |
108 | | - | % |
109 | | - | % Hence, the directivity (in linear scale) is: |
110 | | - | % |
111 | | - | % dir = c*Epow |
112 | | - | % |
113 | | - | % for some constant c. To compute the constant c, we know that |
114 | | - | % the average of the directivity dir * cos(el) over a spherical integral |
115 | | - | % must be one. Hence, if we take mean over the discrete values, you should |
116 | | - | % have that: |
117 | | - | % |
118 | | - | % mean(dir.*cos(el)) / mean(cos(el)) = 1 |
119 | | - | % |
120 | | - | % You can use this relation to find the scale factor, c. |
121 | | - | % |
122 | | - | % TODO: Compute a vector, dir, with the directivity of each point |
123 | | - | % in dBi. Remember, MATLAB's cos() function takes the argument in |
124 | | - | % radians. |
125 | | - | |
126 | | - | |
127 | | - | % TODO: Print the maximum gain. |
128 | | - | |
129 | | - | %% Plotting the 3D antenna pattern |
130 | | - | % To plot the antenna pattern, we will create a CustomAntennaObject in |
131 | | - | % MATLAB's phased array toolbox. However, to use the CustomAntennaObject, |
132 | | - | % we need to re-format the directivity vector into a matrix. The process |
133 | | - | % is tedious, but conceptually simple. What we need to do is create |
134 | | - | % a matrix, |dirMat|, with values, |dirMat(i,j)| is the directivity |
135 | | - | % at (elevation, azimuth) angles |(elval(i), azval(j))|. |
136 | | - | elvals = (-90:2:90)'; |
137 | | - | azvals = (-180:2:180)'; |
138 | | - | nel = length(elvals); |
139 | | - | naz = length(azvals); |
140 | | - | |
141 | | - | %% |
142 | | - | % If you have done everything correctly up to now, you will have a vector, |
143 | | - | % dir, that is should be naz*nel x 1. To convert this to the |
144 | | - | % dirMat matrix, you can do the following: |
145 | | - | % |
146 | | - | % * Reshape the vector, |dir|, into a directory |dirMat| of size |
147 | | - | % |naz x nel| Take the transpose of the matrix so it is |nel x naz|. |
148 | | - | % * Circularly shift (using the MATLAB command circshift) so that the first |
149 | | - | % column of dirMat is moved to the position corresponding to az=0. We do |
150 | | - | % this since the angles in dirMat go from 0 to 360, not -180 to 180 |
151 | | - | % * Flip the dirMat vertically with the MATLAB command flipud. We do this |
152 | | - | % since we want to look at an antenna pattern facing downwards |
153 | | - | % |
154 | | - | % TODO: Create dirMat as above |
155 | | - | |
156 | | - | |
157 | | - | % TODO: Now, create the antenna object with the correct parameters |
158 | | - | % Use an all zero phasePattern. |
159 | | - | % |
160 | | - | % phasePattern = ... |
161 | | - | % ant = phased.CustomAntennaElement(...) |
162 | | - | |
163 | | - | |
164 | | - | % TODO: Plot the antenna pattern with the ant.pattern() command |
165 | | - | fc = 28e9; |
166 | | - | |
167 | | - | |
168 | | - | %% Plot a polar 2D plot |
169 | | - | % We next plot a 2D antenna pattern |
170 | | - | % |
171 | | - | % TODO: Use the ant.patternElevation(...) to plot the antenna cut |
172 | | - | % at azPlot = 0 degrees |
173 | | - | azPlot = 0; |
174 | | - | |
175 | | - | |
176 | | - | %% Computing the half-power beamwidth |
177 | | - | % The half-power beamwidth is a common value in describing the |
178 | | - | % directivity of an antenna. We show how this quantity can be computed. |
179 | | - | % First, get the numerical values of the directivity along a cut |
180 | | - | % at azPlot = 0. We do this with the same command as above, but with |
181 | | - | % an output argument: |
182 | | - | |
183 | | - | % TODO: Run the clf('reset') command. This is needed since the last plot |
184 | | - | % was a pattern plot, |
185 | | - | |
186 | | - | % TODO: dircut = ant.patternElevation(...); |
187 | | - | |
188 | | - | % This returns the directivity along eleation angles elcut |
189 | | - | elcut = (-180:180); |
190 | | - | |
191 | | - | %% |
192 | | - | % The HPBW is the range of angles that correspond to the directivity |
193 | | - | % 3 dB below the peak. |
194 | | - | % |
195 | | - | % TODO: Use the dircut and elcut vectors to find and print the HPBW. |
196 | | - | |
197 | | - | |
198 | | - | %% Computing power fractions. |
199 | | - | % Often we are interested in finding the fraction of radiated power |
200 | | - | % in some angular region. The fraction of power radiated in any |
201 | | - | % region is proportional to the sum of values Epow(i)*cos(el(i)) |
202 | | - | % for all points i in the region. |
203 | | - | % |
204 | | - | % TODO: Use this relation to print the fraction of power radiated in |
205 | | - | % the upper hemisphere. This should be small, since most of the |
206 | | - | % power is radiated downwards. |
207 | | - | |
208 | | - | |
209 | | - | % TODO: Print the power fraction within the HPBW: |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | %% Computing the path loss along a path |
214 | | - | % Following the code in the demo, plot the path loss (omni and |
215 | | - | % with element gain) of a UAV RX flying from (0,0,30) to (500,0,30) |
216 | | - | % in a linear path. Assume the TX is at (0,0,0). |
217 | | - | % |
218 | | - | % TODO: Plot the omni and directional path loss vs. x position. |
219 | | - | % |
220 | | - | % You should see initially that you obtain significant antenna gain |
221 | | - | % since the antenna is facing downwards to the TX. But, as you fly |
222 | | - | % the antenna gain decreases and becomes negative. Before plotting you |
223 | | - | % will want to run the command, clf('reset'). This is necessary since the |
224 | | - | % pattern plots above screw up later figures. |
225 | | - | |
226 | | - | |