Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Links - Developer Zone

Related Links - Products and Services

Using Microsoft Excel and NI Switch Executive in Test System Development

8 ratings | 3.75 out of 5
Read in | Print

Overview

Every automated test system involves some aspect of switching or signal routing. This implementation can span from simple general-purpose relays that control power to a device under test (DUT) all the way to complex matrix configurations that route thousands of test points to dozens of instruments. When the number of relays to control is small, the test code required to control them is straight-forward. When the number of relays and routes enters double-digits or spans multiple switch modules, it becomes advantageous to use some kind of routing database to manage the switch connections.

Typically, customers have chosen either a spreadsheet like Microsoft Excel to handle these routes or used a switch-specific application like NI Switch Executive switch management software. Both methods accomplish the desired task of serving as a “look-up” table for switch routes, but Switch Executive also includes validation, documentation, debugging capabilities, and integration with LabVIEW, LabWindows/CVI, and TestStand for simplified calls to the routing engine. In the past, it was necessary to either choose Switch Executive or Excel to handle the routing, making it difficult for customers who were more comfortable with Excel or had existing route diagrams in Excel to upgrade to the capability of Switch Executive. Starting with Switch Executive 2.1, it is now very simple to integrate the native capabilities of Switch Executive and the spreadsheet functionality of Microsoft Excel (or any other spreadsheet/database). The following document describes the procedure for accomplishing this task and simplifying your automated test code.

Background on NI Switch Executive

NI Switch Executive is an intelligent switch management and routing application. With NI Switch Executive, you gain increased development productivity by interactively configuring and naming switch modules, external connections, and signal routes. You also increase test code reuse and system performance with switch programming in conjunction with National Instruments TestStand, LabVIEW, LabWindows/CVI, and Measurement Studio. Ultimately, NI Switch Executive simplifies switch system configuration and increases test performance, thus lowering your cost to test. It does this through the following features:

Intuitive Configuration Environment
NI Switch Executive has an intuitive configuration environment in which you can create Switch Executive "Virtual Devices". You use the Switch Executive Virtual Device configurations to combine a variety of IVI-compliant NI and third-party switches to create a single virtual switch device. For each switch module, you can specify:
  • Desired channels
  • Hardwires
  • Routes/Route groups
  • Physical attributes
Using NI Switch Executive, you can store the physical attributes associated with each switch configuration and intelligently use the information to help you determine proper switch routes. This helps you protect the large investment in switch hardware from being overdriven or routing a high-frequency signal across a low-frequency switch device.

Rapid Channel Configuration
NI Switch Executive rapid application configuration environment also includes tools for configuring the channels used in complex switching systems. With this, you can create alias names and add unique comments for each channel -- greatly simplifying the management of hundreds or thousands of switch channels in large switch systems because you can refer to a channel as "DMM" or "Scope" instead of "c0" or "c2". You can also take advantage of the channel alias feature when using multiple switch devices.

Easily Connect Channels to Form Routes
Once you have configured all of the required channels, NI Switch Executive provides an interactive utility to assist you in connecting pairs of channels to form routes. With this utility, you simply select two channels to be connected from the list of alias channel names or full channel names and then NI Switch Executive recommends an available route based on the previous specified channel and hardwire information.

The NI Platform
NI Switch Executive integrates perfectly in the complete NI integrated test architecture for a much improved development experience when building ATE test systems. For instance, you can easily integrate NI Switch Executive within the NI TestStand test management environment for controlling your switches on a per test basis. You can also use NI Switch Executive to easily program your switches within individual test modules written in the popular test languages, such as NI LabVIEW, NI LabWindows/CVI, and NI Measurement Studio for Visual Studio.

System Maintenance
Lastly, automated switch systems are far easier to maintain through the use of NI Switch Executive. The interactive and easy-to-use configuration environment makes it easy to quickly change your switch routes and hardware to reflect changes in the product. Because NI Switch Executive takes advantage of the Interchangeable Virtual Instruments (IVI) standard, you can quickly interchange your IVI-compliant switch hardware with another version of the switch or a switch from a different vendor without having to rewrite any of your test code (assuming you are using IVI Switch Class Driver functions).

Combination of NI Switch Executive with Microsoft Excel


Before NI Switch Executive 2.1, there was no option to incorporate pre-existing Excel route maps into a Switch Executive Virtual Device. With the new NI Switch Executive Configuration API, every “behind-the-scenes” function of Switch Executive is exposed to the user so applications or (in the case of Excel) macros can be written to translate configurations in the Switch Executive routing engine. Because moving routes to and from Excel is a popular use case of this API, two example programs were developed to demonstrate this capability.

The first example, GenerateExcelReport.xls, can be found in the Program Files >> National Instruments >> Switch Executive >> Examples >> Excel subdirectory (according to the default installation location). This example program opens with a macro-generated sheet that provides a pulldown menu of the existing virtual devices configured on your system. If you have already developed virtual devices in Switch Executive, you will see them listed in the pulldown menu.



[+] Enlarge Image
Figure 1: GenerateExcelReport.xls example program for NI Switch Executive and Microsoft Excel.


By pressing the “Generate Report” button, you are triggering the Visual Basic Script code written in this example program to pull all of the information from the virtual device and configure it in the cell/tab format of Microsoft Excel. The VB Script macro for this example program can be viewed by selecting Tools >> Macro >> Visual Basic Editor. An example screenshot of the VB Script code is included below:



[+] Enlarge Image
Figure 2: Visual Basic macro written for Excel/Switch Executive integration.

Once the macro finishes running, you will see a new workbook appear with the virtual device data separated into a tab format similar to the tabs that are used for Switch Executive:



[+] Enlarge Image
Figure 3: Example view of generated Excel sheet from a Switch Executive virtual device. The tabs in the Excel sheet match up with the tabs found in Switch Executive.

The virtual device name is listed in cell A1 of each tab. The information for the IVI device, channel aliases, exclusions, hardwires, buses, routes, and route groups are then displayed on each tab. This is often an easier way to look at the entire virtual device than through the Switch Executive route editor. Although Switch Executive has a “generate report” feature of its own, some engineers feel more comfortable with the spreadsheet layout and printing options. In this case, generating an Excel report of an existing virtual device can be very useful.

The other option, which would be generating a virtual device from an Excel file, is generally more useful. The other Excel example that comes with NI Switch Executive is titled “ImportFromExcel.xls” (it is found in the same hierarchy location as the previous example). With the ImportFromExcel example, the user is presented with a similar opening sheet:



[+] Enlarge Image
Figure 4: ImportFromExcel.xls example program for NI Switch Executive and Microsoft Excel.

In this case, the embedded macro for this sheet populates the pulldown with all the currently loaded Excel workbooks. It is possible to generate a virtual device in Switch Executive based upon a loaded workbook – this is done by pressing the “Import” button in the example program.

In order for this to be possible, the VB Script macro in this worksheet translates key information from the chosen loaded workbook and, using the Switch Executive Configuration API, converts that information into a virtual device. In order for this to work, the information must be formatted in the same way that the worksheets in the “GenerateExcelReport” example were formatted. It is possible to translate any existing Excel format, but the macro must be altered to match the new data format. However, the template used in the GenerateExcelReport example is still a very powerful tool for the test system developer to utilize; it provides a template from which to start making a route diagram. When finished, it can be easily imported into a Switch Executive virtual device file without ever having to open Switch Executive (you must have Switch Executive installed on the system, though).

Why is the Excel Import Capability Helpful?


The ability to import configurations from Microsoft Excel into Switch Executive offers several advantages to the ATE system designer. First, it allows existing Excel routing diagrams to be leveraged; there is no need to scrap existing work to use the Switch Executive environment. Second, the “click-and-drag” capability of Excel makes it easy to create hundreds or thousands of aliases, routes, hardwires, etc. based on a parent name. In other words, if you create DUT1 in your first cell, DUT2 in the second cell, then highlight and drag those items to a new cell, the number at the end of DUT will be incremented. While the Switch Executive environment has a method for batch renaming of channel aliases, it can save time in creating a large number of routes as the Switch Executive environment was not made for mass route naming.


Figure 5: Example of consecutive naming capability in Microsoft Excel. When aliases or route names are formed from a parent like "LED_", it is easy to "click and drag" in Excel to create multiple names.

These advantages allow the user to take advantage of Switch Executive’s greater ease-of-use when it comes to communicating with switch hardware or deploying systems in the first place. The hardware abstraction, route grouping, and deployment capability of Switch Executive offer gains in system longevity and reduced programming complexity in ATE systems.

Simplified Switch Programming with NI Switch Executive


Once the virtual device is complete, you can use the Switch Executive API available for LabVIEW, LabWindows/CVI, or Visual Studio to call the routes or route groups you’ve created. An example of the LabVIEW code is shown below. The “what to connect” control represents the location of the route or route group to close. For a system requiring dozens of relays to close in every test step, making a single call to the switch hardware is often much easier and maintainable than closing each relay individually.



[+] Enlarge Image
Figure 6: Screenshot of Switch Executive API in NI LabVIEW.

For systems programmed in NI TestStand, each switch command can be embedded into the property of the test step. The switch programming in these situations is relegated to simply checking the “enable switching” box and then choosing the appropriate virtual device, route/route group, and then selecting the duration of the closure. This method completely separates switch code from the individual test code modules in an ATE system. As switching hardware changes in the future, your instrumentation test code can stay the same in this manner.



Figure 7: Screenshots of NI TestStand sequence editor and step property information. The "switching" tab in the step property allows you to configure all the switching information for a given step without writing a line of code.

Conclusion


As the complexity of ATE systems grows, the complexity of the switching inside these systems will likely grow at an even faster rate. Using tools like Switch Executive and Microsoft Excel can make managing switch routes much easier and make the system much more adaptable to future test needs. The ability to integrate pre-existing Excel route maps or use Excel as a compliment to route creation in Switch Executive combines the best of both worlds for an ATE system designer.
8 ratings | 3.75 out of 5
Read in | Print

Reader Comments | Submit a comment »

doesn't work?
where does the imported excel file get imported to?
- Eric Garrison, Raytheon. eric_j_garrison@raytheon.com - Feb 13, 2007

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).