1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2 | % Two-Way transmission and reception of data using WARPLab(SISO configuration) |
---|
3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4 | % Use WARPLab for two-way communication between two nodes. First node 1 |
---|
5 | % will transmit to node 2 and then node 2 will transmit to node 1. |
---|
6 | % This code uses AGC to set receiver gains |
---|
7 | % We suggest looking at the warplab_siso_example_TxRxAGC_TonePreamble or |
---|
8 | % warplab_siso_example_TxRxAGC_80211aPreamble example to get a better |
---|
9 | % understanding on how AGC works. |
---|
10 | |
---|
11 | % The specific steps implemented in this script are the following |
---|
12 | |
---|
13 | % 0. Initializaton and definition of parameters |
---|
14 | % 1. Generate the vector of samples that node 1 will transmit to node 2 and |
---|
15 | % the vector of samples that node 2 will transmit to node 1, then download |
---|
16 | % the samples to the WARP boards (Sample Frequency is 40MHz) |
---|
17 | % 2. Prepare WARP boards for transmission and reception from node 1 to node 2 |
---|
18 | % and send trigger to start transmission and reception (trigger is the SYNC |
---|
19 | % packet) |
---|
20 | % 3. Disable the radios |
---|
21 | % 4. Prepare WARP boards for transmission and reception from node 2 to node 1 |
---|
22 | % and send trigger to start transmission and reception (trigger is the SYNC |
---|
23 | % packet) |
---|
24 | % 5. Disable the radios |
---|
25 | % 6. Read the received samples from the WARP boards |
---|
26 | % 7. Reset the boards |
---|
27 | % 8. Plot the transmitted and received data and close sockets |
---|
28 | |
---|
29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
30 | % 0. Initializaton and definition of parameters |
---|
31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
32 | %Load some global definitions (packet types, etc.) |
---|
33 | warplab_defines |
---|
34 | |
---|
35 | % Create Socket handles and intialize nodes |
---|
36 | [socketHandles, packetNum] = warplab_initialize; |
---|
37 | |
---|
38 | % Separate the socket handles for easier access |
---|
39 | % The first socket handle is always the magic SYNC |
---|
40 | % The rest of the handles are the handles to the WARP nodes |
---|
41 | udp_Sync = socketHandles(1); |
---|
42 | udp_node1 = socketHandles(2); |
---|
43 | udp_node2 = socketHandles(3); |
---|
44 | |
---|
45 | % Define WARPLab parameters. |
---|
46 | Node1_TxDelay = 0; % Number of noise samples per Rx capture in node 2. In [0:2^14] |
---|
47 | Node2_TxDelay = 0; % Number of noise samples per Rx capture in node 1. In [0:2^14] |
---|
48 | Node1_TxLength = 2^14-1-0; % Length of transmission from node 1. In [0:2^14-1-Node1_TxDelay] |
---|
49 | Node2_TxLength = 2^14-1-0; % Length of transmission from node 2. In [0:2^14-1-Node2_TxDelay] |
---|
50 | CarrierChannel = 9; % Channel in the 2.4 GHz band. In [1:14] |
---|
51 | Node1_Radio2_TxGain_BB = 3; % Tx Baseband Gain. In [0:3] |
---|
52 | Node1_Radio2_TxGain_RF = 40; % Tx RF Gain. In [0:63] |
---|
53 | Node2_Radio2_TxGain_BB = 3; % Rx Baseband Gain. In [0:31] |
---|
54 | Node2_Radio2_TxGain_RF = 40; % Rx RF Gain. In [1:3] |
---|
55 | TxMode = 0; % Transmission mode. In [0:1] |
---|
56 | % 0: Single Transmission |
---|
57 | % 1: Continuous Transmission. Tx board will continue |
---|
58 | % transmitting the vector of samples until the user manually |
---|
59 | % disables the transmitter. |
---|
60 | % AGC related parameter below |
---|
61 | Node1_MGC_AGC_Select = 1; |
---|
62 | Node1_TargetdBmAGC = -10; |
---|
63 | Node1_NoiseEstdBmAGC = -95; |
---|
64 | Node1_Thresh1 = -90; |
---|
65 | Node1_Thresh2 = -53; |
---|
66 | Node1_Thresh3 = -43; |
---|
67 | Node_1Thresholds = uint32(Node1_Thresh3+2^8)*2^16+uint32(Node1_Thresh2+2^8)*2^8+uint32(Node1_Thresh1+2^8); |
---|
68 | Node1_AGCTrigger_nsamps_delay = 50; |
---|
69 | Node1_Enable_DCOffset_Correction = 1; |
---|
70 | |
---|
71 | Node2_MGC_AGC_Select = 1; |
---|
72 | Node2_TargetdBmAGC = -10; |
---|
73 | Node2_NoiseEstdBmAGC = -95; |
---|
74 | Node2_Thresh1 = -90; |
---|
75 | Node2_Thresh2 = -53; |
---|
76 | Node2_Thresh3 = -43; |
---|
77 | Node_2Thresholds = uint32(Node2_Thresh3+2^8)*2^16+uint32(Node2_Thresh2+2^8)*2^8+uint32(Node2_Thresh1+2^8); |
---|
78 | Node2_AGCTrigger_nsamps_delay = 50; |
---|
79 | Node2_Enable_DCOffset_Correction = 1; |
---|
80 | |
---|
81 | warplab_setAGCParameter(udp_node1,MGC_AGC_SEL, Node1_MGC_AGC_Select); |
---|
82 | warplab_setAGCParameter(udp_node1,SET_AGC_TARGET_dBm, Node1_TargetdBmAGC); |
---|
83 | warplab_setAGCParameter(udp_node1,SET_AGC_NOISEEST_dBm, Node1_NoiseEstdBmAGC); |
---|
84 | warplab_setAGCParameter(udp_node1,SET_AGC_THRESHOLDS, Node_1Thresholds); |
---|
85 | warplab_setAGCParameter(udp_node1,SET_AGC_TRIG_DELAY, Node1_AGCTrigger_nsamps_delay); |
---|
86 | warplab_setAGCParameter(udp_node1,SET_AGC_DCO_EN_DIS, Node1_Enable_DCOffset_Correction); |
---|
87 | |
---|
88 | warplab_setAGCParameter(udp_node2,MGC_AGC_SEL, Node2_MGC_AGC_Select); |
---|
89 | warplab_setAGCParameter(udp_node2,SET_AGC_TARGET_dBm, Node2_TargetdBmAGC); |
---|
90 | warplab_setAGCParameter(udp_node2,SET_AGC_NOISEEST_dBm, Node2_NoiseEstdBmAGC); |
---|
91 | warplab_setAGCParameter(udp_node2,SET_AGC_THRESHOLDS, Node_2Thresholds); |
---|
92 | warplab_setAGCParameter(udp_node2,SET_AGC_TRIG_DELAY, Node2_AGCTrigger_nsamps_delay); |
---|
93 | warplab_setAGCParameter(udp_node2,SET_AGC_DCO_EN_DIS, Node2_Enable_DCOffset_Correction); |
---|
94 | |
---|
95 | % Download the WARPLab parameters to the WARP nodes. |
---|
96 | % The nodes store the TxDelay, TxLength, and TxMode parameters in |
---|
97 | % registers defined in the WARPLab sysgen model. The nodes set radio |
---|
98 | % related parameters CarrierChannel, TxGains, and RxGains, using the |
---|
99 | % radio controller functions. |
---|
100 | % Download parameters to node 1 |
---|
101 | warplab_writeRegister(udp_node1,TX_DELAY,Node1_TxDelay); |
---|
102 | warplab_writeRegister(udp_node1,TX_LENGTH,Node1_TxLength); |
---|
103 | warplab_writeRegister(udp_node1,TX_MODE,TxMode); |
---|
104 | warplab_setRadioParameter(udp_node1,CARRIER_CHANNEL,CarrierChannel); |
---|
105 | |
---|
106 | % Download 'Node1_Radio2_TxGain_RF' and 'Node1_Radio2_TxGain_BB' parameters |
---|
107 | % to node 1 using the 'warplab_setRadioParameter' function. |
---|
108 | % Hints: |
---|
109 | % 1. The first argument of the 'warplab_setRadioParameter' function |
---|
110 | % identifies the node to which the parameter will be downloaded to. |
---|
111 | % The id or handle to node 1 is 'udp_node1'. |
---|
112 | % 2. The second argument of the 'warplab_setRadioParameter' function |
---|
113 | % identifies the parameter that will be downloaded. The |
---|
114 | % 'Node1_Radio2_TxGain_RF' and 'Node1_Radio2_TxGain_BB' parameters are |
---|
115 | % downloaded in one call of the 'warplab_setRadioParameter' and the id to |
---|
116 | % download these parameters is 'RADIO2_TXGAINS' |
---|
117 | % 3. The third argument of the 'warplab_setRadioParameter' function is the |
---|
118 | % value the parameter must be set to. The 'Node1_Radio2_TxGain_RF' and |
---|
119 | % 'Node1_Radio2_TxGain_BB' parameters are downloaded in one call of the |
---|
120 | % 'warplab_setRadioParameter', these two values must be combined for |
---|
121 | % download in the following way: |
---|
122 | % (Node1_Radio2_TxGain_RF + Node1_Radio2_TxGain_BB*2^16) |
---|
123 | |
---|
124 | warplab_setRadioParameter(udp_node1,RADIO2_TXGAINS,(Node1_Radio2_TxGain_RF + Node1_Radio2_TxGain_BB*2^16)); |
---|
125 | |
---|
126 | |
---|
127 | % Download parameters to node 2 |
---|
128 | warplab_writeRegister(udp_node2,TX_DELAY,Node2_TxDelay); |
---|
129 | warplab_writeRegister(udp_node2,TX_LENGTH,Node2_TxLength); |
---|
130 | warplab_writeRegister(udp_node2,TX_MODE,TxMode); |
---|
131 | warplab_setRadioParameter(udp_node2,CARRIER_CHANNEL,CarrierChannel); |
---|
132 | |
---|
133 | % Download 'Node2_Radio2_TxGain_RF' and 'Node2_Radio2_TxGain_BB' parameters |
---|
134 | % to node 2 using the 'warplab_setRadioParameter' function. |
---|
135 | % Hints: |
---|
136 | % 1. The first argument of the 'warplab_setRadioParameter' function |
---|
137 | % identifies the node to which the parameter will be downloaded to. |
---|
138 | % The id or handle to node 2 is 'udp_node2'. |
---|
139 | % 2. The second argument of the 'warplab_setRadioParameter' function |
---|
140 | % identifies the parameter that will be downloaded. The |
---|
141 | % 'Node2_Radio2_TxGain_RF' and 'Node2_Radio2_TxGain_BB' parameters are |
---|
142 | % downloaded in one call of the 'warplab_setRadioParameter' and the id to |
---|
143 | % download these parameters is 'RADIO2_TXGAINS' |
---|
144 | % 3. The third argument of the 'warplab_setRadioParameter' function is the |
---|
145 | % value the parameter must be set to. The 'Node2_Radio2_TxGain_RF' and |
---|
146 | % 'Node2_Radio2_TxGain_BB' parameters are downloaded in one call of the |
---|
147 | % 'warplab_setRadioParameter', these two values must be combined for |
---|
148 | % download in the following way: |
---|
149 | % (Node2_Radio2_TxGain_RF + Node2_Radio2_TxGain_BB*2^16) |
---|
150 | |
---|
151 | warplab_setRadioParameter(udp_node2,RADIO2_TXGAINS,(Node2_Radio2_TxGain_RF + Node2_Radio2_TxGain_BB*2^16)); |
---|
152 | |
---|
153 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
154 | % 1. Generate the vector of samples that node 1 will transmit to node 2 and |
---|
155 | % the vector of samples that node 2 will transmit to node 1, then download |
---|
156 | % the samples to the WARP boards (Sample Frequency is 40MHz) |
---|
157 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
158 | % Create time vector. |
---|
159 | t1 = 0:(1/40e6):Node1_TxLength/40e6 - 1/40e6; |
---|
160 | |
---|
161 | % Create a signal to transmit from node 1, the signal can be real or complex. |
---|
162 | % The signal must meet the following requirements: |
---|
163 | % - Signal to transmit must be a row vector. |
---|
164 | % - The amplitude of the real part must be in [-1:1] and the amplitude |
---|
165 | % of the imaginary part must be in [-1:1]. |
---|
166 | % - Highest frequency component is limited to 9.5 MHz (signal bandwidth |
---|
167 | % is limited to 19 MHz) |
---|
168 | % - Lowest frequency component is limited to 30 kHz |
---|
169 | Node1_Radio2_TxData = exp(t1*j*2*pi*2.5e6); |
---|
170 | |
---|
171 | % Download the 'Node1_Radio2_TxData' vector to WARP node 1 using the |
---|
172 | % 'warplab_writeSMWO' function. The 'Node1_Radio2_TxData' vector is the |
---|
173 | % vector of samples to be transmitted from node 1 to node 2. The |
---|
174 | % description of the input arguments of the 'warplab_writeSMWO' function |
---|
175 | % can be found in the 'warplab_example_ChannelEstim_WorkshopExercise.m' code |
---|
176 | % Download samples to node 1 |
---|
177 | warplab_writeSMWO(udp_node1, RADIO2_TXDATA, Node1_Radio2_TxData); |
---|
178 | |
---|
179 | |
---|
180 | % Create time vector. |
---|
181 | t2 = 0:(1/40e6):Node2_TxLength/40e6 - 1/40e6; |
---|
182 | |
---|
183 | % Create a signal to transmit from node 2, the signal can be real or complex. |
---|
184 | % The signal must meet the following requirements: |
---|
185 | % - Signal to transmit must be a row vector. |
---|
186 | % - The amplitude of the real part must be in [-1:1] and the amplitude |
---|
187 | % of the imaginary part must be in [-1:1]. |
---|
188 | % - Signal bandwidth must be less than 19 MHz (Highest frequency component |
---|
189 | % is limited to 9.5 MHz due to radio settings) |
---|
190 | Node2_Radio2_TxData = exp(t2*j*2*pi*5e6); |
---|
191 | |
---|
192 | % Download the 'Node2_Radio2_TxData' vector to WARP node 2 using the |
---|
193 | % 'warplab_writeSMWO' function. The 'Node2_Radio2_TxData' vector is the |
---|
194 | % vector of samples to be transmitted from node 2 to node 1. The |
---|
195 | % description of the input arguments of the 'warplab_writeSMWO' function |
---|
196 | % can be found in the 'warplab_example_ChannelEstim_WorkshopExercise.m' |
---|
197 | % code |
---|
198 | % Download samples to node 2 |
---|
199 | warplab_writeSMWO(udp_node2, RADIO2_TXDATA, Node2_Radio2_TxData); |
---|
200 | |
---|
201 | |
---|
202 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
203 | % 2. Prepare WARP boards for transmission and reception from node 1 to node 2 |
---|
204 | % and send trigger to start transmission and reception (trigger is the SYNC |
---|
205 | % packet) |
---|
206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
207 | % The following lines of code set node 1 as transmitter and node 2 as |
---|
208 | % receiver; transmission and capture are triggered by sending the SYNC |
---|
209 | % packet. |
---|
210 | |
---|
211 | % Enable transmitter radio path in radio 2 in node 1 (enable radio 2 in |
---|
212 | % node 1 as transmitter) by sending the RADIO2_TXEN command to node 1 using |
---|
213 | % the 'warplab_sendCmd' function. |
---|
214 | warplab_sendCmd(udp_node1, RADIO2_TXEN, packetNum); |
---|
215 | |
---|
216 | % Enable transmission of node1's radio 2 Tx buffer (enable transmission |
---|
217 | % of samples stored in radio 2 Tx Buffer in node 1) by sending the |
---|
218 | % RADIO2TXBUFF_TXEN command to node 1 using the 'warplab_sendCmd' function. |
---|
219 | warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXEN, packetNum); |
---|
220 | |
---|
221 | % Enable receiver radio path in radio 2 in node 2 (enable radio 2 in |
---|
222 | % node 2 as receiver) by sending the RADIO2_RXEN command to node 2 using |
---|
223 | % the 'warplab_sendCmd' function. |
---|
224 | warplab_sendCmd(udp_node2, RADIO2_RXEN, packetNum); |
---|
225 | |
---|
226 | % Enable capture in node2's radio 2 Rx Buffer (enable radio 2 rx buffer in |
---|
227 | % node 2 for storage of samples) by sending the RADIO2RXBUFF_RXEN command to |
---|
228 | % node 2 using the 'warplab_sendCmd' function. |
---|
229 | warplab_sendCmd(udp_node2, [RADIO2RXBUFF_RXEN], packetNum); |
---|
230 | |
---|
231 | % Prime transmitter state machine in node 1. Node 1 will be |
---|
232 | % waiting for the SYNC packet. Transmission from node 1 will be triggered |
---|
233 | % when node 1 receives the SYNC packet. |
---|
234 | warplab_sendCmd(udp_node1, TX_START, packetNum); |
---|
235 | |
---|
236 | % Prime receiver state machine in node 2. Node 2 will be waiting |
---|
237 | % for the SYNC packet. Capture at node 2 will be triggered when node 2 |
---|
238 | % receives the SYNC packet. |
---|
239 | warplab_sendCmd(udp_node2, RX_START, packetNum); |
---|
240 | |
---|
241 | % Send the SYNC packet |
---|
242 | warplab_sendSync(udp_Sync); |
---|
243 | |
---|
244 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
245 | % 3. Disable the radios |
---|
246 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
247 | % Disable the transmitter |
---|
248 | warplab_sendCmd(udp_node1, RADIO2_TXDIS, packetNum); |
---|
249 | |
---|
250 | % Disable the receiver |
---|
251 | warplab_sendCmd(udp_node2, RADIO2_RXDIS, packetNum); |
---|
252 | |
---|
253 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
254 | % 4. Prepare boards for transmission and reception from node 2 to node 1 |
---|
255 | % and send trigger to start transmission and reception (trigger is the SYNC |
---|
256 | % packet) |
---|
257 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
258 | % The following lines of code set node 2 as transmitter and node 1 as |
---|
259 | % receiver; transmission and capture are triggered by sending the SYNC |
---|
260 | % packet. |
---|
261 | |
---|
262 | % Enable transmitter radio path in radio 2 in node 2 (enable radio 2 in |
---|
263 | % node 2 as transmitter) by sending the RADIO2_TXEN command to node 2 using |
---|
264 | % the 'warplab_sendCmd' function. |
---|
265 | warplab_sendCmd(udp_node2, RADIO2_TXEN, packetNum); |
---|
266 | |
---|
267 | % Enable transmission of node2's radio 2 Tx buffer (enable transmission |
---|
268 | % of samples stored in radio 2 Tx Buffer in node 2) by sending the |
---|
269 | % RADIO2TXBUFF_TXEN command to node 2 using the 'warplab_sendCmd' function. |
---|
270 | warplab_sendCmd(udp_node2, RADIO2TXBUFF_TXEN, packetNum); |
---|
271 | |
---|
272 | % Enable receiver radio path in radio 2 in node 1 (enable radio 2 in |
---|
273 | % node 1 as receiver) by sending the RADIO2_RXEN command to node 1 using |
---|
274 | % the 'warplab_sendCmd' function. |
---|
275 | warplab_sendCmd(udp_node1, RADIO2_RXEN, packetNum); |
---|
276 | |
---|
277 | % Enable capture in node1's radio 2 Rx Buffer (enable radio 2 rx buffer in |
---|
278 | % node 1 for storage of samples) by sending the RADIO2RXBUFF_RXEN command to |
---|
279 | % node 1 using the 'warplab_sendCmd' function. |
---|
280 | warplab_sendCmd(udp_node1, [RADIO2RXBUFF_RXEN], packetNum); |
---|
281 | |
---|
282 | % Prime transmitter state machine in node 2. Node 2 will be |
---|
283 | % waiting for the SYNC packet. Transmission from node 2 will be triggered |
---|
284 | % when node 2 receives the SYNC packet. |
---|
285 | warplab_sendCmd(udp_node2, TX_START, packetNum); |
---|
286 | |
---|
287 | % Prime receiver state machine in node 1. Node 1 will be waiting |
---|
288 | % for the SYNC packet. Capture at node 1 will be triggered when node 1 |
---|
289 | % receives the SYNC packet. |
---|
290 | warplab_sendCmd(udp_node1, RX_START, packetNum); |
---|
291 | |
---|
292 | % Send the SYNC packet |
---|
293 | warplab_sendSync(udp_Sync); |
---|
294 | |
---|
295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
296 | % 5. Disable the radios |
---|
297 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
298 | % Disable the receiver |
---|
299 | warplab_sendCmd(udp_node1, RADIO2_RXDIS, packetNum); |
---|
300 | |
---|
301 | % Disable the transmitter |
---|
302 | warplab_sendCmd(udp_node2, RADIO2_TXDIS, packetNum); |
---|
303 | |
---|
304 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
305 | % 6. Read the received samples from the WARP boards |
---|
306 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
307 | % Read back the received samples sent from node 1 to node 2 |
---|
308 | [Node2_Radio2_RawRxData] = warplab_readSMRO(udp_node2, RADIO2_RXDATA, Node1_TxLength+Node1_TxDelay); |
---|
309 | % Process the received samples to obtain meaningful data |
---|
310 | [Node2_Radio2_RxData,Node2_Radio2_RxOTR] = warplab_processRawRxData(Node2_Radio2_RawRxData); |
---|
311 | |
---|
312 | % Read back the received samples sent from node 2 to node 1 |
---|
313 | [Node1_Radio2_RawRxData] = warplab_readSMRO(udp_node1, RADIO2_RXDATA, Node2_TxLength+Node2_TxDelay); |
---|
314 | % Process the received samples to obtain meaningful data |
---|
315 | [Node1_Radio2_RxData,Node1_Radio2_RxOTR] = warplab_processRawRxData(Node1_Radio2_RawRxData); |
---|
316 | |
---|
317 | |
---|
318 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
319 | % 7. Reset the boards and close sockets |
---|
320 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
321 | % Set radio 2 Tx buffer in node 1 back to Tx disabled mode |
---|
322 | warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXDIS, packetNum); |
---|
323 | |
---|
324 | % Set radio 2 Tx buffer in node 2 back to Tx disabled mode |
---|
325 | warplab_sendCmd(udp_node2, RADIO2TXBUFF_TXDIS, packetNum); |
---|
326 | |
---|
327 | % Set radio 2 Rx buffer in node 1 back to Rx disabled mode |
---|
328 | warplab_sendCmd(udp_node1, RADIO2RXBUFF_RXDIS, packetNum); |
---|
329 | |
---|
330 | % Set radio 2 Rx buffer in node 2 back to Rx disabled mode |
---|
331 | warplab_sendCmd(udp_node2, RADIO2RXBUFF_RXDIS, packetNum); |
---|
332 | |
---|
333 | % Resets Rx gains to default values of RF Gain of 3 and Baseband gain of |
---|
334 | % 26. Sets AGC ready for a new capture. |
---|
335 | warplab_sendCmd(udp_node1, AGC_RESET, packetNum); |
---|
336 | |
---|
337 | % Resets Rx gains to default values of RF Gain of 3 and Baseband gain of |
---|
338 | % 26. Sets AGC ready for a new capture. |
---|
339 | warplab_sendCmd(udp_node2, AGC_RESET, packetNum); |
---|
340 | |
---|
341 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
342 | % 5. Plot the transmitted and received data and close sockets |
---|
343 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
344 | % Plot data corresponding to node 1 to node 2 transmission |
---|
345 | figure; |
---|
346 | subplot(2,2,1); |
---|
347 | plot(real(Node1_Radio2_TxData)); |
---|
348 | title('Tx Node 1 Radio 2 I'); |
---|
349 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
350 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
351 | subplot(2,2,2); |
---|
352 | plot(imag(Node1_Radio2_TxData)); |
---|
353 | title('Tx Node 1 Radio 2 Q'); |
---|
354 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
355 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
356 | subplot(2,2,3); |
---|
357 | plot(real(Node2_Radio2_RxData)); |
---|
358 | title('Rx Node 2 Radio 2 I'); |
---|
359 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
360 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
361 | subplot(2,2,4); |
---|
362 | plot(imag(Node2_Radio2_RxData)); |
---|
363 | title('Rx Node 2 Radio 2 Q'); |
---|
364 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
365 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
366 | |
---|
367 | % Plot data from B to A transmission |
---|
368 | figure; |
---|
369 | subplot(2,2,1); |
---|
370 | plot(real(Node2_Radio2_TxData)); |
---|
371 | title('Tx Node 2 Radio 2 I'); |
---|
372 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
373 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
374 | subplot(2,2,2); |
---|
375 | plot(imag(Node2_Radio2_TxData)); |
---|
376 | title('Tx Node 2 Radio 2 Q'); |
---|
377 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
378 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
379 | subplot(2,2,3); |
---|
380 | plot(real(Node1_Radio2_RxData)); |
---|
381 | title('Rx Node 1 Radio 2 I'); |
---|
382 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
383 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
384 | subplot(2,2,4); |
---|
385 | plot(imag(Node1_Radio2_RxData)); |
---|
386 | title('Rx Node 1 Radio 2 Q'); |
---|
387 | xlabel('n (samples)'); ylabel('Amplitude'); |
---|
388 | axis([0 2^14 -1 1]); % Set axis ranges. |
---|
389 | |
---|
390 | % Close sockets |
---|
391 | pnet('closeall'); |
---|
392 | |
---|