| 1 | == Spectrum sensing with USRP2 and wiserd == |
| 2 | |
| 3 | [[TOC(Tutorials/k0SDR*)]] |
| 4 | |
| 5 | === Description === |
| 6 | This tutorial will utilize Wiserd to set up USRPs for signal transmission and reception. |
| 7 | |
| 8 | === Hardware / Software Resources utilized === |
| 9 | 1. Grid nodes with a USRP2 connect via Ethernet. |
| 10 | 2. ''ubuntu-14-04-64bit-sdr.ndz'': disk image loaded onto nodes. |
| 11 | 3. [http://wiser.orbit-lab.org/wiki/wiser/mSoftware/aWiserd Wiserd] - interface to configure and stream data to/from USRPs. |
| 12 | 4. octave - generate transmit data file and plot received data file. |
| 13 | |
| 14 | |
| 15 | === Set up === |
| 16 | * To get started first make a reservation on the [https://www.orbit-lab.org/schedule/ Orbit Scheduler] for using the Grid. |
| 17 | |
| 18 | * After logging into grid console, make sure all nodes are turned off |
| 19 | {{{ |
| 20 | nilanjan@console.grid:~$ omf tell -a offh -t system:topo:all |
| 21 | }}} |
| 22 | |
| 23 | * Verify state of node before continuing. Make sure all nodes are in the POWEROFF state. |
| 24 | {{{ |
| 25 | nilanjan@console.grid:~$ omf stat |
| 26 | }}} |
| 27 | |
| 28 | * Image nodes |
| 29 | {{{ |
| 30 | nilanjan@console.grid:~$ omf load -i ubuntu-14-04-64bit-sdr.ndz -t node20-20,node19-19,node8-8 -r 20 |
| 31 | }}} |
| 32 | |
| 33 | * After nodes are imaged, verify that nodes are in POWEROFF state. Otherwise issue the following to turn them off for a reboot |
| 34 | {{{ |
| 35 | nilanjan@console.grid:~$ omf tell -a offh -t system:topo:all |
| 36 | }}} |
| 37 | |
| 38 | * Turn nodes back on and verify they are in POWERON state |
| 39 | {{{ |
| 40 | nilanjan@console.grid:~$ omf tell -a on -t node20-20,node19-19,node8-8 |
| 41 | }}} |
| 42 | |
| 43 | In this example node8-8 and node19-19 is used as the transmitting nodes and the node20-20 as the receiver |
| 44 | |
| 45 | === Generate signal source file using octave === |
| 46 | |
| 47 | On each transmiting node, create a signal file using octave. You can use the scripts provided here as an example. On node8-8 create a file ''s1.bin'' using the lines below |
| 48 | {{{ |
| 49 | root@node8-8:~# cd wiserd |
| 50 | root@node8-8:~/wiserd# octave |
| 51 | octave:1> signal = fGenFDSignal(256,50,10,'1half'); |
| 52 | octave:2> saveToWiserdFile(signal,'s1.bin'); |
| 53 | octave:3> exit |
| 54 | }}} |
| 55 | |
| 56 | The signal will look something like the following in the frequency domain - notice the first half of the spectrum is populated: |
| 57 | || [[Image(s1.png, width=500px)]] || |
| 58 | |
| 59 | Create a similar signal on node19-19 but with the 2nd half of the spectrum populated |
| 60 | {{{ |
| 61 | octave:1> signal = fGenFDSignal(256,50,10,'2half'); |
| 62 | octave:2> saveToWiserdFile(signal,'s2.bin'); |
| 63 | }}} |
| 64 | || [[Image(s2.png, width=500px)]] || |
| 65 | |
| 66 | |
| 67 | === Set up transmitting node === |
| 68 | |
| 69 | |
| 70 | * ssh into each node and start the wiserd interface: |
| 71 | {{{ |
| 72 | root@node8-8> wiserd |
| 73 | linux; GNU C++ version 4.8.2; Boost_105400; UHD_003.008.002-86-g566dbc2b |
| 74 | |
| 75 | -- Opening a USRP2/N-Series device... |
| 76 | -- Current recv frame size: 1472 bytes |
| 77 | -- Current send frame size: 1472 bytes |
| 78 | -- Detecting internal GPSDO.... No GPSDO found |
| 79 | -- Successfully tuned to 900.000000 MHz |
| 80 | -- |
| 81 | -- Successfully tuned to 900.000000 MHz |
| 82 | -- |
| 83 | Ready! |
| 84 | > |
| 85 | }}} |
| 86 | |
| 87 | * At the wiserd prompt set the carrier frequency, sampling rate & gain. Then link the transmitter to the signal source which is the binary file generated in octave from prior step: |
| 88 | {{{ |
| 89 | > --uhd_tx_freq 700e6 --uhd_tx_rate 5e6 --uhd_tx_gain 20 --tran_wavefilename s1.bin |
| 90 | -- Successfully tuned to 700.000000 MHz |
| 91 | uhd_tx_freq 700000000 |
| 92 | uhd_tx_gain 20 |
| 93 | uhd_tx_rate 5000000 |
| 94 | > --addmodule signalfromfile |
| 95 | Consumer signalfromfile added |
| 96 | LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL |
| 97 | > |
| 98 | }}} |
| 99 | |
| 100 | In order to set parameter values, multiple arguments can be used in one line: |
| 101 | |
| 102 | ''--uhd_tx_freq'' set carrier frequenct to 700MHz |
| 103 | |
| 104 | ''--uhd_tx_rate'' set sampling rate to 5M samples/sec |
| 105 | |
| 106 | ''--uhd_tx_gain'' set transmit gain to 20dB. |
| 107 | |
| 108 | ''--tran_wavefilename'' tells the links the transmitter source to a binary filename. |
| 109 | |
| 110 | ''--addmodule signalfromfile'' opens the above filename, reads the samples and streams to the usrp. |
| 111 | |
| 112 | At this point the USRP will continuously transmit the signal util the delete command is issued: |
| 113 | |
| 114 | ''--delmodule signalfromfile'' stops tranmitting signal. |
| 115 | |
| 116 | |
| 117 | Now set up the transmitter on node19-19 using similar commands. |
| 118 | |
| 119 | |
| 120 | |
| 121 | === Set up receiving node(s) === |
| 122 | On the receiving node (node20-20), run wiserd to capture a snapshot of the signal from both transmitters. |
| 123 | {{{ |
| 124 | root@node20-20> wiserd |
| 125 | linux; GNU C++ version 4.8.2; Boost_105400; UHD_003.008.002-86-g566dbc2b |
| 126 | |
| 127 | -- Opening a USRP2/N-Series device... |
| 128 | -- Current recv frame size: 1472 bytes |
| 129 | -- Current send frame size: 1472 bytes |
| 130 | -- Detecting internal GPSDO.... No GPSDO found |
| 131 | -- Successfully tuned to 900.000000 MHz |
| 132 | -- |
| 133 | -- Successfully tuned to 900.000000 MHz |
| 134 | -- |
| 135 | Ready! |
| 136 | > --uhd_rx_freq 700e6 --uhd_rx_rate 5e6 --uhd_rx_gain 20 --recv_running_time 1000 --recv_output_filename rx_signal |
| 137 | -- Successfully tuned to 700.000000 MHz |
| 138 | -- |
| 139 | recv_output_filename rx_signal |
| 140 | recv_running_time 1000 |
| 141 | uhd_rx_freq 700000000 |
| 142 | uhd_rx_gain 20 |
| 143 | uhd_rx_rate 5000000 |
| 144 | > --addmodule timesamplestofile --timed |
| 145 | Consumer timesamplestofile added |
| 146 | Consumer timesamplestofile finished |
| 147 | |
| 148 | > exit |
| 149 | }}} |
| 150 | |
| 151 | |
| 152 | Here the set command has an additional argument to limit capturing to 1000 milliseconds: |
| 153 | |
| 154 | ''--recv_output_filename'' set receiving signal filename. |
| 155 | |
| 156 | ''--recv_running_time'' set receiver run time in milliseconds. (optional) |
| 157 | |
| 158 | The --addmodule command options |
| 159 | |
| 160 | ''--addmodule timesamplestofile'' streams data from receiver to file |
| 161 | |
| 162 | ''--timed'' runs receiver for the specified amount of time. (optional) |
| 163 | |
| 164 | Received signal file name will automatically be appended with the frequency, rate and gain: |
| 165 | {{{ |
| 166 | root@node20-20> ls -ltr *.bin |
| 167 | -rw-r--r-- 1 root root 40003072 May 21 10:56 rx_signal_freq700000000_rate5000000_gain20.bin |
| 168 | }}} |
| 169 | |
| 170 | Use octave to view the spectrum image: |
| 171 | {{{ |
| 172 | octave:1> fReconFDSignal(readWiserdFile('rx_signal_freq700000000_rate5000000_gain20.bin', 256*500), 256); |
| 173 | }}} |
| 174 | |
| 175 | Received signal should look simiar to |
| 176 | || [[Image(signal.png, width=500px)]] || |