Creating SignalExpress Plug-Ins with LabVIEW

Publish Date: Oct 26, 2011 | 28 Ratings | 3.68 out of 5 |  PDF

Overview

SignalExpress is an interactive measurement tool for generating, acquiring, analyzing, and saving signals through an interactive, dialog box-driven approach. You can use SignalExpress to configure a series of steps quickly to create a measurement procedure without programming. A key feature of SignalExpress is that you can extend the functionality of the environment with plug-in steps created with LabVIEW. These plug-in steps are sometimes referred to as a user VI and are used by SignalExpress using the User-Defined Step. Some examples in which a user VI might be required for use in SignalExpress include the following:
  • Controlling an instrument or any measurement hardware not supported by the native SignalExpress steps
  • Reading or writing to custom file formats
  • Performing more advanced analysis computations
  • Displaying pop-up dialog boxes to the user at execution time for instructions or notifications

This document describes how to build plug-ins for SignalExpress using LabVIEW. Refer to the Getting Started with SignalExpress manual to familiarize yourself with SignalExpress interactive measurements and the basic SignalExpress features that you use to acquire and analyze signals.
Note: To use VIs from LabVIEW 8 and 8.20 download the SignalExpress patch from Drivers and Updates

Table of Contents

  1. What Defines a SignalExpress Step?
  2. The Basics - Calling Any LabVIEW VI from SignalExpress
  3. The Facts - What To Be Aware Of
  4. Understanding the SignalExpress Execution Model
  5. An Example - Exploring the SignalExpress User VI Template
  6. Calling a VI from LabVIEW SignalExpress 2.0
  7. Calling a VI from SignalExpress 1.1
  8. Calling a VI from SignalExpress 1.0

1. What Defines a SignalExpress Step?

Steps in SignalExpress have the following features:

  • Steps can have input and/or output signals – an input is a signal that a step needs in order to produce a result. An output is the result of a step and can be used as an input to a following step. Output signals can also be dragged to interactive displays in SignalExpress for viewing or even dragged to other applications which support text drag and drop.
  • Steps have parameters which can be interactively set by the user by entering values or moving controls (sliders, knobs, etc) on an interactive dialog for configuring the operation of the step
  • Steps can run once, or be run continuously based on the run mode of SignalExpress (Run or Run Once)
  • Step have some parameters which can be swept through a range by the Sweep step within the SignalExpress environment.
  • Steps can be converted into LabVIEW sub-VIs or Express VIs when converting a SignalExpress projects to LabVIEW diagrams from with the LabVIEW environment.


You can call almost any LabVIEW VI from SignalExpress with only a few basic requirements on the VI. By simply packaging the VI following a few steps and without touching the actual VI block diagram, you can execute the VI within the SignalExpress environment.

However, depending on what your VI does, you may want to use the User Step VI template included with SignalExpress for handling events from the SignalExpress engine. By responding to the SignalExpress events in your VI, your VI will become aware of the SignalExpress execution model and will take full advantage of the continuously running mode as well as the run once execution mode allowing your VI to behave like regular SignalExpress steps. The following sections describes the process for calling a VI from SignalExpress, and explain how to use the User Step VI template to build plug-ins for SignalExpress.

Back to Top

2. The Basics - Calling Any LabVIEW VI from SignalExpress

Most VIs can be called directly from SignalExpress with very few changes. If you have a VI you would like to use in SignalExpress, make sure that it meets the following requirements:

All inputs and outputs must be wired to the connector pane of the VI. When calling a VI from SignalExpress, it interrogates the connector pane of the VI to learn what the VIs inputs and outputs are. If you do not wire an input or output to the connector pane, SignalExpress will not be able to pass data into or out of the VI and the default value will be used instead. This is also necessary to be able to properly convert a project into a LabVIEW block diagram.

Any inputs or outputs that you expect to use as Inputs or Outputs to the User-Defined step within the SignalExpress environment must conform to a list of supported SignalExpress datatypes. The supported datatypes are:

  • Double-precision scalars
  • Time-Domain waveform
  • Frequency-domain waveform magnitude (in dB or absolute)
  • Frequency-domain waveform phase (in radians or degrees)
  • Booleans


Note: It is often the case that not all inputs to your LabVIEW VI are also Inputs within the SignalExpress environment. For example, a LabVIEW VI with an input called "Device Name" may not be of a supported SignalExpress datatype as shown in the list above. This does not mean however that this "input" cannot be interacted with within SignalExpress, but instead, this "input" is now considered to be a "parameter" regardless of its datatype and MUST still be connected to the connector pane. The different between a SignalExpress "Input" and a "Parameter" is that an Input's value comes from a previous step, whereas a parameter's value comes from that step's configuration dialog and can be edited manually by the user.

 

  • The VI must be saved as a reentrant VI (VI Properties>Execution).

The VI Properties dialog showing the needed settings.
  • LabVIEW 7.x and 8.x: The VI should be saved with options (File >Save with Options) as a linked library (llb) with all of its sub-VIs and vi.lib files included. By placing all sub-VIs into the LLB, you ensure that all of the components necessary to execute the VI are there.

The Save with Options dialog showing the needed settings.
 

LabVIEW 2009 and Newer: To save a VI as a LLB, go to File»Save As and then select New LLB

This is where to find the New LLB button.

 

LabVIEW 7.x and 8.x

  • The procedure for creating an LLB for your main VI is a bit different in LabVIEW 8.x than it is in 7.x. For example, the following steps define how to create a LabVIEW 8.0 user-defined step to be used in LabVIEW SignalExpress 2.0:
  1. Create a new blank project in LabVIEW 8.0.
  2. Add your main User Step VI to the project.
  3. Save the project and VI. Right click on Build Specifications in the Project Explorer window and select New»Source Distribution.  
  4. In the Source Distribution Properties dialog box, go to the Distribution Settings page. Select the Packaging Option "Single Destination" and uncheck "Exclude vi.lib" and “Exclude instr.lib”. Modify the Distribution destination directory such that the final destination location ends with a *.LLB extension, and select "Yes" at the prompt. An example would be C:\Documents\UserStep34970A.LLB
    Note: In LabVIEW 8.2, the "Exclude vi.lib" is found in the Additional Exclusions page, not the Distribution Settings page
  5. Click the Build button. The source distribution will contain your VI as well as all the instrument driver VIs in a single LLB file. You will notice that another folder called <code>data</code> was also created. It contains all non-VI files. The <code>data</code> folder is irrelevant in this case. We are interested only in the LLB we just created.
  6. To set your main User Step VI as your top VI in the LLB click on Tools»LLBManager
  7. Browse to your LLB file and double click on it
  8. Once the contents of the LLB file is displayed inside the LLB Manager, right-click on your main User Step VI and select Top Level.


The Source Distribution dialog in LabVIEW 8.0 showing the needed settings.

 

LabVIEW 2009 and Newer

  1. Set the VI as Reentrant by going to File» VI Properties then select Execution. Check the box for Reentrant Execution. You will want to do this for all the VIs in .llb file you intend on using.
  2. Create a New Empty Project in LabVIEW 
  3. Right-click My Computer in the project explorer go to Add» Folder (Snapshot) and select the .llb file
  4. Save the project
  5. Right-click on Build Specifications. Go to New » Source Distribution
    1. In Information select the destination directory that you wish to save the file. This is the file you will have to locate within SignalExpress later
    2. In Source Files click on the folder that contains you .llb that you added to the project and click the arrow to move it to "Always Include"

       

      The Source Files window in the correct configuration.

       
    3. In Destinations under "Destination Type" select LLB
    4. In Additional Exclusions uncheck "Exclude files from bi.lib" and "Exclude files from instr.lib"
    5. Click Build
  6. In SignalExpress, select Add Step»Run LabVIEW VI
  7. Under "Select VI" browse to and select the Source Distribution you just created in LabVIEW
  8. Select the subVI that you want to use and give it the proper configuration according to your setup
  • Refer to the next section for things NOT to do when creating a LabVIEW VI you want to call from SignalExpress.

Back to Top

3. The Facts - What To Be Aware Of


As mentioned in the previous section, most VI can be called directly from SignalExpress with very few changes. However, there are cases where a VI cannot just be used within SignalExpress without either making some changes or using the User Step VI Template. This section discusses these reasons.

While Loop with Stop Button

A LabVIEW VI already written to run repeatedly using a While Loop until a user action is performed (like pressing a Stop button) will cause an infinite loop. When called from SignalExpress, the VI must be run to completion before returning control to SignalExpress. Thus, if the VI contains a loop which expects an interactive action during the course of an execution, that action will never occur and the VI will continue to execute the loop forever. This is not to say that a While Loop cannot be used, but if used, the termination condition of the loop cannot come from a user action.

For information on how to modify your VI to accomplish the same behavior, please read the following two sections which discuss the SignalExpress execution model and how to use the User Step VI Template.


Event Structures

A LabVIEW VI called from SignalExpress actually acts like a subVI. This means that a VI's Front Panel should be designed like a basic User Interface where values can be changed and viewed, but not an advanced User Interface where the Interface reacts based on value selections. There are two reasons for this. First, an event structure is usually accompanied by a While Loop which leads to the same reason as mentioned previously. The second and more complex reason, is that changes to values through the User-Defined Step's configuration dialog do not fire events that are recognized by Event Structures. Thus, if the VI is running and waiting for a change for the Event Structure to process, the LabVIEW VI will not ever get the event notification. As a result, the LabVIEW VI will wait forever unless a Timeout is specified to the Event Structure (in which case the Timeout event case will always occur).


Popup Dialogs

Be cautious when calling a Popup Dialog box within a LabVIEW VI you plan on calling from SignalExpress. Pressing the Run button in the SignalExpress environment will execute the VI over and over, meaning that if the dialog is called from a part of the VI which is called every iteration, it will be hard to press the SignalExpress Stop button before the next dialog box re-appears. Although this does not cause an infinite loop, this can simply be frustrating.

Calling DLLs


Be aware that when any of your VIs or subVIs call a DLL, the path to that DLL is stored within the VI as either an absolute path or a relative path. Since DLL cannot be placed inside a LabVIEW llb, this is an important dependency that must be kept track of.

Most common problems arise when a VI saves using a relative path to a DLL and the saved llb is then moved to a different relative location. This will case the VI to open in a broken state due to not being able to find the location of the DLL.

Cases where issues should not arise:
  • If your User Defined VI only uses the LV analysis VI, then this does not become an issue since SignalExpress pre-loads this DLL for you.
  • If your VI uses DLLs which are location in your Operating System's system folders, these folders automatically get searched.

Cases where issues could arise:
  • If your VI uses a DLL whose location is neither of the above and the llb containing your VIs is moved. For this case, one solution is to copy the DLL you are using next to your llb, and have your VIs link to that copied DLL. After that, when moving the llb containing your VIs, move the llb AND the DLL(s) so that the relative path does not change or break.

Note: adding the path to these DLL(s) to your LabVIEW development environment search path does NOT solve these issues.

Back to Top

4. Understanding the SignalExpress Execution Model

The internal SignalExpress execution engine fires a number of events to control the execution of the built-in SignalExpress steps. A subset of these events is available to user-defined LabVIEW VIs called "a user step" in SignalExpress. Using these events will enable your VIs to operate optimally when SignalExpress is running repeatedly. For example, if you call a VI that controls a GPIB instrument from SignalExpress, you may experience performance problems when you run your SignalExpress project in Run mode. To understand why, let’s first examine what happens when SignalExpress executes your projects.

When you press the Run Once button, SignalExpress passes the following events to each of the steps in the project:

  • Configure
  • Run
  • Stop


When you press the Run button to execute your project repeatedly, SignalExpress passes the following events to each of the steps in your project:

  • Configure
  • Run
  • Run
  • Run... (over and over, until the Stop button is pushed or until a parameter value is changed)
  • Reconfigure (if the user changes the value of a parameter on a step)
  • Run...
  • Stop (when the Stop button is pushed)


For the case when you are controlling a GPIB instrument, your VI will operate more smoothly in SignalExpress if you take advantage of the event structure in the user step template . Let’s look at the specific case of controlling an Oscilloscope from SignalExpress. When you control a Scope over GPIB, you have to configure its settings (vertical, horizontal, triggering, etc) and then fetch the waveform data or measurement values from the Scope. If you were to call an oscilloscope driver VI directly from SignalExpress, the VI will reconfigure the oscilloscope every time the VI is called. When running in SignalExpress, this is every time the Run event is called – which will result in a very slow, unwieldy performance of your SignalExpress projects. A better solution is to break up the oscilloscope VI such that:

  • the scope is configured only when the Configure event fires
  • the scope returns data whenever the Run event fires
  • the scope closes when the Stop event fires


With this approach, the scope will be controlled in the following manner when the user presses the Run button to run continuously:

  • Configure event fires – scope is initialized and all settings are configured based on default values
  • Run – waveform is fetched and displayed
  • Run – waveform is fetched and displayed
  • Run – etc
  • Stop - when the Stop button is pressed, the scope session is closed


When the user changes the value of a scope parameter while running:

  • Reconfigure event fires – scope settings are configured based on new value. Notice the scope is not re-initialized - that only occurs in the Configure event, not Reconfigure


Note for the previous section: This is equivalent to using a While Loop in LabVIEW. But in the SignalExpress case, the Stop button that you would connect to the LabVIEW While Loop's termination condition is replaced but SignalExpress' own Stop button which fires the Stop event in the User Step VI Template.

Back to Top

5. An Example - Exploring the SignalExpress User VI Template


Modifying your LabVIEW VIs to respond to the SignalExpress events may appear difficult based on this discussion. However, a User Step VI Template included with SignalExpress makes the process of modifying your VIs to use this event structure almost trivial. The User Step VI Template can generally be found under the [SignalExpress dir]\User Step Templates directory. The figures below illustrate how the code is organized in the template, using an oscilloscope driver as an example (the oscilloscope control code was taken directly from the driver's Getting Started VI that is included with the driver). To illustrate more easily, the example's diagram images have been split into the 4 main components: Configure, Reconfigure, Run, and Stop. At the bottom of each image is a small version of the entire VI with the current viewing location highlighted in red.


Figure 1.1 - The Configure case inside the configuration loop.

When looking at the User Step VI Template, the first thing to mention is what should not be edited or changed. In Figure 1.1, you should noticed the subVI and controls in the top-left corner of the diagram. This code is used by the SignalExpress engine and should not be changed. It is used to determine which event is fired and tell the template code which case to run. Next, notice the Configure case which will execute when the Configure event is fired from SignalExpress. For User VIs which do not require special initialization, placing code in this case is optional. We'll discuss the While Loop and Shift Registers which the next image.


Figure 1.2 - The Reconfigure case inside the configuration loop.


Figure 1.2 shows the Reconfigure case. Here, we see that the Configure and Reconfigure cases are related by both being inside of the while loop. In this example, we've modified the standard template to OR the Configure and Reconfigure event together. When the Configure event fires, both the Configure and Reconfigure code will execute – initializing the Oscilloscope and configuring its vertical, horizontal, and triggering setup. However, while running continuously, if the user changes a parameter value, only the Reconfigure code will execute, reconfiguring the scope without re-initializing it. This allows the scope to update its configuration while running continuously in SignalExpress. By OR gating these two events for the Reconfigure code, we do not have to duplicate reconfigure code in the Configure case as well. Another OR gate is used for the reconfigure and run steps.  This allows the run step to execute immediately after the reconfigure step, preventing any breaks in running while the VI is being reconfigured. 

Using the Shift Registers visible on both sides of the While Loop is a way in LabVIEW to store data across multiple runs, thus, the Oscilloscope's session handle will be stored on the Shift Register to use every run even when the Configure and Reconfigure cases are not called. Also notice that a Constant TRUE is connected to the loop's termination condition - this means the loop will always execute only once - which is what we want. For User VIs which do not require special reconfiguration, placing code in this case is optional.


Figure 1.3 - The Run case.


Figure 1.3 shows that the Run event simply reads the waveform from the scope. Most User VIs which do work during regular SignalExpress execution will have to implement this case. The only reason for not implementing this case would be if the User VI only wanted to do all the work once at the begin only (in that case, all the code would be in the Configure or Reconfigure case), or do all the work once at end only (in that case, all the code would be in the Stop case).



Figure 1.4 - The Stop case.


Figure 1.4 shows that the Stop event quite simply closes the scope session. For User VIs which do not require special clean-up, placing code in this case is optional.

By understanding how these four basic events are used, you can easily make your VIs behave as regular SignalExpress step. Keep in mind, that in many cases, you will not even need to do this much – you can just call the VI "as is" without using the User Step VI Template. As long as the Configure step of the VI is not time-consuming, you can run your VI without affecting performance in SignalExpress.

See Also:
Product Manuals: Getting Started with SignalExpress

Back to Top

6. Calling a VI from LabVIEW SignalExpress 2.0

The process for calling a VI from LabVIEW SignalExpress 2.0 as a user step is almost exactly the same as in SignalExpress 1.1 described in the next section. The main difference is in the very first step.

  1. Open LabVIEW SignalExpress 2.0 and click on Add Step. Expand the Run LabVIEW VI option. Select the corresponding LabVIEW version for your main VI.

For the rest of the steps, read the next section.

Back to Top

7. Calling a VI from SignalExpress 1.1


The process for calling a VI from SignalExpress 1.1 as a user step is straightforward. Refer to the following steps to call a LabVIEW VI from SignalExpress:


Figure 2.1 - The User-Defined Step configuration dialog with a selected VI.


  1. From the SignalExpress environment, insert a User-Defined Step into your project. The User-Defined Step configuration page will appear, as shown in Figure 2.1
  2. Select a VI by either typing a path to the VI manually into the "Select VI" box or by using the browse button.
  3. SignalExpress then interrogates the connector pane to create a list of the inputs to the VI, and displays them in the inputs list control. You must define which inputs to the VI are SignalExpress signal inputs and which are to be parameters. By default, inputs to a LabVIEW VI are parameters in SignalExpress, but you can make a parameter into a SignalExpress Input by selecting the "Connect Input..." button. From the dialog which appears, select the control name you would like to convert to an Input, and click Ok. To remove the Input, press the "Disconnect Input" button.
    • Note: Parameters are controls that will be set interactively on the front panel of the VI. For example, if you have a VI that performs a filter on a signal, you would configure the input signal as an Input to the step, but the values that configure the characteristics of the filter are considered to be parameters. Remember, parameters can also be changed automatically by the Sweep Step in SignalExpress.
  4. The User-Defined Step builds a list of the VI's outputs and displays them in the Outputs list. For each output signal, you must specify the appropriate SignalExpress signal type. Doing this will enable steps downstream in your project to process these signals correctly.



Figure 2.2 - You can view the front panel of the VI and change values of the parameters by selecting the Configure VI tab.


After specifying information about the Input signals and Output signals of your User-Defined Step, you can now run the step continuously within your SignalExpress projects. Simply select the "Configure VI" tab and change the parameters of the step while it is executing, and it will execute appropriately, very similar to regular SignalExpress steps. For more technical information regarding building and using LabVIEW VIs to extend the functionality of SignalExpress, refer to the SignalExpress documentation.

Back to Top

8. Calling a VI from SignalExpress 1.0


The process for calling a VI from SignalExpress 1.0 as a user step is straightforward. Refer to the following steps to call a LabVIEW VI from SignalExpress:


Figure 3.1 - The User-Defined Step configuration dialog with a selected VI.


  1. From the SignalExpress environment, insert a User-Defined Step into your project. The User-Defined Step configuration page will appear, as shown in Figure 3.1
  2. Select a VI by either typing a path to the VI manually into the "Select VI" box or by using the browse button.
  3. SignalExpress then interrogates the connector pane to create a list of the inputs to the VI, and displays them in the inputs list control. You must define which inputs to the VI are SignalExpress signal inputs and which are to be parameters. By default, inputs to a LabVIEW VI are parameters in SignalExpress, but you can make a parameter into a SignalExpress Input by selecting the parameter name and pressing the "Make Input" button. To reverse the process, press the "Make Parameter" button.
    • Note: Parameters are controls that will be set interactively on the front panel of the VI. For example, if you have a VI that performs a filter on a signal, you would configure the input signal as an Input to the step, but the values that configure the characteristics of the filter are considered to be parameters. Remember, parameters can also be changed automatically by the Sweep Step in SignalExpress.
  4. The User-Defined Step builds a list of the VI's outputs and displays them in the Outputs list. For each output signal, you must specify the appropriate SignalExpress signal type. Doing this will enable steps downstream in your project to process these signals correctly.



Figure 3.2 - You can view the front panel of the VI and change values of the parameters by pressing the Open VI Front Panel button.


After specifying information about the Input signals, Output signals, and Parameters of your User-Defined Step, you can now run the step continuously within your SignalExpress projects. Simply open the dialog and change the parameters of the step while it is executing, and it will execute appropriately, very similar to regular SignalExpress steps. For more technical information regarding building and using LabVIEW VIs to extend the functionality of SignalExpress, refer to the SignalExpress documentation.

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit