wiki:Old/Tutorials/k0SDR/Tutorial00

Version 78 (modified by jonshan, 17 years ago) ( diff )

GNURadio

This document is not meant to be a complete tutorial on GNU Radio, but to help you start to play around GNU Radio on Orbit Sandbox and to share my experiences on exploring this wonderful toy.

Prerequisites

Before you jump into GNU Radio on Orbit, you should have a clear picture on what GNU Radio is. An excellent starting reading material is Eric Blossom’s Exploring GNU Radio:http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html. Eric is the founder of the whole GNU Radio project. Make sure you understand the data flow paths, including the receive path and the transmit path, understand the role that the USRP (Universal Software Radio Peripheral) plays. USRP is a flexible USB device that connects the PC to the RF world. USRP has one motherboard, which connected to the PC via USB 2.0 and can support up to four daughterboard. Each daughterboard has RF ends that can either transmit or receive waveform from the air. There are different types of daughterboard supporting a variety radio range, e.g. for example, Flex400 supports both transmit and receive in the frequency band 400MHz to 500 Mhz. You need to refresh your memory on the sample theory (Nyquist interval).

To create GNU Radio scripts, you need to build a radio by creating a graph (as in graph theory) where the vertices are signal processing blocks and the edges represent the data flow between them. The signal processing blocks are implemented in C++. The graphs are constructed and run in Python. If you are not familiar with C++ or Python, find a tutorial online and learn it.

What is Sandbox5 on Orbit-Lab?

Sandbox5 consists of two nodes, i.e. node1-1 and node1-2. Each individual node is connected to one Gnuradio motherboard, and each motherboard in turn has two BasicRX and two BasicTX mounted on it, as show in the following picture.

No image "sandbox5.JPG" attached to Documentation/GNURadio

The frequency that the BasicTX operates on ranges from 2 MHz to 200 MHz, and the BasicRX can receive from 2 MHz to 300+ MHz.

The image above shows TX_A connected to RX_B through a 50 ohm attenuator. Likewise, side B of both nodes are connected through an attenuator. The ports are connected by wires in order to minimize noise. However, both TX and RX can use actual antenna.

Setting up Sandbox 5

I assume you’ve read the tutorial about Orbit, and you know how to reserve a time slot, how to log into the nodes, and how to image the nodes. (Otherwise, read Getting Started.)

To load the nodes with the right image:

  • Step 1: Login to the console.
          ssh username@ console.sb5.orbit-lab.org
    
  • Step 2: Image the nodes.
          imageNodes [1,1],[1,2] gnuradio.ndz
          
          Other images are: baseline-2.1.ndz (for building from scratch, supported)
                            gnuradio_visual.ndz (for visual outputs, unsupported)
    
  • Step 3: Power up node1-1 and node1-2.
          wget -O - -q 'http://cmc:5012/cmc/on?x=1&y=1'
          wget -O - -q 'http://cmc:5012/cmc/on?x=1&y=2'
    
  • Step 4: Log into the node.
              ssh root@node1-1
    	  ssh root@node1-2
    

Example: Transmitting/Receiving Sine Waves

Before you run these examples, do the following:

copy http://www.orbit-lab.org/attachment/wiki/Documentation/GNURadio/usrp_siggen_multiple_sine.py usrp_siggen_multiple_sine.py to node1-1 (transmitter)

copy http://www.orbit-lab.org/attachment/wiki/Documentation/GNURadio/usrp1_rx_cfile.py usrp1_rx_cfile.py to node1-2 (receiver).

Give your scripts permission to run. (chmod +x filename)

  1. Receiver only The transmitter doesn't send any thing, only the receiver receives. In this case, what the receiver receives is white noise.
       ./usrp1_rx_cfile.py -f 10e3 -N21000 -g 10 noise.dat
    
    • '-f 10e3': tells the GnuRadio to listen to the frequency band centered at 10kHz.
    • '-N21000': write 21000 data points to file.
    • '-g 10': set the gain to 10.
    • 'noise.dat': set the file name that will store the data samples.

Using the matlab script plotall('noise.dat'), you will see the following output:

No image "noise.dat.jpeg" attached to Documentation/GNURadio

  1. Transmitter and Receiver at 1MHz The transmitter sends out waveform at 1MHz, and the receiver receives at 1MHz as well. At the Transmitter node1-1:
        ./usrp_siggen_multiple_sine.py -f 1e6 -w 10k -a 1000 -m 1 --sine
    
    • '-f 1e6': tells the USRP to modulate the baseband waveform to 1MHz.
    • '—sine': the type of the waveform that will be sent out is a sine wave.
    • '-w 10k': set the original baseband frequency to 10k.
    • '-a 1000': set the amplitude to 1000.
    • '-m 1': only transmit one sine wave, instead of multiple sine waves.

At the receiver node1-2:

   ./usrp1_rx_cfile.py -f 1e6 -N21000 -g 10 rx_1m.dat
  • '-f 1e6': tells the GnuRadio to listen to the frequency band centered at 1MHz.
  • '-N21000': write 21000 data points to file.
  • '-g 10': set the gain to 10.
  • 'rx_1m.dat': set the file name that will store the data samples.

Using the matlab script plotall('rx_1m.dat'), you can get the following figure:

No image "rx_1m.dat.jpeg" attached to Documentation/GNURadio

What we observe in the above plot is not a perfect sine wave. There are some high frequency components around the 10KHz sine wave. This is because that we set the target frequency as 1MHz, which is out of the working range of BasicRX and BasicTX. Recall that the working range of BasicRX and BasicTX is from 2MHz to 200MHz+. Now let’s try to set the correct frequency.

  1. Transmitter and Receiver at 10MHz The transmitter sends out waveform at 10MHz, and the receiver receives at 10MHz as well. At the Transmitter node1-1:
        ./usrp_siggen_multiple_sine.py -f 10e6 -w 10k -a 1000 -m 1 --sine
    

At the receiver node1-2:

   ./usrp1_rx_cfile.py -f 10e6 -N21000 -g 10 rx_1m.dat

The resulting plot is :

No image "rx_10m.dat.jpeg" attached to Documentation/GNURadio

This time the received sine wave is indeed a regular sine wave.

Note: the first 1000 data in rxXXX should be discarded. Since the receiver is starting up, the first 1000 data points are not correct.

Example: Visual Outputs

Before you try these examples, you should have imaged nodes on sandbox 5 using gnuradio_visual.ndz OR manually installed x-window-system and wx-python on the node. Also be sure to have an x-server running on the local machine and make sure X is enabled on all ssh-running machines.

In the previous example, the received signal could only be viewed after it has been moved onto a machine running plotting software. With visual outputs, the researcher can analyze transmitted and received waveforms in real-time.

Some interesting visual applications included with the gnuradio software:

  • usrp_fft.py — real-time fft
  • usrp_oscope.py — real-time oscilloscope

No image "double_sine.2.PNG" attached to Documentation/GNURadio

Potential applications:

  • Visual spectrum analyzer

Example: Audio Outputs

Even though there is no sound card on the nodes, it is still possible to listen to sounds generated by the nodes. Our particular implementation uses NAS (Network Audio System) to move sound from the node (client) to a local machine (server). Before we run audio examples, we must make sure remote audio is working by itself.

To hear remote audio generated by GNURadio with the USRP:

  1. Tunnel from local machine to node. The default port to enable is 8000.
  1. Install and run nasd (server) on the local machine. The local machine should have a way to play sounds locally (soundcard).
  1. Install NAS, set AUDIOSERVER, and run auinfo (client) on the remote machine. There should be an output describing all potential audio outputs on the local machine running nasd. Running auinfo is simply a means of checking if the remote connection is working as intended. You can also try "auplay FILE" to actually play sounds remotely.
  1. Modify the gnuradio audio scripts to use NAS libraries. Image "gnuradio_audio.ndz" already has modified audio blocks. Note: if you use the custom image, OSS audio is disabled.
  1. Run any example scripts from /gnuradio-examples/python/audio (mono_tone.py, dial_tone.py preferred). Also, any gnuradio script which outputs to audio_sink will work.

Steps 1-3 are necessary for any remote audio applications that use NAS. Step 4 inserts NAS functions into the GNURadio audio block. There exists a wrapper library, libaudiooss, that takes all input to /dev/dsp and "pipes" it to NAS. Thus, conceivably, any program that outputs OSS audio can be played remotely. Examples: SoX, mpg123, … However, libaudiooss currently does not work on the node. If it did, then step 4 could be omitted.

http://www.orbit-lab.org/attachment/wiki/Documentation/GNURadio/gnusound.wav

This is a recording of an AM station that GNURadio demodulated, downsampled, and converted to floats. NAS moved the data from the remote machine to a local machine. So, this is actually a "recording of real-time audio".

Troubleshooting

  • Have you picked the right node as the transmitter and receiver?
  • Have you run the correct Python script at the transmitter?
  • Have you tune the frequency within the Radio Front’s working range?
  • Have you matched the receiver’s frequency to the transmitter’s?
  • Have you set the gain properly? If you fail to set the gain correctly, chances are the device will run on the saturated mode, and the result will not be pretty.

Attachments (10)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.