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