| 1 | = USRP2 configration and data collection with OEDL script = |
| 2 | |
| 3 | == Description == |
| 4 | In this tutorial we'll demonstrate exactly what the title says. |
| 5 | |
| 6 | == Hardware / Software Resourcesutilized == |
| 7 | 1. 4 grid nodes with a USRP2 connect via Ethernet. |
| 8 | 2. ''ubuntu-12-04-uhd-daemon.ndz'': node image with all the precompiled software required to configure the USRPs. |
| 9 | 3. ''uhd.rb'' - OEDL script executed on the console. This script configures the USRPs for data collection at specified frequencies, sampling rate, etc... |
| 10 | 4. ''uhd_daemon'' - a node background process that bridges the gap between OMF commands and USRP2. |
| 11 | |
| 12 | == Set up == |
| 13 | * To get started first make a reservation on the [https://www.orbit-lab.org/schedule/ Orbit Scheduler]. |
| 14 | |
| 15 | * Let's pick 4 nodes with a USRP2. For a current list of nodes with USRPs, goto the [https://www.orbit-lab.org/schedule/ Orbit Scheduler], click on ''Status Page'' under ''Quick Links''. Select the ''Grid'' Tab and filter by ''SDR'' and USRP_N210 or SBX. This will give a topology list of nodes (below) that can be used with the OMF commands: |
| 16 | {{{ |
| 17 | [node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org, |
| 18 | node2-1.grid.orbit-lab.org,node2-2.grid.orbit-lab.org,node2-19.grid.orbit-lab.org,node2-20.grid.orbit-lab.org, |
| 19 | node19-1.grid.orbit-lab.org,node19-19.grid.orbit-lab.org,node19-20.grid.orbit-lab.org,node20-1.grid.orbit-lab.org, |
| 20 | node20-19.grid.orbit-lab.org,node20-20.grid.orbit-lab.org,node1-1.sb3.orbit-lab.org,node1-2.sb3.orbit-lab.org] |
| 21 | }}} |
| 22 | |
| 23 | * After logging into grid console, make sure all nodes are turned off |
| 24 | {{{ |
| 25 | nilanjan@console.grid:~$ omf tell -a offh -t node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org |
| 26 | }}} |
| 27 | |
| 28 | * Verify state of node before continuing. Make sure all nodes are in the POWEROFF state. |
| 29 | {{{ |
| 30 | nilanjan@console.grid:~$ omf stat -t node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org |
| 31 | }}} |
| 32 | |
| 33 | * Image nodes |
| 34 | {{{ |
| 35 | nilanjan@console.grid:~$ omf load -i ubuntu-12-04-uhd-daemon.ndz -r 20 -t node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org |
| 36 | }}} |
| 37 | |
| 38 | * After nodes are imaged, verify that nodes are in POWEROFF state. Otherwise issue the following to turn them off for a reboot |
| 39 | {{{ |
| 40 | nilanjan@console.grid:~$ omf tell -a offh -t node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org |
| 41 | }}} |
| 42 | |
| 43 | * Turn nodes back on and verify they are in POWERON state |
| 44 | {{{ |
| 45 | nilanjan@console.grid:~$ omf tell -a on -t node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org |
| 46 | }}} |
| 47 | |
| 48 | * Download the OEDL experiment script uhd.rb to your local directory on the console. Executing this script will tell the USRP2 record spectrum data for a few seconds at different carrier frequencies. |
| 49 | The contents of the uhd file is shown with additional comments: |
| 50 | {{{ |
| 51 | nilanjan@console.grid:~/UHD$ cat uhd.rb |
| 52 | defProperty('rxfreq', 2400e6, "Starting rx frequency") |
| 53 | defProperty('rxstep', 10e6, "Rx frequency increments") |
| 54 | defProperty('nfreq', 10, "Number of frequency steps") |
| 55 | defProperty('dwell', 10, "Number of seconds at each frequency step") |
| 56 | |
| 57 | |
| 58 | defGroup('rxnode', 'node1-1.grid.orbit-lab.org,node1-2.grid.orbit-lab.org,node1-19.grid.orbit-lab.org,node1-20.grid.orbit-lab.org') |
| 59 | |
| 60 | { |n| |
| 61 | } |
| 62 | |
| 63 | |
| 64 | onEvent(:ALL_UP) do |event| |
| 65 | info "Give machines some time to warm up" |
| 66 | wait 4 |
| 67 | |
| 68 | |
| 69 | allGroups.uhd.u0.activate # starts uhd_daemon |
| 70 | wait 3 |
| 71 | |
| 72 | group("rxnode").uhd.u0.rxrate = "8e6" # set receive chain sampling rate |
| 73 | group("rxnode").uhd.u0.rxgain = "20" # set receive chain gain (dB) |
| 74 | group("rxnode").uhd.u0.numbins = "128" # set size of fft |
| 75 | group("rxnode").uhd.u0.avgwinlen = "32" # set averaging window size for each fft bin across time. |
| 76 | |
| 77 | group("rxnode").uhd.u0.omlfile = "spectrum.grid" # oml database filename to store fft data |
| 78 | group("rxnode").uhd.u0.omlserver = "idb2:3003" # oml server |
| 79 | |
| 80 | group("rxnode").uhd.u0.record # enable recording thread |
| 81 | |
| 82 | (0..property.nfreq).each { |i| # set up loop |
| 83 | cf = property.rxfreq + (property.rxstep*i) # compute next carrier frequency |
| 84 | group("rxnode").uhd.u0.rxfreq = cf # set receive chain carrier frequency (Hz) |
| 85 | |
| 86 | wait property.dwell # wait for number of seconds before computing next frequency |
| 87 | } |
| 88 | |
| 89 | group("rxnode").uhd.u0.stop # stop recording thread |
| 90 | |
| 91 | allGroups.uhd.u0.deactivate # turn off uhd_daemon |
| 92 | |
| 93 | |
| 94 | info "Finish it." |
| 95 | Experiment.done |
| 96 | end |
| 97 | }}} |
| 98 | |
| 99 | |
| 100 | == Execute script and view recorded data == |
| 101 | |
| 102 | * To run the experiment script: |
| 103 | {{{ |
| 104 | nilanjan@console.grid:~/UHD$ omf exec uhd.rb |
| 105 | }}} |
| 106 | |
| 107 | * Once the script finishes, check the contents of the database file on specified oml server and directory. The data should be |
| 108 | |
| 109 | recorded in ''spectrum.grid.sq3''. |
| 110 | {{{ |
| 111 | nilanjan@console.grid:~/UHD$ ssh idb2 |
| 112 | nilanjan@idb2:~$ cd /var/lib/oml2 |
| 113 | nilanjan@idb2:/var/lib/oml2$ |
| 114 | nilanjan@idb2:/var/lib/oml2$ ls -l spectrum.grid.sq3 |
| 115 | -rw-r--r-- 1 oml2 oml2 753561600 May 14 10:41 spectrum.grid.sq3 |
| 116 | }}} |
| 117 | |
| 118 | * Dump the contents of ''spectrum.grid.sq3'' to have a quick look inside the sql file. |
| 119 | {{{ |
| 120 | nilanjan@idb2:/var/lib/oml2$ sqlite3 spectrum.grid.sq3 ".dump" |
| 121 | }}} |
| 122 | |
| 123 | * The magnitude value of the fft bins are stored in binary format. The first entry of the db file is shown below. So when dumping the file contents the ftt bins data is shown as consecutive ascii representation of the binary floating point numbers. |
| 124 | |
| 125 | |
| 126 | * 5/15/2013 - Work in progress... |
| 127 | How to parse this data and |
| 128 | |
| 129 | |
| 130 | == Frequency detection with multiple nodes. == |
| 131 | |
| 132 | |
| 133 | == Spectrum sensing code == |
| 134 | |
| 135 | |
| 136 | == Logging spectrum data directly to an OML server == |
| 137 | |