APx LabVIEW Getting Started
APx LabVIEW Getting Started
Introduction
Audio Precision has developed a full-featured LabVIEW driver for its APx500 Series audio analyzers. The APx LabVIEW Driver is a collection of Virtual Instruments (VIs) aimed at providing LabVIEW users the ability to access most of the functionality available in the APx500 Application Programming Interface (API) using high level, LabVIEW-typical subVIs, with a minimum number of programming steps. Using the driver collection, LabVIEW users will be able to quickly and efficiently develop APx applications with clean, concise LabVIEW code.
Contents
Introduction ................................................................................................................................................... 1 How to Use This Document .......................................................................................................................... 2 Background ................................................................................................................................................... 2 LabVIEW Version Requirements ................................................................................................................. 3 Driver Version Information .......................................................................................................................... 3 Whats New in Version 2.9 of the APx LabVIEW Driver? .......................................................................... 3 Features of the APx LabVIEW Driver .......................................................................................................... 4 Limitations of the APx LabVIEW Driver ..................................................................................................... 4 Installing the APx LabVIEW Driver ............................................................................................................ 4 Note for Windows Vista and Windows 7 Users ........................................................................................... 5 Organization of VIs in the APx LabVIEW Driver Collection ...................................................................... 5 Use a LabVIEW Project and Corresponding .config File ............................................................................. 7 The APx500 Open VI ................................................................................................................................... 9 Getting Started - A First Simple APx LabVIEW VI..................................................................................... 9 Using the APx500 Close VI ........................................................................................................................ 10 Running a Measurement in the APx Project ............................................................................................... 11 Error Handling in the APx LabVIEW Driver ............................................................................................. 16 The Signal Path & Measurement Cluster .................................................................................................... 17 Changing APx Measurement Settings with the Driver VIs ........................................................................ 19 How the Driver VIs Handle Units in Configuration Settings ..................................................................... 23 Changing Measurement Settings A Simple Example .............................................................................. 23 Changing Measurement Settings A Better Example................................................................................ 24 Generating Arbitrary Waveforms with the LabVIEW Driver VIs.............................................................. 30 Measuring .wav Files with the LabVIEW Driver VIs ................................................................................ 31 Recap Configuring Measurement Settings .............................................................................................. 31 About the Orange Colored Controls ........................................................................................................... 32 Working with Cluster Control Subsets ....................................................................................................... 33
Getting Started with the Audio Precision APx LabVIEW Driver Page 1 of 54
Accessing Primary Measurement Results with the LabVIEW Driver ........................................................ 36 Handling Dynamic Measurement Results................................................................................................... 40 How the Driver VIs Handle Measurement Data Units ............................................................................... 40 Running an APx Measurement Sequence ................................................................................................... 40 The User Interface Example ....................................................................................................................... 43 Configuring the Signal Path Setup .............................................................................................................. 44 Reference Levels ......................................................................................................................................... 48 Acquiring Raw Data from the Signal Analyzer Measurement ................................................................... 51 Controlling Input and Output Switchers ..................................................................................................... 51 Using the WaveReader DLL ....................................................................................................................... 52 Conclusion .................................................................................................................................................. 54
Background
The APx500 series, first introduced in 2006 with the APx585, has grown to a series of audio analyzers that encompasses a wide variety of features and options. Models are available as analog only or dual domain analog/digital, with 2, 4, 8, or 16 analog channels. Optional modules are available that add HDMI (and HDMI ARC), multi-channel digital serial interface (DSIO), and Bluetooth connectivity. All models in the APx500 Series use the APx500 measurement software. It features a highly intuitive feature-rich user interface (UI) that makes APx instruments the easiest to use audio analyzers in the world. The APx500 software has many test automation features built in, including customizable user prompts and the ability to call external applications. For users that want to go beyond the automation features built into the APx500 measurement software, a full-featured Application Programming Interface (API) is available. The API is built on the Microsoft .NET platform, allowing custom APx programs to be developed in any .NET capable language. National Instruments LabVIEW is a graphical programming language that uses block diagrams instead of text-based code to create applications. LabVIEW is a popular development platform in test automation circles because it has an extensive library of instrument drivers and a broad test
Page 2 of 54
development feature set. Because LabVIEW supports .NET connectivity, it is one of the many programming languages that can be used to develop custom APx500 applications using the APx .NET-based API. For more information on LabVIEW, visit http://www.ni.com/labview. Since version 2.0 of the APx500 measurement software, Audio Precision has provided code samples in VB.NET and C#.NET that demonstrate interacting with the APx API. Code samples for LabVIEW were added in version 2.1. These code samples are located on the APx Resources Disc in the folder ~API\Examples. As the LabVIEW samples on the APx Resources Disc help to illustrate, every feature available in the APx API can be accessed from LabVIEW, using basic low level calls to the .NET properties and methods available in the API. However, due to the graphical nature of LabVIEW and the way in which it interfaces with .NET objects, APx LabVIEW programs developed using these low level .NET calls would be considered awkward by many programmers accustomed to using LabVIEW. This awkward appearance is due to (1) the requirement to connect together .NET method and property nodes with long names, resulting in long, narrow LabVIEW block diagrams, and (2) the need to use a relatively large number of objects to accomplish a task. The APx LabVIEW Driver is a collection of Virtual Instruments (VIs) intended to eliminate this awkwardness, and to enhance the development of APx programs using LabVIEW. It provides LabVIEW users the ability to access most of the functionality available in the API using higher level LabVIEW-typical subVIs, with fewer program steps. As a result, APx LabVIEW applications can be developed much more quickly and efficiently, with cleaner, more concise LabVIEW code.
Page 3 of 54
To install the APx LabVIEW Driver, navigate to the LabVIEW Driver folder on the APx Resources disc and run the setup.exe program. By default, the installer will install the driver in the instr.lib sub folder of the LabVIEW installation on the computer, as shown below. This
Exception: The Signal Path Diagnostics measurement is not supported in the LabVIEW driver. However, access to low level .NET API calls is still available for users that wish to access this measurement context. 2 Note: Access to more advanced API features that are not implemented in the driver is still available using basic low-level .NET API calls.
Page 4 of 54
default location should not be changed. Otherwise, the drivers menu palette will not be available in LabVIEW. On completion, the installer directs the user to this Getting Started guide.
Page 5 of 54
On the main menu palette, there is a link to a VI named APx500 VI Tree.vi. This is a special type of VI provided with LabVIEW drivers to help document the VIs in the driver collection. When opened, the front panel of this VI appears as shown in Figure 3. The VI Tree is not meant to be executable, as evidenced by the broken run arrow on the toolbar below the View menu item. The block diagram for this VI shows every high level VI in the driver collection (Figure 4).
Page 6 of 54
Consistent with the National Instruments guidelines for an instrument driver, the VIs in the in the APx500 VI Tree (Figure 4) are organized into categories including Initialize, Configure, Action/Status, Data, Examples and Close. These same categories are visible in the drivers menu palette (Figure 2). Driver Vis may be loaded from the drivers menu palette or copied from the VI Tree.
Page 7 of 54
n.m\LabVIEW (where n.m represents the APx version number). There is also a shortcut to this project on the Users start menu. As shown in Figure 5, this project has a folder containing all of the examples that ship with the LabVIEW driver.
Figure 5
The project file shown in Figure 5 has an accompanying configuration file named APx500 Examples Project.lvproj.config. This is an XML file that directs LabVIEW to use the correct version of the APx500 API. Using a project file and accompanying .config file like this when working with the APx Driver VIs will prevent errors caused by cross-linking and by LabVIEW referencing the wrong version of the APx API. If a project file and .config file are not used, in some cases the LabVIEW driver VIs may not work. Working with LabVIEW project files is easy. If you create a new VI with the Project Explorer open, the new VI will automatically be added to the active project. If you need to create a new LabVIEW project, you can create a matching .config file by copying the example .config file described above and renaming the copy to have the same name as your LabVIEW project. For example, if you create a new LabVIEW project named MyAPx500Project.lvproj, make a copy of the .config file above in the same folder as the project and rename it to MyAPx500Project.lvproj.config.
Page 8 of 54
Figure 6
By default, the APx500 Open VI makes the APx500 application visible. Users who prefer to use the API with the APx500 Application invisible, can simply wire a Boolean False to the Visible input of the APx500 Open VI.
Page 9 of 54
Figure 7. Block diagram of a first simple VI to control an APx analyzer, and the Version Info cluster on the front panel
This simple VI is now ready to run. Note that if the PC is not properly connected to an APx500 analyzer that is powered on, the APx500 measurement software can be run in demo mode3. In fact, if the APx application is loaded from the API (e.g., using LabVIEW) rather than from Windows, the software is automatically loaded in demo mode when an instrument is not connected. Demo mode simulates almost all of the functionality of the APx software, but returns random data. Fortunately, all of the API calls function normally in demo mode, and therefore, LabVIEW VIs to control APx analyzers can be mostly developed without an APx analyzer being connected. To run this simple VI, click the white Run arrow on the VIs front panel. After several seconds (the amount of time depends on the PC speed and available memory resources), the APx application will load, and the Version Info will be displayed in the indicator on the front panel4. As explained in the context help, if the APx application is running in demo mode, some of the indicators in the Version Info cluster return blank values.
Note: If you are running the APx500 software for the first time after upgrading to a new version, you must run it from Windows at least one time before opening it with LabVIEW, to allow the instrument firmware to be updated. Note: An exception to this occurs the first time an APx analyzer is used with a new version of the APx500 application. In this situation, the application pauses to update the instruments firmware, and an error will be generated. Therefore, when upgrading APx500, the application should be loaded directly from Windows the first time an APx analyzer is used with the new software.
4
Page 10 of 54
close any driver references when a VI is finished its task. Figure 8 shows the block diagram of the simple VI from Figure 7 with the Close VI added.
The APx LabVIEW driver is not a traditional LabVIEW instrument driver in the sense that running the APx500 Open VI without running the Close VI does not open an additional instance of the APx500 measurement software. Therefore, there is no advantage to adding the APx500 Close VI to every VI. In fact, closing the application every time a VI finishes running can be a disadvantage, because of the time it takes to re-open the application. We do not recommend adding the APx500 Close VI to every top level VI. The only potential disadvantage to the above strategy is if the APx500 application is running with its UI invisible when you are finished using it with LabVIEW. In this case, if the APx500 Close VI is not used somewhere in the LabVIEW program, the APx500 application will remain in memory without the user knowing it, because the UI window is invisible. Users who are concerned about this should add the APx500 Close VI to their APx VIs. However, in our opinion, the inconvenience of having to re-open the APx500 application every time a VI is run far outweighs the disadvantage of the application occasionally being left running and invisible.
Page 11 of 54
1. Delete all sub-VIs from the block diagram, except the APx500 Open VI and the Simple Error Handler
2. Add the APx500 Utility Strings to Signal Path & Measurement VI and the APx500 Perform Measurement VI to the diagram and connect them as shown.
Page 12 of 54
3. Right-click on the appropriate inputs to the Utility Strings to Signal Path & Measurement VI, and create controls for the Signal Path and Measurement name strings. 4. Right-click on the Measurement Complete output of the Perform Measurement VI and create an indicator.
5. Enter the names Signal Path1 and Level and Gain in the appropriate string controls on the front panel of the VI, as shown.
Page 13 of 54
6. Open the APx500 application (if it is not already open). If it is open, start a new Project with the Default template. This will ensure that a Signal Path named Signal Path1 exists in the Project and that a measurement named Level and Gain exists within that Signal Path. It will also ensure that the Report checkbox is checked.
7. Run the VI by clicking the Run arrow. This will cause the APx500 application to complete a Level and Gain measurement and create a report. Once complete, the RMS Level result of the Level and Gain measurement will be highlighted in the APx Application. On the front panel of the VI, the Measurement Complete LED should now be green instead of grey.
The above simple program illustrates running an APx measurement from LabVIEW. The Perform Measurement VI uses the APx Sequencer to run the measurement. This is equivalent to checking the measurements checkbox in the APx Navigator, and then right-clicking on the measurement and selecting Run Measurement (Figure 9). Running the measurement via the Sequencer is preferred over simply turning on the generator and reading the instantaneous data, because the Sequencer method returns settled readings.
Page 14 of 54
Figure 9
Note that specifying the Signal Path and measurement name is a critical step. This tells the APx API precisely which measurement in APx that our LabVIEW program wants to interact with. It is critical that these two items are specified correctly, and that they exist in the project. Otherwise, the API will generate an error. To see this in action, change the string in the Signal Path control on the LabVIEW front panel from Signal Path1 to Signal Path2, and run the VI again. This time it will generate the error message shown in Figure 10.
Figure 10
Page 15 of 54
The same error message is generated if the measurement name specified in the Measurement string control does not match a measurement in the specified Signal Path. Therefore, you must ensure that the specified Signal Path name exists within the APx project, and that the specified measurement name exists within that Signal Path.
Figure 11
Page 16 of 54
Figure 12
Figure 13
To take a closer look at this special control, add a Signal Path & Measurement indicator to the My APx Program.vi after the Strings to Signal Path & Measurement VI as shown in Figure 14 (right-click on the wire and select Create Indicator). Next, change the Signal Path string back to Signal Path1 and run the VI. The resulting front panel is shown in Figure 12 (controls have been rearranged for better visibility).
Page 17 of 54
Figure 14
Figure 15. An indicator for the Signal Path & Measurement cluster added to the VI.
As shown in Figure 15, the Signal Path & Measurement indicator now contains an array of measurements. If you change the Measurements array index, you will see that each element in the array corresponds to a measurement in Signal Path1 of the currently active APx project. The array also contains a check box denoting whether the measurement is checked, and a Measurement Type (enumerated type) indicator. One important feature of the Signal Path & Measurement cluster is not immediately obvious: The Selected Measurement Index control (shown below the Path Name) in the cluster, is the control used to specify the measurement within the Signal Path. This index is zero-based. In the example shown in Figure 15, the Selected Measurement Index is equal to 3. Note that this
Getting Started with the Audio Precision APx LabVIEW Driver Page 18 of 54
corresponds to the position of the measurement in the Signal Path, with index 0 being the first measurement (Signal Path Setup), index 1 = Signal Path Diagnostics, index 2 = Reference Levels, and index 3 = Level & Gain. There are many utility VIs in the driver collection for working with Signal Paths and measurements. For example, the Get Signal Paths VI (Figure 16) returns an array of Signal Path & Measurement clusters with one element for every Signal Path in the currently loaded APx project. This structure provides a way of addressing every measurement in a project. This utility will be useful when you create more advanced VIs as will be seen later in the tutorial.
Figure 16
Page 19 of 54
Figure 17
Figure 18
Now look at the Level & Gain Config control on the front panel of the VI. Figure 19 shows the front panel (you may need to rearrange controls and indicators to make your front panel match Figure 19). This control is a LabVIEW cluster control, that contains two other cluster controls one at the top called Signal Generator Settings (L&G), and another below it called Signal AcqAnalysis Settings (L&G). Now look at the APx UI. With the Level and Gain measurement highlighted in the Navigator, you may notice the similarity between the LabVIEW cluster controls and the APx controls used to configure the measurement, located in the grey panel to the right of the Navigator tree (Figure 20). The LabVIEW controls have been designed to have a one-to-one correspondence with the APx controls. This is obvious in the case of the Signal Acquisition and Analysis control, because there is only one control in this case (Low-pass Filter), and both LabVIEW and APx have the same control. But what about the Signal Generation Controls? Why are there more controls in the LabVIEW cluster than there are in APx? In fact, the APx UI has the same number of controls as the LabVIEW cluster, but they are not all visible at the same time. The APx500 application hides any controls that are not relevant in a given measurement context.
Page 20 of 54
Figure 19
Page 21 of 54
Figure 20
For example, Figure 20 shows the APx Signal Generation controls for the case of an Analog Output Connector type, when the Waveform type is Sine (the standard sine generator). Figure 21 shows other variations in the Signal Generation controls, depending on whether the Output type is analog or digital, and the Waveform type is Sine or Arbitrary Waveform.
Figure 21. Variation in Signal Generation controls displayed by Output type and Waveform type
By studying Figure 20 and Figure 21, you can see that the LabVIEW Signal Generator Settings cluster contains all of the basic generator controls that could be needed for any combination of output type and waveform type. On first glance, it might appear that this doesnt make sense - for example, why make the digital level control visible when using the analog generator? However, it should be noted that (1) these are driver VIs that are not meant to be visible, not a User Interface, and (2) the controls must be present in order for LabVIEW to be able to pass them into
Page 22 of 54
and out of a subVI. Hence, the controls for all signal path contexts are present, and it is up to the users to ensure that their program uses the right controls.
Numerical value and units are combined in one control (e.g., 1.000 Vrms) Values are converted to SI formatting (e.g., 1.000 mVrms or 1.000 Vrms) Conversion among units occurs within the control (e.g., Vrms, Vp, Vp-p, dBV, etc.)
In the APx LabVIEW Driver VIs, controls for setting the measurement configuration handle this by using a numerical control accompanied by a units control. Hence, as shown in Figure 22, to set the analog generator to 100 mVrms, you would set the Analog Level control to 100m, and the Analog Units control to Vrms. To set the analog generator level to -20 dBV, you would set the Analog Level control to -20.0 and the Analog Level Units control to dBV. Note that LabVIEW controls do support the use of SI formatting (100m = 0.100, 10.0k = 10,000, etc.)
Figure 22
Units are handled differently for results returned from APx. This will be discussed in the section on Accessing Measurement Results, later in this document.
Figure 23
Next, change the values of some of the controls in the Level & Gain Config cluster on the front panel of the some of the My APx Program VI. For example, change the Analog Level to 200m, the Frequency to 2.0k, uncheck some of the checkboxes of the Generator Chs enabled control, and change the Low-pass Filter from None to 20 kHz (Figure 24). Now run the VI. The corresponding settings in the APx Level and Gain measurement will be changed and the measurement will be run.
Page 23 of 54
Figure 24
Page 24 of 54
Figure 25
As shown, this VI has two functions: it can be used to get the configuration settings from APx or to set them. Note that the GetSet VI always reads the settings back from the APx500 application after setting them. This ensures that the state of the APx500 application is always maintained by the application itself rather than by LabVIEW. This helps to prevent confusion. So lets look at how to use these Get and Set functions in a LabVIEW VI. We will modify the My APx Program VI to be interactive, to allow the user to change only the specific controls that they wish to. Proceed as follows. 1. In the My APx Program VI, delete the Perform Measurement VI, the Simple Error Handler VI and the Measurement Complete indicator. These will be added again later. Next, add white space to the diagram as shown in Figure 26 (e.g., using Ctrl-drag with the mouse).
Figure 26
2. Add a Boolean button control to the front panel and label it Update APx Settings (Figure 27).
Page 25 of 54
Figure 27
3. Add an Event Case around the APx500 Config-Level & Gain GetSet All VI, move the Update APx Settings control into that case, and change the event handled by the case to be a Value Change of the Update APx Settings control (Figure 28). When the modifications are finished, this will cause the configuration settings to be sent to APx when the button is pressed.
Figure 28
4. Add a While loop around the event case, change its input tunnels to shift registers, and then wire and rearrange the shift registers as shown in Figure 29.
Figure 29
Page 26 of 54
5. Create a local variable for the Level & Gain Config control as follows. Right-click on the controls terminal on the block diagram and select Create Local Variable. Insert the local variable between the beginning of the While Loop and the Event Structure, and wire it as shown. You will need to add another shift register to the While Loop (Figure 30).
Figure 30
6. To make this VI function properly, we need to connect something to the input of the shift register created in step 5. Otherwise, the Level & Gain Config control will not be initialized properly. We want to initialize it to the values that are currently set in APx. Therefore, we need to get the values from APx. Add a copy of the APx500 Config-Level & Gain GetSet All VI to the diagram outside the While loop and wire it as shown in Figure 31. Note that the nothing is wired to the Boolean Set input at the top of the VI. Hence the default value (Get) will be used, causing the VI to get all the current settings from APx and initialize the Level & Gain Config control to those values.
Figure 31
Page 27 of 54
7. To make the VI functional, we need to wire something to the conditional terminal of the While loop. Create a stop button by right-clicking on the terminal and selecting Create Control. Next, create a Stop case in the event structure, move the Stop controls terminal inside the case and wire it as shown in Figure 32.
Figure 32
8. Next, we will add the capability to run the Level and gain measurement. Add a Boolean button Control to the front panel and change its label to Run Measurement. On the block diagram, add a case to the event structure that handles a value change of this control, and move the controls terminal inside this case. Finally, add the Perform Measurement VI to this case and wire the case as shown in Figure 33.
Figure 33
The front panel of the finished VI is shown in Figure 34. When you run this VI, it will get the current Generator and Signal Acquisition and Analysis settings from the APx application and
Page 28 of 54
initialize the LabVIEW Level & Gain Config control to these values. Then, you can change various settings in the LabVIEW control, and pass the settings to APx by clicking the Update APx Settings button. To try it, before running the VI, change a few of the Generator settings in APx. Once you run the VI, it will update the Level & Gain Config control to the current APx settings. Next, change some settings in LabVIEW and then click the Update APx Settings button, to change the settings in the APx500 application. Finally, you can click the Run Measurement button in LabVIEW to make the APx500 application run the Level & Gain measurement.
Figure 34
Note that if the Output Connector is one of the analog types (Analog Unbalanced or Balanced), when you run this VI, it sets the Digital Level control to 0.00 and its units to FS. Furthermore, if you change the Digital Level control and again click the Update APx Settings button, it again resets the Digital Level to 0.00 and the units to FS. This is because the Digital Level setting has no meaning in the context of a signal path with an Analog Output. Therefore, users should be careful to ensure that the context is correct for the controls they are using. For example, if you change the Signal Path from LabVIEW (to be discussed later in this document), be sure to get the measurement configuration settings after doing so.
Page 29 of 54
Figure 35
In the LabVIEW driver VIs, this waveform functionality is accessed using the controls shown in Figure 36, which are part of the Signal Generator Settings cluster. In the LabVIEW Driver, the Waveform Names control is an array containing the names of all the waveforms loaded into the APx project, and the Selected Waveform Index is the index of the Waveform Names array corresponding to the currently selected waveform. For example, the left side of Figure 36 shows how the controls would appear if the APx waveform was set to Sine (index 0), and the right side of Figure 36 shows how the controls would appear if the APx waveform was set to the 4th arbitrary waveform contained in the project (in this case the file named 7kHz-L_8kHz-R.wav). In LabVIEW, it is the Selected Waveform Index that is used to change the waveform in APx.
Figure 36
You can use the My APx Program VI to try this out: First load a few waveforms into the APx project using the Waveform Browse for file option shown on the left side of Figure 35. Set the Waveform control in APx to any one of the loaded files. Then run the VI. The Waveform Names control in LabVIEW will be updated to contain the list of waveforms you just loaded, and the Selected Waveform Index will correspond to the index of the selected waveform, To change the Waveform in APx, change the Selected Waveform Index to a different number, and click the Update APx Values button. The APx waveform selected will change accordingly. To change the
Page 30 of 54
Generator back to Sine, change the Selected Waveform Index in LabVIEW to 0 (zero) and click the Update APx Values button. Note that there is no provision in the APx API for adding waveforms to a project; they can only be added to a project from the APx500 applications UI.
Figure 37
In the LabVIEW Driver VIs, this list of .wav files is handled as a string array labeled Input File List in the Signal Acquisition and Analysis Settings cluster control (Figure 38). When LabVIEW gets the settings, this string array will be loaded with strings such that each element of the array represents the full name and path of one file in the APx file list. The LabVIEW String to Path function can then be used to convert these strings to LabVIEW file paths. To remove a file using LabVIEW, string elements may be removed from the end of the array before passing the array back to APx using the set function.
Figure 38
Page 31 of 54
configuration VIs. Those measurements with three VIs are ones like Level and Gain, which have both Generator settings and Signal Acquisition and Analysis settings. In this case, there is a GetSet Generator VI, a GetSet Signal Acquisition & Analysis VI and a GetSet All VI. This allows LabVIEW user to get or set either of the Generator settings, the Signal Acquisition and Analysis settings, or both. Measurements with only one configuration VI are those which in APx have only Generator settings (e.g., Frequency Response) or Signal Acquisition and Analysis settings (e.g. Noise), but not both (Figure 39). These VIs should be used exactly as described above. Users should get the current settings from APx before changing any parameters, and then do a set to update APx. In addition, the set VIs always do a get after setting, to ensure that they return the correct state of APx.
Figure 39
changed once, and the 50 dependent VIs will be updated automatically. The orange color is used simply to make it obvious that a custom control is a Type Def. It is easy to change the orange color of controls used in the driver VIs. First, you need to disconnect the control from its Type Def. To do so, right-click on the edge of a cluster control and select Disconnect from Type Def. You will be prompted with a dialog box to confirm this operation. Note that many of the cluster controls contain sub-controls that are also Type Defs. Therefore, you may need to disconnect several controls from their Type Defs to completely remove the orange color. Figure 40 illustrates the process for one of the Type Defs in the Level & Gain Config cluster, and the final result when the color of every orange control has been changed.
Figure 40
Page 33 of 54
1. Since we are only changing the generator settings, we can use the Level & Gain GetSet Generator VI instead of the GetSet All VI. Right-click on the GetSet All VI on the block diagram, and use the Replace menu to change the VI (Figure 41).
Figure 41
2. Disconnect the Level & Gain Config control from its Type Def. (if is not already disconnected) and disconnect the Signal Generator Settings (L&G) cluster from its Type Def. 3. Drag the Frequency and Analog Level controls out of the Level & Gain Config control cluster. 4. Delete the Level & Gain Config cluster, so that only the Frequency and Analog Level controls remain in its place (Figure 42 and Figure 43).
Figure 42
Page 34 of 54
Figure 43
5. Finally, re-wire the block diagram as shown in Figure 44. Note the use of the Unbundle by Name function outside the Event Structure, and the use of the Bundle by Name function. These functions are used to get the values of only the Frequency and Level controls from the Signal Generator Settings (L&G) output cluster, and to pass them back in to the corresponding input cluster.
Figure 44
The My APx Program VI as modified to allow the user to change only the generator frequency and level of the Level and Gain measurement is now ready to run. If you run it, you will see that it functions as it did before. The APx LabVIEW Driver VIs use cluster controls extensively. The best way to get individual data items out of a cluster or into a cluster is by using the Bundle by Name and Unbundle by Name functions in LabVIEW. Figure 45 (left) shows the Unbundle by Name function being used to extract specific elements of the Signal Generator Settings (L&G) cluster.
Page 35 of 54
Figure 45
Figure 45 (right) shows the Bundle by Name function being used to replace 4 specific elements of a Signal Generator Settings (L&G) cluster.
Figure 46
Page 36 of 54
In the case of the Stepped Frequency Sweep measurement, there are 7 results available. If you run a Stepped Frequency Sweep measurement and browse through the results, you will notice that 6 of the 7 results are displayed as an XY graph (e.g., Level is displayed as a graph of Level versus frequency). These are referred to as XY type results. One of the results in the collection Deviation - is displayed as a bar graph with one bar per channel Figure 47. These latter results, which consist of a single value, are referred to as Meter type results.
Figure 47
Each measurement has a different results collection - some have all Meter type results, some have all XY type results, and some have a combination of the two result types. Now lets look at how the LabVIEW driver handles measurement results. Open the APx500 Example-Simple Meter Measurement VI (available from the Examples subpalette of the driver palette) and examine its front panel. Ignore the orange color of the controls. This simply denotes that they are still associated with their Type Defs. This VI is set up to configure and run a Level and Gain measurement located in Signal Path1 (one of the defaults for a new project file created with the default template). Notice that the Selected Measurement Index is set to 3 (the position of the Level and Gain measurement in Signal Path1. The Level & Gain Config control as set in the project will set the analog generator to 100 mVrms or -20 dBFS at 1 kHz, and enable all generator channels. Configure the APx500 application to use 2 Input Channels (in Signal Path Setup). Now run the VI and observe the contents of the Measurement Results Cluster (Figure 48). Note that it now lists the Path Name as Signal Path1, and the Measurements array inside the Measurement Results cluster has one element - with Measurement Name field containing Level and Gain. Inside the Data cluster are two more arrays named XY Results and Meter Results. Note that the XY Results array is empty (this makes sense, because Level and Gain has no XY type results). Also, the Meter Results array has two elements: one for the Level result and one for the Gain result. As shown, clusters in the Meter Results array contain an indicator showing the result name, the units, and whether all channels passed upper and lower limits.
Page 37 of 54
Figure 48
If you change the index of the Meter Results array, you will notice that there are two elements in the array, corresponding to the two results available (Level and Gain). Inside the cluster is an array called Readings, which in turn contains a cluster of result Values, and indicators Passed Upper Limit and Passed Lower Limit (Figure 49). Note that the number of elements in the Reading array corresponds to the number of Input channels selected in APx (in this case 2).
Figure 49
At first glance, the Measurement Results cluster appears complicated. However, if you study it, you will find that the data is organized in much the same fashion as the measurements results are
Page 38 of 54
organized within the APx500 application. Furthermore, it is a very efficient scheme for getting the measurement data from APx, because all of the results from one measurement are contained in a single cluster that can be passed to subVIs in a single wire (Figure 50). In fact, the Measurement Results cluster can hold the results for all the measurements in one signal path. This will be demonstrated later, with an example that runs a Sequence in APx.
Figure 50
Note in Figure 50 that there are only three VIs needed to open a reference to APx, select and run a Level and Gain measurement, and get back all the data for that measurement. There is a similar example in the driver VI collection named APx500 Example-Simple Sweep Measurement.vi. This example runs a Stepped Frequency Sweep and returns the Measurement Results cluster. If you run it, you will see that the XY and Meter results returned correspond to those available for this measurement in APx. There are two driver VIs in the collection that simplify getting Meter results and XY results from the Measurement Results cluster. Their context help is shown in Figure 51.
Figure 51
For an example of how to use the above two VIs, see the example VI named APx500 ExampleSimple Data Results, available from the Examples sub-palette of the driver menu Palette.
Page 39 of 54
Figure 52
Note the API provides the ability to change units programmatically, but this is not supported in this release of the APx LabVIEW Driver.
Page 40 of 54
measurement. Note that the elements in this array of clusters are the same as Measurement Results cluster returned by the Perform Measurement VI. In this case, the array contains one element for each signal Path in the sequence. This is a very efficient way to get an entire sequence worth of measurement data from APx to LabVIEW. And as shown in Figure 54, the LabVIEW code required to get all this data is very simple.
Figure 53
Another variation on running a sequence is illustrated in the example named APx500 Example Run Sequence & Save PDF Report.vi, shown in Figure 55. This example was designed to look more like a User Interface (there are no orange colored controls). It runs a sequence and optionally exports the APx report to an external file (PDF, HTML, RTF, xls or text). This example illustrates the use of three utility VIs included in the driver collection: one to open a project file, one to set the visibility of the APx500 application, and one to turn the APx signal monitors on or off. See the context help for these VIs in Figure 56. Note that turning the signal monitors off can save significant CPU resources, especially with high channel counts.
Page 41 of 54
Figure 54
Figure 55
Page 42 of 54
Figure 56
Page 43 of 54
Figure 57
The Perform Measurement button on the Test Configuration panel will cause the APx500 application to run the selected measurement. After the measurement is complete, on the Test Results panel, the user can select which measurement results to display. XY graph type measurements are displayed as a graph, and Meter type results are displayed as a list. This example VI can also be used to run all checked measurements in the sequence. If the sequence is run from the VI, all of the sequence measurement results will be available for browsing in the Test Results panel of the VI. The User Interface example is not meant to replace the APx500 applications UI, but it does demonstrate many of the feature available in the LabVIEW Driver for working with the APx API. Many users will be able to customize this example to create LabVIEW applications that suit their own needs.
Page 44 of 54
Figure 58
For an example of how to set the Output Connector Type, see the VI named APx500 Example Set Output Connector Type.vi. This VIs front panel is shown in Figure 59, and its block diagram is shown in Figure 60. If you run the VI and change the Output Connector Type, this change will be reflected in the APx500 UI, if the connector type is valid for the connected instrument. If the connector type is not valid (for example, setting the control to Digital HDMI when the HDMI option is not present), APx will generate an error. The function of the GetSet Input Connector Type VI is very similar.
Figure 59
Page 45 of 54
Figure 60
In the APx500 application, settings can be configured for each Input and Output Connector type. Note the Settings button to the right of the Connector list box control in the Output Configuration area of Signal Path Setup. When you click this button, the Output Settings dialog box for the selected connector type opens as shown in Figure 61. There is a similar Settings dialog for the Input Configuration in APx500.
Figure 61
Page 46 of 54
In Figure 61, the selected Output Connector is Digital Unbalanced. The VI for configuring these settings is named APx500 Config-SigPath GetSet Output Digital Unbalanced. Its context help and configuration settings control are shown in Figure 62. Note the correspondence between the LabVIEW controls in Figure 62 and the APx500 controls in Figure 61.
Figure 62
There are similar VIs for configuring input configuration settings and output configuration settings of the following connector types:
Analog Unbalanced Analog Balanced Digital Unbalanced Digital Balanced Digital Optical Digital HDMI
Note that VIs are not included for configuration settings of the Digital Serial input and output connector types. This is because the LabVIEW driver does not support their configuration. In addition, there is no VI for the None (External) output connector type, because in this case, there are no settings to set. Figure 63 shows an example VI from the driver collection named APx500 Example - Configure Digital Unbalanced Output. This example illustrates configuring the Digital Unbalanced output connector settings from LabVIEW. It is similar in structure to the example shown in Figure 59.
Page 47 of 54
Figure 63
Reference Levels
There are two sets of VIs in the driver collection for dealing with APx500 reference levels. The first is the VI named APx500 Utility-Get Set Reference Levels. This VI is similar in function to the other configuration VIs. A cluster named Reference Levels is passed into and out of this VI. The context help for the VI and the Reference Levels cluster are shown in Figure 64. Note the similarity of the controls in the cluster to those on the References page (accessed from the References button near the bottom of the APx500 screen in the Reference Levels measurement).
Figure 64
Page 48 of 54
To set a reference level in LabVIEW, the procedure would be (1) get the reference levels cluster to determine the current settings, (2) use the Bundle by Name function to change the value of the reference level you want to change, and (3) set the reference levels using this VI to update APx500. There are two additional VIs in the driver collection related to reference levels. These VIs are for accessing the auto-set generator level feature in APx500. The window in Figure 65 becomes visible in APx when you click the Auto Gen Level button in the Signal Generation box of the Reference Levels measurement.
Figure 65
The VI on the left side of Figure 66, called Reference Levels GetSet Auto Gen Level.vi is used to get or set the auto-set generator level settings. The VI on the right side of Figure 66 is used to initiate the auto-set generator level measurement. It is equivalent to pressing the Set Generator Level button (at the bottom of the window shown in Figure 65.
Figure 66
Page 49 of 54
Note that the Auto Gen Level feature is a type of regulation measurement that iteratively tries to find a generator level that produces the specified distortion. If it can not find a suitable generator level, APx will generate an error that will be returned to LabVIEW. However, the error message passed to LabVIEW in this case is not as easy to understand as the one generated by APx (Figure 66).
Figure 67
Figure 68 shows the front panel of an example VI included in the driver collection that illustrates working with auto-generator level VIs.
Figure 68
Page 50 of 54
Figure 69
Figure 70
Page 51 of 54
Figure 71
Figure 72
Page 52 of 54
Figure 73
Figure 74 shows a sample VI from the Driver Examples folder that illustrates using the WaveReader DLL. This example, with the accompanying APx project file (WaveReaderExample.approjx), illustrates acquiring two channels of data at a 48 kHz sample rate from APx500 with the VIs waveform and FFT graphs being updated every 0.1 seconds. The example uses a chirp signal that sweeps from 20 Hz to 20 kHz in 3 seconds.
Figure 74
Page 53 of 54
Conclusion
This concludes the getting started tutorial. We hope that the APx LabVIEW Driver will be a good resource for LabVIEW developers wanting to control and interact with an APx audio analyzer. Users wanting additional information should check our web site (www.ap.com) or contact Audio Precision Technical Support.
XII0117163900
Page 54 of 54