wiki:WARPLab/Porting

Version 5 (modified by murphpo, 11 years ago) (diff)

--

WARPLab 7: Porting Code from old WARPLab

Coming soon... For now see the new WARPLab 7 examples


Initialization: WARPLab 7 provides a utility script wl_initNodes which simplifies the process of establishing a connection from MATLAB to multiple WARP nodes running the WARPLab reference design. The array returned by wl_initNodes replaces the individual socket handles used in WARPLab 6.

%WARPLab 6

%Load the many global variables for the framework
warplab_defines

%Initialize two WARP nodes
[socketHandles, packetNum] = warplab_initialize(2);

%Retrieve socket handles for the trigger and both nodes
udp_Sync = socketHandles(1);
udp_node1 = socketHandles(2);
udp_node2 = socketHandles(3);
%WARPLab 7

%Initialize two WARP nodes
nodes = wl_initNodes(2);

%Retrieve IDs for available RF interfaces
[RFA, RFB] = wl_getInterfaceIDs(nodes(1));

%Create an Ethernet trigger and assign it to both nodes
eth_trig = wl_trigger_eth_udp_broadcast;
wl_triggerManagerCmd(nodes, 'add_ethernet_trigger', eth_trig);


Setting Parameters: WARPLab 7 enables setting the same RF and baseband parameters as previous versions. However the syntax for sending commands to nodes has changed. The new syntax allows the same command to be sent to multiple nodes in one line. Each node can be assigned the same parameter value, or multiple values (one per node) can be passed as an array argument. The example below shows equivalent code for setting a few parameters for two nodes.

%WARPLab 6
warplab_writeRegister(udp_node1, TX_DELAY, 0);
warplab_writeRegister(udp_node1, TX_LENGTH, 2^14);

warplab_writeRegister(udp_node2, TX_DELAY, 0);
warplab_writeRegister(udp_node2, TX_LENGTH, 2^14);

warplab_setRadioParameter(udp_node1, CARRIER_CHANNEL, 11);
warplab_setRadioParameter(udp_node2, CARRIER_CHANNEL, 11);
%WARPLab 7
wl_basebandCmd(nodes, 'tx_delay', 0);
wl_basebandCmd(nodes, 'tx_length', 2^14);
wl_interfaceCmd(nodes, 'RF_ALL', 'channel', 2.4, 11);

Writing Samples: WARPLab 7 enables setting the same RF and baseband parameters as previous versions. However the syntax for sending commands to nodes has changed. The new syntax allows the same command to be sent to multiple nodes in one line. Each node can be assigned the same parameter value, or multiple values (one per node) can be passed as an array argument. The example below shows equivalent code for setting a few parameters for two nodes.

%WARPLab 6

%Time vector (assumes 40MHz sampling rate)
t = (1/40e6) .* [0 : 2^14-1];

%Generate a 1MHz sinusoid
txSigA = exp(1i*2*pi*t*1e6);

%Generate a 2MHz sinusoid
txSigB = exp(1i*2*pi*t*2e6);

%Write the two signals to RF A and B on both nodes
warplab_writeSMWO(udp_node1, RADIO2_TXDATA, txSigA);
warplab_writeSMWO(udp_node1, RADIO3_TXDATA, txSigB);
warplab_writeSMWO(udp_node2, RADIO2_TXDATA, txSigA);
warplab_writeSMWO(udp_node2, RADIO3_TXDATA, txSigB);
%WARPLab 7

%Time vector (assumes 40MHz sampling rate)
t = (1/40e6) .* [0 : 2^14-1];

%Generate a 1MHz sinusoid
txSigA = exp(1i*2*pi*t*1e6);

%Generate a 2MHz sinusoid
txSigB = exp(1i*2*pi*t*2e6);

%Write the two signals to RF A and B on both nodes
% Use vector arguments for interface selection and per-interface signals
wl_basebandCmd(nodes, [RFA RFB], 'write_IQ', [txSigA txSigB]);