4.1 Examples of Using VISA ...................................................................... 73
4.2 Examples of Using Sockets/Telnet ..................................................... 84
2 SSA3000X Programming Guide
SIGLENT
1.Programming Overview
SSA3000X Series Spectrum Analyzer support LAN, USB Device, and GPIB--USB Host
interfaces. By using these interfaces, in combination with programming languages and/or NIVISA software, users can remotely control the analyzer based on SCPI (Standard Commands
for Programmable Instruments) command set, and interoperate with other programmable
instruments.
This chapter introduces how to build communication between the spectrum analyzer and a
controller computer with these interfaces.
1.1 Remotely Operating the Analyzer
The analyzer provides both the USB and LAN connection which allows you to set up a
remote operation environment with a controller computer. A controller computer could be a
personal computer (PC) or a minicomputer. Some intelligent instruments also function as
controllers.
1.1.1 Connecting the Analyzer via the USB Device port
Refer to the following steps to finish the connection via USB-Device:
1. Install NI-VISA on your PC for USB-TMC driver.
2. Connect the analyzer USB Device port to a PC with a USB A-B cable.
3. Switch on the analyzer
The analyzer will be detected automatically as a new USB hardware.
1.1.2 Connecting the Analyzer via the LAN port
Refer to the following steps to finish the connection via LAN:
1. Install NI-VISA on your PC for VXI driver. Or without NI-VISA, using socket or telnet
in your PC’s Operating System.
2. Connect the analzyer to PC or the local area network with a LAN cable
3. Switch on the analyzer
SSA3000X Programming Guide 3
SIGLENT
4. Press button on the front panel System→Interface→LAN to enter the LAN Config
function menu.
5. Select the IP Config between Static and DHCP
DHCP: the DHCP server in the current network will assign the network parameters
automaticlly (IP address, subnet mask, gate way) for the analzyer.
Static: you can set the IP address, subnet mask, gate way manually. Press Apply.
The analyzer will be detected automatically or manually as a new LAN point.
1.1.3 Connecting the Analyzer via the USB-Host port
(With USB-GPIB Adaptor)
Refer to the following steps to finish the connection via USB:
1. Install NI-VISA on your PC for GPIB driver.
2. Connect the analyzer USB Host port to a PC’s GPIB card port, with SIGLENT USBGPIB adaptor.
3. Switch on the analyzer
4. Press button on the front panel System→Interface→GPIB to enter the GPIB number.
The analyzer will be detected automatically as a new GPIB point.
1.2 Build Communication
1.2.1 Build Communication Using VISA
NI-VISA includes a Run-Time Engine version and a Full version. The Run-Time Engine
version provides NI device drivers such as USB-TMC, VXI, GPIB, etc. The full version
includes the Run-Time Engine and a software tool named NI MAX that provides a user
interface to control the device.
You can get NI-VISA full version from:
4 SSA3000X Programming Guide
SIGLENT
http://www.ni.com/download/.
After download you can follow the steps below to install it:
a. Double click the visa_full.exe, dialog shown as below:
b. Click Unzip, the installation process will automatically launch after unzipping files. If your
computer needs to install .NET Framework 4, its setup process will auto start.
c. The NI-VISA installing dialog is shown above. Click Next to start the installation process.
Set the install path, default path is “C:\Program Files\National Instruments\” , you can
change it. Click Next, dialog shown as above.
SSA3000X Programming Guide 5
SIGLENT
d. Click Next twice, in the License Agreement dialog, select the “ I accept the above 2 License
Agreement(s).” ,and click Next, dialog shown as below:
e. Click Next to run installation.
Now the installation is complete, reboot your PC.
1.2.2 Build Communication Using Sockets/Telnet
Through LAN interface, VXI-11, Sockets and Telnet protocols can be used to communicate
with the spectrum analyzer. VXI-11 is provided in NI-VISA, while Sockets and Telnet are
6 SSA3000X Programming Guide
SIGLENT
commonly included in PC’s OS initially.
Sockets LAN is a method used to communicate with the spectrum analyzer over the LAN
interface using the Transmission Control Protocol/Internet Protocol (TCP/IP). A socket is a
fundamental technology used for computer networking and allows applications to
communicate using standard mechanisms built into network hardware and operating systems.
The method accesses a port on the spectrum analyzer from which bidirectional
communication with a network computer can be established.
Before you can use sockets LAN, you must select the analyzer’s sockets port number to use:
Standard mode. Available on port 5025. Use this port for programming.
Telnet mode. The telnet SCPI service is available on port 5024.
1.3 Remote Control Capabilities
1.3.1 User-defined Programming
Users can use SCPI commands to program and control the spectrum analyzer. For details,
refer to the introductions in “Programming Examples”.
1.3.2 Send SCPI Commands via NI MAX
Users can control the spectrum analyzer remotely by sending SCPI commands via NI-MAX
software.
1.3.2.1 Using USB
Run NI MAX software.
1, Click “Device and interface” at the upper left corner of the software;
2, Find the “USBTMC” device symbol
3, Click “Open VISA Test Panel” option button, then the following interface will appear.
4, Click the “Input/Output” option button and click the “Query” option button in order to view
the operation information.
SSA3000X Programming Guide 7
SIGLENT
NOTE: The *IDN? command (known as the Identification Query) returns the instrument
manufacturer, instrument model, serial number, and other identification information.
1.3.2.2 Using LAN
select, Add Network Device, and select VISA TCP/IP Resource as shown:.
Run NI MAX software.
1, Click “Device and interface” at the upper left corner of the software;
2, Find the “Network Devices” symbol , click “Add Network Devices”;
3. Select Manual Entry of LAN instrument, select Next, and enter the IP address as shown.
Click Finish to establish the connection:
NOTE: Leave the LAN Device Name BLANK or the connection will fail.
8 SSA3000X Programming Guide
SIGLENT
4. After a brief scan, the connection should be shown under Network Devices:
5. Right-click on the product and select Open NI-VISA Test Panel:
6. Click “Input/Output” option button and click “Query” option button. If everything is OK,
you will see the Read operation information returned as shown below.
SSA3000X Programming Guide 9
SIGLENT
1.3.3 EasySpectrum Software
Users can control the spectrum analyzer remotely by EasySpectrum. PC software
EasySpectrum is an easy-to-use, PC-Windows-based remote control tool for Siglent’s
spectrum analyzer. You can download it from Siglent’s website. To connect the analyzer via
the USB/LAN port to a PC, you need install the NI VISA first.
It is able to be used as:
A monitor to display and control the trace scans simultaneously with the analyzer;
A filemaker to get user defined Limit/Correction files, and load them to the anaylzer;
An EMI receiver to perform EMI Pre-compliance test including prescan, peak search,
finalscan and report generating.
For the further descrption of the software, please refer to the online help embedded in this
software.
10 SSA3000X Programming Guide
SIGLENT
2.SCPI Overview
2.1 Command Format
SCPI commands present a hierarchical tree structure containing multiple subsystems, each
of the subsystems is made up of a root keyword and several subkeywords. The command
string usually starts with “:”, the keywords are separated by “:” and the followed parameter
settings are separated by space. Query commands add “?” at the end of the string.
For example:
:SENSe:FREQuency:CENTer <freq>
:SENSe:FREQuency:CENTer?
SENSe is the root key of the command, FREQuency and CENTer are second and third
keywords. The command begins with “:”, and separates the keywords at the same time,
<freq> separated by space and represents the parameter available for setting; “?” represents
a query.
2.2 Symbol Instruction
The following four symbols are not the content of SCPI commands and can not be sent with
the commands, but are usually used in the commands.
1, Triangle Brackets < >
The parameter in the triangle brackets must be replaced by an effective value. For example:
Send the “:DEMod:VOLume <value>” command in “:DEMod:VOLume 5”.
2, Square Brackets [ ]
The content in the square brackets can be ignored. When the parameter is ignored, the
instrument will set the parameter to its default. For example,
In the “[:SENSe]:POWer[:RF]:ATTenuation?” command, sending any of the four commands
below can generate the same effect:
The parameter can be set as “192.168.1.12” string.
4, Integer
Except other notes, the parameter can be any integer within the effective value range. For
example:
[:SENSe]:DEMod:VOLume <value>
The parameter < value >can be set to any integer between 0 and 10.
5, Float
The parameter could be any value within the effective value range according to the accuracy
requirement (the default accuracy contains up to 9 digits after the decimal points). For example:
:CALCulate:BANDwidth:NDB <value>
The parameter < value > can be set to anyreal number between -100 and 100.
12 SSA3000X Programming Guide
SIGLENT
6, Discrete
The parameter could only be one of the specified values and these values are discontinuous. For
example:
[:SENSe]:BWIDth:VIDeo:RATio <number>
The parameter <number> could only be one of 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0,
30.0, 100.0, 300.0, 1000.0.
2.4 Command Abbreviation
All of the commands are not case sensitive, so you can use any of them. But if abbreviation
is used, all the capital letters in the command must be written completely. For example:
:DISPlay:WINDow:TRACe:Y:DLINe:STATe?
Can be abbreviated to:
:DISP:WIND:TRAC:Y:DLIN:STAT?
SSA3000X Programming Guide 13
SIGLENT
Command
Format
*IDN?
Instruction
Returns an instrument identification information string. The string will contain
the manufacturer, model number, serial number, software number, FPGA
number and CPLD number.
This command presets the instrument to a factory defined condition that is
appropriate for remote programming operation. *RST is equivalent to
performing the two commands :SYSTem:PRESet and *CLS. This command
always performs a factory preset.
Menu
None
Example
*RST
Command
Format
*CLS
Instruction
Clears the status byte register. It does this by emptying the error queue and
3.System Commands
This chapter introduces the Siglent Technologies SSA3000X SCPI commands, include:
clearing all bits in all of the event registers. The status byte register summarizes
the states of the other registers. It is also responsible for generating service
requests.
Menu
None
Example
*CLS
Command
Format
*ESE <number>
*ESE?
Instruction
Set the bits in the standard event status enable register. This register monitors
I/O errors and synchronization conditions such as operation complete, request
control, query error, device dependent error,execution error, command error
and power on. A summary bit is generated on execution of the command.
The query returns the state of the standard event status enable register.
Menu
None
Example
*ESE 16
Command
Format
*ESR?
Instruction
Queries and clears the standard event status event register. (This is a
destructive read.) The value returned reflects the current state (0/1) of all the
bits in the register.
Menu
None
Example
*ESR?
Command
Format
*OPC
*OPC?
Instruction
Set bit 0 in the standard event status register to “1” when all pending operations
have finished.
The query stops any new commands from being processed until the current
processing is complete. Then it returns a “1”, and the program continues. This
query can be used to synchronize events of other instruments on the external
bus.
Returns a “1”if the last processing is complete. Use this query when there’s a
need to monitor the command execution status, such as a sweep execution.
Menu
None
Example
*OPC?
Command
Format
*SRE <integer>
*SRE?
Instruction
This command enables the desired bits of the service request enable register.
The query returns the value of the register, indicating which bits are currently
enabled. The default value is 255.
Menu
None
Example
*SRE 1
3.1.4 Standard Event Status Enable (*ESE)
3.1.5 Standard Event Status Register Query (*ESR)
3.1.6 Operation Complete Query (*OPC)
3.1.7 Service Request Enable (*SRE)
SSA3000X Programming Guide 15
SIGLENT
Command
Format
*STB
Instruction
This query is used by some instruments for a self test.
Menu
None
Example
*STB
Command
Format
*WAI
Instruction
This command causes the instrument to wait until all pending commands are
completed before executing any additional commands.
There is no query form to the command.
Menu
None
Example
*WAI
Command
Format
*TST?
Instruction
This query is used by some instruments for a self test.
Menu
None
Example
*TRG
Command
Format
:SYSTem:TIME <hhmmss>
:SYSTem:TIME?
Instruction
Sets System time.
Gets System time.
Parameter
Type
String
Parameter
Range
hour(0~23), minute(0~59), second(0~59)
Return
String
Default
None
Menu
System > date & time
Example
Sets System time:
:SYSTem:TIME 182559
Gets System time:
:SYSTem:TIME?
Command
Format
:SYSTem:DATE <yyyymmdd>
:SYSTem:DATE?
Instruction
Sets system date.
Gets system date.
3.1.8 Status Byte Query (*STB)
3.1.9 Wait-to-Continue (*WAI)
3.1.10 Self Test Query (*TST)
3.2 System Subsystem
3.2.1 System Time (:SYSTem:TIME)
3.2.2 System Date (:SYSTem:DATE)
16 SSA3000X Programming Guide
Parameter
Type
String
Parameter
Range
year(four digits), month(1~12), date(1~31)
Return
String
Default
None
Menu
System > date&time
Example
Sets System date:
:SYSTem:DATE 20050101
Gets System date:
:SYSTem:DATE?
This command sets the reference level for the Y-axis.
Gets reference level.
Parameter
Type
Float, unit: dBm, dBmV, dBuV, V, W
Parameter
Range
Unit is dBm: -100 dBm ~ 30 dBm
Unit is dBmV: -53.01 dBmV ~ 76.99 dBmV,
Unit is dBuV: 6.99 dBuV ~ 136.99 dBuV,
Unit is Volts: 2.24 uV ~ 7.07 V
Unit is Watts: 100 fW ~ 1 W
Toggles the vertical graticule divisions between logarithmic unit and linear unit.
The default logarithmic unit is dBm, and the linear unit is V.
Gets scale type.
This command sets the per-division display scaling for the y-axis when scale
type of Y axis is set to Log.
Gets Scale/Div when scale type of Y axis is set to Log.
Parameter
Type
Float
Parameter
Range
1 dB ~ 10 dB
Return
Float, unit: dB
Default
10 dB
Menu
Amplitude > Scale/Div
Example
:DISPlay:WINDow:TRACe:Y:PDIVision 10 dB
Command
Format
[:SENSe]:CORRection:OFF
Instruction
Turn off the amplitude correction function off and all of the correction sets are
off.
Turns on or off the amplitude corrections.
When turned on, only the correction sets that were turned on are enabled.
When turned off, all of the correction Sets are disabled. If there is no correction
enabled, state can not be set to on.
Specifies the resolution bandwidth. For numeric entries, all RBW types choose
the nearest (arithmetically, on a linear scale, rounding up) available RBW to the
value entered.
WRITe: puts the trace in the normal mode, updating the data.
MAXHold: displays the highest measured trace value for all the data that has
been measured since the function was turned on.
MINHold: displays the lowest measured trace value for all the data that has
([:SENSe]:BWIDth:VIDeo:RATio:CONfig?)
SIGLENT
3.5.4.7 Filter Type ([:SENSe]:FILTer:TYPE)
3.5.5 Trace Subsection
3.5.5.1 Trace mode (:TRACe[1]|2|3|4:MODE)
SSA3000X Programming Guide 33
SIGLENT
been measured since the function was turned on.
VIEW: turns on the trace data so that it can be viewed on the display.
BLANk: turns off the trace data so that it is not viewed on the display.
AVERage: averages the trace for test period.
Return
Enumeration
Default
Trace1: WRITe, Trace2|3|4: BLANk
Menu
Trace
Example
:TRAC1:MODE VIEW
Command
Format
:TRACe[:DATA]? 1|2|3|4
Instruction
This query command returns the current displayed data.
Parameter
Type
Enumeration
Parameter
Range
1|2|3|4
Return
String
Default
1 Menu
None
Example
:TRACe:DATA? 1
Command
Format
:TRACe:SWEep:STATe?
Instruction
This query command returns 1 if trace scan is completed else returns 0.
Sets trace math type.
Gets trace math type.
In this command, the lower-case parameters should not be neglected, for
example:X-Y+Ref->Z can not write as X-Y+R->Z.
Parameter
Type
Enumeration
Parameter
Range
Off: turns off the trace math function.
X-Y+Ref->Z: math variable X minus math variable Y and add reference level
then to output trace.
Y-X+Ref->Z: math variable Y minus math variable X and add reference level
then to output trace.
X+Y-Ref->Z: math variable X add math variable Y and minus reference level
then to output trace.
X+Const->Z: math variable X add const then to output trace.
X-Const->Z: math variable X minus const then to output trace.
Return
Enumeration
Default
Off
Menu
Trace > Math Type
Example
:TRACe:MATH:TYPE X-Y+Ref->Z
Command
Format
:TRACe:MATH:X A|B|C
:TRACe:MATH:X?
Instruction
Sets trace math variable X.
Gets trace math variable X.
Parameter
Type
Enumeration
Parameter
Range
A|B|C
Return
Enumeration
Default
A Menu
Trace > Math > Variable X
Example
:TRACe:MATH:X A
Command
Format
:TRACe:MATH:Y A|B|C
:TRACe:MATH:Y?
Instruction
Sets trace math variable Y.
Gets trace math variable Y.
Parameter
Type
Enumeration
Parameter
Range
A|B|C
Return
Enumeration
Default
B Menu
Trace > Math > Variable Y
SIGLENT
3.5.5.6 Trace Math Variable X (:TRACe:MATH:X)
3.5.5.7 Trace Math Variable Y (:TRACe:MATH:Y)
SSA3000X Programming Guide 35
SIGLENT
Example
:TRACe:MATH:Y A
Command
Format
:TRACe:MATH:Z A|B|C
:TRACe:MATH:Z?
Instruction
Sets trace math output.
Gets trace math output.
Parameter
Type
Enumeration
Parameter
Range
A|B|C
Return
Enumeration
Default
C Menu
Trace > Math > Output
Example
:TRACe:MATH:Z A
Command
Format
:TRACe:MATH:CONSt <const>
:TRACe:MATH:CONSt?
Instruction
Sets trace math const.
Gets trace math const.
Parameter
Type
Enumeration
Parameter
Range
-300dB ~300 dB
Return
Float
Default
0.00dB
Menu
Trace > Math > Const
Example
:TRACe:MATH:CONSt 7
Command
Format
[:SENSe]:DETector:TRACe[1]|2|3|4[:FUNCtion]
NEGative|POSitive|SAMPle|AVERage|NORMAL|QUASi
[:SENSe]:DETector:TRACe[1]|2|3|4[:FUNCtion]?
Instruction
Specifies the detection mode. For each trace interval (bucket), average
detection displays the average of all the samples within the interval.
Parameter
Type
Enumeration
Parameter
Range
NEGative: Negative peak detection displays the lowest sample taken during the
interval being displayed.
POSitive: Positive peak detection displays the highest sample taken during the
interval being displayed.
SAMPle: Sample detection displays the sample taken during the interval being
displayed, and is used primarily to display noise or noise-like signals.
In sample mode, the instantaneous signal value at the present display point is
placed into memory. This detection should not be used to make the most
3.5.5.8 Trace Math Output (:TRACe:MATH:Z)
3.5.5.9 Trace Math Const (:TRACe:MATH:CONSt)
3.5.6 Detector Subsection
3.5.6.1 Type of Detection
([:SENSe]:DETector:TRACe[1]|2|3|4[:FUNCtion])
36 SSA3000X Programming Guide
accurate amplitude measurement of non noise-like signals.
AVERage: Average detection is used when measuring the average value of the
amplitude across each trace interval (bucket). The averaging method used by
the average detector is set to either video or power as appropriate when the
average type is auto coupled.
NORMAL: Normal detection selects the maximum and minimum video signal
values alternately. When selecting Normal detection,”Norm”appears in the
upper-left corner.
QUASi: Quasipeak detection is a form of detection where a signal level is
weighted based on the repetition frequency of the spectral components making
up the signal. That is to say, the result of a quasi-peak measurement depends
on the repetition rate of the signal.
Specifies the time in which the instrument sweeps the display. A span value of 0
Hz causes the analyzer to enter zero span mode. In zero span the X-axis
represents time rather than frequency.
Selects the type of markers that you want to activate.
Gets the type of markers.
Parameter
Type
Enumeration
Parameter
Range
POSition: selects a normal marker that can be positioned on a trace and from
which trace information will be generated.
DELTa: activates a pair of markers, one of which is fixed at the current marker
location. The other marker can then be moved around on the trace. The marker
readout shows the marker value which moves.
BAND: activates a pair of markers, one of which is fixed at the current marker
location. The two marker can then be moved around on the trace. The marker
readout shows the difference between the two markers.
OFF: turns the designated marker off. If a marker is not active when the mode
is queried, “off” will be returned.
This command positions the designated marker on its assigned trace at the
specified trace X value.
The value is in the X-axis units, which can be a frequency or time.
The query returns the current X value of the designated marker.
When the readout mode is frequency, the query returns the X value of the span
of the marker in integer and the unit is “Hz”.
When the readout mode is time or period, the query returns the X value of the
span of the marker in scientific notation and the unit is “s”.
3.6.1.4 Marker to Trace (:CALCulate:MARKer[1]|2|3|4:TRACe)
3.6.1.5 Marker Relative To
(:CALCulate:MARKer[1]|2|3|4:RELative:TO)
3.6.1.6 Marker X Value (:CALCulate:MARKer[1]|2|3|4:X)
This command positions the designated reference marker on its assigned trace
at the specified trace X value.
The value is in the X-axis units, which can be a frequency or time.
The query returns the current X value of the designated reference marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
When the readout mode is frequency, the query returns the X value of the span
of the marker in integer and the unit is “Hz”.
When the readout mode is time or period, the query returns the X value of the
span of the marker in scientific notation and the unit is “s”.
Reference Command:
:CALCulate:MARKer[1]|2|3|4:X:READout
This command positions the designated delta marker on its assigned trace at
the specified trace X value.
The value is in the X-axis units, which can be a frequency or time.
The query returns the current X value of the designated delta marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
When the readout mode is frequency, the query returns the X value of the span
of the marker in integer and the unit is “Hz”.
(:CALCulate:MARKer[1]|2|3|4:X:REFerence)
SIGLENT
3.6.1.8 Marker Delta X Value
(:CALCulate:MARKer[1]|2|3|4:X:DELTa)
SSA3000X Programming Guide 43
SIGLENT
When the readout mode is time or period, the query returns the X value of the
span of the marker in scientific notation and the unit is “s”.
Reference Command:
:CALCulate:MARKer[1]|2|3|4:X:READout
Sets the center frequency of the center pair marker and the default unit is Hz.
Gets the center frequency of the center pair marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
When the readout mode is frequency, the query returns the X value of the span
of the marker in integer and the unit is “Hz”.
When the readout mode is time or period, the query returns the X value of the
span of the marker in scientific notation and the unit is “s”.
Reference Command:
:CALCulate:MARKer[1]|2|3|4:X:READout
Sets the X value corresponding to the span of the Span Pair marker.
Gets the X value corresponding to the span of the Span Pair marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
When the readout mode is frequency, the query returns the X value of the span
of the marker in integer and the unit is “Hz”.
When the readout mode is time or period, the query returns the X value of the
span of the marker in scientific notation and the unit is “s”.
Reference Command:
:CALCulate:MARKer[1]|2|3|4:X:READout
3.6.1.9 Center Pair Marker X Value
(:CALCulate:MARKer[1]|2|3|4:X:CENTer)
3.6.1.10 Span Pair Marker X Value
(:CALCulate:MARKer[1]|2|3|4:X:SPAN)
0 Hz ~ 3.2 GHz(3.0 GHz, 2.1 GHz, 1.8 GHz, 1.5 GHz, 1.0 GHz) or 10 ms ~
1000 s
Return
Float
Default
0 Hz or0 s
Menu
Marker > Delta Pair > Span
Example
:CALCulate:MARKer4:X:SPAN 2 GHz
Command
Format
:CALCulate:MARKer[1]|2|3|4:Y?
Instruction
This command reads the current Y value for the designated marker.
This command can be used to read the results of noise marker.
Make sure that Marker is on, Reference Command:
:CALCulate:MARKer[1]|2|3|4:STATe
:CALCulate:MARKer[1]|2|3|4:MODE
Parameter
Type
None
Parameter
Range
None
Return
Float, unit: dBm
Default
None
Menu
Marker > Normal
Example
:CALCulate:MARKer1:Y?
Return: -25
Command
Format
:CALCulate:MARKer[1]|2|3|4:Y:REFerence?
Instruction
Gets the current Y value for the designated reference marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
Parameter
Type
None
Parameter
Range
None
Return
Float, unit: dBm
Default
None
Menu
Marker > Delta Pair
Example
:CALCulate:MARKer1:Y:REFerence?
Return: -25
Command
Format
:CALCulate:MARKer[1]|2|3|4:Y:DELTa?
3.6.1.11 Query Marker Y Value (:CALCulate:MARKer[1]|2|3|4:Y?)
3.6.1.12 Reference Marker Y Value
(:CALCulate:MARKer[1]|2|3|4:Y:REFerence?)
3.6.1.13 Marker Delta Y Value
(:CALCulate:MARKer[1]|2|3|4:Y:DELTa?)
SSA3000X Programming Guide 45
SIGLENT
Instruction
Gets the current Y value for the designated delta marker.
This command only can be used when marker mode is DELTa|BAND,
Reference Command:
:CALCulate:MARKer[1]|2|3|4:MODE
Toggles the marker table between on and off.
Gets the status of the marker table.
Parameter
Type
Boolean
Parameter
Range
ON|OFF|0|1
Return
0|1
Default
0 Menu
Marker > Marker Table
Example
:CALCulate:MARKer:TABLe ON
Command
Format
:CALCulate:MARKer[1]|2|3|4[:SET]:START
Instruction
Sets the start frequency to the value of the specified marker frequency. This
command is not available in zero span.
If the Marker is OFF, it will set the marker on center.
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > M→Start Freq
Example
:CALCulate:MARKer1:START
Command
Format
:CALCulate:MARKer[1]|2|3|4[:SET]:STOP
Instruction
Sets the stop frequency to the value of the specified marker frequency. This
3.6.1.14 Marker Table (:CALCulate:MARKer:TABLe)
3.6.1.15 Marker to Start Frequency
(:CALCulate:MARKer[1]|2|3|4[:SET]:START)
3.6.1.16 Marker to Stop Frequency
(:CALCulate:MARKer[1]|2|3|4[:SET]:STOP)
46 SSA3000X Programming Guide
command is not available in zero span.
If the Marker is OFF, it will set the marker on center.
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > Marker→Stop Freq
Example
:CALCulate:MARKer1:STOP
3.6.1.17 Marker to Center Frequency
Command
Format
:CALCulate:MARKer[1]|2|3|4[:SET]:CENTer
Instruction
This command sets the center frequency equal to the specified marker
frequency, which moves the marker to the center of the screen. This command
is not available in zero span.
If the Marker is OFF, it will set the marker on center.
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > M→CF
Example
:CALCulate:MARKer1:CENTer
Command
Format
:CALCulate:MARKer[1]|2|3|4[:SET]:STEP
Instruction
This command sets the center frequency step equal to the specified marker
frequency. This command is not available in zero span.
If the Marker is OFF, it will set the marker on center.
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > M→CF Step
Example
:CALCulate:MARKer1:STEP
Command
Format
:CALCulate:MARKer[1]|2|3|4[:SET]:RLEVel
Instruction
This command sets the reference level equal to the specified marker frequency.
(:CALCulate:MARKer[1]|2|3|4[:SET]:CENTer)
SIGLENT
3.6.1.18 Marker to Center Frequency Step
(:CALCulate:MARKer[1]|2|3|4[:SET]:STEP)
3.6.1.19 Marker to Reference Level
(:CALCulate:MARKer[1]|2|3|4[:SET]:RLEVel)
SSA3000X Programming Guide 47
SIGLENT
If the Marker is OFF, it will set the marker on center.
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > M→Ref Level
Example
:CALCulate:MARKer2:RLEVel
Command
Format
:CALCulate:MARKer[1]|2|3|4:DELTa[:SET]:SPAN
Instruction
This command sets the span equal to the specified delta marker frequency.
This command can be only used in DELTa|BAND marker mode, Reference
Command:CALCulate:MARKer[1]|2|3|4:MODE
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Marker > △ M→Span
Example
:CALCulate:MARKer2:DELTa:SPAN
Command
Format
:CALCulate:MARKer[1]|2|3|4:DELTa[:SET]:CENTer
Instruction
This command sets the center frequency equal to the specified delta marker
frequency.
This command can be only used in DELTa|BAND marker mode, Reference
Command:CALCulate:MARKer[1]|2|3|4:MODE
Specifies the minimum signal level for the analyzers internal peak identification
routine to recognize a signal as a peak. This applies to all traces and all
windows.
Gets the minimum signal level for the analyzers internal peak identification
routine to recognize a signal as a peak.
Toggles the continuous peak search function between on and off.
Gets the continuous peak search function state.
Parameter
Type
Boolean
Parameter
Range
OFF|ON|0|1
Return
0|1
Default
None
Menu
Peak > Cont Peak
Example
:CALCulate:MARKer1:CPEak ON
Command
Format
:CALCulate:MARKer[1]|2|3|4:MAXimum
Instruction
Performs a peak search based on the search mode settings.
(based on the search mode settings, include: peak search mode, peak
threshold and peak excursion, Reference Commands:
:CALCulate:MARKer:PEAK:SEARch:MODE
:CALCulate:MARKer:PEAK:THReshold
:CALCulate:MARKer:PEAK: EXCursion)
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Peak
3.6.1.26 Query Peak Table Data (:CALCulate:PEAK:TABLe)
Places the selected marker on the next highest signal peak of the current
marked peak.
(based on the search mode settings, include: peak search mode, peak
threshold and peak excursion, Reference Commands:
:CALCulate:MARKer:PEAK:SEARch:MODE
:CALCulate:MARKer:PEAK:THReshold
:CALCulate:MARKer:PEAK: EXCursion)
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Peak > Next Peak
Example
:CALCulate:MARKer1:MAXimum:NEXT
Command
Format
:CALCulate:MARKer[1]|2|3|4:MAXimum:LEFT
Instruction
Places the selected marker on the next highest signal peak to the left of the
current marked peak.
(based on the search mode settings, include: peak search mode, peak
threshold and peak excursion, Reference Commands:
:CALCulate:MARKer:PEAK:SEARch:MODE
:CALCulate:MARKer:PEAK:THReshold
:CALCulate:MARKer:PEAK: EXCursion)
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Peak > Next Left Peak
Example
:CALCulate:MARKer1:MAXimum:LEFT
Command
Format
:CALCulate:MARKer[1]|2|3|4:MAXimum:RIGHt
Instruction
Places the selected marker on the next highest signal peak to the right of the
current marked peak.
(based on the search mode settings, include: peak search mode, peak
(:CALCulate:MARKer[1]|2|3|4:MAXimum:NEXT)
SIGLENT
3.6.1.30 Marker Peak Left Search
(:CALCulate:MARKer[1]|2|3|4:MAXimum:LEFT)
3.6.1.31 Marker Peak Right Search
(:CALCulate:MARKer[1]|2|3|4:MAXimum:RIGHt)
SSA3000X Programming Guide 51
SIGLENT
threshold and peak excursion, Reference Commands:
:CALCulate:MARKer:PEAK:SEARch:MODE
:CALCulate:MARKer:PEAK:THReshold
:CALCulate:MARKer:PEAK: EXCursion)
Parameter
Type
None
Parameter
Range
None
Return
None
Default
None
Menu
Peak > Next Right Peak
Example
:CALCulate:MARKer1:MAXimum:RIGHt
Command
Format
:CALCulate:MARKer[1]|2|3|4:PTPeak
Instruction
Positions a pair of delta markers on the highest and lowest points on the trace.
This command selects the marker function for the designated marker.
Gets the selected marker function for the designated marker.
Parameter
Type
Enumeration
Parameter
Range
OFF: refers to the normal function.
FCOunt: refers to the frequency counter function.
NOISe: refers to the noise measurement function.
NDB: refers to the N dB bandwith function.
Return
Enumeration
Default
OFF
Menu
Marker Fn
Example
:CALCulate:MARK1:FUNCtion FCOunt
Command
Format
:CALCulate:MARKer[1]|2|3|4:FCOunt:X?
Instruction
To query the frequency counter
Parameter
None
3.6.1.32 Peak to Peak Search
(:CALCulate:MARKer[1]|2|3|4:PTPeak)
3.6.1.33 Marker Function (:CALCulate:MARKer[1]|2|3|4:FUNCtion)
3.6.1.34 Query Frequency Counter
(:CALCulate:MARKer[1]|2|3|4:FCOunt:X?)
Mode sets a limit line to be either an upper or lower type limit line. An upper line
will be used as the maximum allowable value when comparing with the data.
Gets limit type.
Parameter
Type
Enumeration
Parameter
Range
UPPer|LOWer
Return
Enumeration
Default
The default setting of LINe1 is UPPer, the default setting of LINe2 is LOWer
Sets the Y-axis value of a limit line. Limit line Y-axis value is set independently
and is not affected by the X-axis units.
Gets the Y-axis value of a limit line.
Parameter
Type
Float
Parameter
-400 dBm~330 dBm
SIGLENT
3.6.2.6 Limit Mode (:CALCulate:LLINe[1]|2:MODE)
3.6.2.7 Limit Line Y-axis Value (:CALCulate:LLINe[1]|2:Y)
Use this command to turn on/off the limit beep status.
Gets limit beep state.
Parameter
Type
Boolean
Parameter
Range
OFF|ON|0|1
Return
0|1
Default
ON
Menu
Limit > Setup > Buzzer
Example
:CALCulate:LLINe:CONTrol:BEEP OFF
Command
Format
:CALCulate:LLINe:FAIL?
Instruction
This query returns the limits pass/failed result. If the test result fails, this
command will get result FAIL. If the test result passes, it will get result PASS.
3.6.2.11 Delete All Limit Points (:CALCulate:LLINe:ALL:DELete)
3.6.2.12 Limit X-axis Unit (:CALCulate:LLINe:CONTrol:DOMain)
3.6.2.13 Limit Beep State (:CALCulate:LLINe:CONTrol:BEEP)
3.6.2.14 Query Limits Result (:CALCulate:LLINe:FAIL?)
Specifies the range of integration used in calculating the power in the main
channel.
Gets the range of integration used in calculating the power in the main channel.
Specifies the bandwidth used in calculating the power in the adjacent channel.
Gets the bandwidth used in calculating the power in the adjacent channel.
This command toggles the method of OBW measurement between percent and
dBc.
Gets the method of OBW measurement.
Parameter
Type
Enumeration
Parameter
Range
PERCent|DBC
Return
Enumeration
Default
PERCent
Menu
Meas > Occupied BW > Meas Setup > Method
Example
:OBW:METHod PERCent
Command
[:SENSe]:OBWidth:PERCent <para>
3.7.2.4 Query Channel Power (:MEASure:CHPower:CHPower?)
3.7.2.5 Query Power Spectral Density
(:MEASure:CHPower:DENSity?)
3.7.3 OBW Subsection
3.7.3.1 Select the Method of OBW ([:SENSe]:OBWidth:METHod)
3.7.3.2 Set Percentage(%) Method of OBW
([:SENSe]:OBWidth:PERCent)
62 SSA3000X Programming Guide
SIGLENT
Format
[:SENSe]:OBWidth:PERCent?
Instruction
Edit the percentage of signal power used when determining the occupied
bandwidth. Press {%} to set the percentage ranging from 10.00% to 99.99%.
Gets the percentage of signal power.
Specify the power level used to determine the emission bandwidth as the
number of dB down from the highest signal point, within the occupied bandwidth
span.
Gets dBc value.
Parameter
Type
Float
Parameter
Range
0.1~100
Return
Float
Default
26
Menu
Meas > Occupied BW > Meas Setup > dBc
Example
:OBWidth:XDB 3
Command
Format
:MEASure:OBWidth?
Instruction
Use this command to query the occupied bandwidth and bandwidth centroid
according to the method you set.
Parameter
Type
None
Parameter
Range
None
Return
Float, unit: Hz
Default
None
Menu
Meas > Occupied BW
Example
:MEASure:OBW?
Command
Format
:MEASure:OBWidth:OBWidth?
Instruction
Use this command to query the occupied bandwidth according to the method
you set.
Query Centroid Result.
Parameter
None
3.7.3.3 Set dBc Method of OBW ([:SENSe]:OBWidth:XDB)
3.7.3.4 Query OBW and Centroid (:MEASure:OBWidth?)
3.7.3.5 Query OBW (:MEASure:OBWidth:OBWidth?)
SSA3000X Programming Guide 63
SIGLENT
Type
Parameter
Range
None
Return
Float, unit: Hz
Default
None
Menu
Meas > Occupied BW
Example
:MEASure:OBW:OBW?
Command
Format
:MEASure:OBWidth:CENTroid?
Instruction
Use this command to query the occupied bandwidth according to the method
you set.
Parameter
Type
None
Parameter
Range
None
Return
Float, unit: Hz
Default
None
Menu
Meas > Occupied BW
Example
: MEASure:OBW:CENTroid?
Command
Format
:MEASure:OBWidth:OBWidth:FERRor?
Instruction
Use this command to query transmit frequency error.
Specifies the level at which a video trigger will occur. Video is adjusted using
this command, but must also be selected using the command.
Gets video Trigger Level.
Parameter
Type
Float, unit: dBm, dBmV, dBuV, V, W
Parameter
Range
Unit is dBm: -300 dBm ~ 50 dBm
uni is dBmV: -253.01 dBmV ~ 96.99 dBmV
unit is dBuV: -193.01 dBuV ~ 156.99 dBuV
unit is Volts: 223.61 aV ~ 70.71 V
unit is Watts: 1.00E-33 W ~ 100 W
This command activates the trigger condition that allows the next sweep to start
when the external voltage (connected to EXT TRIG IN connector) passes
through approximately 1.5 volts. The external trigger signal must be a 0V to
+5V TTL signal. This function only controls the trigger polarity (for positive or
negative-going signals).
Gets Trigger edge.
This chapter gives some examples for the programmer. In these examples you can see how
to use the VISA or sockets, in combination with the commands have been described above
to control the spectrum analyzer. By following these examples, you can develop many more
applications.
4.1 Examples of Using VISA
4.1.1 Example of VC++
Environment: Win7 32bit system, Visual Studio
The functions of this example: use the NI-VISA, to control the device with USBTMC or
TCP/IP access to do a write and read.
Follow the steps to finish the example:
1、 Open Visual Studio, create a new VC++ win32 console project.
2、 Set the project environment to use the NI-VISA lib, there are two ways to use NI-VISA,
static or automatic:
(1) Static: find files: visa.h, visatype.h, visa32.lib in NI-VISA install path. Copy them to your
project, and add them into project. In the projectname.cpp file, add the follow two lines:
(2) Automatic:
Set the .h file include directory, the NI-VISA install path, in our computer we set the path is:
C:\Program Files\IVI Foundation \VISA\WinNT\include. Set this path to project---properties--c/c++---General---Additional Include Directories: See the picture.
Set lib path set lib file:
Set lib path: the NI-VISA install path, in our computer we set the path is: C:\Program Files\IVI
Foundation\VISA\WinNT
\lib\msc. Set this path to project---properties---Linker---General---Additional Library
Directories: as seen in the pictures below.
SSA3000X Programming Guide 73
SIGLENT
Set lib file:project---properties---Linker--- Command Line---Additional Options: visa32.lib
Include visa.h file: In the projectname.cpp file:
#include <visa.h>
3、Add codes:
(1)USBTMC access code.
Write a function Usbtmc_test:
int Usbtmc_test()
{
/* This code demonstrates sending synchronous read & write commands */ /* to an USB Test & Measurement Class (USBTMC) instrument using */ /* NI-VISA */ /* The example writes the "*IDN?\n" string to all the USBTMC */ /* devices connected to the system and attempts to read back */ /* results using the write and read functions. *//* The general flow of the code is */ /* Open Resource Manager */ /* Open VISA Session to an Instrument */ /* Write the Identification Query Using viPrintf */ /* Try to Read a Response With viScanf */ /* Close the VISA Session */ /***********************************************************/
ViSessiondefaultRM;
ViSessioninstr;
ViUInt32numInstrs;
ViFindListfindList;
ViStatus status;
char instrResourceString[VI_FIND_BUFLEN]; unsigned char buffer[100]; int i; /** First we must call viOpenDefaultRM to get the manager
* handle. We will store this handle in defaultRM.*/
status=viOpenDefaultRM (&defaultRM);
if (status<VI_SUCCESS)
{
printf ("Could not open a session to the VISA Resource Manager!\n");
return status;
}
74 SSA3000X Programming Guide
SIGLENT
/* Find all the USB TMC VISA resources in our system and store the number of resources in the system in
numInstrs.*/
status = viFindRsrc (defaultRM, "USB?*INSTR", &findList, &numInstrs, instrResourceString);
if (status<VI_SUCCESS)
{
printf ("An error occurred while finding resources.\nPress 'Enter' to continue.");
fflush(stdin);
getchar();
viClose (defaultRM);
return status;
}
/** Now we will open VISA sessions to all USB TMC instruments.
* We must use the handle from viOpenDefaultRM and we must
* also use a string that indicates which instrument to open. This
* is called the instrument descriptor. The format for this string
* can be found in the function panel by right clicking on the
* descriptor parameter. After opening a session to the
* device, we will get a handle to the instrument which we
* will use in later VISA functions. The AccessMode and Timeout
* parameters in this function are reserved for future
* functionality. These two parameters are given the value VI_NULL.*/
for (i=0; i<int(numInstrs); i++)
{
if (i> 0)
{ viFindNext (findList, instrResourceString);
} status = viOpen (defaultRM, instrResourceString, VI_NULL, VI_NULL, &instr);
if (status<VI_SUCCESS)
{
printf ("Cannot open a session to the device %d.\n", i+1);
continue;
}
/* * At this point we now have a session open to the USB TMC instrument.
* We will now use the viPrintf function to send the device the string "*IDN?\n",
* asking for the device's identification. */
char * cmmand ="*IDN?\n";
status = viPrintf (instr, cmmand);
if (status<VI_SUCCESS)
{
printf ("Error writing to the device %d.\n", i+1);
status = viClose (instr);
continue;
}
/** Now we will attempt to read back a response from the device to
* the identification query that was sent. We will use the viScanf
* function to acquire the data.
* After the data has been read the response is displayed.*/
status = viScanf(instr, "%t", buffer);
if (status<VI_SUCCESS)
{ printf ("Error reading a response from the device %d.\n", i+1);
} else
{ printf ("\nDevice %d: %s\n", i+1, buffer);
}status = viClose (instr);
}
/** Now we will close the session to the instrument using
* viClose. This operation frees all system resources. */
status = viClose (defaultRM);
printf("Press 'Enter' to exit.");
fflush(stdin);
getchar();return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
Usbtmc_test();
return 0;
}
Run result.
SSA3000X Programming Guide 75
SIGLENT
(2)TCP/IP access code.
Write a function TCP_IP_Test:
int TCP_IP_Test(char *pIP)
{
char outputBuffer[VI_FIND_BUFLEN];
ViSessiondefaultRM, instr;
ViStatusstatus;
/* First we will need to open the default resource manager. */
status = viOpenDefaultRM (&defaultRM);
if (status<VI_SUCCESS)
{
printf("Could not open a session to the VISA Resource Manager!\n");
}
/* Now we will open a session via TCP/IP device */
char head[256] ="TCPIP0::";
char tail[] ="::INSTR";
strcat(head,pIP);
strcat(head,tail);
status = viOpen (defaultRM, head, VI_LOAD_CONFIG, VI_NULL, &instr);
if (status<VI_SUCCESS)
{
printf ("An error occurred opening the session\n");
viClose(defaultRM);
}
status = viPrintf(instr, "*idn?\n");
status = viScanf(instr, "%t", outputBuffer);
if (status<VI_SUCCESS)
{
printf("viRead failed with error code: %x \n",status);
viClose(defaultRM);
}else
{ printf ("\nMesseage read from device: %*s\n", 0,outputBuffer);
} status = viClose (instr);
status = viClose (defaultRM);
printf("Press 'Enter' to exit.");
fflush(stdin);
getchar(); return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
printf("Please input IP address:");
char ip[256];
fflush(stdin);
gets(ip);
TCP_IP_Test(ip);
return 0;
}
Run result.
76 SSA3000X Programming Guide
SIGLENT
4.1.2 Example of VB
Environment: Win7 32bit system, Microsoft Visual Basic 6.0
The function of this example: Use the NI-VISA, to control the device with USBTMC and
TCP/IP access to do a write and read.
Follow the steps to complete the example:
1、 Open Visual Basic, build a standard application program project (Standard EXE)
2、 Set the project environment to use the NI-VISA lib, Click the Existing tab of Project>>Add
Existing Item. Search for the visa32.bas file in the include folder under the NI-VISA
installation path and add the file.
This allows the VISA functions and VISA data types to be used in a program.
3、 Add codes:
(1)USBTMC access code.
Write a function Usbtmc_test:
Private Function Usbtmc_test() As Long
' This code demonstrates sending synchronous read & write commands
' to an USB Test & Measurement Class (USBTMC) instrument using
' NI-VISA
' The example writes the "*IDN?\n" string to all the USBTMC
' devices connected to the system and attempts to read back
' results using the write and read functions.
' The general flow of the code is
' Open Resource Manager
' Open VISA Session to an Instrument
' Write the Identification Query Using viWrite
' Try to Read a Response With viRead
' Close the VISA Session
SSA3000X Programming Guide 77
SIGLENT
Const MAX_CNT = 200
Dim defaultRM As Long
Dim instrsesn As Long
Dim numlnstrs As Long
Dim findList As Long
Dim retCount As Long
Dim status As Long
Dim instrResourceString As String * VI_FIND_BUFLEN
Dim Buffer As String * MAX_CNT
Dim i As Integer
' First we must call viOpenDefaultRM to get the manager
' handle. We will store this handle in defaultRM.
status = viOpenDefaultRM(defaultRM)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Could not open a session to the VISA Resource Manager!"
Usbtmc_test = status
ExitFunction
End If
' Find all the USB TMC VISA resources in our system and store the
' number of resources in the system in numInstrs.
status = viFindRsrc(defaultRM, "USB?*INSTR", findList, numlnstrs, instrResourceString)
If (status < VI_SUCCESS) Then
resultTxt.Text = "An error occurred while finding resources."
viClose (defaultRM)
Usbtmc_test = status
Exit Function
End If
' Now we will open VISA sessions to all USB TMC instruments.
' We must use the handle from viOpenDefaultRM and we must
' also use a string that indicates which instrument to open. This
' is called the instrument descriptor. The format for this string
' can be found in the function panel by right clicking on the
' descriptor parameter. After opening a session to the
' device, we will get a handle to the instrument which we
' will use in later VISA functions. The AccessMode and Timeout
' parameters in this function are reserved for future
' functionality. These two parameters are given the value VI_NULL.
For i = 0 To numInstrs
If (i > 0) Then
status = viFindNext(findList, instrResourceString)
End If
status = viOpen(defaultRM, instrResourceString, VI_NULL, VI_NULL, instrsesn)
If (status < VI_SUCCESS) Then resultTxt.Text = "Cannot open a session to the device " + CStr(i + 1)
GoTo NextFind
End If
' At this point we now have a session open to the USB TMC instrument.
' We will now use the viWrite function to send the device the string "*IDN?",
' asking for the device's identification.
status = viWrite(instrsesn, "*IDN?", 5, retCount)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error writing to the device."
status = viClose(instrsesn)
GoTo NextFind
End If
78 SSA3000X Programming Guide
SIGLENT
' Now we will attempt to read back a response from the device to
' the identification query that was sent. We will use the viRead
' function to acquire the data.
' After the data has been read the response is displayed.
status = viRead(instrsesn, Buffer, MAX_CNT, retCount)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error reading a response from the device." + CStr(i + 1)
' Now we will close the session to the instrument using
' viClose. This operation frees all system resources.
status = viClose(defaultRM)
Usbtmc_test = 0
End Function
(2)TCP/IP access code.
Write a function TCP_IP_Test:
Private Function TCP_IP_Test(ByVal ip As String) As Long
Dim outputBuffer As String * VI_FIND_BUFLEN
Dim defaultRM As Long
Dim instrsesn As Long
Dim status As Long
Dim count As Long
' First we will need to open the default resource manager.
status = viOpenDefaultRM (defaultRM)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Could not open a session to the VISA Resource Manager!"
TCP_IP_Test = status
Exit Function
End If
' Now we will open a session via TCP/IP device
status = viOpen(defaultRM, "TCPIP0::" + ip + "::INSTR", VI_LOAD_CONFIG, VI_NULL, instrsesn)
If (status < VI_SUCCESS) Then
resultTxt.Text = "An error occurred opening the session"
viClose (defaultRM)
TCP_IP_Test = status
Exit Function
End If
status = viWrite(instrsesn, "*IDN?", 5, count)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error writing to the device."
End If
status = viRead(instrsesn, outputBuffer, VI_FIND_BUFLEN, count)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error reading a response from the device." + CStr(i + 1)
Else
resultTxt.Text = "read from device:" + outputBuffer
End If
status = viClose(instrsesn)
status = viClose(defaultRM)
TCP_IP_Test = 0
End Function
(3) Button control code:
PrivateSub exitBtn_Click()
End
EndSub
PrivateSub tcpipBtn_Click()
SSA3000X Programming Guide 79
SIGLENT
Dim stat AsLong
stat = TCP_IP_Test(ipTxt.Text)
If (stat < VI_SUCCESS) Then
resultTxt.Text = Hex(stat)
EndIf
EndSub
PrivateSub usbBtn_Click()
Dim stat AsLong
stat = Usbtmc_test
If (stat < VI_SUCCESS) Then
resultTxt.Text = Hex(stat)
EndIf
EndSub
Run result:
4.1.3 Example of MATLAB
Environment: Win7 32bit system, MATLAB R2013a
The function of this example: Use the NI-VISA, to control the device with USBTMC or
TCP/IP access to do a write and read.
Follow the steps to complete the example:
1、 Open MATLAB, modify the current directory. In this demo, the current directory is
modified to D:\USBTMC_TCPIP_Demo.
2、 Click File>>New>>Script in the Matlab interface to create an empty M file
3、 Add codes:
(1)USBTMC access code
Write a function Usbtmc_test.
function USBTMC_test()
% This code demonstrates sending synchronous read & write commands
% to an USB Test & Measurement Class (USBTMC) instrument using
% NI-VISA
%Create a VISA-USB object connected to a USB instrument
vu = visa('ni','USB0::0xF4ED::0xEE3A::sdg2000x::INSTR');
%Open the VISA object created
fopen(vu);
%Send the string "*IDN?",asking for the device's identification.
80 SSA3000X Programming Guide
fprintf(vu,'*IDN?');
%Request the data
outputbuffer = fscanf(vu);
disp(outputbuffer);
%Close the VISA object
fclose(vu);
delete(vu);
clear vu;
end
Run result:
2)TCP/IP access code.
Write a function TCP_IP_Test:
function TCP_IP_test()
% This code demonstrates sending synchronous read & write commands
% to an TCP/IP instrument using NI-VISA
%Create a VISA-TCPIP object connected to an instrument
%configured with IP address.
%Send the string "*IDN?",asking for the device's identification.
fprintf(vt,'*IDN?');
%Request the data
outputbuffer = fscanf(vt);
disp(outputbuffer);
%Close the VISA object
fclose(vt);
delete(vt);
clear vt;
end
Run result:
SIGLENT
(
4.1.4 Example of LabVIEW
Environment: Win7 32bit system, LabVIEW 2011
The functions of this example: use the NI-VISA, to control the device with USBTMC and
TCP/IP access to do a write and read.
SSA3000X Programming Guide 81
SIGLENT
Follow the steps to complete the example:
1、 Open LabVIEW, create a VI file.
2、 Add controls. Right-click in the Front Panel interface, select and add VISA resource
name, error in, error out and some indicators from the Controls column.
3、 Open the Block Diagram interface. Right-click on the VISA resource name and you can
select and add the following functions from VISA Palette from the pop-up menu: VISA Write,
VISA Read, VISA Open and VISA Close.
4、 Connect them as shown in the figure below
5、 Select the device resource from the VISA Resource Name list box and run the program.
In this example, the VI opens a VISA session to a USBTMC device, writes a command to the
device, and reads back the response. In this example, the specific command being sent is
the device ID query. Check with your device manufacturer for the device command set. After
all communication is complete, the VI closes the VISA session.
6、Communicating with the device via TCP/IP is similar to USBTMC. But you need to
change VISA Write and VISA Read Function to Synchronous I/O. The LabVIEW default is
asynchronous I/O. Right-click the node and select Synchronous I/O Mod>>Synchronous
from the shortcut menu to write or read data synchronously.
7、 Connect them as shown in the figure below
82 SSA3000X Programming Guide
8、 Input the IP address and run the program.
SIGLENT
SSA3000X Programming Guide 83
SIGLENT
4.2 Examples of Using Sockets/Telnet
4.2.1 Example of Python
Python is an interpreted programming language that lets you work quickly and is very
portable.Python has a low-level networking module that provides access to the socket
interface.Python scripts can be written for sockets to do a variety of test and measurements
tasks.
Environment: Win7 32bit system, Python v2.7.5
The functions of this example: Open a socket, sends a query, and closes the socket. It
does this loop 10 times.
Below is the code of the script:
#!/usr/bin/env python
#-*- coding:utf-8 –*#----------------------------------------------------------------------------# The short script is a example that open a socket, sends a query,
# print the return message and closes the socket.
#----------------------------------------------------------------------------import socket # for sockets
import sys # for exit
import time # for sleep
#-----------------------------------------------------------------------------
remote_ip = "10.11.13.32" # should match the instrument’s IP addressport = 5024 # the port number of
the instrument service
count = 0
def SocketConnect():
try:
#create an AF_INET, STREAM socket (TCP)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error:
print ('Failed to create socket.')
sys.exit();
try:
#Connect to remote server
s.connect((remote_ip , port))
info = s.recv(4096)
print (info)
except socket.error:
print ('failed to connect to ip ' + remote_ip)
return s
def main():
global remote_ip
global port
global count
# Body: send the SCPI commands *IDN? 10 times and print the return message
s = SocketConnect()
for i in range(10):
qStr = SocketQuery(s, b'*IDN?')
print (str(count) + ":: " + str(qStr))
count = count + 1 SocketClose(s)
input('Press "Enter" to exit')
if __name__ == '__main__':
proc = main()
Run result:
4.2.2 Example of Telnet
Telnet SCPI: Provides the ability to send single SCPI commands from a remote PC to the
analyzer using LAN port number 5024.
How to send single SCPI commands using Telnet:
1. On the remote PC, click Start, then Run
2. Type: telnet <ip address> 5024
3. A Telnet window with a >> prompt should appear on the remote PC screen.
4. From the SCPI prompt:
Type single SCPI commands. Press Enter to send the command.
SSA3000X Programming Guide 85
SIGLENT
To exit the telnet window click X in the upper-right corner.
To get a normal telnet prompt, press Ctrl ] (closing bracket).
To get SCPI prompt again, type open <ip Address> 5024.
To close the normal telnet window, type Quit and press Enter.
86 SSA3000X Programming Guide
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.