Section 14: Instrument programming
Fundamentals of programming for TSP
To conduct a test, a computer (controller) is programmed to send sequences of commands to an
instrument. The controller orchestrates the actions of the instrumentation. The controller is typically
programmed to request measurement results from the instrumentation and make test sequence
decisions based on those measurements.
To use the advanced features of the instrument, you can add programming commands to your scripts.
Programming commands control script execution and provide tools such as variables, functions,
branching, and loop control.
The Test Script Processor (TSP
the Lua programming language has been extended with Keithley-specific instrument
control commands.
What is Lua?
Lua is a programming language that can be used with TSP-enabled instruments. Lua is an efficient
language with simple syntax that is easy to learn.
Lua is also a scripting language, which means that scripts are compiled and run when they are sent to
the instrument. You do not compile them before sending them to the instrument.
Lua basics
This section contains the basics about the Lua programming language to allow you to start adding
Lua programming commands to your scripts quickly.
For more information about Lua, see the
is the
Lua users group
Comments
You can start a comment anywhere outside a string by typing a double hyphen (--). If the text
immediately after -- is anything other than double left brackets ([[), the comment is a short
comment, which continues until the end of the line.
If -- is followed by [[, the following characters are a long comment, which continues until double
right brackets (]]) close the comment. Long comments may continue for several lines and may
contain nested [[ . . . ]] pairs. The example below shows how to use code comments.
An example of a short comment is:
-- Turn off the virtual front-panel display.
An example of a long comment is:
--[[Display a menu with three menu items. If the second menu item is selected,
the selection is given the value Test2.]]
14-14
Model 2606B System SourceMeter® Instrument Reference Manual
®
) scripting engine is a Lua interpreter. In TSP-enabled instruments,
Lua website
(lua-users.org), created for and by users of Lua programming language.
(lua.org). Another source of useful information
2606B-901-01 Rev. C November 2021
Need help?
Do you have a question about the KEITHLEY SourceMeter 2606B and is the answer not in the manual?