Part I: What is a script?
Programmable instruments have existed in one form or another for many years. While specific functionality varies, programmable instruments allow the user to create and store a set of instructions (or program) in the instrument and run the instructions on demand. Typically, early programmable instruments had very limited capabilities and capacity, which limited the use of programmability to relatively small and simple applications. Larger or more complex applications require the use of a separate computer or controller to control the programmable instrument through a communications interface (usually GPIB).
Advances in computing technology and programming languages, along with the steadily decreasing cost of embedded computing capacity, have led to a new generation of programmable instruments. New instruments break through old limitations and offer greatly increased performance and flexibility. A key advancement in these instruments is the use of scripting languages to provide programmability. This article provides a detailed introduction to scripting and how to use it to simplify and speed up test and measurement.
So what is a script? What is the difference between a test instrument script and a PC script?
Simply put, a script is a program written in a scripting language to manage a series of actions.
Scripts are far superior to the commonly used macros or recorded sequences. Scripts take full advantage of the scripting language, including loops, jumps, and data processing. While macros can be repeated with basic loop control methods, scripts provide a full execution environment where values can be stored in variables. These variables can then be used to control loops and jump decisions.
The main difference between scripting languages and other programming languages is that there is no need to precompile the script program before running it. If necessary, the script environment can directly interrupt the program or automatically compile the program. In addition, scripting languages also have all the capabilities of programming languages, including storing variable values and creating stored procedures (functions) for code reuse.
Since scripts do not need to be compiled separately, scripting languages are well suited for embedded applications in test and measurement equipment. Scripts can be downloaded to the instrument, providing users with more convenience without the need for additional preparation.
The key difference between a scripting language running on a PC and a scripting language embedded in an instrument is the environment. When a scripting language runs on a PC, it usually has access to a file system, nearly unlimited memory, a graphics display, and a keyboard and mouse. When a scripting language runs on an instrument, it does not have to access any of these devices, but they usually do not need to.
We will have a detailed introduction to the scripts in the measuring instrument tomorrow, so stay tuned!
Part II: Scripts used in measuring instruments
Popular scripting languages include Perl, Python, VBScript, and JavaScript. The Lua scripting language is particularly well suited for embedded applications because it runs faster than most other scripting languages and is implemented as a library that takes up very little code space. Keithley selected Lua for its family of instruments that support the Test Script Processor (TSP).
When adding scripting support to test and measurement instruments, what is the most difficult choice? Yes, how to introduce scripting to users!
This difficulty includes answering difficult questions such as: "How do you integrate the instrument command set and the scripting environment?" and "How do users load scripts into the instrument?" Keithley chose to fully integrate the scripting environment and the command set, which means that all instrument commands are completely legal Lua statements. Basically, every command message sent to the instrument is executed as a Lua program.
This option makes it easy for users to transition from controlling instruments with single commands to controlling instruments with scripts because there is no need to learn an entire new command set. Commands can be sent to instruments over the GPIB or LXI interface, the same commands used in scripts. This greatly simplifies the transition from simple command-based control to script-based control. Users can simply send larger scripts to instruments instead of individual commands.
Let's use code to illustrate this:
Case Study
The disadvantage of this choice is that the instrument commands may be a little unfamiliar to a first-time user. Some examples will help illustrate this disadvantage. These examples compare the Keithley Model 2400 SourceMeter Instrument (a SCPI-based unit) and the Keithley Model 2602 Dual-Channel SourceMeter Instrument (a TSP-based unit).
The command to source the 2400 to output current is:
::SOUR:FUNC CURR
The corresponding command for the 2602 is:
smua.source.func = smua.DC_AMPS
The smua prefix specifies channel A of the 2602 dual channel instrument. The rest of the command is similar to the SCPI command except for the equal sign. This is a Lua assignment operation that sets the mua.source.func property to the value of smua.DC_AMPS.
The query command is a little unfamiliar. Because the command is a valid Lua statement, the print function is used to produce the output. The SCPI query returns the source function of the 2400: :
SOUR:FUNC?
The corresponding command for the 2602 is:
print(smua.source.func)
Just as SCPI instruments support compound commands by separating individual commands with semicolons, script-based instruments can also support compound commands by separating commands with statement delimiters. In Lua, the statement delimiter is the whitespace character.
Let's assume that our instrument has been configured to source voltage. For the 2400, the following command message will set the output level and then turn the output on:
:SOUR:VOLT 1.0; :OUTP 1
For the 2602, the corresponding command message is:
smua.source.levelv = 1.0 smua.source.output = 1
The above example shows that scripted instruments can behave very similarly to traditional devices. Only the command syntax has changed slightly. In order to utilize the full power of the scripting engine, the user only needs to send messages to use the scripting language functions.
Part III Script Case Analysis and LXI in Instrument Testing
Today we will introduce some examples and experiences in actual operation, and introduce LXI and scripts.
By sending the following script, the user can let the instrument perform a binary search to search for a voltage source that can output 1mA current:
The benefit of such a script is that it avoids the communication time required to read each result and send instructions to output the new level. While it is reasonable to ask how long it takes to send a longer message, it is usually much faster to send one long message than to communicate many shorter messages back and forth. However, one advantage of a scripting environment is that the above code can be encapsulated as a function definition and then reused, avoiding the long message sending altogether. For example:
The previous command will not cause the instrument to execute immediately, but it creates a stored procedure named "Search", which can be called later with the search command:
Search(2.5, 0.001)
Instruments have features that complement scripting engines. If the scripting environment provides programmatic access to the instrument's front panel, users can create interactive scripts that prompt the user to enter parameters or display results on the front panel. Instruments can also provide nonvolatile on-board script storage so that these stored scripts can be automatically executed when the instrument is powered on. This allows pre-loaded applications to be executed without any user action other than turning on the power to the instrument.
Embedded scripting offers significant advantages to test and measurement instrument users. Although embedded scripting has some minor disadvantages, such as the unfamiliarity of the queries described earlier, most users can easily use or adapt to it.
Scripting languages usually manage memory automatically, so the user does not need to allocate and free storage for strings or matrices. While this is convenient for the user, the scripting engine needs to periodically reclaim memory that is no longer in use, a process called "garbage collection." Although garbage collection can be done automatically, it takes time and can cause problems if it occurs during critical time periods in the test sequence. These problems can be prevented, but first the user must understand the impact of the garbage collector and know how to avoid garbage collection during critical time periods in the test sequence.
Here is an introduction to LXI and scripts
The current LXI standard for test instruments does not require instruments to be programmable or implement scripts. However, many features in the LXI standard anticipate programmable instruments and provide useful functionality to enhance the scripting capabilities of LXI-compliant instruments.
The LXI standard requires Class A and Class B instruments to support peer-to-peer messaging via LAN messages, and allows Class C instruments to support this messaging. LAN messages can be used to notify other LXI instruments of events or to trigger another instrument to perform some function. Upon receiving a LAN message, the user must be able to specify what action to take. To achieve this, the most flexible method and the method recommended by the LXI standard is to allow the user to download executable code (i.e., scripts or programs) into the instrument, which is then executed upon receiving the appropriate LAN message. This provides great flexibility because the user is not limited to a set of predetermined actions.
In addition, the LAN message format defined by LXI contains a small space for including arbitrary data as part of the message. Executable code (such as a short script) can be transmitted as part of the LAN message. This allows one instrument to control another instrument via a LAN message without having to pre-set up a response. For example, assume that one instrument can measure a device under test (DUT). Based on the results of the measurement, the first instrument must be able to change the stimulus applied to the DUT by another instrument. The new stimulus value is calculated based on the first measurement, so it is not known to the first instrument beforehand. In this case, the first instrument can send a LAN message containing a short script to the second instrument to adjust the stimulus value.
Part IV Advantages of Using Scripts in Test and Measurement
The following are the advantages of script-based instrumentation. Many of these advantages are enhanced when the instrumentation is also LXI compliant.
For many test and measurement applications, it is a good idea to use a PC as a controller to communicate with individual instruments or use a slot-based system with an integral controller. But for other cases, those approaches are either too expensive because they are overkill or not up to the task. These applications can benefit from the additional power and flexibility provided by script-based instruments. This section describes the advantages of scripting in test and measurement applications.
1. Structural flexibility
Small test systems with a few instruments can be built without separate controllers; one instrument acts as the controller and manages the work of the other instruments. Large systems can be divided into subsystems containing a few instruments each, where each subsystem is managed by script-based instruments. This simplifies system design and helps improve performance. For example, in assembly lines, scientific applications, or RF test applications, such subsystems can be physically separated to a large extent using LXI script-based instruments.
2. Improve performance
Dividing large systems into subsystems managed by script-based instruments spreads control and data handling functions across multiple processors, increasing the total processing power available to the system and often improving overall speed and throughput. In addition, this division of work supports parallel testing: instruments or subsystems do not have to remain idle while the central controller is busy with other tasks.
Because there is less latency caused by communicating with the controller when transferring commands or data, scripts running on the instrument can run at maximum speed. This is especially important when the instrument is executing a repetitive test sequence. With a single controller, the command sequence must be sent to the instrument for each pass, even if the same sequence is run hundreds or thousands of times. Compare this to the scripting approach, where the script is transmitted only once and can be run as many times as desired using short commands.
Conditional processing (for example, when the result of a measurement determines the next function to execute) provides another means of improving performance. Performing conditional checks locally in the script can remove the delay caused by sending the first result to the controller, waiting for the controller to process it, and then sending the next instruction to the instrument.
In systems involving high data rates and/or large data sets, communication delays, bandwidth limitations, and controller throughput can all be severe bottlenecks. Script-based instruments can compress data to reduce bandwidth requirements and/or buffer data and transmit it in the background when bandwidth is available. Script-based instruments can also filter data, such as by transmitting only data that exceeds normal limits. As mentioned earlier, scripts also reduce the communication bandwidth consumed to send commands from the controller to the instrument, thereby improving performance in bandwidth-limited applications and minimizing delays caused by communication delays.
3. Reduced costs
Building smaller or less complex test systems using script-based instrumentation does not require a separate controller, saving the cost of the controller and the cost of any separate test runner software used to control the instrument. The same cost savings can be achieved when building large test systems when subsystems are built from script-based instrumentation.
Previous article:Design of telerehabilitation information collection system based on fuzzy control
Next article:Combining the advantages of LXI and scripting (Part 2)
- Popular Resources
- Popular amplifiers
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Power amplifier application】 Lamb wave signal analysis based on dry-coupled ultrasonic testing
- Working of LM331
- TUSB1210 and processor cannot communicate
- Spring thunder sounds, and everything starts to grow.
- The modelsim simulation of the shift-add multiplier written in vhdl does not meet expectations
- ESP32 is set as AP. After the client disconnects from WIFI and then reconnects to WIFI, the client socket cannot connect
- How does Anlu FPGA output the clock to ordinary IO?
- Stack reuse in GD32VF103 multi-tasking applications
- [ATmega4809 Curiosity Nano Review] Wifi Controlled Lighting (IoT Led Part 2)
- 10UA current drive