Skip to content

Sweep and Measurement Commands

Commands for controlling frequency sweep and measurement parameters.

Perform a frequency sweep and output measured data.

scan <start> <stop> [points] [outmask]
ParameterDescriptionDefault
startStart frequency in HzRequired
stopStop frequency in HzRequired
pointsNumber of sweep points (1–401)Current setting
outmaskOutput control bitmask (see below)0 (no per-point output)

The outmask parameter is a bitmask controlling both what data is output and how it is processed:

BitValueNameDescription
01OUT_FREQInclude frequency (Hz) for each point
12OUT_DATA0Include S11 real/imaginary pair
24OUT_DATA1Include S21 real/imaginary pair
38NO_CALIBRATIONSkip calibration correction
416NO_EDELAYSkip electrical delay compensation
532NO_S21OFFSSkip S21 offset correction

Common mask values:

  • 7 = frequencies + S11 + S21 (calibrated)
  • 6 = S11 + S21 data only (no frequencies)
  • 15 = frequencies + S11 + S21, uncalibrated raw data

For each point, outputs selected fields separated by spaces:

[frequency] [S11_re S11_im] [S21_re S21_im]
ch> scan 1000000 100000000 101 7
1000000 0.998234 -0.023456 0.012345 0.001234
1990099 0.997234 -0.024567 0.012456 0.001345
...
ch> scan 1M 100M 101 6
0.998234 -0.023456 0.012345 0.001234
...
ch> scan 1M 100M 101 14
0.998234 -0.023456 0.012345 0.001234
...
  • Interrupts any ongoing sweep
  • Applies current calibration (unless bit 3 is set)
  • Data is in linear format (not dB)
  • With outmask 14 (OUT_DATA0 | OUT_DATA1 | NO_CALIBRATION), you get raw uncalibrated S-parameters

Binary output variant of scan for faster data transfer. Accepts the same arguments as scan but forces binary output mode regardless of the outmask BINARY bit.

scan_bin <start> <stop> [points] [outmask]

The output begins with a 4-byte header, followed by per-point data:

Header (4 bytes):

FieldTypeSizeDescription
maskuint16_t2 bytesOutmask with BINARY bit (0x80) set
pointsuint16_t2 bytesNumber of sweep points

Per-point data (variable size):

FieldTypeSizeCondition
frequencyuint32_t4 bytesIf mask bit 0 (OUT_FREQ) set
S11_re, S11_imfloat[2]8 bytesIf mask bit 1 (OUT_DATA0) set
S21_re, S21_imfloat[2]8 bytesIf mask bit 2 (OUT_DATA1) set

All values are little-endian. Floats are IEEE 754 single precision.

import struct
import serial
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=5)
ser.write(b'scan_bin 1000000 100000000 101 7\r')
# Read 4-byte header
header = ser.read(4)
mask, points = struct.unpack('<HH', header)
# Calculate bytes per point based on mask bits
bytes_per_point = 0
if mask & 0x01: bytes_per_point += 4 # frequency (uint32)
if mask & 0x02: bytes_per_point += 8 # S11 (2 floats)
if mask & 0x04: bytes_per_point += 8 # S21 (2 floats)
data = ser.read(points * bytes_per_point)
# Parse each point
offset = 0
for i in range(points):
if mask & 0x01:
freq = struct.unpack_from('<I', data, offset)[0]
offset += 4
if mask & 0x02:
s11_re, s11_im = struct.unpack_from('<ff', data, offset)
offset += 8
if mask & 0x04:
s21_re, s21_im = struct.unpack_from('<ff', data, offset)
offset += 8

Get or set sweep frequency range and points. Supports both positional arguments and named subcommands for individual parameter control.

sweep # query current settings
sweep <start> [stop] [points] # set range (positional)
sweep {start|stop|center|span|cw|step|var} <value> # set individual parameter
ParameterDescriptionRange
startStart frequency in Hz600 Hz – 2 GHz
stopStop frequency in Hz600 Hz – 2 GHz
pointsNumber of sweep points1–401 (F072) or 1–101 (F303)
SubcommandDescription
startSet start frequency only
stopSet stop frequency only
centerSet center frequency (adjusts start/stop symmetrically)
spanSet frequency span (adjusts start/stop around center)
cwSet CW frequency (single-point sweep)
stepSet frequency step size between points
varSet variable parameter (for parameter sweep modes)
ch> sweep
1000000 100000000 101
ch> sweep 50k 300M
ch> sweep 1M 100M 201
ch> sweep center 145M
ch> sweep span 10M
ch> sweep cw 432.1M
ch> sweep step 100k
  • With no arguments, returns current settings: start stop points
  • Named subcommands accept exactly 2 arguments: the keyword and a frequency value
  • Setting sweep parameters triggers recalculation of frequency points and may require calibration interpolation

Set or get CW (single frequency) mode.

freq [frequency]
ParameterDescription
frequencyCW frequency in Hz
ch> freq
145000000
ch> freq 145M
ch> freq 432.100M
  • Sets sweep to single point at specified frequency
  • Useful for continuous monitoring at one frequency
  • Equivalent to sweep <freq> <freq> 1

Set or get output power level.

power [level|auto]
ValueDescription
auto or 255Automatic power selection
02 mA drive
14 mA drive
26 mA drive
38 mA drive
ch> power
auto
ch> power 2
ch> power auto
  • Higher power improves dynamic range but may cause compression on some DUTs
  • Auto mode selects power based on frequency band

Set or get IF (intermediate frequency) bandwidth.

bandwidth [bw]
ValueBandwidthSweep Speed
40004000 HzFastest
20002000 HzFast
10001000 HzMedium
333333 HzSlow
100100 HzSlower
3030 HzSlowest
ch> bandwidth
1000
ch> bandwidth 100
  • Lower bandwidth = more averaging = less noise but slower
  • For accurate measurements of narrow filters, use lower bandwidth
  • Default is 1000 Hz

Pause continuous sweep.

pause
ch> pause
  • Sweep stops at current position
  • Data remains valid
  • Use resume to continue

Resume paused sweep.

resume
ch> resume
  • Continues sweep from where it was paused
  • If sweep was not paused, has no effect

Set frequency offset (if USE_VARIABLE_OFFSET enabled).

offset [value]
ParameterDescription
valueFrequency offset in Hz
  • Used for external mixers or frequency converters
  • Adds offset to displayed frequencies

The firmware maintains sweep mode flags:

FlagValueDescription
SWEEP_ENABLE0x01Continuous sweep enabled
SWEEP_ONCE0x02Single sweep requested
SWEEP_UI_MODE0x04Processing UI (not sweeping)

Sweep timing depends on:

  1. Number of points: More points = longer sweep
  2. IF bandwidth: Lower bandwidth = longer per point
  3. Frequency range: Band changes add settling time

Approximate times for 101 points:

BandwidthTime
4000 Hz0.7 s
1000 Hz1.2 s
333 Hz3.6 s
100 Hz10 s
30 Hz33 s

Command implementations in main.c:

  • cmd_scan: line 1379 — scan mask definitions at line 1371
  • cmd_scan_bin: line 1454
  • cmd_sweep: line 1606 — subcommand parsing with get_str_index
  • cmd_freq: line 621
  • cmd_power: line 642
  • cmd_bandwidth: line 1294
  • cmd_pause: line 500
  • cmd_resume: line 507
  • cmd_offset: line 610 (conditional: USE_VARIABLE_OFFSET)