1. What Is NI LabVIEW MathScript RT Module?
LabVIEW MathScript RT Module adds math-oriented, textual programming to LabVIEW. MathScript joins graphical programming as another means to define the custom software you develop using LabVIEW. Working with LabVIEW, you can choose a textual approach, a graphical approach, or a combination of the two. You can choose the most effective syntax for algorithm development, whether you are developing algorithms, exploring signal processing concepts, or analyzing results. As we will explore in this paper, the significance of LabVIEW and MathScript lies in this “best of both worlds” approach that it facilitates.
At the heart of LabVIEW MathScript RT Module is a high-level text-based programming language with syntax and functionality (Table 1) that abstracts the complexity of tasks related to signal processing, analysis and math. The LabVIEW MathScript RT Module includes more than 800 built-in functions for such work you can also create your own new user-defined functions.
|LabVIEW MathScript RT Module Feature||Description|
|Powerful Textual Math||LabVIEW MathScript RT Module includes more than 800 built-in functions for math, signal processing and analysis; functions cover areas such as linear algebra, curve fitting, digital filters, differential equations, probability/statistics and much more.|
|Math-oriented data types||LabVIEW MathScript RT Module uses matrices and arrays as fundamental data types, with built-in operators for generating data, accessing elements and other operations.|
|Data type highlighting||LabVIEW MathScript RT Module analyzes your .m file scripts to determine the data types of your inputs and constants during editing for enhanced script debugging and readability.|
|Compatible||You can use MathScript to leverage thousands of algorithms available on the web and textbooks. LabVIEW MathScript RT Module is able to process your files created using the current MathScript syntax and, for backwards compatibility, files created using legacy MathScript syntaxes. LabVIEW MathScript RT Module can also process certain of your files utilizing other text-based syntaxes, such as files you cerated using MATLAB® software. Because the MathScript RT engine is used to process scripts contained in a MathScript Windows or MathScript Node, and because the MathScript RT engine does not support all syntaxes, not all existing text-based scripts are supported.|
|Extendible||You can extend the LabVIEW MathScript RT Module by defining your own custom functions.|
|Part of LabVIEW||LabVIEW MathScript RT Module does not require additional third-party software to compile and execute.|
|Real-Time Support||LabVIEW Real-Time allows you to compile and download code to develop deterministic applications designed to run on real-time hardware targets. The LabVIEW MathScript RT Module has the ability to run your custom .m file scripts on these targets without having to rewrite your existing VIs, greatly reducing development time and increasing your deployment options. For more information, see Deploying Text-Based Math to Real-Time Hardware with the LabVIEW MathScript RT Module.|
Working with the LabVIEW MathScript RT Module
You can work with LabVIEW MathScript RT Module through both interactive and programmatic interfaces. For an interactive interface in which you can load, save, design, and execute your .m file scripts, you can work with the MathScript Interactive Window. To deploy your .m file scripts as part of a LabVIEW application and combine graphical and textual programming, you can work with the MathScript Node.
Using the MathScript Interactive Window
The LabVIEW MathScript Window (shown in Figure 1) offers an interactive interface in which you can enter .m file script commands and see immediate results, variables and commands history. The window includes a command-line interface where you can enter commands one-by-one for quick calculations, script debugging or learning. Alternatively, you can enter and execute groups of commands through a script editor window.
As you work, a variable display updates to show the graphical / textual results and a history window tracks your commands. The history view facilitates algorithm development by allowing you to use the clipboard to reuse your previously executed commands.
Figure 1. The MathScript Window provides an interactive interface in which you can enter / execute commands and immediately see results.
Using the MathScript Node
The MathScript Node offers an intuitive means of combining graphical and textual code within LabVIEW. Figure 2 shows the MathScript Node on the block diagram, represented by the blue rectangle. Using MathScript Nodes, you can enter .m file script text directly or import it from a text file.
You can define named inputs and outputs on the MathScript Node border to specify the data to transfer between the graphical LabVIEW environment and the textual MathScript code. Figure 2 shows variable inputs on the left side of the MathScript Node named fstoplow, fpasslow, and taps that input these parameters to the .m file script. The MathScript Node contains output variables, F and sH, to transfer the array-based result to the LabVIEW graphical code.
You can associate .m file script variables with LabVIEW graphical programming, by wiring Node inputs and outputs. Then you can transfer data between .m file scripts with your graphical LabVIEW programming. The textual .m file scripts can now access features from traditional LabVIEW graphical programming.
Instrument Your Algorithms
One benefit of working with the MathScript Node is the ability to easily “instrument your algorithms” by using powerful, built-in LabVIEW tools for defining custom interactive user interfaces. You can create custom, interactive user interfaces for .m file script algorithms by associating the variables of your textual .m file script code with LabVIEW controls and indicators such as knobs, sliders, buttons, and 2D/3D plots, shown in Figure 3.
You can wire MathScript Nodes to any of hundreds of ready-to-use user interface elements that are shipped with LabVIEW, including graphs, charts, knobs, dials, and thermometers, to implement custom user interfaces for your .m file scripts.
Figure 3. You can instrument your .m file scripts by using built-in user-interface elements available within LabVIEW.
Graphical Signal Processing, Analysis, and Math
Plugging textual .m file scripts into LabVIEW graphical code with the MathScript Node also provides access to an extensive library of graphical tools for signal processing, analysis, and math. LabVIEW has more than 700 graphical Virtual Instruments with functionality covering such areas as:
- Signal Processing: Signal Generation, Signal Conditioning, Monitoring, Digital Filtering, Windowing, and Spectral Analysis
- Mathematics: Transforms, Curve Fitting, Interpolation/Extrapolation, Probability/Statistics, Optimization, Ordinary Differential Equations, Geometry, Polynomial Functions, 1D/2D Evaluation, and Calculus
Employing Measurement Hardware
Another benefit of merging textual with graphical programming using the MathScript Node is simplified data acquisition, signal generation and instrument control. .m file scripts that execute from within MathScript Nodes can use hardware control capabilities that are a pervasive part of the LabVIEW development environment. The graphical environment naturally manages continuous data acquisition operations and saves significant time for developers. LabVIEW sets the standard for integration with measurement hardware by providing support for:
- More than 100 plug-in data acquisition devices
- More than 5,000 stand-alone instruments from more than 200 vendors
- More than 1,200 PXI-based modular devices from more than 70 vendors
- More than 10,000 supported sensors from more than fifteen 3rd party plug&play sensor vendors
- More than 1,000 motion stages and drives
- More than 400 industrial and scientific cameras
Integrating Software Components
You can take advantage of the MathScript Node to bridge the gap between .m file scripts and external software or data. As a widely used development platform for a variety of applications and disciplines, LabVIEW offers a broad collection of software integration tools, libraries, and file formats to link it with many different design and simulation tools. LabVIEW also offers connectivity to a variety of software standards for integration with other software tools and packages, or with such measurement resources as:
- DLLs, shared libraries
- ActiveX, COM and .NET (Microsoft)
- DDE, TCP/IP, UDP, Ethernet, Bluetooth
- CAN, DeviceNet, ModBus, OPC
- USB, IEEE 1394 (FireWire), RS232/485, GPIB
- Databases (ADO, SQL, etc.)
Exploring Internet-Based Remote Panels and Distance-Learning Tools
Other connectivity options enabled by the MathScript Node go beyond local software or hardware. .M file scripts can employ LabVIEW features such as the remote panel to allow remote web-based control—with no additional programming. You can embed your custom LabVIEW user interfaces in a standard Web browser, with only two mouse clicks. Users then can control your applications remotely from a standard Web browser without installing LabVIEW. This feature is especially important for distance learning remote experiments, where professors can enhance lectures with live demonstrations, students can access laboratories after hours, and researchers can share costly equipment and collaborate on research.
The LabVIEW MathScript RT Module complements traditional LabVIEW graphical programming for such tasks as algorithm development, signal processing, and analysis. The LabVIEW MathScript RT Module speeds up these and other tasks by giving users a single environment in which they can choose the most effective syntax, whether textual, graphical, or a combination of the two. In addition, you can exploit the best of LabVIEW and thousands of publicly available .m file scripts from the web, textbooks, or your own existing m-script applications. LabVIEW MathScript RT Module is able to process your files created using the current MathScript syntax and, for backwards compatibility, files created using legacy MathScript syntaxes. LabVIEW MathScript RT Module can also process certain of your files utilizing other text-based syntaxes, such as files you cerated using MATLAB® software. Because the MathScript RT engine is used to process scripts contained in a MathScript Windows or MathScript Node, and because the MathScript RT engine does not support all syntaxes, not all existing text-based scripts are supported.
MATLAB® is a registered trademark of The MathWorks, Inc. All other trademarks are the property of their respective owners.