SM API
Sweep Mode

Sweep mode represents the common spectrum analyzer measurement of plotting amplitude over frequency. The API provides a simple interface through smGetSweep for acquiring single sweeps, or using smStartSweep and smFinishSweep, you can perform high throughput sweep measurements up to 1THz per second.

Example

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

// Configure the device for sweeps and perform a single sweep.
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "sm_api.h"
void sm_example_sweep()
{
int handle = -1;
SmStatus status = smNoError;
// Uncomment this to open a USB SM device
status = smOpenDevice(&handle);
// Uncomment this to open a networked SM device with a default network config
//status = smOpenNetworkedDevice(&handle, SM_ADDR_ANY, SM_DEFAULT_ADDR, SM_DEFAULT_PORT);
// Check open status
if(status != smNoError) {
printf("Unable to open device\n");
exit(-1);
}
// Configure the sweep
smSetRefLevel(handle, -20.0); // -20dBm reference level
smSetSweepCenterSpan(handle, 2.45e9, 100.0e6); // ISM band
smSetSweepCoupling(handle, 10.0e3, 10.0e3, 0.001); // 10kHz rbw/vbw, 1ms acquisition
smSetSweepDetector(handle, smDetectorAverage, smVideoPower); // average power detector
smSetSweepScale(handle, smScaleLog); // return sweep in dBm
smSetSweepSpurReject(handle, smFalse); // No software spur reject
// Initialize the device for sweep measurement mode
status = smConfigure(handle, smModeSweeping);
if(status != smNoError) {
printf("Unable to configure device\n");
printf("%s\n", smGetErrorString(status));
smCloseDevice(handle);
exit(-1);
}
// Get the configured sweep parameters as reported by the receiver
double actualRBW, actualVBW, actualStartFreq, binSize;
int sweepSize;
smGetSweepParameters(handle, &actualRBW, &actualVBW, &actualStartFreq, &binSize, &sweepSize);
// Create memory for our sweep
std::vector<float> sweep(sweepSize);
// Get sweep, ignore the min sweep and the sweep time
status = smGetSweep(handle, nullptr, sweep.data(), nullptr);
if(status != smNoError) {
printf("Sweep status: %s\n", smGetErrorString(status));
}
// Done with the device
smCloseDevice(handle);
}
API functions for the SM435/SM200 spectrum analyzers.
SM_API SmStatus smOpenDevice(int *device)
@ smScaleLog
Definition: sm_api.h:309
SM_API SmStatus smSetSweepWindow(int device, SmWindowType window)
SM_API SmStatus smSetSweepCoupling(int device, double rbw, double vbw, double sweepTime)
SM_API SmStatus smSetSweepDetector(int device, SmDetector detector, SmVideoUnits videoUnits)
SM_API SmStatus smGetSweep(int device, float *sweepMin, float *sweepMax, int64_t *nsSinceEpoch)
SM_API SmStatus smGetSweepParameters(int device, double *actualRBW, double *actualVBW, double *actualStartFreq, double *binSize, int *sweepSize)
SM_API SmStatus smSetSweepScale(int device, SmScale scale)
@ smVideoPower
Definition: sm_api.h:325
@ smFalse
Definition: sm_api.h:378
@ smWindowFlatTop
Definition: sm_api.h:335
@ smModeSweeping
Definition: sm_api.h:246
SM_API SmStatus smSetRefLevel(int device, double refLevel)
SM_API SmStatus smSetSweepSpurReject(int device, SmBool spurRejectEnabled)
SM_API SmStatus smSetSweepCenterSpan(int device, double centerFreqHz, double spanHz)
SM_API SmStatus smCloseDevice(int device)
SM_API SmStatus smConfigure(int device, SmMode mode)
SM_API const char * smGetErrorString(SmStatus status)
SmStatus
Definition: sm_api.h:142
@ smNoError
Definition: sm_api.h:203
@ smDetectorAverage
Definition: sm_api.h:299

Basics

Only 1 sweep configuration can be active at a time.

Changing a sweep setting requires reconfiguring the device with a new sweep configuration.

All sweeps must be finished to change sweep configuration.

To achieve a sustained 1THz/s sweep speed, use fast sweep speed and queued sweeps.

Only linear spaced sweeps can be performed.

Sweep Format

A sweep is returned from the API as a 1-dimensional array of measurement values. Each element in the array corresponds to a specific frequency. The frequency of any given element can be calculated as

Frequency of N'th element in sweep = StartFreq + N * BinSize

where StartFreq and BinSize are reported in the smGetSweepParameters function.

The measurement values can be returned in dBm or mV units.

Min and Max Sweep Arrays

All sweep functions in the API return 2 separate sweep arrays. The parameters are typically named sweepMin and sweepMax. To understand the purpose of these arrays, it is important to understand their relation to the analyzer’s detector setting. Traditionally, spectrum analyzers offer several detector settings, the most common being peak-, peak+, and average. The API reduces this to either minmax or average. When the detector is set to minmax, the sweepMin array will contain the sweep as if a peak- detector is running, and the sweepMax array will contain the sweep of a peak+ detector. When average detector is enabled, sweepMin and sweepMax will be identical arrays and will be the result of an average detector.

If you are not interested in one of the sweeps, you can pass a NULL pointer for this parameter.

Most users will be interested in the sweepMax array as it will provide you either the peak+ and average detector results depending on detector setting. In this case, pass NULL for the sweepMin parameter.

Blocking vs. Queued Sweep Acquisition

The simple method of acquiring sweeps is to use the smGetSweep function. This function starts a sweep and blocks until the sweep is completed. This is adequate for many types of measurements but does not optimize for sweep speed. System latencies can be very large compared to total acquisition/processing time. To eliminate latencyies, you will need to take advantage of queued acquisitions.

The smStartSweep and smFinishSweep functions provide a way to eliminate latencies between sweeps which allows the device to sustain the full sweep speed throughput. Using these functions you can start up to several sweeps which ensures the receiver is continuously acquiring data for the next sweep. Using a circular buffer approach, you can ensure that there is no down time in sweep acquisition. See an example of this in the provided code examples.

Blocking and queued sweep acquisitions should not be mixed.

Sweep Speed

All SM devices have 3 sweeps speeds depending on the user’s configuration. The sweep speed is determined from the sweep configuration, except in a few cases. The user can also configure the API to automatically choose the fastest sweep speed. The sweep speeds are described below.

  • Fast – The SM sweeps > 1THz per second in this mode. There are restrictions on settings which allow fast sweep. The max FFT size is 16K which limits RBW to ~30-60kHz depending on the window function selected. Additionally, VBW must equal RBW, and sweep time is not selectable.
    • In fast sweep speed, the SM steps the LO in 156.25MHz steps across the desired frequency range.
  • Normal – This mode offers better RF performance than fast sweep mode, with a sweep speed reduction of about 3X.
    • Maximum speed in this mode is ~300GHz/s.
    • In normal sweep speed, the SM steps the LO in 39.0625MHz steps across the desired frequency range.
  • Slow/Narrow – For spans below 5MHz, the API will perform sweeps in a way to achieve lower RBW/VBWs. The sweep is accomplished by dwelling at a LO frequency. This is necessary for the low RBWs that accompany the narrow spans. The API will use this sweep speed below 5 MHz regardless of the users sweep speed selection.

This sweep speed can be partially controlled smSetSweepSpeed. Also see SmSweepSpeed.