Keysight Technologies N437 Series, N4374B Application Note

Page 1
Keysight Technologies
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
i) Define VNA measurement settings and perform electrical calibration – VNA
application
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.
iii) Define LCA measurement settings – LCA application
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
Instrument LAN
(remote GPIB)
ENA – E5071C NO YES YES NO YES YES
PNA – N522xA YES YES YES YES YES YES
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)
USB GPIB
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
Operation PNA ENA
Instrument Reset :S YST:PRES :S YST:PRES
Save Instrument State :MMEMory:STORe 'filename.csa' :MMEM:STOR 'filename.sta'
Recall Instrument State :MMEM:LOAD 'filename.csa' :MMEM:LOAD 'filename.sta'
Start Frequency :SENS1:FREQ:STAR <double> :SENS1:FREQ:STAR <double>
Stop Frequency :SENS1:FREQ:STOP <double> :SENS1:FREQ:STOP <double>
IF Bandwidth :SENS1:BWID <double> :SENS1:BAND <double>
Number of Points :SENS1:SWE:POIN <int> :SENS1:SWE:POIN <int>
Autoscale Trace :DISP:WIND:TRAC:Y:AUTO :DISP:WIND:TRAC:Y:AUTO
Query Available Traces DISP:WIND1:CAT? CALC1:PAR:COUNT?
Query Trace Data CALC1: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 File MMEM: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
10. if inst_VNA == 'PNA':
11. myVNA.write(':MMEM:LOAD "C:\\Users\\Public\\PNA_state.csa"')
12. myVNA.write('*OPC?')
13. print ('Recall PNA State Complete: ' + myVNA.read())
14. elif inst_VNA == 'ENA':
15. myVNA.write(':MMEM:LOAD "C:\\Users\\Public\\ENA_state.sta"')
16. myVNA.write('*OPC?')
17. print ('Recall ENA State Complete: ' + myVNA.read())
18.
19.
20. #Insert Code here for LCA - See next section on LCA Automation
21.
22. #Query VNA trace data
23. if inst_VNA == 'PNA':
24. #Define trace data transfer as ASCII
25. myVNA.write(':FORMAT ASC')
26. myVNA.write(':FORMAT?')
27. print('Data Xfer Format: ' + myVNA.read())
28. #Select measurement data using trace number
29. myVNA.write('CALC1:PAR:MNUM 1')
30. #Query data as formatted - FDATA
31. #Query data in complex format - SDATA
32. myVNA.write('CALC1:DATA? FDATA')
33. myydata = myVNA.read()
34. elif inst_VNA == 'ENA':
35. #Define return trace format
36. myVNA.write(':FORM:DATA ASC')
37. myVNA.write(':FORM:DATA?')
38. print('Data Xfer Format: ' + myVNA.read())
39. #Query data as formatted - FDATA
40. #Query data in complex format - SDATA
41. #Note on ENA FDATA:
42. #Array returned for ENA formatted data will have 2x the number of data
43. #points in the returned array. The data points of interest are
44. #at the odd elements (i.e. n*2-2 where n = 1 to number of points)
45. myVNA.write(':CALC1:TRAC1:DATA:FDAT?')
46. myydata = myVNA.read()
47.
48. #Save VNA *.csv file
49. filename = '"C:\\Users\\Public\\trace1.csv"'
50. if inst_VNA == 'PNA':
51. #Save trace 1
52. #Append filename to the command string
53. command = ':MMEM:STORe:DATA ' + filename
54. command = command + ',"CSV Formatted Data","Trace","Displayed",1'
55. myVNA.write(command)
56. myVNA.write('*OPC?')
57. complete = myVNA.read()
58. elif inst_VNA == 'ENA':
59. #Select and save trace 1
60. command = ':MMEMory:STORe:FDATa ' + filename
61. myVNA.write('CALC1:PAR1:SEL')
62. myVNA.write(command)
63. myVNA.write('*OPC?')
64. complete = myVNA.read()
65.
66. #Query VNA Errors
67. err_num = 1
68. while (err_num != 0):
69. myVNA.write(':SYST:ERR?')
70. err_VNA = myVNA.read()
71. print('VNA_err: ' + err_VNA)
72. err_VNA = err_VNA.split(',')
73. err_num = int(err_VNA[0])
Page 7
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
Table 3: SCPI Commands for each LCA parameter
GUI Control SCPI Command Measurement Mode
1 Start :MEAS:INIT:EE
:MEAS:INIT:EO :MEAS:INIT:OE :MEAS:INIT:OO
EE EO OE OO
2 Abort :MEAS:ABOR EE / EO / OE / OO
3 Advanced :PAR:ADVA:MODE 0/1 EO / OE / OO
4 Measure Mode :PAR:MEAS:MODE SING/DIFF EO / OE
5 Wavelength :PAR:WAV 850/1310/1550 EO / OE / OO
6 Optical Power :PAR:OPT:OU T:POW <doubl e> OE / OO
External Input Not Currently Available OE / OO
7 Optical Input :PAR:OPT:INP:POW:HIGH 0/1 EO / OO
8 Modulator Optimization :PAR:MODU:BIAS:MODE CONT/EVER/ONCE OE / OO
9 Forward RF Power :RF:POW:FWD <double> EO / OE / OO
10 Optical Path De-embedding :PAR:OPT:PATH:DEEM 0/1 EO / OE / OO
11 De-embedding Data :PAR:OPTical:S2PFile:USE 0/1 EO / OE / OO
12 Source Length :PAR:SOUR:PATH:LENG <double> EO / OE / OO
13 Source Refractive Index :PAR:SOUR:REFR:IND <double> EO / OE / OO
14 Source Attenuation :PAR:SOUR:REFR:IND <double> EO / OE / OO
15 Receiver Length :PAR:REC:PATH:LENG <double> EO / OE / OO
16 Receiver Refractive Index :PAR:REC:REFR:IND <double> EO / OE / OO
17 Receiver Attenuation :PAR:REC:ATT <double> EO / OE / OO
18 S2P File (Source) :PAR:OPT:SOUR:S2PF <string> EO / OE / OO
19 S2P File (Receiver) :PAR:OPT:SOUR:S2PF <string> EO / OE / OO
20 RF Path De-embedding :PAR:ELEC:PATH:DEEM 0/1 EO / OE / OO
21 S2P File (Src 1) :PAR:ELEC:SOUR:S2PF1 <string> EO / OE / OO
22 S2P File (Src 2) :PAR:ELEC:SOUR:S2PF2 <string> EO / OE / OO
23 S2P File (Rcv 1) :PAR:ELEC:REC:S2PF1 <string> EO / OE / OO
24 S2P File (Rcv 2) :PAR:ELEC:REC:S2PF2 <string> EO / OE / OO
75 Ohm Not Currently Available EO / OE / OO
Page 10
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
LCA Example
1. #*IDN? - Query Instrumnet ID
2. myLCA.write('*CLS')
3. myLCA.write('*IDN?')
4. print ('LCA ID: ' + myLCA.read())
5.
6. #Init LCA to EE Mode
7. print ('Init EE InProgress')
8. myLCA.write(':MEAS:INIT:EE')
9. myLCA.write(':MEAS:CURR:TYPE?')
10. mode = myLCA.read()
11. while (mode != 'EE'):
12. myLCA.write(':MEAS:CURR:TYPE?')
13. mode = myLCA.read()
14. print(mode)
15. time.sleep(1)
16. myLCA.write(':MEAS:CURR:TYPE?')
17. print ('Current LCA Measurement: ' + myLCA.read())
18.
19. #Setup LCA Measurement Parameters
20. myLCA.write(':PAR:MEAS:MODE diff')
21. myLCA.write(':PAR:MEAS:MODE?')
22. print ('Meas Mode: ' + myLCA.read())
23. myLCA.write(':PAR:WAV 1310')
24. myLCA.write(':PAR:WAV?')
25. print ('Wavelength: ' + myLCA.read())
26. myLCA.write(':PAR:OPT:OUT:POW -2')
27. myLCA.write(':PAR:OPT:OUT:POW?')
28. print ('Optical Power: ' + myLCA.read())
29. myLCA.write(':PAR:MODU:BIAS:MODE ever')
30. myLCA.write(':PAR:MODU:BIAS:MODE?')
31. print ('Modulator Optimization: ' + myLCA.read())
32. myLCA.write(':RF:POW:FWD -10')
33. myLCA.write(':RF:POW:FWD?')
34. print ('RF Power: ' + myLCA.read())
35.
36. #Init OE Measurement
37. myLCA.write(':MEAS:INIT:OE')
38. print ('Init OE InProgress')
39. myLCA.write(':MEAS:CURR:TYPE?')
40. mode = myLCA.read()
41. while (mode != 'OE'):
42. myLCA.write(':MEAS:CURR:TYPE?')
43. mode = myLCA.read()
44. print(mode)
45. time.sleep(1)
46. print ('Current LCA Measurement: ' + mode)
47.
48. #Perform Measurement
49. myLCA.write(':MEAS:STAR sing')
50. sweep_comp = 0
51. while (sweep_comp == 0):
52. myLCA.write('*OPC?')
53. sweep_comp = int(myLCA.read())
54. time.sleep(1)
55. print ('Sweep Compete')
56.
57. #Query LCA Errors
58. err_num = 1
59. while (err_num != 0):
60. myLCA.write(':SYST:ERR?')
61. err_LCA = myLCA.read()
62. print('Sweep LCA_err: ' + err_LCA)
63. err_LCA = err_LCA.split(',')
64. err_num = int(err_LCA[0])
Page 15
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
http://literature.cdn.keysight.com/litweb/pdf/5989-7808EN.pdf
[2] Instrument Control using Direct IO vs. Drivers
http://literature.cdn.keysight.com/litweb/pdf/5989-1414EN.pdf?id=638991
[3] PNA On-Line Help File
http://na.support.keysight.com/pna/help/latest/help.htm
[4] ENA On-Line Help File
http://ena.support.keysight.com/e5071c/manuals/webhelp/eng/
[5] N437x LCA Programming Manual
http://literature.cdn.keysight.com/litweb/pdf/437XB-90A01.pdf
[6] N4374B LCA User Guide
http://literature.cdn.keysight.com/litweb/pdf/4374B-90A02.pdf
[7] N4375D LCA User Guide
http://literature.cdn.keysight.com/litweb/pdf/4375D-90A02.pdf
[8] N4376D LCA User Guide
http://literature.cdn.keysight.com/litweb/pdf/4376D-90B01.pdf
[9] N4373D LCA User Guide
http://literature.cdn.keysight.com/litweb/pdf/4373D-90A02.pdf
Page 16
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. import visa
3. import time
4. import numpy as np
5. import matplotlib.pyplot as plt
6.
7. # define VNA_LCA Functions
8.
9. def recall_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())
14.
15. def get_data_VNA(my_INST, mytrace):
16. #get_VNA Data
17. if my_INST == 'PNA':
18. #Define trace data transfer as ASCII
19. myVNA.write(':FORMAT ASC')
20. myVNA.write(':FORMAT?')
21. print('Data Xfer Format: ' + myVNA.read())
22. #Select Measurement Data using trace number
23. myVNA.write('CALC1:PAR:MNUM ' + str(int(mytrace)))
24. #Query data as formatted - FDATA
25. #Query data in complex format - SDATA
26. myVNA.write('CALC1:DATA? FDATA')
27. myydata = myVNA.read()
28. return myydata
29. elif my_INST == 'ENA':
30. #Define return trace format
31. myVNA.write(':FORM:DATA ASC')
32. myVNA.write(':FORM:DATA?')
33. print('Data Xfer Format: ' + myVNA.read())
34. #Query data as formatted - FDATA
35. #Query data in complex format - SDATA
36. #Note on FDATA:
37. #Array returned for ENA formatted data will have 2x the number of
38. #points in the returned array. The data points of interest are
39. #at the odd elements (i.e. n*2-2 where n = 1 to number of points)
40. myVNA.write(':CALC1:TRAC'+str(int(mytrace))+':DATA:FDAT?')
41. myydata = myVNA.read()
42. return myydata
43.
44. def save_csv_VNA(my_INST, mytrace, myfile):
45. #Save VNA Data
46. if my_INST == 'PNA':
47. #Format command to save PNA Data
48. command = "'" + myfile + 'TR' + str(mytrace) + '.csv' + "'" + ','
49. command = command + "'" + 'CSV Formatted Data' + "'" + ','
50. command = command + "'" + 'Trace' + "'" + ','
51. command = command + "'" + 'Displayed' + "'" + ',' + str(mytrace)
52. command = 'MMEM:STORe:DATA ' + command
53. myVNA.write(command)
54. myVNA.write('*OPC?')
55. print ('PNA trace save complete: ' + myVNA.read())
56. elif my_INST == 'ENA':
57. myVNA.write('CALC1:PAR'+str(mytrace)+':SEL')
58. #Format command to save ENA Data
59. command = ':MMEMory:STORe:FDATa ' + "'" + myfile
60. command = command + 'TR' + str(mytrace) + '.csv' + "'"
61. myVNA.write(command)
Page 20
20 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
62. myVNA.write('*OPC?')
63. print ('ENA trace save complete: ' + myVNA.read())
64.
65. def get_err_VNA():
66. #query VNA Errors
67. myVNA.write(':SYST:ERR?')
68. myVNAerr = myVNA.read()
69. return myVNAerr
70.
71. def set_LCA_OE(mymeas, mywave, myopt_pow, mymod_opt, myrf_pow):
72. #set_LCA_OE Code
73. myLCA.write(':PAR:MEAS:MODE ' + mymeas)
74. myLCA.write(':PAR:MEAS:MODE?')
75. print ('Meas Mode: ' + myLCA.read())
76. myLCA.write(':PAR:WAV ' + mywave)
77. myLCA.write(':PAR:WAV?')
78. print ('Wavelength: ' + myLCA.read())
79. myLCA.write(':PAR:OPT:OUT:POW ' + myopt_pow)
80. myLCA.write(':PAR:OPT:OUT:POW?')
81. print ('Optical Power: ' + myLCA.read())
82. myLCA.write(':PAR:MODU:BIAS:MODE ' + mymod_opt)
83. myLCA.write(':PAR:MODU:BIAS:MODE?')
84. print ('Modulator Optimization: ' + myLCA.read())
85. myLCA.write(':RF:POW:FWD ' + myrf_pow)
86. myLCA.write(':RF:POW:FWD?')
87. print ('RF Power: ' + myLCA.read())
88.
89. def init_LCA_EE():
90. myLCA.write(':MEAS:INIT:EE')
91. print ('Init EE InProgress')
92. myLCA.write(':MEAS:CURR:TYPE?')
93. mode = myLCA.read()
94. while (mode != 'EE'):
95. myLCA.write(':MEAS:CURR:TYPE?')
96. mode = myLCA.read()
97. print(mode)
98. time.sleep(1)
99. myLCA.write(':MEAS:CURR:TYPE?')
100. print ('Current LCA Measurement: ' + myLCA.read())
101.
102. def init_LCA_OE():
103. myLCA.write(':MEAS:INIT:OE')
104. print ('Init OE InProgress')
105. myLCA.write(':MEAS:CURR:TYPE?')
106. mode = myLCA.read()
107. while (mode != 'OE'):
108. myLCA.write(':MEAS:CURR:TYPE?')
109. mode = myLCA.read()
110. print(mode)
111. time.sleep(1)
112. print ('Current LCA Measurement: ' + mode)
113.
114. def meas_LCA(mysweep):
115. #perform measurement
116. myLCA.write(':MEAS:STAR ' + mysweep)
117. sweep_comp = 0
118. while (sweep_comp == 0):
119. myLCA.write('*OPC?')
120. sweep_comp = int(myLCA.read())
121. time.sleep(1)
122. print ('Sweep Compete')
Page 21
21 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
123.
124. def get_err_LCA():
125. #query LCA errors
126. myLCA.write(':SYST:ERR?')
127. myLCAerr = myLCA.read()
128. return myLCAerr
129.
130. #define if using ENA or PNA
131. inst_VNA = 'PNA'
132.
133. #Define VISA address for VNA and LCA
134. if inst_VNA == 'PNA':
135. my_visa_VNA = 'TCPIP0::10.112.87.152::5025::SOCKET' #PNA
136. elif inst_VNA == 'ENA':
137. my_visa_VNA = 'TCPIP0::156.140.157.99::inst0::INSTR' #ENA
138.
139. my_visa_LCA = 'TCPIP0::10.112.87.152::5026::SOCKET'
140.
141. #Define VNA Variables
142. ecal_VNA = "'C:\\Users\\Public\\VNA_test.csa'" #PNA
143. #ecal_VNA = "'C:\\Users\\Public\\VNA_test.sta'" #ENA
144. file_csv = 'C:\\Users\\Public\\LCA_'
145.
146. #Define LCA Variables
147. meas = 'diff'
148. wave = '1310'
149. opt_pow = '-2'
150. mod_opt = 'ever'
151. rf_pow = '-10'
152.
153. try:
154. #Open Connection to VNA and LCA
155. rm = visa.ResourceManager('C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\ag
visa\\agbin\\visa32.dll')
156. #Connect to VISA Address
157. #LAN - SOCKET Connection: 'TCPIP0::xxx.xxx.xxx.xxx::5025::SOCKET'
158. #LAN - HiSLIP Connection: 'TCPIP0::xxx.xxx.xxx.xxx::hislip0::INSTR'
159. #USB Connection: 'USB0::xxxxxx::xxxxxx::xxxxxxxxxx::0::INSTR'
160. #GPIB Connection: 'GPIP0::xx::INSTR'
161.
162. myVNA = rm.open_resource(my_visa_VNA)
163. myLCA = rm.open_resource(my_visa_LCA)
164.
165. #Define terminations for SOCKET connection
166. myVNA.send_end = True;
167. myVNA.term_char = True;
168. myVNA.read_termination = '\n'
169. myVNA.write_termination = '\n'
170.
171. myLCA.send_end = True;
172. myLCA.term_char = True;
173. myLCA.read_termination = '\n'
174. myLCA.write_termination = '\n'
175.
176. #Set timeout - 5 seconds
177. myVNA.timeout = 5000
178. myLCA.timeout = 5000
179.
180. #*IDN? - Query Instrumnet ID
181. myVNA.write('*CLS')
182. myVNA.write('*IDN?')
Page 22
22 | Keysight | N437x Lightwave Component Analyzer Automation – Getting Started with SCPI - Application Note
183. print ('VNA ID: ' + myVNA.read())
184.
185. myLCA.write('*CLS')
186. myLCA.write('*IDN?')
187. print ('LCA ID: ' + myLCA.read())
188.
189. #Preset VNA
190. myVNA.write(':SYST:PRES')
191. myVNA.write('*OPC?')
192. print ('VNA Reset Complete: ' + myVNA.read())
193.
194. #Preset LCA to EE Mode
195. init_LCA_EE()
196.
197. #Recall VNA State
198. recall_state_VNA(ecal_VNA)
199.
200. #Setup LCA
201. set_LCA_OE(meas, wave, opt_pow, mod_opt, rf_pow)
202.
203. #Query for LCA Errors
204. err_num = 1
205. while (err_num != 0):
206. err_LCA = get_err_LCA()
207. print('Set LCA_err: ' + err_LCA)
208. err_LCA = err_LCA.split(',')
209. err_num = int(err_LCA[0])
210.
211. #Init OE
212. init_LCA_OE()
213.
214. #Query for LCA Errors
215. #LCA Errors
216. err_num = 1
217. while (err_num != 0):
218. err_LCA = get_err_LCA()
219. print('Init LCA_err: ' + err_LCA)
220. err_LCA = err_LCA.split(',')
221. err_num = int(err_LCA[0])
222.
223. #Perform OE Measurement
224. sweep = 'sing'
225. meas_LCA(sweep)
226.
227. #Query for LCA Errors
228. #LCA Errors
229. err_num = 1
230. while (err_num != 0):
231. err_LCA = get_err_LCA()
232. print('Sweep LCA_err: ' + err_LCA)
233. err_LCA = err_LCA.split(',')
234. err_num = int(err_LCA[0])
235.
236. #Query VNA Trace Count and Trace Names
237. if inst_VNA == 'PNA':
238. #Query currently defined measurements
239. myVNA.write('DISP:WIND1:CAT?')
240. trace = myVNA.read()
241. trace = trace.split(',')
242. trace_count = len(trace)
243. elif inst_VNA == 'ENA':
Page 23
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.
http://www.keysight.com/find/emt_product_registration
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—one­stop 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:
www.keysight.com/find/contactus
Americas
Canada (877) 894 4414 Brazil 55 11 3351 7010 Mexico 001 800 254 2440 United States (800) 829 4444
Asia Pacific
Australia 1 800 629 485 China 800 810 0189 Hong Kong 800 938 693 India 1 800 11 2626 Japan 0120 (421) 345 Korea 080 769 0800 Malaysia 1 800 888 848 Singapore 1 800 375 8100 Taiwan 0800 047 866 Other AP Countries (65) 6375 8100
Europe & Middle East
Austria 0800 001122 Belgium 0800 58580 Finland 0800 523252 France 0805 980333 Germany 0800 6270999 Ireland 1800 832700 Israel 1 809 343051 Italy 800 599100 Luxembourg +32 800 58580 Netherlands 0800 0233200 Russia 8800 5009286 Spain 800 000154 Sweden 0200 882255 Switzerland 0800 805353
Opt. 1 (DE) Opt. 2 (FR) Opt. 3 (IT)
United Kingdom 0800 0260637
For other unlisted countries:
www.keysight.com/find/contactus
(BP-9-7-17)
DEKRA Certified
ISO9001 Quality Management System
www.keysight.com/go/quality
Keysight Technologies, Inc. DEKRA Certified ISO 9001:2015 Quality Management System
This information is subject to change without notice. © Keysight Technologies, 2017 Published in USA, December 1, 2017 5992-2126EN
www.keysight.com
Loading...