User manual

Table Of Contents
Part 2: Automation Programming Reference
Program
Note: Characters in angle brackets are placeholders. Omit the brackets from your code.
Connect to the Oscilloscope
In your text editor, write these lines to make the remote connection to VISA and to the oscilloscope:
import visa
rm = visa.ResourceManager()
lecroy = rm.open_resource("TCPIP0::<hostname|IP address>::INSTR")
lecroy.timeout = 5000
lecroy.clear()
If your oscilloscope and PC are both known to the same network name server, you can use the hostname
syntax (e.g., "TCPIP0::LCRY0450N70355::INSTR") instead of the actual IP address.
The timeout of 5000 milliseconds ensures the oscilloscope will wait 5000 milliseconds for operations to
complete whenever writing commands or reading responses. Reading continues until the entire response
is received (EOI is reached) or for 5 full seconds. After 5 seconds, there will be a "time out" error.
The clear is intended to clear out the buffers on the oscilloscope listing the commands sent to it and also
responses sent from it. Clear removes anything leftover from a previous use and is a good practice as a
first step in any program.
Several other preliminary settings can be made to prepare the general oscilloscope "environment" prior to
writing new setups or reading measurements. In your program, type:
lecroy.write("COMM_HEADER OFF")
lecroy.write(r"""vbs 'app.settodefaultsetup' """)
The command "COMM_HEADER OFF" is a legacy 488.2 command that tells the oscilloscope "don't return
the command header with query result." This helps to read back values in a format that is more friendly to
being viewed on screen or imported into other programs.
Recalling the default setup, while not required, ensures that all setups are at a known baseline value before
you begin.
Notice that the method 'app.settodefaultsetup' is the first actual Automation command being passed to
the oscilloscope. It is enclosed in the VBS command wrapper, as are all Automation commands sent by
remote connection, rather than through a COM/DCOM connection.
Note: The three double-quotes around the VBS command are required because the double-quotes
around the arguments within the command could be interpreted by Python as the end of the
command string. You would probably create a function to put the VBS wrapper around whatever
automation commands you wanted to send. Here, we're showing each full line of code for
demonstration.
2-21