Sweep and Measurement Commands
Commands for controlling frequency sweep and measurement parameters.
Perform a frequency sweep and output measured data.
Syntax
Section titled “Syntax”scan <start> <stop> [points] [outmask]Parameters
Section titled “Parameters”| Parameter | Description | Default |
|---|---|---|
start | Start frequency in Hz | Required |
stop | Stop frequency in Hz | Required |
points | Number of sweep points (1–401) | Current setting |
outmask | Output control bitmask (see below) | 0 (no per-point output) |
Outmask Bits
Section titled “Outmask Bits”The outmask parameter is a bitmask controlling both what data is output and how it is processed:
| Bit | Value | Name | Description |
|---|---|---|---|
| 0 | 1 | OUT_FREQ | Include frequency (Hz) for each point |
| 1 | 2 | OUT_DATA0 | Include S11 real/imaginary pair |
| 2 | 4 | OUT_DATA1 | Include S21 real/imaginary pair |
| 3 | 8 | NO_CALIBRATION | Skip calibration correction |
| 4 | 16 | NO_EDELAY | Skip electrical delay compensation |
| 5 | 32 | NO_S21OFFS | Skip 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
Output Format
Section titled “Output Format”For each point, outputs selected fields separated by spaces:
[frequency] [S11_re S11_im] [S21_re S21_im]Examples
Section titled “Examples”ch> scan 1000000 100000000 101 71000000 0.998234 -0.023456 0.012345 0.0012341990099 0.997234 -0.024567 0.012456 0.001345...
ch> scan 1M 100M 101 60.998234 -0.023456 0.012345 0.001234...
ch> scan 1M 100M 101 140.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
outmask14 (OUT_DATA0 | OUT_DATA1 | NO_CALIBRATION), you get raw uncalibrated S-parameters
scan_bin
Section titled “scan_bin”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.
Syntax
Section titled “Syntax”scan_bin <start> <stop> [points] [outmask]Binary Output Format
Section titled “Binary Output Format”The output begins with a 4-byte header, followed by per-point data:
Header (4 bytes):
| Field | Type | Size | Description |
|---|---|---|---|
mask | uint16_t | 2 bytes | Outmask with BINARY bit (0x80) set |
points | uint16_t | 2 bytes | Number of sweep points |
Per-point data (variable size):
| Field | Type | Size | Condition |
|---|---|---|---|
frequency | uint32_t | 4 bytes | If mask bit 0 (OUT_FREQ) set |
S11_re, S11_im | float[2] | 8 bytes | If mask bit 1 (OUT_DATA0) set |
S21_re, S21_im | float[2] | 8 bytes | If mask bit 2 (OUT_DATA1) set |
All values are little-endian. Floats are IEEE 754 single precision.
Example Usage
Section titled “Example Usage”import structimport serial
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=5)ser.write(b'scan_bin 1000000 100000000 101 7\r')
# Read 4-byte headerheader = ser.read(4)mask, points = struct.unpack('<HH', header)
# Calculate bytes per point based on mask bitsbytes_per_point = 0if 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 pointoffset = 0for 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 += 8Get or set sweep frequency range and points. Supports both positional arguments and named subcommands for individual parameter control.
Syntax
Section titled “Syntax”sweep # query current settingssweep <start> [stop] [points] # set range (positional)sweep {start|stop|center|span|cw|step|var} <value> # set individual parameterPositional Parameters
Section titled “Positional Parameters”| Parameter | Description | Range |
|---|---|---|
start | Start frequency in Hz | 600 Hz – 2 GHz |
stop | Stop frequency in Hz | 600 Hz – 2 GHz |
points | Number of sweep points | 1–401 (F072) or 1–101 (F303) |
Named Subcommands
Section titled “Named Subcommands”| Subcommand | Description |
|---|---|
start | Set start frequency only |
stop | Set stop frequency only |
center | Set center frequency (adjusts start/stop symmetrically) |
span | Set frequency span (adjusts start/stop around center) |
cw | Set CW frequency (single-point sweep) |
step | Set frequency step size between points |
var | Set variable parameter (for parameter sweep modes) |
Examples
Section titled “Examples”ch> sweep1000000 100000000 101
ch> sweep 50k 300Mch> sweep 1M 100M 201
ch> sweep center 145Mch> sweep span 10Mch> sweep cw 432.1Mch> 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.
Syntax
Section titled “Syntax”freq [frequency]Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
frequency | CW frequency in Hz |
Examples
Section titled “Examples”ch> freq145000000
ch> freq 145Mch> 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.
Syntax
Section titled “Syntax”power [level|auto]Parameters
Section titled “Parameters”| Value | Description |
|---|---|
auto or 255 | Automatic power selection |
0 | 2 mA drive |
1 | 4 mA drive |
2 | 6 mA drive |
3 | 8 mA drive |
Examples
Section titled “Examples”ch> powerauto
ch> power 2ch> power auto- Higher power improves dynamic range but may cause compression on some DUTs
- Auto mode selects power based on frequency band
bandwidth
Section titled “bandwidth”Set or get IF (intermediate frequency) bandwidth.
Syntax
Section titled “Syntax”bandwidth [bw]Parameters
Section titled “Parameters”| Value | Bandwidth | Sweep Speed |
|---|---|---|
4000 | 4000 Hz | Fastest |
2000 | 2000 Hz | Fast |
1000 | 1000 Hz | Medium |
333 | 333 Hz | Slow |
100 | 100 Hz | Slower |
30 | 30 Hz | Slowest |
Examples
Section titled “Examples”ch> bandwidth1000
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.
Syntax
Section titled “Syntax”pauseExample
Section titled “Example”ch> pause- Sweep stops at current position
- Data remains valid
- Use
resumeto continue
resume
Section titled “resume”Resume paused sweep.
Syntax
Section titled “Syntax”resumeExample
Section titled “Example”ch> resume- Continues sweep from where it was paused
- If sweep was not paused, has no effect
offset
Section titled “offset”Set frequency offset (if USE_VARIABLE_OFFSET enabled).
Syntax
Section titled “Syntax”offset [value]Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
value | Frequency offset in Hz |
- Used for external mixers or frequency converters
- Adds offset to displayed frequencies
Sweep Mode Flags
Section titled “Sweep Mode Flags”The firmware maintains sweep mode flags:
| Flag | Value | Description |
|---|---|---|
SWEEP_ENABLE | 0x01 | Continuous sweep enabled |
SWEEP_ONCE | 0x02 | Single sweep requested |
SWEEP_UI_MODE | 0x04 | Processing UI (not sweeping) |
Timing Considerations
Section titled “Timing Considerations”Sweep timing depends on:
- Number of points: More points = longer sweep
- IF bandwidth: Lower bandwidth = longer per point
- Frequency range: Band changes add settling time
Approximate times for 101 points:
| Bandwidth | Time |
|---|---|
| 4000 Hz | 0.7 s |
| 1000 Hz | 1.2 s |
| 333 Hz | 3.6 s |
| 100 Hz | 10 s |
| 30 Hz | 33 s |
Source Code Reference
Section titled “Source Code Reference”Command implementations in main.c:
cmd_scan: line 1379 — scan mask definitions at line 1371cmd_scan_bin: line 1454cmd_sweep: line 1606 — subcommand parsing withget_str_indexcmd_freq: line 621cmd_power: line 642cmd_bandwidth: line 1294cmd_pause: line 500cmd_resume: line 507cmd_offset: line 610 (conditional:USE_VARIABLE_OFFSET)