TSP and Scripting for Programmable Instruments
Programmable instruments have been available in one form or another for many years. Although specific capabilities vary, a programmable instrument allows the user to create and store a set of instructions (a program) in the instrument itself, where it can be executed on demand. Early programmable instruments generally had quite limited capability and capacity, which restricted the usefulness of the programmability to relatively small and simple applications. Larger or more complex applications required the use of a separate computer or controller, which controlled the instrument via a communications interface, often GPIB.

Improvements in computing technology and programming languages and the steadily declining cost of embedded computing capacity have led to a new generation of programmable instruments. This new breed of instruments breaks through the old limits to provide greatly increased capability and flexibility. One key improvement realized in these instruments is the use of a scripting language to provide programmability.

What is scripting?

Simply put, scripting is writing programs in a scripting language to coordinate a sequence of actions.

Scripting goes well beyond the more conventional use of macros or recorded sequences. It employs the full power of a scripting language, which includes looping, branching, and data processing. Although macros can be repeated in a way that provides rudimentary looping control, scripting offers a full run-time environment in which values can be stored in variables. These variables can then be used to control both looping and branching decisions.

The main difference between a scripting language and other programming languages is that script programs do not need to be precompiled before being run. Scripting environments will either interpret the program directly or compile it automatically when needed. Beyond that, scripting languages offer the full power of a programming language. This includes storing values in variables and creating stored procedures (functions) for code reuse.

A script need not be compiled as a separate step, so scripting languages are well suited for embedded use in test and measurement equipment. Scripts can be downloaded to the instrument without the need for extra preparation steps for greater user convenience.

One key difference between a scripting language running on a PC and a scripting language embedded in an instrument is the environment. When running on a PC, the scripting language generally has access to a file system, virtually unlimited memory, and a graphical display, as well as a keyboard and mouse. When running on an instrument, a scripting language does not necessarily have access to any of these amenities, but they are generally not needed.

Scripting in instrumentation

Popular scripting languages include Perl®, Python®, VBScript®, and JavaScript®. The Lua scripting language is particularly well suited for embedded use because it executes faster than most other scripting languages and is implemented as a library that takes very little code space. Keithley Instruments chose Lua for its Test Script Processor (TSP) enabled line of instruments.

When adding scripting support to test and measurement instrumentation, one of the most difficult choices to make is how to present the scripting to the user. This includes answering tough questions such as: “How do I integrate the instrument command set with the scripting environment?” “How will the user load scripts into the instrument?” Keithley chose to integrate the scripting environment fully with the command set, which means that all instrument commands are also fully legal Lua statements. Essentially, each command message sent to the instrument is executed as a Lua program.

This choice makes it easy for the user to transition from controlling an instrument with single commands to using scripts because there’s no need to learn a whole new command set. Commands that can be sent to the instrument over a GPIB or LXI interface are the same as the ones used within a script. This greatly simplifies the process of migrating from simple command-based control to script-based control. The user can simply send larger scripts to the instrument instead of individual commands.

Explore these TSP and test scripting resources:

Application Notes
  Demos, Product
  Tours, and Web Seminars
  White Paper
  Articles
  Software and Example Scripts
 
 
LXI Overview
The LXI (LAN eXtensions for Instrumentation) Standard for Test and Measurement, the LAN-based successor to GPIB, combines the advantages of Ethernet with the simplicity and familiarity of GPIB.

Introduced in 2005, the LXI Standard has been rapidly adopted by a growing list of test and measurement companies as a logical replacement for the General Purpose Interface Bus (GPIB) to make it easier for test system designers and integrators to create faster, more efficient systems. As the LXI Consortium’s website (www.lxistandard.org) makes clear, LXI reduces the time needed to set up, configure and debug test systems, providing a variety of distinct advantages over GPIB-based systems:
  • The speed, simplicity, worldwide reach, low cost, ongoing enhancement and backward compatibility of LAN.
  • Quick, easy configuration through the intuitive web interface built into compliant instruments.
  • Simplified programming and greater software reuse through IVI drivers.
  • The ability to create hybrid systems that include LXI, GPIB, VXI, PXI, CANbus, etc.
  • Enhanced system performance and event handling via hardware- and LAN-based triggering modes.
  • Synchronization of local and remote instruments through the IEEE 1588 precision time protocol.

LXI and scripting

The current LXI standards for instrumentation do not require that instruments be programmable or implement scripting. However, several features in the LXI specification anticipate programmable instruments and provide useful functionality that enhances scripting’s capabilities on LXI conformant instruments..

The LXI specification requires Class A and B instruments to support peer-to- peer messaging via LAN messages, and it permits Class C instruments to support it. LAN messages can be used to notify other LXI instruments of events or to trigger another instrument to perform some function. Users must be able to specify what action is performed upon receipt of a LAN message. The most flexible way to implement this, and the way recommended by the LXI specification, is to allow the user to download executable code (i.e., a script or program) into the instrument, which is then executed upon receipt of the appropriate LAN message. This provides a great deal of flexibility because the user is not constrained to a predefined set of actions.

Furthermore, the LAN message format defined by LXI includes a small space for including arbitrary data as part of the message. It is feasible to transfer executable code, such as a short script, as part of the LAN message. This would allow one instrument to control another via LAN messages without pre-programming the response. For example, suppose an instrument performs a measurement on a device under test (DUT). Based on the result of that measurement, it must change a stimulus applied to the DUT by another instrument. The new stimulus value is calculated based on the first measurement, so it not known in advance. In this case, the first instrument could send a LAN message containing a short script to the second instrument to adjust the stimulus value.

To learn more about LXI, explore these resources:

Useful Links
  White Paper
  Articles
 
 
TSP- and LXI-Related Products
Scripting is a powerful and convenient way to provide programmability for instruments in test and measurement applications. Script-based instruments like those with TSP capabilities provide architectural flexibility, improved performance, and lower cost for many applications. Scripting enhances the benefits provided by LXI instruments, and LXI provides features that both enable and enhance scripting. Users comfortable with conventional instruments will find it easy and straightforward to begin using script-based instruments. If so desired, they can be programmed in much the same way as conventional instruments are. However, with minor adjustments to system design and programming, the flexibility, improved performance, and other benefits of scripting are easy to incorporate into system configurations.

To learn more about TSP- and LXI-based instrumentation:

  TSP-Based Instruments
Data Sheet
  Demos, Product Tours, and Web Seminars
  LXI-Based Instruments
  Data Sheets
  Demos, Product Tours, and Web Seminars
  Instruments that combine TSP and LXI Technologies
  Data Sheet
  Demos, Product Tours, and Web Seminars