Spectrum Analyzer · SCPI command reference

Keysight N9000B SCPI commands

The Keysight N9000B spectrum analyzer is controlled remotely with SCPI commands. TestFlow's instrument library holds 84 commands for it, 27 of them queries that read values or state, grouped below by subsystem with their arguments. It is the same library TestFlow's AI agent uses to drive the N9000B on a real bench.

Commands
84
Queries
27
Subsystems
17
Models covered
1

Run this on your bench

Describe the test; TestFlow's agent uses this command set to drive your Keysight N9000B and writes the report from the measured results.

Get started

Control the Keysight N9000B from Python

With PyVISA, any VISA backend, and the instrument on USB, LAN or GPIB, this opens a session, identifies the instrument, sends one setting, and reads one value. Every command in it comes from the reference below. For a full walkthrough, see the PyVISA tutorial and the SCPI command cheat sheet.

import pyvisa

rm = pyvisa.ResourceManager()
print(rm.list_resources())  # find the Keysight N9000B's VISA address

# Paste the address of your Keysight N9000B (USB, LAN or GPIB).
inst = rm.open_resource("PASTE_VISA_ADDRESS_HERE")
inst.timeout = 5000  # ms

print(inst.query("*IDN?"))  # identify the instrument
inst.write(":CONFigure:SANalyzer")  # Config Swept SA
print(inst.query(":FETCh:CHPower?"))  # Read Channel Power

inst.close()

Run this on your bench

Describe the test; TestFlow's agent uses this command set to drive your Keysight N9000B and writes the report from the measured results.

Get started

Run a N9000B test without writing code

Describe the test in a sentence, for example “config swept sa on the N9000B, then read channel power and log it against a limit”. TestFlow's agent builds the steps from this command library, runs them on your bench through the TestFlow desktop app, and writes the report from the measured values. See AI test automation for lab instruments for how that works and where it stops.

Get started

SCPI command reference

84 commands in 17 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values.

Sense (SENSe) (39)

CommandWhat it doesArguments
:SENSe:FREQuency:CENTer <Frequency>Set Center Freq. Sets the center frequency of the displayed span in Hz.Number
:SENSe:FREQuency:CENTer?Read Center Freq. Returns the current center frequency in Hz.None
:SENSe:FREQuency:STARt <Frequency>Set Start Freq. Sets the start (left edge) frequency of the sweep in Hz.Number
:SENSe:FREQuency:STARt?Read Start Freq. Returns the current start frequency in Hz.None
:SENSe:FREQuency:STOP <Frequency>Set Stop Freq. Sets the stop (right edge) frequency of the sweep in Hz.Number
:SENSe:FREQuency:STOP?Read Stop Freq. Returns the current stop frequency in Hz.None
:SENSe:FREQuency:SPAN <Span>Set Span. Sets the frequency span of the displayed sweep in Hz.Number
:SENSe:FREQuency:SPAN?Read Span. Returns the current frequency span in Hz.None
:SENSe:FREQuency:SPAN:FULLSet Full Span. Sets the span to the full frequency range of the analyzer.None
:SENSe:POWer:RF:ATTenuation <Attenuation>Set Attenuation. Sets the input mechanical attenuation in dB.Number
:SENSe:POWer:RF:ATTenuation?Read Attenuation. Returns the current input attenuation in dB.None
:SENSe:POWer:RF:ATTenuation:AUTO ONAttenuation Auto On. Enables automatic selection of input attenuation.None
:SENSe:POWer:RF:ATTenuation:AUTO OFFAttenuation Auto Off. Disables automatic attenuation so the manual value is used.None
:SENSe:POWer:RF:GAIN:STATe ONPreamp On. Turns the internal RF preamplifier on.None
:SENSe:POWer:RF:GAIN:STATe OFFPreamp Off. Turns the internal RF preamplifier off.None
:SENSe:BANDwidth:RESolution <Bandwidth>Set RBW. Sets the resolution bandwidth (RBW) in Hz.Number
:SENSe:BANDwidth:RESolution?Read RBW. Returns the current resolution bandwidth in Hz.None
:SENSe:BANDwidth:RESolution:AUTO ONRBW Auto On. Enables automatic coupling of resolution bandwidth to span.None
:SENSe:BANDwidth:RESolution:AUTO OFFRBW Auto Off. Disables RBW auto-coupling so the manual value is used.None
:SENSe:BANDwidth:VIDeo <Bandwidth>Set VBW. Sets the video bandwidth (VBW) in Hz.Number
:SENSe:BANDwidth:VIDeo?Read VBW. Returns the current video bandwidth in Hz.None
:SENSe:BANDwidth:VIDeo:AUTO ONVBW Auto On. Enables automatic coupling of video bandwidth to resolution bandwidth.None
:SENSe:BANDwidth:VIDeo:AUTO OFFVBW Auto Off. Disables VBW auto-coupling so the manual value is used.None
:SENSe:SWEep:TIME <Time>Set Sweep Time. Sets the sweep time in seconds.Number
:SENSe:SWEep:TIME?Read Sweep Time. Returns the current sweep time in seconds.None
:SENSe:SWEep:TIME:AUTO ONSweep Time Auto On. Enables automatic selection of the sweep time.None
:SENSe:SWEep:TIME:AUTO OFFSweep Time Auto Off. Disables sweep-time auto so the manual value is used.None
:SENSe:SWEep:POINts <Points>Set Sweep Points. Sets the number of trace (sweep) points across the span.Number: 101,100,110,001
:SENSe:SWEep:POINts?Read Sweep Points. Returns the current number of sweep points.None
:SENSe:AVERage:COUNt <Count>Set Average Count. Sets the number of sweeps to be averaged.Number
:SENSe:AVERage:COUNt?Read Average Count. Returns the configured number of averages.None
:SENSe:AVERage:STATe ONAverage On. Turns trace averaging on.None
:SENSe:AVERage:STATe OFFAverage Off. Turns trace averaging off.None
:SENSe:AVERage:CLEarAverage Clear. Clears and restarts the average accumulation.None
:SENSe:AVERage:TYPE <Type>Set Average Type. Sets the averaging type (power/RMS, log-power/video, or voltage/scalar).Text: RMS,LOG,SCALar
:SENSe:DETector:FUNCtion <Detector>Set Detector. Sets the trace detector function.Text: NORMal,AVERage,POSitive,SAMPle,NEGative,QPEak,EAVerage,RAVerage
:SENSe:DETector:FUNCtion?Read Detector. Returns the current trace detector function.None
:SENSe:CHPower:BANDwidth:INTegration <Bandwidth>Set Chan Power BW. Sets the integration bandwidth used by the Channel Power measurement in Hz.Number
:SENSe:OBWidth:PERCent <Percent>Set OBW Percent. Sets the percent of total power used to define the occupied bandwidth.Number

Calculate (CALCulate) (11)

CommandWhat it doesArguments
:CALCulate:MARKer1:STATe ONMarker On. Turns marker 1 on (normal marker).None
:CALCulate:MARKer1:STATe OFFMarker Off. Turns marker 1 off.None
:CALCulate:MARKer1:X <Frequency>Set Marker X. Sets the X-axis (frequency) position of marker 1 in Hz.Number
:CALCulate:MARKer1:X?Read Marker X. Returns the X-axis (frequency) position of marker 1 in Hz.None
:CALCulate:MARKer1:Y?Read Marker Y. Returns the Y-axis (amplitude) value at marker 1.None
:CALCulate:MARKer1:MAXimumMarker Peak Search. Moves marker 1 to the highest amplitude point on the trace (peak search).None
:CALCulate:MARKer1:MAXimum:NEXTMarker Next Peak. Moves marker 1 to the next-highest peak on the trace.None
:CALCulate:MARKer1:MINimumMarker Min Search. Moves marker 1 to the lowest amplitude point on the trace.None
:CALCulate:MARKer1:SET:CENTerMarker To Center. Sets the center frequency equal to the marker 1 frequency.None
:CALCulate:MARKer1:SET:RLEVelMarker To Ref Level. Sets the reference level equal to the marker 1 amplitude.None
:CALCulate:DATA?Read Measurement Data. Returns the calculated data for the active measurement.None

Initiate (INITiate) (4)

CommandWhat it doesArguments
:INITiate:CONTinuous ONContinuous Sweep On. Sets the analyzer to continuous (free-run) sweep mode.None
:INITiate:CONTinuous OFFContinuous Sweep Off. Sets the analyzer to single sweep mode.None
:INITiate:IMMediateInitiate Sweep. Triggers a new single sweep/measurement.None
:INITiate:RESTartRestart Sweep. Restarts the current sweep/measurement from the beginning.None

Configure (CONFigure) (3)

CommandWhat it doesArguments
:CONFigure:SANalyzerConfig Swept SA. Selects and configures the Swept SA measurement with its default settings.None
:CONFigure:CHPowerConfig Channel Power. Selects and configures the Channel Power measurement.None
:CONFigure:OBWidthConfig OBW. Selects and configures the Occupied Bandwidth measurement.None

Display (DISPlay) (3)

CommandWhat it doesArguments
:DISPlay:WINDow:TRACe:Y:SCALe:RLEVel <Level>Set Ref Level. Sets the amplitude reference level (top of the graticule) in the current Y-axis units.Number
:DISPlay:WINDow:TRACe:Y:SCALe:RLEVel?Read Ref Level. Returns the current reference level.None
:DISPlay:WINDow:TRACe:Y:SCALe:PDIVision <Scale>Set Y Scale Per Div. Sets the vertical scale per division (dB/div) of the amplitude axis.Number

Trace (TRACe) (3)

CommandWhat it doesArguments
:TRACe1:TYPE <Type>Set Trace Type. Sets trace 1 update type (clear write, average, max hold, or min hold).Text: WRITe,AVERage,MAXHold,MINHold
:TRACe1:TYPE?Read Trace Type. Returns the current trace 1 type.None
:TRACe:DATA? TRACE1Read Trace Data. Returns the amplitude data for trace 1 as a comma-separated list.None

Instrument (INSTrument) (2)

CommandWhat it doesArguments
:INSTrument:SELect SASelect SA Mode. Selects the Spectrum Analyzer (SA) mode on the X-Series analyzer.None
:INSTrument:SELect?Read Mode. Queries the currently selected instrument mode.None

Trigger (TRIGger) (2)

CommandWhat it doesArguments
:TRIGger:SOURce <Source>Set Trigger Source. Selects the trigger source for the sweep.Text: IMMediate,EXTernal1,EXTernal2,LINE,VIDeo,RFBurst
:TRIGger:VIDeo:LEVel <Level>Set Trigger Level. Sets the video trigger level.Number

Fetch (FETCh) (2)

CommandWhat it doesArguments
:FETCh:CHPower?Read Channel Power. Returns the most recent Channel Power measurement result.None
:FETCh:OBWidth?Read OBW. Returns the most recent Occupied Bandwidth measurement result.None

Read (READ) (2)

CommandWhat it doesArguments
:READ:CHPower?Measure Channel Power. Initiates a Channel Power measurement and returns the result.None
:READ:OBWidth?Measure OBW. Initiates an Occupied Bandwidth measurement and returns the result.None

UNIT subsystem (1)

CommandWhat it doesArguments
:UNIT:POWer <Units>Set Y Units. Sets the amplitude (Y-axis) measurement units.Text: DBM,DBMV,DBMA,W,V,A,DBUV,DBUA,DBUVM,DBUAM,DBPT,DBG

System (SYSTem) (1)

CommandWhat it doesArguments
:SYSTem:ERRor?Read Error. Reads the first message from the error queue (0,"No error" if empty).None

CAL subsystem (1)

CommandWhat it doesArguments
:CALibration:ALL?Self Calibration. Runs the full internal alignment (calibration) and returns 0 on success.None

Other subsystem (1)

CommandWhat it doesArguments
<Output Variable>=<Equation>Math. Variable equals an equation like (${Var_name}= ${Var_name}/2)Number; Text

WAIT subsystem (1)

CommandWhat it doesArguments
wait(<ms>)Wait. Waits for number of millisecondsNumber

SAVE subsystem (1)

CommandWhat it doesArguments
save2var <Variable_name>Save2Variable. Saves last measurement to a variableText

IEEE 488.2 common commands (7)

CommandWhat it doesArguments
*IDN?Identify. Returns the instrument identification string (manufacturer, model, serial, firmware).None
*RSTReset. Resets the instrument to its default state.None
*CLSClear Status. Clears all event registers and the error queue.None
*TST?Self Test. Runs the self-test and returns 0 for pass or 1 for failure.None
*OPC?Operation Complete. Returns 1 when all pending operations are complete.None
*WAIWait To Continue. Waits until all pending operations are complete before continuing.None
*TRGTrigger Bus. Generates a bus trigger when the instrument is in wait-for-trigger state.None

Where these commands come from

This reference is generated from TestFlow's instrument library, which is drafted from Keysight's programming documentation for the N9000B and checked when the agent runs it. Ranges, timing, and option-dependent commands are defined by Keysight's programming manual: check it before you rely on an edge case. Last updated November 12, 2026.

Frequently asked questions

Does the Keysight N9000B support SCPI remote control?

Yes. The Keysight N9000B accepts SCPI commands over its remote interfaces. TestFlow's instrument library holds 84 SCPI commands for it: 27 queries that read values or state, and 57 settings and actions.

How do I control the Keysight N9000B from Python?

Install PyVISA and a VISA backend, find the instrument's address with ResourceManager().list_resources(), open it, then send commands with write() and read values with query(). The example on this page sends *IDN?, :CONFigure:SANalyzer and :FETCh:CHPower?.

Which command reads a value from the Keysight N9000B?

:FETCh:CHPower? (read channel power). Returns the most recent Channel Power measurement result. The full list of queries is in the command reference on this page, grouped by subsystem.

Can I automate the Keysight N9000B without writing code?

Yes. TestFlow is an AI agent for electronics testing: you describe the test, and it builds the automation from this command library, runs it on the Keysight N9000B through the TestFlow desktop app, and writes the report from the measured results.

Your next test, automated today

Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.