root/ResearchApps/PHY/WARPLAB/WARPLAB_SISO/M_code/TxRx_Test_warplab_siso_v1.m

Revision 780, 4.4 kB (checked in by MelissaDuarte, 9 months ago)

Modified warplab_enableRx.m, warplab_enableTx.m,warplab_initialize.m. Updates examples to work with these changes. TxRx_Test_warplab_siso_v1.m is an old code use warplab_example_TxRx.m instead

Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% Transmitting and Receiving Data using Warplab
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4% The specific steps implemented in this script are the following
5
6% 0. Initializaton and definition of parameters
7% 1. Generate a vector of samples to transmit and send the samples to the
8% Warp board (Sample Frequency is 40MHz)
9% 2. Prepare boards for transmission and reception and send trigger to
10% start transmission and reception (trigger is the SYNC packet)
11% 3. Read the received samples from the Warp board
12% 4. Reset and disable the boards
13% 5. Plot the transmitted and received data
14
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16% 0. Initializaton and definition of parameters
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18% Create Socket hanldes and intialize nodes
19warplab_initialize
20
21% Define the warplab options (parameters)
22CaptOffset = 1000; %Number of noise samples per Rx capture; in [0:2^14]
23TxLength = 2^14-1000; %Length of transmission; in [0:2^14-CaptOffset]
24TxGainBB = 3; %Tx Baseband Gain in [0:3]
25TxGainRF = 40; %Tx RF Gain in [0:63]
26RxGainBB = 18; %Rx Baseband Gain in [0:31]
27RxGainRF = 1; %Rx RF Gain in [1:3]
28CarrierChannel = 11;
29
30% Define the options vector; the order of options is set by the FPGA's code
31% (C code)
32optionsVector = [CaptOffset TxLength-1 (RxGainBB + RxGainRF*2^16) (TxGainRF + TxGainBB*2^16) CarrierChannel];
33% Send options vector to the nodes
34warplab_setOptions(socketHandles,optionsVector);
35
36%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37% 1. Generate a vector of samples to transmit and send the samples to the
38% Warp board (Sample Frequency is 40MHz)
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40% Prepare some data to be transmitted
41t = 0:(1/40e6):TxLength/40e6 - 1/40e6; %Create time vector.
42TxData = exp(t*j*2*pi*1e6); % Create a signal to transmit
43
44% Download the samples to be transmitted
45warplab_writeSMWO(udp_Tx, TxData, RADIO2_TXDATA);
46
47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48% 2. Prepare boards for transmission and reception and send trigger to
49% start transmission and reception (trigger is the SYNC packet)
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51% Enable transmission
52warplab_enableTx
53
54% Enable reception
55warplab_enableRx
56
57% Send the SYNC packet
58warplab_sendSync(udp_Sync);
59
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61% 3. Read the received smaples from the Warp board
62%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63% Read back the received samples
64[RawRxData] = warplab_readSMRO(udp_RxA, RADIO2_RXDATA, TxLength+CaptOffset);
65% Process the received samples to obtain meaningful data
66[RxData,RxOTR] = warplab_processRawRxData(RawRxData);
67% Read stored RSSI data
68[RawRSSIData] = warplab_readSMRO(udp_RxA, RADIO2_RSSIDATA, (TxLength+CaptOffset)/8);
69% Procecss Raw RSSI data to obtain meningful RSSI values
70[RxRSSI] = warplab_processRawRSSIData(RawRSSIData);
71
72%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% 4. Reset and disable the boards
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75% Reset the receiver
76warplab_sendCmd(udp_RxA, RX_DONEREADING, packetNum);
77
78% Disable the receiver
79warplab_sendCmd(udp_RxA, RADIO2_RXDIS, packetNum);
80
81% Disable the transmitter
82warplab_sendCmd(udp_Tx, RADIO2_TXDIS, packetNum);
83
84% Close sockets
85pnet('closeall');
86
87%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88% 5. Plot the transmitted and received data
89%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90figure;
91subplot(2,2,1);
92plot(real(TxData));
93title('Tx I');
94xlabel('n (samples)'); ylabel('Amplitude');
95axis([0 2^14 -1 1]); % Set axis ranges.
96subplot(2,2,2);
97plot(imag(TxData));
98title('Tx Q');
99xlabel('n (samples)'); ylabel('Amplitude');
100axis([0 2^14 -1 1]); % Set axis ranges.
101subplot(2,2,3);
102plot(real(RxData));
103title('Rx I');
104xlabel('n (samples)'); ylabel('Amplitude');
105axis([0 2^14 -1 1]); % Set axis ranges.
106subplot(2,2,4);
107plot(imag(RxData));
108title('Rx Q');
109xlabel('n (samples)'); ylabel('Amplitude');
110axis([0 2^14 -1 1]); % Set axis ranges.
Note: See TracBrowser for help on using the browser.