Customized software solutions for any measurement

Macro programming for Shimadzu UV-Vis and FTIR

The data output of spectro­photometers has come a long way since the time of mechanical writers. Today, the user gets a full-blown software suite with lots of different measurement options and integrated data processing. While the specifications – such as scan speed, signal-to-noise ratio or resolution – are still improving gradually with each new instrument, the software included has become an equally important selling point.

Even though LabSolutions IR and UV already offer a wide variety of tools, there are cases which demand a custom solution to a very specific problem. Whereas one customer might require a simplified user interface and automated analyses to support the company’s technicians in their daily routine, a different client might be bound to a very specialized data processing which is not common enough to be implemented into the LabSolutions software.

Such requests are served by customized software or macros. Shimadzu offers different tools depending on the complexity of the task. This article gives a brief overview of the possibilities of controlling Shimadzu FTIR and UV-Vis instruments by a custo­mized software.

FTIR – Easy Macro

The starting point for most FTIR macros is the Easy Macro tool included in LabSolutions IR. It allows users to automate usual analysis by ‘drag and drop’ of easy to understand building blocks, such as “Sample Scan”, “Smoothing” or “Spectrum Search.” Customized messages can be shown between the steps, e.g. telling the user to set the sample or clean the ATR. Figure 1 gives an example of an Easy Macro.

Figure 1: Example of an Easy Macro for a simple measurement with pre-defined measurement parameters

Figure 2: Execute macro window. The LabSolutions IR program used for the easy macro is run in the background. The macro execution can be stopped at any step.

In this example, the spectrum software is used. It is started in step 1, then the instrument is initialized in step 2 and the scan parameters are set in step 3. When the macro is run, the spectrum software opens in the background; without the command “Scan Parameters”, it will just use the last set parameters. Steps 4 and 5 first measure the background, and then the sample. The sample and file name can be defined by the macro, but in this example a prompt will be shown to allow the user to enter sample and file name. Each Easy Macro must start with the command “Program Start” and end with the command “Program End.”

Easy Macro provides the benefit that even users without any knowledge of programming can develop such a macro. Because of the pre-defined building blocks, syntax errors and malicious code are prevented. The user can see in the execute window if an Easy Macro tries loading a potentially malicious basic file, and prevent the execution.

Most operators meet Easy Macro by the validation functions included with their Shimadzu FTIR, which are started by such macros. Each building block of the Easy Macro generates visual basic code which is interpreted by LabSolutions IR.

FTIR – Visual Basic (VB) macro

The visual basic code behind such an Easy Macro can be extracted and used as the basis for more complex Lab Solutions VB macros, like the IR Pilot included with the Shimadzu IRSpirit, shown in figure 3.

Figure 3: User interface of the IRPilot

The visual basic macro editor included in LabSolutions IR offers a full development environment for the trained specialist. Finalized macros are either added to the toolbar of LabSolutions IR Post­run or Spectrum, or they are started by the “Load Basic File” command of Easy Macro. Figure 4 shows a screenshot from the LabSolutions IR VB macro editor with the code for the “Initialize” building block from Easy Macro.

Figure 4: The initialize command from Easy Macro as visual basic source code

UV – Automatic Control

In the world of LabSolutions UV-Vis, there is no counterpart for Easy Macro, since LabSolutions UV-Vis already offers a high degree of automation – e.g. for text export, postrun calculations or spectrum evaluation. But it is possible to further automate LabSolutions UV-Vis and connect it to customized software by the Automatic Control option. A typical application for this option is the communication between LabSolutions UV-Vis and an autosampler software.

Figure 5: Schematic of the communication between LabSolutions UV-Vis and a host system by the Automatic Control option

The scripts use commands similar to the building blocks of LabSolutions FTIR Easy Macro. Text files with these commands are placed in a special folder which is scanned continuously by LabSolutions UV-Vis. LabSolutions reads the commands from “command” text files and writes the result into “response” text files.

The syntax of these commands is easy to understand, and the only prerequisite of the programming environment is to be able to read and write text files. As the user rights and audit trail settings of LabSolutions DB are not circumvented by such scripts, LabSolutions UV-Vis Automatic Control can be used even in a validated environment. A bi-direct­ional communication between LabSolutions UV-Vis and a third-party lab management system is possible by writing command files for the LabSolutions UV-Vis Automatic Control Option and then reading the text or pdf report generated after each measurement.

Figure 6: Autosampler control as example for a LabSolutions UV Automatic Control application

UV – string commands

The most accessible way to read out data from UV-Vis instruments by customized software is with the external commands documented in the instruction manuals of UV-1280 and UV-1900i. They are also known as string commands, because the communication is established by simple ASCII strings sent over a virtual COM port. These commands are typically used in customized Excel-macros with instrument control or to program drivers for software with control of instruments from multiple vendors. Example code for the implementation in Microsoft Visual Basic 2015 is given in the manual along with the required settings of the virtual com port, but a much deeper understanding of interface programming is required compared to developing software with the LabSolutions Automatic Control.

Figure 7: Excel-Macro for Bilirubin in Spinal Fluid as typical customized application using string-commands

UV – OCX commands

Another possibility for direct instrument control is given by the option UV-OCX. Here, an Active X control is used to translate commands written in a VBA or Microsoft.net Framework source code into machine code for the spectrophotometer. It is possible to control UV-1280, UV-1900i, UV-2600i and UV-2700i.

Figure 8: Simple instrument control window in a VBA form made with UV-OCX

Figure 9: UV-OCX instrument control embedded directly in an Excel sheet

Compared to string commands, programming with OCX commands requires less understanding of interfaces, as the communication with the instrument is done by the OCX control and communication errors (such as setting impossible wavelength values) are prevented by this interface. The UV-OCX is implemented as a class with pre-defined methods and parameters. This spares one step compared to the string commands, where the programmers must write their own class to translate between e.g. VBA code and ASCII-strings.

When a programming environment such as Microsoft Visual Studio or the Microsoft Excel VBA editor is used, the UV-OCX even implements helpful functions, e.g. intelligent code completion, to prevent syntax errors.

Figure 10: The optional VisEase software which was developed with UV-OCX

Conclusion

Macro programming is a powerful tool to support customers. Some macros enable applications which are not covered by the standard software, while other macros serve to automate tedious tasks and prevent user errors. The best approach depends not only on the complexity of the application, but also on the experience of the programmer.

Table 1 compares the different tools to program custom software for Shimadzu FTIR, and table 2 shows the tools for Shimadzu UV-Vis spectrophotometers.

Table 1: Comparison of macro tools for Shimadzu FTIR

Table 2: Comparison of macro tools for Shimadzu UV-Vis