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.
Describe the test; TestFlow's agent uses this command set to drive your Keysight N9000B and writes the report from the measured results.
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()Describe the test; TestFlow's agent uses this command set to drive your Keysight N9000B and writes the report from the measured results.
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.
84 commands in 17 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values.
| Command | What it does | Arguments |
|---|---|---|
| :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:FULL | Set 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 ON | Attenuation Auto On. Enables automatic selection of input attenuation. | None |
| :SENSe:POWer:RF:ATTenuation:AUTO OFF | Attenuation Auto Off. Disables automatic attenuation so the manual value is used. | None |
| :SENSe:POWer:RF:GAIN:STATe ON | Preamp On. Turns the internal RF preamplifier on. | None |
| :SENSe:POWer:RF:GAIN:STATe OFF | Preamp 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 ON | RBW Auto On. Enables automatic coupling of resolution bandwidth to span. | None |
| :SENSe:BANDwidth:RESolution:AUTO OFF | RBW 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 ON | VBW Auto On. Enables automatic coupling of video bandwidth to resolution bandwidth. | None |
| :SENSe:BANDwidth:VIDeo:AUTO OFF | VBW 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 ON | Sweep Time Auto On. Enables automatic selection of the sweep time. | None |
| :SENSe:SWEep:TIME:AUTO OFF | Sweep 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 ON | Average On. Turns trace averaging on. | None |
| :SENSe:AVERage:STATe OFF | Average Off. Turns trace averaging off. | None |
| :SENSe:AVERage:CLEar | Average 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 |
| Command | What it does | Arguments |
|---|---|---|
| :CALCulate:MARKer1:STATe ON | Marker On. Turns marker 1 on (normal marker). | None |
| :CALCulate:MARKer1:STATe OFF | Marker 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:MAXimum | Marker Peak Search. Moves marker 1 to the highest amplitude point on the trace (peak search). | None |
| :CALCulate:MARKer1:MAXimum:NEXT | Marker Next Peak. Moves marker 1 to the next-highest peak on the trace. | None |
| :CALCulate:MARKer1:MINimum | Marker Min Search. Moves marker 1 to the lowest amplitude point on the trace. | None |
| :CALCulate:MARKer1:SET:CENTer | Marker To Center. Sets the center frequency equal to the marker 1 frequency. | None |
| :CALCulate:MARKer1:SET:RLEVel | Marker 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 |
| Command | What it does | Arguments |
|---|---|---|
| :INITiate:CONTinuous ON | Continuous Sweep On. Sets the analyzer to continuous (free-run) sweep mode. | None |
| :INITiate:CONTinuous OFF | Continuous Sweep Off. Sets the analyzer to single sweep mode. | None |
| :INITiate:IMMediate | Initiate Sweep. Triggers a new single sweep/measurement. | None |
| :INITiate:RESTart | Restart Sweep. Restarts the current sweep/measurement from the beginning. | None |
| Command | What it does | Arguments |
|---|---|---|
| :CONFigure:SANalyzer | Config Swept SA. Selects and configures the Swept SA measurement with its default settings. | None |
| :CONFigure:CHPower | Config Channel Power. Selects and configures the Channel Power measurement. | None |
| :CONFigure:OBWidth | Config OBW. Selects and configures the Occupied Bandwidth measurement. | None |
| Command | What it does | Arguments |
|---|---|---|
| :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 |
| Command | What it does | Arguments |
|---|---|---|
| :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? TRACE1 | Read Trace Data. Returns the amplitude data for trace 1 as a comma-separated list. | None |
| Command | What it does | Arguments |
|---|---|---|
| :INSTrument:SELect SA | Select 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 |
| Command | What it does | Arguments |
|---|---|---|
| :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 |
| Command | What it does | Arguments |
|---|---|---|
| :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 |
| Command | What it does | Arguments |
|---|---|---|
| :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 |
| Command | What it does | Arguments |
|---|---|---|
| :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 |
| Command | What it does | Arguments |
|---|---|---|
| :SYSTem:ERRor? | Read Error. Reads the first message from the error queue (0,"No error" if empty). | None |
| Command | What it does | Arguments |
|---|---|---|
| :CALibration:ALL? | Self Calibration. Runs the full internal alignment (calibration) and returns 0 on success. | None |
| Command | What it does | Arguments |
|---|---|---|
| <Output Variable>=<Equation> | Math. Variable equals an equation like (${Var_name}= ${Var_name}/2) | Number; Text |
| Command | What it does | Arguments |
|---|---|---|
| wait(<ms>) | Wait. Waits for number of milliseconds | Number |
| Command | What it does | Arguments |
|---|---|---|
| save2var <Variable_name> | Save2Variable. Saves last measurement to a variable | Text |
| Command | What it does | Arguments |
|---|---|---|
| *IDN? | Identify. Returns the instrument identification string (manufacturer, model, serial, firmware). | None |
| *RST | Reset. Resets the instrument to its default state. | None |
| *CLS | Clear 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 |
| *WAI | Wait To Continue. Waits until all pending operations are complete before continuing. | None |
| *TRG | Trigger Bus. Generates a bus trigger when the instrument is in wait-for-trigger state. | None |
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.
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.
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?.
: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.
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.
Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.