= This page is WIP = = Working with USRP - Universal Software Radio Peripheral = == Description == In this tutorial we'll use the 2 USRPs on Sandbox 3 to transmit and receive a single frequency over the air to demonstrate the use of ''Universal software Radio peripheral'' Hardware Drivers (UHD) which is used standalone to configure and enable the USRPs. == Hardware / Software Resources utilized == 1. Sandbox 3 - consists of two nodes (node1-1 & node1-2). Each node has a USRP2 connect via Ethernet. 2. ''ubuntu-11-10-gnuradio.ndz'': disk image loaded onto nodes. This image has all the precompiled - software required to configure the USRPs and analyze recorded data. The USRP2's interface with the node is already configured. 3. omf-5.2 / omf-5.3: used to image to nodes 4. octave: GNU version of MATLAB == Set up == * To get started first make a reservation on the [https://www.orbit-lab.org/schedule/ Orbit Scheduler] for using Sandbox 3 * After logging into sandbox 3 console, make sure both nodes are turned off {{{ nilanjan@console.sb3:~$ omf-5.2 tell offh all }}} * Verify state of node before continuing. Make sure all nodes are in the POWEROFF state. {{{ nilanjan@console.sb3:~$ omf-5.2 stat }}} * Image both nodes {{{ nilanjan@console.sb3:~$ omf-5.3 load -i ubuntu-11-10-gnuradio.ndz -t node1-1.sb3.orbit-lab.org,node1-2.sb3.orbit-lab.org }}} * After nodes are imaged, verify that nodes are in POWEROFF state. Otherwise issue the following to turn them off for a reboot {{{ nilanjan@console.sb3:~$ nilanjan@console.sb3:~$ omf-5.2 tell offh all }}} * Turn nodes back on and verify they are in POWERON state before proceeding {{{ nilanjan@console.sb3:~$ nilanjan@console.sb3:~$ omf-5.2 tell on all }}} == Usage == * Once nodes are imaged, ssh into each node. Use the USRP2 on node1-1 as the transmitter and USRP2 on node1-2 as receiver.[[BR]] ssh into node1-1 {{{ nilanjan@console.sb3:~$ ssh root@node1-1 root@node1-1:~# cd uhd/host/build/examples/ }}} ssh into node1-2 {{{ nilanjan@console.sb3:~$ ssh root@node1-2 root@node1-1:~# cd uhd/host/build/examples/ }}} * The directory content should look like the following in both nodes {{{ root@node1-1:~/uhd/host/build/examples# ls benchmark_rate latency_test rx_samples_to_file test_pps_input tx_waveforms CMakeFiles Makefile rx_samples_to_udp tx_bursts cmake_install.cmake network_relay rx_timed_samples tx_samples_from_file CTestTestfile.cmake rx_multi_samples test_messages tx_timed_samples }}} * Once inside the node verify that the node can talk to the USRP {{{ root@node1-1:~/uhd/host/build/examples# uhd_find_devices }}} * It should return something like the following: {{{ root@node1-1:~/uhd/host/build/examples# uhd_find_devices linux; GNU C++ version 4.6.1; Boost_104601; UHD_003.004.003-0-unknown -------------------------------------------------- -- UHD Device 0 -------------------------------------------------- Device Address: type: usrp2 addr: 192.168.10.2 name: serial: 1232 }}} * Probe the device {{{ root@node1-1:~/uhd/host/build/examples# uhd_usrp_probe linux; GNU C++ version 4.6.1; Boost_104601; UHD_003.004.003-0-unknown -- Opening a USRP2/N-Series device... -- Current recv frame size: 1472 bytes -- Current send frame size: 1472 bytes _____________________________________________________ / | Device: USRP2 / N-Series Device | _____________________________________________________ | / | | Mboard: USRP2-REV4 | | hardware: 1024 | | mac-addr: 00:50:c2:85:34:d0 | | ip-addr: 192.168.10.2 | | gpsdo: none | | serial: 1232 | | | | Time sources: none, external, _external_, mimo | | Clock sources: internal, external, mimo | | Sensors: mimo_locked, ref_locked | | _____________________________________________________ | | / | | | RX DSP: 0 | | | Freq range: -50.000 to 50.000 Mhz | | _____________________________________________________ | | / | | | RX DSP: 1 | | | Freq range: -50.000 to 50.000 Mhz | | _____________________________________________________ | | / | | | RX Dboard: A | | | ID: XCVR2450 (0x0061) | | | _____________________________________________________ | | | / | | | | RX Subdev: 0 | | | | Name: XCVR2450 (0x0061) | | | | Antennas: J1, J2 | | | | Sensors: lo_locked, rssi | | | | Freq range: 2400.000 to 6000.000 Mhz | | | | Gain range LNA: 0.0 to 30.5 step 15.0 dB | | | | Gain range VGA: 0.0 to 62.0 step 2.0 dB | | | | Connection Type: IQ | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | RX Codec: A | | | | Name: ltc2284 | | | | Gain Elements: None | | _____________________________________________________ | | / | | | TX DSP: 0 | | | Freq range: -250.000 to 250.000 Mhz | | _____________________________________________________ | | / | | | TX Dboard: A | | | ID: XCVR2450 (0x0060) | | | _____________________________________________________ | | | / | | | | TX Subdev: 0 | | | | Name: XCVR2450 (0x0060) | | | | Antennas: J1, J2 | | | | Sensors: lo_locked | | | | Freq range: 2400.000 to 6000.000 Mhz | | | | Gain range VGA: 0.0 to 30.0 step 0.5 dB | | | | Gain range BB: 0.0 to 5.0 step 1.5 dB | | | | Connection Type: QI | | | | Uses LO offset: No | | | _____________________________________________________ | | | / | | | | TX Codec: A | | | | Name: ad9777 | | | | Gain Elements: None }}} If the commands ''uhd_find_devices'' & ''uhd_usrp_probe '' return No UHD Devices Found, please refer to the troubleshooting section. * On node1-1 use the waveform generator to continuously transmit a single frequency sine wave with a frequency of 100k Hz sampled at a rate of 8 MSamples / second and modulated upto 5000MHz {{{ root@node1-1:~/uhd/host/build/examples# ./tx_waveforms --wave-freq 100e3 --wave-type SINE --freq 5000e6 --rate 8e6 --gain 20 --ampl 0.9 linux; GNU C++ version 4.6.1; Boost_104601; UHD_003.004.003-0-unknown Creating the usrp device with: ... -- Opening a USRP2/N-Series device... -- Current recv frame size: 1472 bytes -- Current send frame size: 1472 bytes Using Device: Single USRP: Device: USRP2 / N-Series Device Mboard 0: USRP2-REV4 RX Channel: 0 RX DSP: 0 RX Dboard: A RX Subdev: XCVR2450 (0x0061) TX Channel: 0 TX DSP: 0 TX Dboard: A TX Subdev: XCVR2450 (0x0060) Setting TX Rate: 8.000000 Msps... UHD Warning: The hardware does not support the requested TX sample rate: Target sample rate: 8.000000 MSps Actual sample rate: 7.692308 MSps Actual TX Rate: 7.692308 Msps... Setting TX Freq: 5000.000000 MHz... Actual TX Freq: 5000.000000 MHz... Setting TX Gain: 20.000000 dB... Actual TX Gain: 20.000000 dB... Setting device timestamp to 0... Checking TX: LO: locked ... Press Ctrl + C to stop streaming... }}} * Now set up the USRP2 on node1-2 to sniff the spectrum at 5000MHz using the rx_ascii_art_dft tool {{{ root@node1-2:~/uhd/host/build/examples# ../../examples/rx_ascii_art_dft --freq 5000e6 --gain 20 --rate 8e6 --frame-rate 10 --ref-lvl -50 --dyn-rng 70 }}} * The output should display a frequency spectrum in the terminal using the ascii art! This plot is showing the a peak at 5000 MHz. Note that this peak is composed of the carrier which is centered at 5000 MHz and the tx waveform at 5000 MHz + 100 kHz. {{{ -50 | | ! | ||| -60 ||| ||| ||| ||| -70 ||| ||| |||| |||| -80 !|||||!!. ||||||||| ||||||||| . ||||||||| .| !| ||||||||| || -90 . !|||.|||||||||.||! : :. !| :|||||||||||||||||||:. .| ::| . .:.| ||!! ||||.||||||||||||||||||||||| .:|| !||| || |||| ||||: |||||||||||||||||||||||||||||||||: ||||. : !| -100 .: . ||.||||! ||||||||||||||||||||||||||||||||||||||||.|||||.|: .|| ! . .. || ||||:!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||| :||.|| || || |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||:|||||| ! . . || .|:|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |.| !||.! | -110 !.|:|. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||:|||.|||||||.: ||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||:||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -120 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| dBfs 4997MHz 4998MHz 4999MHz 5000MHz 5001MHz 5002MHz 5003MHz O }}} * Now going back to node1-1, turn off the waveform generator so nothing is transmitted. That is do a ''ctrl-c'' in the node1-1 terminal. The frequency spectrum display on node1-2 should display the noise floor {{{ -50 -60 -70 -80 -90 ! :. : : | || | | ! ! -100 . |. . .||! | ||! |!:. || :| | | .:|| ! . ! |: |!|| | ||||! | |||.||||:||:|| || |:||||::|.| ! !.! .|. . :| ||: ::||.||||:|:!||||| |!!||||||||||||||!||:|||||||||||:|:||| :.:.|||||!: | | :|:.||:||| ||||||||||||||||||:|||||||||||||||||||||||||||||||||||||| ||||||||||| :: . : . | -110 !|:| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||.|||||||||||.||! :|.| | |. !| |!|||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||| |!||| |. || ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||| || ||:|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||!|||||.|| -120 :||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| dBfs 4997MHz 4998MHz 4999MHz 5000MHz 5001MHz 5002MHz 5003MHz O }}} * Now generate a waveform at 1 MHz with a carrier centered at 5000 MHz. {{{ root@node1-1:~/uhd/host/build/examples# ./tx_waveforms --wave-freq 1e6 --wave-type SINE --freq 5000e6 --rate 8e6 --ampl 0.5 }}} Two distinguishable peaks should be present in the frequency spectrum of the receiving node. The peak at 5001 MHz corresponds to the 1 MHz sine wave generate and the smaller peak at 5000 MHz corresponds to carrier signal. This can be a very rough estimate of the carrier signal strength of about 75 dBm. {{{ :. || -60 || || || || || : || | || -80 | || | || | .|| | ||| |: .. |||| : .. .|| .|||||||! -100 . : . !| || :.::||| : .. |||||||||| ! : |!|: . | |!||||| |:| :||||||| | | ||:|||||||||| |.! || !. | :!||||| ..|| |:|||||||!|||. ||||||||.|!|!||||||||||||||:||||.||: | !. .. :: ! . ||:| !: |||||||.||||! |||||||||||||| ||||||||||||||||||||||||||||||||||||! |.||| |.|| || !.!. ! |: | |!!| .|:!|||| ||:|||||||||||||!|||||||||||||| |||||||||||||||||||||||||||||||||||||.|||||||||| ||:!||||.| .| ||||! ||||.||||||||:||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||||||||||||||||||||||.|||||||||||.: || ||||| !||||||||||||||||||||||||||||||||||||||||||||||.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||:|| -120 ||||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| dBfs 4997MHz 4998MHz 4999MHz 5000MHz 5001MHz 5002MHz 5003MHz }}} * Play around with the options on tx_waveforms - vary the tx_waveforms amplitude (--ampl option) and the waveform frequency (--wave-freq); verify the corresponding change in the received frequency spectrum. To view all options do the following: {{{ root@node1-1:~/uhd/host/build/examples# ./tx_waveforms --help }}} == Capture waveform and record to file & add time-domain plot of waveform == * Now record the received signal to an OCTAVE / MATLAB file. From node1-1 transmit a waveform with the following attributes {{{ root@node1-1:~/uhd/host/build/examples# ./tx_waveforms --wave-freq 1e6 --wave-type SINE --freq 5000e6 --rate 8e6 --ampl 0.5 }}} * On node1-2, use the rx_sample_to_file utility to dump the received samples into a file. {{{ root@node1-2:~/uhd/host/build/examples# ./rx_samples_to_file --freq 5000e6 --rate 8e6 --type float }}} * The samples will be recorded into the file ''usrp_samples.dat''. Upload this file into octave and plot the time-domain samples. On node1-2, start up octave {{{ root@node1-2:~/uhd/host/build/examples# octave GNU Octave, version 3.2.4 Copyright (C) 2009 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. Octave was configured for "i686-pc-linux-gnu". Additional information about Octave is available at http://www.octave.org. Please contribute if you find this software useful. For more information, visit http://www.octave.org/help-wanted.html Report bugs to (but first, please read http://www.octave.org/bugs.html to learn how to write a helpful report). For information about changes from previous versions, type `news'. octave:1> }}} From the Octave prompt verify received signal in the file {{{ octave:5> c=read_float_binary('usrp_samples.dat'); octave:6> creal = c([1:2:length(c)]); octave:7> cimage = c([2:2:length(c)]); octave:8> subplot(211) ; plot(creal(100:230)) ; title('real') ; axis([0 140 -0.010 0.010]) ; octave:9> subplot(212) ; plot(cimage(100:230)) ; title('imag') ; axis([0 140 -0.010 0.010]) }}} An octave plot window displaying the sine wave should be similar to the following. ||Plot of received sine wave|| || [[Image(SineWave1MHz.png, width=500px)]] || == Troubleshooting == * ''uhd_find_devices'' & ''uhd_usrp_probe '' return '''No UHD Devices Found''' If problems arise when trying find and probe the device, it's most likely the case that interface between the node and USRP2 needs to be reconfigured. In most scenarios, if finding the USRP2s fails it should return the following for ''uhd_find_devices'' {{{ root@node1-1:~# uhd_find_devices linux; GNU C++ version 4.6.1; Boost_104601; UHD_003.004.003-0-unknown No UHD Devices Found }}} The USRP2 has an ethernet interface (ip address: 192.168.10.2) to the node's eth2 interface (ip address: 192.168.10.1). To verify the nodes interface configuration: {{{ root@node1-1:~# ifconfig eth2 eth2 Link encap:Ethernet HWaddr 00:03:1d:07:49:5c inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0 inet6 addr: fe80::203:1dff:fe07:495c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:10 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:370 (370.0 B) TX bytes:862 (862.0 B) Interrupt:17 Memory:fdce0000-fdd00000 }}} If the interface is not configured, then do then following: {{{ root@node1-1:~# ifconfig eth2 192.168.10.1 netmask 255.255.255.0 up }}} The USRP2 ip-address is 192.168.10.2. Now try pinging the USRP2. {{{ root@node1-1:~# ping 192.168.10.2 PING 192.168.10.2 (192.168.10.2) 56(84) bytes of data. 64 bytes from 192.168.10.2: icmp_req=1 ttl=32 time=1.04 ms 64 bytes from 192.168.10.2: icmp_req=2 ttl=32 time=1.00 ms 64 bytes from 192.168.10.2: icmp_req=3 ttl=32 time=1.04 ms 64 bytes from 192.168.10.2: icmp_req=4 ttl=32 time=1.05 ms 64 bytes from 192.168.10.2: icmp_req=5 ttl=32 time=1.04 ms }}} At this point the node and USRP2 are able to see each other. Now retry finding and probing the USRPs.