2600AS-901-01 Rev. B / September 2008
Return to
12-3
Series 2600A System SourceMeter® Instruments Reference Manual
Section 12: TSP Fundamentals and Script Management
A global variable can be removed from the environment by assigning it the
nil
value. For
example, the command
x = nil
will remove the global variable
x
from the run-time environment.
When the unit is turned off, the entire run-time environment will be lost.
Queries
TSP-enabled instruments do not have inherent query commands. Like any other scripting
environment the
command and other related
commands are used to generate
output. The
command will create one response message.
An example of generating an output message is the following chunk (two commands) that takes a
measurement and returns its value:
x = smua.measure.v() print(x)
Note that the measurement value is stored in the global variable x between the two commands.
Scripts
When taking advantage of the TSP to perform more complicated sequences of commands,
especially sequences utilizing advanced scripting features such as looping and branching, sending
the entire sequence in one message is very cumbersome. Two special messages can be used to
collect a sequence of command messages together into one chunk.
The
loadscript
message will instruct the TSP-enabled instrument to begin collecting all
subsequent messages rather than executing them immediately. After sending the sequence of
command messages, the
endscript
message is used to instruct the TSP-enabled instrument to
compile the test sequence and make it available to run in a subsequent message. This chunk is
called the “anonymous script.”
The anonymous script can be run at any time by sending the command
script.run()
. The
anonymous script can be run many times without needing to re-send it. Each time the
script.run()
command is given, the anonymous script will be executed.
Sending a new script using the
loadscript
and
endscript
messages will instruct the TSP-
enabled instrument to replace the anonymous script with the new script. While creating and using
scripts this way is a very powerful feature of TSP-enabled instruments, only being able to access
one script at a time in this way would be very limited.
(below) describes how to use
named scripts to store many scripts in the instrument at one time.
Naming scripts
The
loadscript
message can also be used to create named scripts. When the
loadscript
message is used to create a named script, the anonymous script is not replaced with the named
script. Instead, It creates an entry in the
script.user.scripts
table under the name given. In
addition, a global variable with the same name in the run-time environment is created to reference
the script. Because the script is referenced by a global variable, the name of the script must be a
legal TSL variable name.
The name of the script can be specified by including it in the
loadscript
message. The message
loadscript
MyScript
instructs the TSP-enabled instrument to begin gathering command
messages that are used to create a script named
MyScript
. Upon receipt of the
endscript
message, the instrument compiles the script. If there are no errors, the script can be accessed
using the global variable
MyScript
. For example, the script may be executed at any time by
sending the
MyScript()
message.
If a new script is sent with the same name, the previous script becomes an unnamed script. If
there are no other variables referencing the previous script, it is effectively removed. Sending new
scripts with different names will not remove any previously sent scripts. By using named scripts,