SP API
Real-Time Spectrum Analysis

Real-time spectrum analysis allows you to perform continuous, gap free spectrum analysis on bandwidths up to 40MHz. This provides you with the ability to detect short transient signals down to 3.125us in length.

Example

For a list of all examples, please see the examples/ folder in the SDK.

#include <cstdio>
#include <cstdlib>
#include "sp_api.h"
// Configure the device for real-time spectrum analysis, and retrieve the real-time sweeps and frames.
static void checkStatus(SpStatus status)
{
if(status > 0) { // Warning
printf("Warning: %s\n", spGetErrorString(status));
return;
} else if(status < 0) { // Error
printf("Error: %s\n", spGetErrorString(status));
exit(-1);
}
}
void sp_example_real_time()
{
int handle = -1;
SpStatus status = spNoError;
status = spOpenDevice(&handle);
// Check open status
checkStatus(status);
// Configure the measurement
spSetRefLevel(handle, -20.0); // -20dBm reference level
spSetRealTimeCenterSpan(handle, 2.45e9, 40.0e6); // 40MHz span at 2.45GHz center freq
spSetRealTimeRBW(handle, 30.0e3); // 30kHz min RBW with Nuttall window
spSetRealTimeScale(handle, spScaleLog, -20.0, 100.0); // On the frame, ref of -20, 100dB height
// Initialize the measurement
status = spConfigure(handle, spModeRealTime);
checkStatus(status);
// Get the configured measurement parameters as reported by the receiver
double actualRBW, actualStart, binSize, poi;
int sweepSize, frameWidth, frameHeight;
spGetRealTimeParameters(handle, &actualRBW, &sweepSize, &actualStart,
&binSize, &frameWidth, &frameHeight, &poi);
// Create memory for our sweep and frame
float *sweep = new float[sweepSize];
float *frame = new float[frameWidth * frameHeight];
// Retrieve a series of sweeps/frames
for(int i = 0; i < 100; i++) {
// Retrieve just the color frame and max sweep.
spGetRealTimeFrame(handle, frame, nullptr, nullptr, sweep, nullptr, nullptr);
// Do something with data here
}
// Done with the device
spAbort(handle);
spCloseDevice(handle);
// Clean up
delete [] sweep;
delete [] frame;
}
API functions for the SP145 spectrum analyzer.
SpStatus
Definition: sp_api.h:104
@ spNoError
Definition: sp_api.h:156
SP_API SpStatus spSetRealTimeCenterSpan(int device, double centerFreqHz, double spanHz)
SP_API SpStatus spSetRealTimeScale(int device, SpScale scale, double frameRef, double frameScale)
SP_API SpStatus spCloseDevice(int device)
@ spModeRealTime
Definition: sp_api.h:211
SP_API const char * spGetErrorString(SpStatus status)
SP_API SpStatus spAbort(int device)
SP_API SpStatus spOpenDevice(int *device)
SP_API SpStatus spSetRefLevel(int device, double refLevel)
SP_API SpStatus spGetRealTimeParameters(int device, double *actualRBW, int *sweepSize, double *actualStartFreq, double *binSize, int *frameWidth, int *frameHeight, double *poi)
@ spWindowNutall
Definition: sp_api.h:263
SP_API SpStatus spSetRealTimeRBW(int device, double rbw)
@ spDetectorMinMax
Definition: sp_api.h:227
SP_API SpStatus spConfigure(int device, SpMode mode)
@ spScaleLog
Definition: sp_api.h:235
SP_API SpStatus spSetRealTimeDetector(int device, SpDetector detector)
SP_API SpStatus spGetRealTimeFrame(int device, float *colorFrame, float *alphaFrame, float *sweepMin, float *sweepMax, int *frameCount, int64_t *nsSinceEpoch)
SP_API SpStatus spSetRealTimeWindow(int device, SpWindowType window)

Basics

Real-time spectrum analysis is a frequency domain measurement. For time domain measurements see I/Q Streaming.

RBW directly affects the 100% POI of signals in real-time mode.

Real-time spectrum analysis returns a sweep, frame, and alphaFrame from the spGetRealTimeFrame function. These are described in the sections below.

The real-time measurement is performed over short consecutive time periods and returned to the user as a sweep and frame representing spectrum activity over that time period. The duration of these time periods is ~33ms. This means you will receiver ~30 sweep/frame pairings per second.

Once the measurement is initialized via spConfigure, the API is continuously generating sweeps and frames for retrieval. The API can buffer ~1 second worth of past measurements. It is the responsibility of the user to request sweeps/frames at a rate that prevents the accumulation of measurements in the API.

Real-time spectrum analysis is accomplished using 50% overlapping FFTs with zero-padding to accomplish arbitrary RBWs.

Real-Time Sweep

The sweeps returned in real-time spectrum analysis are the result of applying the detector over all FFTs that occur during the measurement period. The min/max detector will return the peak-/peak+ sweeps. The average detector will return the averaged sweep over that time period.

When average detector is selected, both sweepMin and sweepMax return identical sweeps and one of them can be ignored.

Real-Time Frame

The frame is a 2-dimensional grid representing frequency on the x-axis and amplitude levels on the y-axis. Each index in the grid is the percentage of time the signal persisted at this frequency and amplitude. If a signal existed at this location for the full duration of the frame, the percentage will be close to 1.0. An index which contains the value 0.0 infers that no spectrum activity occurred at that location during the frame acquisition.

The alphaFrame is the same size as the frame and each index correlates to the same index in the frame. The alphaFrame values represent activity in the frame. When activity occurs in the frame, the index correlating to that activity is set to 1. As time passes and no further activity occurs in that bin, the alphaFrame exponentially decays from 1 to 0. The alpha frame is useful to determine how recent the activity in the frame is and useful for plotting the frames.

The sweep size is always an integer multiple of the frame width, which means the bin size of the frame is easily calculated. The vertical spacing can be calculated using the frame height, reference level, and frame scale (specified by the user in dB).

An example of a frame plotted as a gray scale image, mapping the density values between [0.0,1.0] to gray scale values between [0,255]. The frame shows a persistent CW signal near the center frequency and a short-lived CW signal.
The same frame above as is plotted in Spike, where density values are mapped onto a color spectrum.

RBW Restrictions

RBW is limited to the range of [2kHz, 1MHz].