N437x Lightwave Component Analyzer
Automation – Getting Started with SCPI
Application Note
Page 2
Introduction
The Keysight N437x Series Lightwave Component Analyzer (LCA) is a solution which
integrates a vector network analyzer (VNA) along with a calibrated lightwave test set
to measure the transfer function of electrical to electrical (EE), electrical to optical
(EO), optical to electrical (OE), and optical to optical (OO) components. Similar to a
vector network analyzer both the magnitude and phase response of a component are
characterized as a function of frequency. Typical measurements performed by the LCA
include: gain, bandwidth, frequency response, flatness, and electrical return loss. A key
value of the LCA is that the calibrated response of the lightwave test set is automatically
de-embedded from the measurement and the reported results are isolated to the optical
component under test. Additional information on the measurement fundamentals for the
LCA can be found in the Keysight application note, High Speed Lightwave Component
Analysis. [1] In this paper, we will review the steps required to automate the N437xA
LCA and provide suggestions to help a new user quickly integrate the LCA into their
automated test environment.
The LCA application running on the network analyzer integrates the VNA with the
lightwave test set. Automating the LCA requires that commands are sent to both
the VNA and the LCA. Here is a summar y of the typical steps required to perform
measurements along with the application which is automated for each step.
Page 3
03 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
The VNA settings such as start and stop frequency, number of measurement points,
and IF bandwidth are set for a specific measurement. Once the instrument state is
defined an electronic or mechanical calibration is performed to define the electrical
reference plane and compensate for losses in the test fixturing and/or cabling. After
the calibration is complete, the instrument state is saved so it can be quickly recalled.
Additional information on performing the VNA calibration is available in the specific
N437x LCA user guide. [6, 7, 8 9]
ii) Start LCA application – LCA application
The LCA application is star ted and the measurement type (EO, OE, or OO) is selected.
For remote automation, rather than starting the LCA application the user will start the
LCA SCPI Server. More details on this are provided in the section, LCA Automation.
The LCA measurement settings including: wavelength, optical power, electrical
power, and modulator optimization are defined in the LCA application for a given
measurement. The user can also enable additional optical path or electrical path
de-embedding along with specifying a path for the appropriate s-parameter file.
iv) Initialize LCA – LCA application
The LCA is initialized with the settings defined in step iv). Initializing a measurement
will set up the instrument and load the appropriate lightwave test set calibration data.
For example, initializing an OE measurement will setup the LCA to de-embed the
response of the optical modulator in the lightwave test set so the final measurement
result is isolated to the optical to electrical component under test. Once the LCA is
initialized for a given measurement, multiple sweeps can be performed to characterize
multiple devices.
v) Perform LCA Measurement – LCA application
The LCA application sweeps the VNA over the defined frequency range to measure
the magnitude and phase response of the component under test. This step can be
repeated multiple times once the LCA is initialized in step iv). If the measurement type
or any of the LCA parameters are changed then step iv) needs to be repeated.
vi) Query VNA Trace Data / Save *.csv File – VNA application
The final step once a measurement sweep is completed is to query the VNA trace data
so the gain, bandwidth, frequency response, flatness, and electrical return loss can be
determined. It is also possible to position markers directly on the VNA to gather this
information.
To completely automate an LCA measurement, the control program needs to interface
with both the VNA application in steps i), vi) and the LCA application in steps ii), iii), iv),
and v). The remainder of this paper will outline the steps required to interface with both
the VNA and the LCA application.
Page 4
04 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
PNA/ENA Automation
There are two series of Keysight VNAs which are integrated into the N437x Series LCA.
The low frequency N4374B LCA incorporates an E5071C ENA, while the higher frequency
N437x LCA use the N522x PNA. There are a number of standard IO programming
interfaces available for each instrument, as summarized in Table 1.
Table 1: ENA/PNA Programming Interfaces
InstrumentLAN
(remote GPIB)
ENA – E5071CNOYESYESNOYESYES
PNA – N522xAYESYESYESYESYESYES
Once an IO interface is selected, there are a few options for sending instructions to the
VNA. Both the ENA and PNA can be automated using an IVI driver or by sending ASCII
text commands to the instrument using direct IO. The ASCII text commands follow a
convention known as ‘Standardized Commands for Programmable Instruments’ which
is abbreviated as SCPI. There are trade-offs between using an IVI driver vs. SCPI
commands. [2] This paper will focus on using SCPI commands to automate the VNA;
SCPI is a simple and intuitive approach for basic instrument operations. Each front-panel
keystroke performed by the user has an equivalent SCPI command which is sent to the
instrument to perform an operation. Typical VNA operations which require automation,
along with the corresponding SCPI command, are detailed in Table 2. These SCPI
commands are typically sent to the instrument using the Keysight VISA IO library. [2]
LAN
(VXI-11)
LAN
(Socket)
LAN
(HiSlip)
USBGPIB
The remote command structure for the ENA and PNA need to manage the general case
where there could potentially be multiple channels, windows, and traces used as part of
the measurement. Managing the data generated by the LCA application is simplified as
only a single VNA window and a single VNA channel are generated. For a single ended
E/O or O/E measurement there are two traces generated, electrical return loss and
insertion loss. While for a differential E/O or O/E measurement there are a total of three
traces generated, an electrical return loss and two insertion loss traces.
The SCPI commands in Table 2 are formatted for a single channel, as set up by the LCA
application. Many of the ENA and PNA commands are identical; the main exception are
commands for querying trace data and saving/recalling files. Complete documentation
for the ENA and PNA SCPI commands are available in the on-line help files. [3][4]
Page 5
05 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Table 2: SCPI Commands for ENA /PNA Automation
OperationPNAENA
Instrument Reset:S YST:PRES:S YST:PRES
Save Instrument State:MMEMory:STORe 'filename.csa' :MMEM:STOR 'filename.sta'
Query Available TracesDISP:WIND1:CAT?CALC1:PAR:COUNT?
Query Trace DataCALC1:PAR:MNUM <int>
:CALC1:TRAC<int>:DATA:FDAT?
CALC1:DATA? FDATA
SDATA - Complex Measurement Data
SDATA - Complex Measurement Data
FDATA - Formatted Measurement Data
FDATA - Formatted Measurement Data
where <int> represents the trace number
where <int> represents the trace number
Operation Complete*OPC?*OPC?
Save *.CSV FileMMEM:STORe:DATA <string>,’CSV Formatted
Data’,’Trace’,’Displ ayed’, <int>
:CALC1:PAR<int>:SEL
:MMEMory:STORe:FDATa <string>
where <string> represents the file name and <int>
represents the trace number
where <string> represents the file name and <int>
represents the trace number
It is important to make sure that the automation program is synchronized with the
operations being performed by the test equipment. Often this is accomplished using the
operation complete query, ‘*OPC?’, which returns a ‘1’ when an operation has finished.
The instruments in this example will wait until the operation is complete and then return
a ‘1’. In other words, nothing is returned until the operation is complete. It is important
that the inter face timeout is set for a value which is longer the operation. For example,
if the interface timeout is set to 1 second but the measurement requires 3 seconds to
complete then a timeout error will result in response to the ‘*OPC?’.
Here is a brief example which summarizes typical operations and SCPI commands
required to setup the VNA. The syntax of the example in this section has been
abbreviated to highlight the commands required for each step. Comments are included
on lines starting with the ‘#’ character. A complete Python example which sends
SCPI commands using the PyVisa libraries is provided in Appendix B. The individual
SCPI commands sent to the instrument using the ‘myVNA.write()’ statements are the
important commands which can be transported to a different language. The example
code below will query one of the VNA traces as a comma separated string which can be
parsed and formatted into an array. The trace is returned as a real and imaginary pair
if ‘SDATA’ is specified or in the currently displayed format (i.e. log magnitude, phase,
group delay, etc.) if ‘FDATA’ is used in the command string. The example program also
highlights the command to save *.csv file to the VNA hard disk drive.
Page 6
06 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
1. #Define VNA as PNA or ENA
74.
2. inst_VNA = 'PNA'
3.
4. #Preset instrument and wait until complete
5. myVNA.write(':SYST:PRES')
6. myVNA.write('*OPC?')
7. print ('VNA Reset Complete: ' + myVNA.read())
8.
9. #Recall instrument state which includes electrical calibration
07 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
LCA Automation
Traditionally, the LCA application is automated using Microsoft .NET remoting over a LAN
interface. This requires that a remote client is installed on the control PC. To automate
the LCA, the control program calls the methods and properties of the remote client
which in turn communicates with the server running on the LCA via L AN. Additional
information on programming the LCA using .NET remoting is available in the N437x
LCA Programming Manual. [5] An important point is that the .NET remoting exposes
the complete functionality of the LCA and is the most flexible interface for controlling
the instrument. However, for programming environments other than Microsoft Visual
Studio .NET, interfacing with the required drivers can require extra steps. Using the .NET
remoting also limits the control PC to a Windows OS and requires communication via
LAN. Finally, for test and measurement engineers not familiar with automation using
drivers, there is a learning curve to use the .NET remoting. To overcome these challenges
and simplify the steps required to automate the LCA, a SCPI server has recently been
added. This allows users to directly send SCPI commands to the LCA SCPI ser ver over a
LAN Socket or USB interface. Similar to using SCPI commands to control the VNA, using
SCPI commands to automate the LCA is a simple and intuitive approach.
One point to consider at present is that commands to automate the external optical input
and the 75 Ohm selection in the LCA application are not currently available with the
SCPI server. These are on the roadmap for a future release of the LCA application. The
next section of this paper will summarize the required automation steps for the LCA SCPI
Server.
LCA Automation – SCPI
LCA automation using SCPI commands is a straight forward and intuitive approach; each
front panel operation performed by the user has an equivalent SCPI command. The LCA
user interface tab for performing OE measurements is provided in Figure 1. For a typical
measurement, the user will select LCA parameters including: wavelength, optical power,
and RF power. Additional selections are available for optical and RF path de-embedding.
Page 8
08 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Figure 1. Typical LCA Macro GUI tab for per forming OE Measurements
After the measurement parameters are defined, the instrument is initialized by
pressing the ‘Start’ button which sends the parameters to the LCA to set up the
measurement. This is important to remember; when the user selects the wavelength
for an OE measurement (either manually in the LCA GUI or by sending the
‘:PARameter:WAVelength’ command) the actual wavelength of the source is not changed
until the ‘Start’ button is selected or the ‘:MEASurement:INITialize:OE’ command is
sent. Af ter initialization is complete the user is able to perform a single measurement
or continuously repeat the measurement scan. If any of the LCA settings need to be
changed, the appropriate command is sent to the LCA along with the command to
initialize the measurement. A summary of the specific SCPI commands corresponding to
each of the LCA Macro entries is summarized in Table 3. Complete documentation for the
LCA SCPI commands are available in the N437x programming guide. [5]
Page 9
09 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
10 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
LCA Automation – Starting the SCPI Server
Prior to sending any SCPI commands to the LCA, the user needs to close the LCA
application and start the LCA SCPI Server as shown in the images below. This is an
important point; either the LCA Macro or the LCA SCPI Server can be active, but not
both at the same time. The SCPI Server provides connections to the LCA using either a
LAN Socket connection on port 5026 or by directly connecting to the VNA with a USB
cable. The user can select to start the SCPI Server with either a LAN Socket or USB
interface active. The steps to close the LCA macro and start the LCA SCPI server are
detailed in Figure 2 and 3. One point is that the VNA only has a single USB device port.
This can be used to control either the VNA application or the LCA application via SCPI. If
the VNA is being controlled using the USB port then the LAN interface needs to be used
for LCA automation.
Figure 2. Close LCA Application prior to starting LCA SCPI Server
Page 11
11 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Figure 3. Starting SCPI Server on the LCA
Once the SCPI server is active we can test the connection between the control PC and the LCA
using the Keysight Connection Expert (KCE). This is an application which installs on the control
PC as part of the Keysight IO Libraries Suite ( www.keysight.com/find/iolibraries ). The Keysight
Connection Expert is started from the toolbar by highlighting the ‘IO’ icon and selecting
‘Connection Expert’ as shown in Figure 4.
Figure 4. Starting the Keysight Connection Expert on the
Control PC
Page 12
12 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Once the Keysight Connection Expert has started, the steps to add a LAN Socket Connection
are shown below in Figure 5. A similar approach could be used for a USB connection. The only
information which is required to connect with the LCA via a socket connection is the ‘Host
Name’ or ‘IP Address’ for the VNA. An impor tant point to remember if communicating via a LAN
socket connection is that the LCA SCPI Server uses port 5026, while the PNA uses port 5025.
The steps highlighted below can also be used to troubleshoot and verify the communication
with the VNA. Additional interfaces are available for communicating with the PNA and ENA as
detailed in Table 1.
Figure 5. Configuring a L AN socket connection on port 5 026 to the LCA
The LCA should now appear as an instrument in the Keysight Connection Expert. We can send
individual SCPI commands to the instrument by highlighting the LCA instrument in the Keysight
Connection Expert and selecting ‘Send Commands to Instrument’ as shown in Figure 6. This will
start the Keysight Interactive IO which is a utility for testing SCPI commands. The user enters
the command and presses the ‘Send Command’ button to execute a command. If sending a
query such as ‘*IDN?’ to get information back from the LCA the user can select the ‘Send and
Read’ button as shown in Figure 6. After verifying the connectivity, the Keysight Interactive IO
can be closed and commands can be sent to the LCA using a programming environment. An
important point is that only a single session with the LCA SCPI server can be active at a time.
This requires that the Keysight Interactive IO is closed before opening a session with another
application.
Page 13
13 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Figure 6: Sending Commands to the LCA SCPI Server
After closing the Keysight Interactive IO application we can send commands to the LCA SCPI
server from the automation environment. Similar to the VNA, there are LCA operations such
as performing a measurement sweep which can take time to complete. It is important to make
sure that the current operation is complete and the LCA is ready to receive a new command.
Similar to the VNA, for most of the LCA operations, we can use the operation complete query,
‘*OPC?’. For example, when a measurement sweep is initiated using the ‘:MEAS:STAR sing’
command, the control program knows the sweep is complete when the ‘*OPC?’ returns a ‘1’.
One exception is initializing an OE, EO, or OO measurement. The recommended approach to
synchronize the control program after sending the initialize command is to poll the current
instrument state. Once the returned measurement type matches the initialization command,
the program can move to the next command. For example, after sending the initialization
command, ‘:MEASurement:INITialize:OE’, the automation program can poll the current
instrument state using the ‘:MEAS:CURR:TYPE?’ query. The initialization is complete when the
‘OE’ string is returned. Here is an example of typical commands which are sent to the LCA to
perform an OE measurement. Similar to the VNA example, this example has been abbreviated
to focus on the commands required for each step. A complete Python example which sends
SCPI commands using the PyVisa libraries is provided in Appendix B.
Page 14
14 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
15 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Summary
In order to successfully automate the LCA, a control program needs to interface with
both the VNA and the LCA. This paper summarized the available inter faces and SCPI
commands to automate the LCA. The new SCPI server which has recently been added
to the LCA application is highlighted along with example code to help a new user get
started quickly. A complete summary of interfacing with the LCA using either .NET
remoting or SCPI commands is available in the LCA programming guide. [5]
References
[1] High Speed Lightwave Component Analysis – Application Note
16 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Appendix A) Troubleshooting Tips
– Make sure the SCPI server has been started on the instrument.
– ‘Reset LCA System’ and ‘Reset Remote Interface’ from the LCA Server as below if the
expected behavior is not observed.
– Test individual SCPI commands using the Keysight Connection Exper t; this is a good
approach to verify command syntax. If sending a command to set an instrument
parameter (i.e. ‘:PARameter:WAVelength 1310’) immediately query the set value to see
if the LCA recognized the command (i.e. ‘:PARameter:WAVelength?’). Additionally, for
every command which is tested in the Keysight Connection Exper t, send the command to
query for system errors (i.e. ‘:SYST:ERR?’). This will help identify if there is a portion of the
command which is not recognized by the instrument.
Page 17
17 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
– Monitor the ‘Keysight Translator Framework’ on the VNA as commands are sent to
the LCA. This can provide helpful troubleshooting information if a command is not
recognized.
– Only a single socket connection to the LCA SCPI server can be open at a time. This
requires the Keysight Interactive IO to be closed prior to opening connections with a
second application.
Page 18
18 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
– Activate the ‘Keysight IO Monitor’ on the control PC to monitor the commands being
sent to the LCA or VNA along with the data being returned from the instrument. This can
provide useful information to help troubleshoot command syntax issues and problems
with VISA termination characters.
– Make sure the Windows Firewall on the VNA is not blocking communication on por t 5025
or 5026.
– Ensure you are using the most recent LCA application. An important point for WinXP
instruments, the last version of the macro which supports WinXP is Version 3.00.03.
Instruments with Win7 can use the currently released version of the LCA application.
Page 19
19 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Appendix B) Python Example Program
1. # Import python modules
2. importvisa
3. importtime
4. importnumpy as np
5. importmatplotlib.pyplot as plt
6.
7. # define VNA_LCA Functions
8.
9. defrecall_state_VNA(mystate):
10. #Recall Instrument State
11. myVNA.write(':MMEM:LOAD ' + mystate)
12. myVNA.write('*OPC?')
13. print ('Recall VNA State Complete: ' + myVNA.read())
23 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
244. #Query Trace Count CALC1:PAR:COUNT?
245. myVNA.write('CALC1:PAR:COUNT?')
246. trace_count = myVNA.read()
247.
248. for i in range(1,int(trace_count)+1):
249. #Save VNA data as *.csv files for each trace
250. save_csv_VNA(inst_VNA, i, file_csv)
251. #Recall VNA Trace Data / Save VNA Data to a trace file
252. ydata = get_data_VNA(inst_VNA, i)
253. ydata = ydata.split(',')
254. #ENA FDATA returns a zero element @ even positions.
255. #Array returned for ENA formatted data will have 2x the number of data
256. #points in the returned array. The data points of interest are
257. #at the odd elements (i.e. n*2-2 where n = 1 to number of points)
258. if inst_VNA == 'ENA':
259. ydata = ydata[::2]
260. #Convert list to Array of Float to Plot Data
261. my_array = np.array(ydata)
262.
263. # Plot Array
264. plt.plot(my_array)
265. plt.show()
266.
267. #Query for VNA Errors
268. err_num = 1
269. while (err_num != 0):
270. err_VNA = get_err_VNA()
271. print('VNA_err: ' + err_VNA)
272. err_VNA = err_VNA.split(',')
273. err_num = int(err_VNA[0])
274.
275. #Query for LCA Errors
276.
277. err_num = 1
278. while (err_num != 0):
279. err_LCA = get_err_LCA()
280. print('LCA_err: ' + err_LCA)
281. err_LCA = err_LCA.split(',')
282. err_num = int(err_LCA[0])
283.
284. #Close Connection
285. myVNA.close()
286. print ('Close VNA Connection')
287. myLCA.close()
288. print ('Close LCA Connection')
289.
290. except Exception as err:
291. print ('Exception: ' + str(err.message))
292.
293. finally:
294. #perform clean up operations
295. print ('Complete')
Page 24
24 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
Evolving Since 1939
Our unique combination of hardware, software, services, and people can help you
reach your next breakthrough. We are unlocking the future of technology.
From Hewlett-Packard to Agilent to Keysight.
myKeysight
www.keysight.com/find/mykeysight
A personalized view into the information most relevant to you.
Register your products to get up-to-date product information and
find warranty information.
Keysight Services
www.keysight.com/find/service
Keysight Services can help from acquisition to renewal across your
instrument’s lifecycle. Our comprehensive service offerings—onestop calibration, repair, asset management, technology refresh,
consulting, training and more—helps you improve product quality
and lower costs.
Keysight Assurance Plans
www.keysight.com/find/AssurancePlans
Up to ten years of protection and no budgetary surprises to ensure
your instruments are operating to specification, so you can rely on
accurate measurements.
Keysight Channel Partners
www.keysight.com/find/channelpartners
Get the best of both worlds: Keysight’s measurement expertise and
product breadth, combined with channel partner convenience.
For more information on Keysight
Technologies’ products, applications or
services, please contact your local Keysight
office. The complete list is available at: