root/ResearchApps/PHY/WARPLAB/WARPLab_SISO_MIMO2x2/M_Code/warplab_siso_example_TxRxTwoWay_WorkshopExercise_Solution.m

Revision 839, 25.2 kB (checked in by MelissaDuarte, 4 months ago)

WARPLab Release 02 April 09 2008. Release for 2x2 MIMO and improved SISO. Matlab code is modified to support MIMO. SISO now supports continuous transmission. There is one bitstream for MIMO and one bitstream for SISO. The xps project for MIMO and SISO is different but the M code is the same (The 'warplab_' functions are the same, the argument input to the functions is the only thing that changes from SISO to MIMO).

Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% Two-Way transmission and reception of data using Warplab (SISO configuration)
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4% To run this code the boards must be programmed with the
5% warplab_siso_v02.bit bitstream
6
7% Use Warplab for two-way communication between two nodes. First node A
8% will transmit to node B and then node B will transmit to node A.
9
10% The specific steps implemented in this script are the following
11
12% 0. Initializaton and definition of parameters
13% 1. Generate the vector of samples that node A will transmit to node B and
14% the vector of samples that node B will transmit to node A, then download
15% the samples to the Warp boards (Sample Frequency is 40MHz)
16% 2. Prepare boards for transmission and reception from node A to node B
17% and send trigger to start transmission and reception (trigger is the SYNC
18% packet)
19% 3. Disable the radios
20% 4. Prepare boards for transmission and reception from node B to node A
21% and send trigger to start transmission and reception (trigger is the SYNC
22% packet)
23% 5. Disable the radios
24% 6. Read the received samples from the Warp boards
25% 7. Reset the boards and close sockets
26% 8. Plot the transmitted and received data
27
28% In this lab exercise you will write a matlab script that implements the
29% nine steps above. Part of the code is provided, some part of the code you
30% will write. Read the code below and fill in with your code wherever you
31% are asked to do so.
32
33% NOTE: To avoid conflict with other groups using the boards, please test
34% the code you write in this script in any of the following three ways:
35%
36% Option 1. Run this script from matlab's Command Window by entering the
37% name of the script (enter warplab_example_TxRx_WorkshopExercise in
38% matlab's Command Window).
39% Option 2. In the menu bar go to Debug and select Run. If there
40% are errors in the code, error messages will appear in the Command Window.
41% Option 3. Press F5. If the are errors in the code, error messages will
42% appear in the Command Window.
43%
44% DO NOT USE the Evaluate selection option and DO NOT run the script by
45% sections. To test any change, always run the whole script by following
46% any of the three options above.
47
48try,
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50% Code to avoid conflict between users, only needed for the workshop, go to
51% step 0 below to start the initialization and definition of parameters
52%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53fid = fopen('c:\boards_lock.txt');
54
55if(fid > -1)
56    fclose('all');
57        errordlg('Boards already in use - Please try again!');
58        return;
59end
60
61!echo > c:\boards_lock.txt
62
63
64%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65% 0. Initializaton and definition of parameters
66%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67%Load some global definitions (packet types, etc.)
68warplab_defines
69
70% Create Socket handles and intialize nodes
71[socketHandles, packetNum] = warplab_initialize;
72
73%Separate the socket handles for easier access
74% The first socket handle is always the magic SYNC
75% The rest can be arranged in any combination of Tx and Rx
76udp_Sync = socketHandles(1);
77udp_nodeA = socketHandles(2);
78udp_nodeB = socketHandles(3);
79
80% Define the warplab options (parameters)
81CaptOffset = 1000; %Number of noise samples per Rx capture; in [0:2^14]
82TxLength = 2^14-1000; %Length of transmission; in [0:2^14-CaptOffset]
83TransMode = 0; %Transmission mode; in [0:1]
84               % 0: Single Transmission
85               % 1: Continuous Transmission. Tx board will continue
86               % transmitting the vector of samples until the user manually
87               % disables the transmitter.
88CarrierChannel = 8; % Channel in the 2.4 GHz band. In [1:14]
89TxGainBB = 3; %Tx Baseband Gain in [0:3]
90TxGainRF = 40; %Tx RF Gain in [0:63]
91RxGainBB = 15; %Rx Baseband Gain in [0:31]
92RxGainRF = 1; %Rx RF Gain in [1:3]
93
94% Define the options vector; the order of options is set by the FPGA's code
95% (C code)
96optionsVector = [CaptOffset TxLength-1 TransMode CarrierChannel (RxGainBB + RxGainRF*2^16) (TxGainRF + TxGainBB*2^16)];
97% Send options vector to the nodes
98warplab_setOptions(socketHandles,optionsVector);
99
100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101% 1. Generate the vector of samples that node A will transmit to node B and
102% the vector of samples that node B will transmit to node A, then download
103% the samples to the Warp boards (Sample Frequency is 40MHz)
104%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105% Create time vector.
106t = 0:(1/40e6):TxLength/40e6 - 1/40e6;
107
108%-------------------------------------------------------------------------%
109% USER CODE HERE
110
111% Create a signal to transmit from node A to node B.
112% The signal must be a row vector. The Signal is a function of the time
113% vector 't'. The signal can be real or complex, the only constraint is
114% that the amplitude of the real part must be in [-1:1] and the amplitude
115% of the imaginary part must be in [-1:1].
116
117% Store the signal to transmit in a variable called
118% TxDataAB (TxDataAB = your signal from node A to node B)
119
120% Create a signal to transmit from node A to node B
121TxDataAB = exp(t*j*2*pi*1e6); %Signal must be a row vector. The signal can
122% be real or complex, the only constraint is that the amplitude of the real
123% part must be in [-1:1] and the amplitude of the imaginary part must be
124% in [-1:1]
125%-------------------------------------------------------------------------%
126
127%-------------------------------------------------------------------------%
128% USER CODE HERE
129
130% Use the 'warplab_writeSMWO' function to download to node A the samples to
131% be transmitted from node A to B ('TxDataAB' vector). The
132% 'warplab_writeSMWO' function has been used in all the previous exercises.
133
134% Hints:
135
136% 1. The first argument of the 'warplab_writeSMWO' function identifies the
137% node to which samples will be downloaded to. The handle for node A is
138% 'udp_nodeA' so use 'udp_nodeA' as the first argument.
139
140% 2. The second argument of the 'warplab_writeSMWO' function is the
141% vector of samples to be downloaded, which in this case is the 'TxDataAB'
142% vector.
143
144% 3. The third argument of 'warplab_writeSMWO' is RADIO2_TXDATA,
145% RADIO2_TXDATA is defined in 'warplab_defines'. RADIO2_TXDATA can be
146% understood as an id that identifies the transmitter buffer.
147
148% 4. In sumary, the first argument of the 'warplab_writeSMWO' identifies
149% the node and the third argument identifies which buffer in the node will
150% the samples be downloaded to. The second argument is the vector of
151% samples to download.
152
153% Download the samples to be transmitted
154warplab_writeSMWO(udp_nodeA, TxDataAB, RADIO2_TXDATA); % Download samples to node A
155%-------------------------------------------------------------------------%
156
157%-------------------------------------------------------------------------%
158% USER CODE HERE
159
160% Create a signal to transmit from node B to node A.
161% The signal must be a row vector. The Signal is a function of the time
162% vector 't'. The signal can be real or complex, the only constraint is
163% that the amplitude of the real part must be in [-1:1] and the amplitude
164% of the imaginary part must be in [-1:1].
165
166% Store the signal to transmit in a variable called
167% TxDataBA (TxDataBA = your signal from node B to node A)
168
169% Create a signal to transmit from node B to node A
170TxDataBA = linspace(0,1,TxLength).*exp(t*j*2*pi*5e6);
171% Signal must be a row vector. The signal can be real or complex,
172% the only constraint is that the amplitude of the real part must be in
173% [-1:1] and the amplitude of the imaginary part must be in [-1:1]
174%-------------------------------------------------------------------------%
175
176%-------------------------------------------------------------------------%
177% USER CODE HERE
178
179% Use the 'warplab_writeSMWO' function to download to node B the samples to
180% be transmitted from node B to A ('TxDataBA' vector). The
181% 'warplab_writeSMWO' function has been used in all the previous exercises.
182
183% Hints:
184
185% 1. The first argument of the 'warplab_writeSMWO' function identifies the
186% node to which samples will be downloaded to. The handle for node B is
187% 'udp_nodeB' so use 'udp_nodeB' as the first argument.
188
189% 2. The second argument of the 'warplab_writeSMWO' function is the
190% vector of samples to be downloaded, which in this case is the 'TxDataBA'
191% vector.
192
193% 3. The third argument of 'warplab_writeSMWO' is RADIO2_TXDATA,
194% RADIO2_TXDATA is defined in 'warplab_defines'. RADIO2_TXDATA can be
195% understood as an id that identifies the transmitter buffer.
196
197% 4. In sumary, the first argument of the 'warplab_writeSMWO' identifies
198% the node and the third argument identifies which buffer in the node will
199% the samples be downloaded to. The second argument is the vector of
200% samples to download.
201
202warplab_writeSMWO(udp_nodeB, TxDataBA, RADIO2_TXDATA); % Download samples to node B
203%-------------------------------------------------------------------------%
204
205%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206% 2. Prepare boards for transmission and reception from node A to node B
207% and send trigger to start transmission and reception (trigger is the SYNC
208% packet)
209%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210
211%-------------------------------------------------------------------------%
212% USER CODE HERE
213
214% Enable the transmitter radio path in node A by sending the RADIO2_TXEN
215% command to node A using the 'warplab_sendCmd' function. This function has
216% been used in all the previous exercises.
217
218% Hints:
219
220% 1. The first argument of the 'warplab_sendCmd' function identifies the
221% node to which the command will be sent. The handle for node A is
222% 'udp_nodeA' so use 'udp_nodeA' as the first argument.
223
224% 2. The second argument of the 'warplab_sendCmd' function identifies the
225% instruction or command to be sent. In this case, the command to send is
226% the RADIO2_TXEN command defined in 'warplab_defines'.
227
228% 3. The third argument of the 'warplab_sendCmd' command is a field that
229% is not used at the moment, it may be used in future versions of WARPLab
230% to keep track of packets. Use 'packetNum' as the third argument of the
231% 'warplab_sendCmd' command.
232
233% Enable transmitter radio path in node A
234warplab_sendCmd(udp_nodeA, RADIO2_TXEN, packetNum);
235%-------------------------------------------------------------------------%
236
237%-------------------------------------------------------------------------%
238% USER CODE HERE
239
240% Enable the receiver radio path in node B by sending the RADIO2_RXEN
241% command to node B using the 'warplab_sendCmd' function. This function has
242% been used in all the previous exercises.
243
244% Hints:
245
246% 1. The first argument of the 'warplab_sendCmd' function identifies the
247% node to which the command will be sent. The handle for node B is
248% 'udp_nodeB' so use 'udp_nodeB' as the first argument.
249
250% 2. The second argument of the 'warplab_sendCmd' function identifies the
251% instruction or command to be sent. In this case, the command to send is
252% the RADIO2_RXEN command defined in 'warplab_defines'.
253
254% 3. The third argument of the 'warplab_sendCmd' command is a field that
255% is not used at the moment, it may be used in future versions of WARPLab
256% to keep track of packets. Use 'packetNum' as the third argument of the
257% 'warplab_sendCmd' command.
258
259% Enable receiver radio path in node B
260warplab_sendCmd(udp_nodeB, RADIO2_RXEN, packetNum);
261%-------------------------------------------------------------------------%
262
263%-------------------------------------------------------------------------%
264% USER CODE HERE
265
266% Prime transmitter state machine in node A by sending the TX_START command
267% to node A using the 'warplab_sendCmd' function. This function has
268% been used in all the previous exercises and it is described in the Hints
269% above.
270
271% Node A will start waiting for the SYNC packet as soon as it receives the
272% TX_START command. Transmission from node A will be triggered when node A
273% receives the SYNC packet.
274
275% Prime transmitter state machine in node A. Node A will be waiting for
276% the SYNC packet. Transmission will be triggered when node A receives
277% the SYNC packet.
278warplab_sendCmd(udp_nodeA, TX_START, packetNum);
279%-------------------------------------------------------------------------%
280
281%-------------------------------------------------------------------------%
282% USER CODE HERE
283
284% Prime receiver state machine in node B by sending the RX_START command
285% to node B using the 'warplab_sendCmd' function. This function has
286% been used in all the previous exercises and it is described in the Hints
287% above.
288
289% Node B will start waiting for the SYNC packet as soon as it receives the
290% RX_START command. Capture on node B will be triggered when node B
291% receives the SYNC packet.
292
293% Prime receiver state machine in node B. Node B will be waiting for
294% the SYNC packet. Capture will be triggered when node B receives
295% the SYNC packet.
296warplab_sendCmd(udp_nodeB, RX_START, packetNum);
297%-------------------------------------------------------------------------%
298
299% Send the SYNC packet
300warplab_sendSync(udp_Sync)
301
302%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
303% 3. Disable the radios
304%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305
306%-------------------------------------------------------------------------%
307% USER CODE HERE
308
309% Disable the receiver radio path in node B by sending the RADIO2_RXDIS
310% command to node B using the 'warplab_sendCmd' function. This function has
311% been used in all the previous exercises and it is described in the Hints
312% above.
313
314% Disable the receiver
315warplab_sendCmd(udp_nodeB, RADIO2_RXDIS, packetNum);
316%-------------------------------------------------------------------------%
317
318%-------------------------------------------------------------------------%
319% USER CODE HERE
320
321% Disable the transmitter radio path in node A by sending the RADIO2_TXDIS
322% command to node A using the 'warplab_sendCmd' function. This function has
323% been used in all the previous exercises and it is described in the Hints
324% above.
325
326% Disable the transmitter
327warplab_sendCmd(udp_nodeA, RADIO2_TXDIS, packetNum);
328%-------------------------------------------------------------------------%
329
330%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331% 4. Prepare boards for transmission and reception from node B to node A
332% and send trigger to start transmission and reception (trigger is the SYNC
333% packet)
334%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335
336%-------------------------------------------------------------------------%
337% USER CODE HERE
338
339% Enable the transmitter radio path in node B by sending the RADIO2_TXEN
340% command to node B using the 'warplab_sendCmd' function. This function has
341% been used in all the previous exercises.
342
343% Enable transmitter radio path in node B
344warplab_sendCmd(udp_nodeB, RADIO2_TXEN, packetNum);
345%-------------------------------------------------------------------------%
346
347%-------------------------------------------------------------------------%
348% USER CODE HERE
349
350% Enable the receiver radio path in node A by sending the RADIO2_RXEN
351% command to node A using the 'warplab_sendCmd' function. This function has
352% been used in all the previous exercises.
353
354% Enable receiver radio path in node A
355warplab_sendCmd(udp_nodeA, RADIO2_RXEN, packetNum);
356%-------------------------------------------------------------------------%
357
358%-------------------------------------------------------------------------%
359% USER CODE HERE
360
361% Prime transmitter state machine in node B by sending the TX_START command
362% to node B using the 'warplab_sendCmd' function. This function has
363% been used in all the previous exercises and it is described in the Hints
364% above.
365
366% Node B will start waiting for the SYNC packet as soon as it receives the
367% TX_START command. Transmission from node B will be triggered when node B
368% receives the SYNC packet.
369
370% Prime transmitter state machine in node B. Node B will be waiting for
371% the SYNC packet. Transmission will be triggered when node B receives
372% the SYNC packet.
373warplab_sendCmd(udp_nodeB, TX_START, packetNum);
374%-------------------------------------------------------------------------%
375
376%-------------------------------------------------------------------------%
377% USER CODE HERE
378
379% Prime receiver state machine in node A by sending the RX_START command
380% to node A using the 'warplab_sendCmd' function. This function has
381% been used in all the previous exercises and it is described in the Hints
382% above.
383
384% Node A will start waiting for the SYNC packet as soon as it receives the
385% RX_START command. Capture on node A will be triggered when node A
386% receives the SYNC packet.
387
388% Prime receiver state machine in node A. Node A will be waiting for
389% the SYNC packet. Capture will be triggered when node A receives
390% the SYNC packet.
391warplab_sendCmd(udp_nodeA, RX_START, packetNum);
392%-------------------------------------------------------------------------%
393
394% Send the SYNC packet
395warplab_sendSync(udp_Sync)
396
397%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398% 5. Disable the radios
399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400
401%-------------------------------------------------------------------------%
402% USER CODE HERE
403
404% Disable the receiver radio path in node A by sending the RADIO2_RXDIS
405% command to node A using the 'warplab_sendCmd' function. This function has
406% been used in all the previous exercises and it is described in the Hints
407% above.
408
409% Disable the receiver
410warplab_sendCmd(udp_nodeA, RADIO2_RXDIS, packetNum);
411%-------------------------------------------------------------------------%
412
413%-------------------------------------------------------------------------%
414% USER CODE HERE
415
416% Disable the transmitter radio path in node B by sending the RADIO2_TXDIS
417% command to node B using the 'warplab_sendCmd' function. This function has
418% been used in all the previous exercises and it is described in the Hints
419% above.
420
421% Disable the transmitter
422warplab_sendCmd(udp_nodeB, RADIO2_TXDIS, packetNum);
423%-------------------------------------------------------------------------%
424
425%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426% 6. Read the received samples from the Warp boards
427%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
428
429%-------------------------------------------------------------------------%
430% USER CODE HERE
431
432% Read the samples received at node B (samples sent from A to B) using the
433% 'warplab_readSMRO' function. This function was used in the
434% previous exercises. Store the samples in a variable named 'RawRxDataAB'
435
436% Hints:
437
438% 1. The first argument of the 'warplab_readSMRO' function identifies the
439% node from which samples will be read. The handle for node B is
440% 'udp_nodeB' so use 'udp_nodeB' as the first argument.
441
442% 2. The second argument of 'warplab_readSMRO' is RADIO2_RXDATA,
443% RADIO2_RXDATA is defined in 'warplab_defines'. RADIO2_RXDATA can be
444% understood as an id that identifies the receiver buffer.
445
446% 3. The third argument of the 'warplab_readSMRO' function is the number of
447% samples to read. For this exercise, the third argument of the 'warplab_readSMRO'
448% function is equal to 'TxLength+CaptOffset'
449
450% 4. In sumary, the first argument of the 'warplab_readSMWO' identifies
451% the node and the second argument identifies which buffer in the node will
452% be read. The third argument is the number of samples to read.
453
454% Read back the received samples sent from A to B
455[RawRxDataAB] = warplab_readSMRO(udp_nodeB, RADIO2_RXDATA, TxLength+CaptOffset);
456%-------------------------------------------------------------------------%
457
458% Process the received samples to obtain meaningful data
459[RxDataAB,RxOTRAB] = warplab_processRawRxData(RawRxDataAB);
460% Read stored RSSI data corresponding to A to B transmission
461[RawRSSIDataAB] = warplab_readSMRO(udp_nodeB, RADIO2_RSSIDATA, (TxLength+CaptOffset)/8);
462% Procecss Raw RSSI data to obtain meningful RSSI values
463[RxRSSIAB] = warplab_processRawRSSIData(RawRSSIDataAB);
464
465%-------------------------------------------------------------------------%
466% USER CODE HERE
467
468% Read the samples received at node A (samples sent from B to A) using the
469% 'warplab_readSMRO' function. This function was used in the two
470% previous exercises. Store the samples in a variable named 'RawRxDataBA'
471
472% Hints:
473
474% 1. The first argument of the 'warplab_readSMRO' function identifies the
475% node from which samples will be read. The handle for node A is
476% 'udp_nodeA' so use 'udp_nodeA' as the first argument.
477
478% 2. The second argument of 'warplab_readSMRO' is RADIO2_RXDATA,
479% RADIO2_RXDATA is defined in 'warplab_defines'. RADIO2_RXDATA can be
480% understood as an id that identifies the receiver buffer.
481
482% 3. The third argument of the 'warplab_readSMRO' function is the number of
483% samples to read. For this exercise, the third argument of the 'warplab_readSMRO'
484% function is equal to 'TxLength+CaptOffset'
485
486% 4. In sumary, the first argument of the 'warplab_readSMWO' identifies
487% the node and the second argument identifies which buffer in the node will
488% be read. The third argument is the number of samples to read.
489
490% Read back the received samples sent from B to A
491[RawRxDataBA] = warplab_readSMRO(udp_nodeA, RADIO2_RXDATA, TxLength+CaptOffset);
492%-------------------------------------------------------------------------%
493
494% Process the received samples to obtain meaningful data
495[RxDataBA,RxOTRBA] = warplab_processRawRxData(RawRxDataBA);
496% Read stored RSSI data corresponding to B to A transmission
497[RawRSSIDataBA] = warplab_readSMRO(udp_nodeA, RADIO2_RSSIDATA, (TxLength+CaptOffset)/8);
498% Procecss Raw RSSI data to obtain meningful RSSI values
499[RxRSSIBA] = warplab_processRawRSSIData(RawRSSIDataBA);
500
501%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
502% 7. Reset the boards and close sockets
503%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504
505%-------------------------------------------------------------------------%
506% USER CODE HERE
507
508% Reset node A by sending the RX_DONEREADING command to node A using the
509% 'warplab_sendCmd' function. When the node receives the RX_DONEREADING
510% command it knows that the samples in the receiver buffer have been read
511% and sets the node ready for a new capture.
512
513% Reset node A
514warplab_sendCmd(udp_nodeA, RX_DONEREADING, packetNum);
515%-------------------------------------------------------------------------%
516
517%-------------------------------------------------------------------------%
518% USER CODE HERE
519
520% Reset node B by sending the RX_DONEREADING command to node B using the
521% 'warplab_sendCmd' function. When the node receives the RX_DONEREADING
522% command it knows that the samples in the receiver buffer have been read
523% and sets the node ready for a new capture. 
524
525% Reset node B
526warplab_sendCmd(udp_nodeB, RX_DONEREADING, packetNum);
527%-------------------------------------------------------------------------%
528
529% Close sockets
530pnet('closeall');
531
532%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533% 5. Plot the transmitted and received data
534%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
535% Plot data from A to B transmissio
536figure;
537subplot(2,2,1);
538plot(real(TxDataAB));
539title('Tx I A to B');
540xlabel('n (samples)'); ylabel('Amplitude');
541axis([0 2^14 -1 1]); % Set axis ranges.
542subplot(2,2,2);
543plot(imag(TxDataAB));
544title('Tx Q A to B');
545xlabel('n (samples)'); ylabel('Amplitude');
546axis([0 2^14 -1 1]); % Set axis ranges.
547subplot(2,2,3);
548plot(real(RxDataAB));
549title('Rx I A to B');
550xlabel('n (samples)'); ylabel('Amplitude');
551axis([0 2^14 -1 1]); % Set axis ranges.
552subplot(2,2,4);
553plot(imag(RxDataAB));
554title('Rx Q A to B');
555xlabel('n (samples)'); ylabel('Amplitude');
556axis([0 2^14 -1 1]); % Set axis ranges.
557
558% Plot data from B to A transmission
559figure;
560subplot(2,2,1);
561plot(real(TxDataBA));
562title('Tx I B to A');
563xlabel('n (samples)'); ylabel('Amplitude');
564axis([0 2^14 -1 1]); % Set axis ranges.
565subplot(2,2,2);
566plot(imag(TxDataBA));
567title('Tx Q B to A');
568xlabel('n (samples)'); ylabel('Amplitude');
569axis([0 2^14 -1 1]); % Set axis ranges.
570subplot(2,2,3);
571plot(real(RxDataBA));
572title('Rx I B to A');
573xlabel('n (samples)'); ylabel('Amplitude');
574axis([0 2^14 -1 1]); % Set axis ranges.
575subplot(2,2,4);
576plot(imag(RxDataBA));
577title('Rx Q B to A');
578xlabel('n (samples)'); ylabel('Amplitude');
579axis([0 2^14 -1 1]); % Set axis ranges.
580
581%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582% Code to avoid conflict between users, only needed for the workshop
583%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584pnet('closeall');
585!del c:\boards_lock.txt
586catch,
587% Close sockets
588pnet('closeall');
589!del c:\boards_lock.txt
590lasterr
591end
Note: See TracBrowser for help on using the browser.