Skip to content
Josh Blum edited this page Sep 6, 2015 · 23 revisions

SDR blocks tutorial

https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_stream_params.png

The device arguments are a dictionary of key-value pairs used for specifying a SDR device on the system. If only one SDR device is present on the system, an empty dictionary "{}" may be specified instead.

The key value pairs are the same ones printed by the Soapy SDR Util application:

SoapySDRUtil --find
######################################################
## Soapy SDR -- the SDR abstraction library
######################################################

Found device 0
  backend = libusb
  device = 0x01:0x02
  driver = bladerf
  instance = 0
  serial = 123456789abcdef
  • The device argument {"driver":"bladerf"} would cause other devices, such as rtl, to be ignored.
  • Or use {"driver":"bladerf", "serial":"123456789abcdef"} if the system has multiple blade RFs.

The data type is a string that specifies the format of the sample stream. Options are available for all complex, integer, and floating point data types, however not all formats may be supported depending upon the underlying driver for the hardware.

  • Note: complex float32 and complex int16 are almost universally supported by most hardware drivers.
https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_stream_channels.png

Channels is an array of channel indexes that will be used for streaming. By default this array is empty, meaning that channel 0 of the device will be used. However when specified, each entry in the array maps a device channel to a streaming port.

Stream arguments are a dictionary of key-value pairs used for passing extra arguments to the stream initialization. Implementation of the stream arguments is specific to the hardware driver, however common uses include specifying the underlying transport sample format and internal scaling. Check your device's manual about stream arguments for more information.

This is the sample rate (in samples per second) for all configured stream ports. All channels listed in the channels parameter will be configured to the same sample rate. Otherwise, use multiple blocks to support heterogeneous sample rates for different channels.

By default, the SDR block is activated upon topology activation. This setting can be disabled for advanced stream control, more on this topic in the sections below.

https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_source_stream.png

The receive stream may be decorated with several different labels to indicate configuration and events:

  • The "rxTime" label is produced at the start of streaming to indicate the stream time. The data of the label is a 64-bit integer containing the device time in nanoseconds. When using the burst capabilities, each burst will start with an "rxTime" label. In addition, "rxTime" is produced after overflow conditions so that downstream blocks can resynchronize their time-tracking.
  • The "rxEnd" label is produced at the end of a burst and when streaming is stopped.
  • The "rxFreq" label is produced after the center frequency has been configured. The data of the label is a double value representing the frequency in Hz. Many of the signal analysis plotters use this label to automatically configure the axis.
  • The "rxRate" label is produced after the sample rate has been configured. The data of the label is a double value representing the sample rate in samples per second. Many of the signal analysis plotters use this label to automatically configure the axis.

The user has explicit control for bursts and timing using the streamControl() slot. The default behavior of the SDR source is to stream continuously upon activation of the topology. Disable the auto-activation parameter before using advanced the stream control capabilities.

https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_auto_activate_param.png

The following arguments can be passed to the streamControl() slot to control streaming:

  • streamControl("ACTIVATE") - stream continuously immediately
  • streamControl("ACTIVATE_AT", timeNs) - stream continuously starting at timeNs
  • streamControl("ACTIVATE_BURST", 0, numElems) - stream a burst of size numElems immediately
  • streamControl("ACTIVATE_BURST_AT", timeNs, numElems) - stream a burst of size numElems at timeNs
  • streamControl("DEACTIVATE") - halt a continuous stream
  • streamControl("DEACTIVATE_AT", timeNs) - halt a continuous stream at timeNs

As a useful demonstration of streamControl(), the periodic trigger block can be used to request bursts at a regular rate. Since many of the plotters only display periodic chunks of the sample stream, this little trick makes it possible to display stream from remote or embedded devices configured at very high sample rates.

https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_burst_trigger.png https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_sink_stream.png

Transmit bursts are controlled by stream labels created by upstream blocks. In particular:

  • The "txTime" label indicates the transmit time of the first sample in a burst. The data of the label is a 64-bit integer containing the device time in nanoseconds.
  • The "txEnd" label indicates the end of a burst to the hardware. Without the end of burst, the hardware may incur an underflow event.

Typically, bursts are sent to the hardware in several fragments. Which means that the hardware can transmit the first fragment before the next arrives. However, burst scheduling can prevent transmission before until all fragments arrive.

As a general utility to users and to demonstrate burst scheduling, the pothos-sdr toolkit comes with a TX burst timer block -- which keeps track of current hardware time and inserts a txTime label into the stream to schedule the bursts.

https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_sink_sched.png https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_channel_params.png https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_clocking_params.png https://raw.githubusercontent.com/wiki/pothosware/pothos-sdr/images/docs_sdr_gpio_params.png