Keithley 2651A Reference Manual page 264

High power system sourcemeter instrument
Hide thumbs Also See for 2651A:
Table of Contents

Advertisement

Section 6: Instrument programming
Create functions using scripts
You can use scripts to define functions. Scripts that define a function are like any other script: They
do not cause any action to be performed on the instrument until they are executed. The global
variable of the function does not exist until the script that created the function is executed.
A script can consist of one or more functions. Once a script has been run, the computer can call
functions that are in the script directly.
The following steps use TSB Embedded. You can also use the loadscript and endscript
commands to create the script. See
(on page 6-4).
Steps to create a function using a script
Steps
1. In TSB Embedded, enter a name into the
TSP Script box
2. Enter the function as the body of the script
3. Click Save Script
4. Run the script as a function
5. Run the new function with a value
Group commands using the function keyword
The following script contains instrument commands that display the name of the person that is using
the script on the front panel of the instrument. It takes one parameter to represent this name. When
this script is run, the function is loaded in memory. Once loaded into memory, you can call the
function outside of the script to execute it.
When calling the function, you must specify a string for the name argument of the function. For
example, to set the name to John, call the function as follows:
myDisplay("John")
6-20
Model 2651A High Power System SourceMeter® Instrument Reference Manual
NOTE
Load a script by sending commands over the remote interface
Example
MakeMyFunction
This example concatenates two strings:
MyFunction = function (who)
print("Hello " .. who)
end
MakeMyFunction now exists on the instrument
in a global variable with the same name as the
script (MakeMyFunction). However, the function
defined in the script does not yet exist because
the script has not been executed.
MakeMyFunction()
This instructs the instrument to run the script,
which creates the MyFunction global variable
(which is also a function).
MyFunction("world")
The response message is:
Hello world
2651A-901-01 Rev. A / March 2011

Advertisement

Table of Contents
loading

Table of Contents