odbc data management under dasylab 9 · 2007. 4. 19. · to the dasylab worksheet so all of your...

7
TECHTIP 60102 ODBC Data Management under DASYLab ® 9.0 www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected] www.iotech.com INTRODUCTION Data Acquisition System owners and users often store data within an Excel Spreadsheet environment regarding the sensors and actuators that they use in various systems. The list is a “database” frequently used to inventory components such as valves, accelerometers, and other sensors and actuators and schedule them for periodic calibration or maintenance. In addition, the critical specifications are frequently listed so they are easy to select at a glance. Some spreadsheets may contain only a few devices, while larger company inventories may contain thousands of devices. Such Excel Spreadsheet data are easy to import into DASYLab as a database to build a custom system configuration or conduct tests. In addition, these variables can be used to configure the test parameters such as setting full-scale ranges and gains. This data may also typically be printed out as a part of a test report documenting the process. DISCUSSION Start the process by formatting the Excel worksheet containing your data. First, enter a title for each column in Row 1. Format the content of the cells as Text or Number. The precision of the data also may be specified now if desired. PROCEDURE For the following example, the “search data” (the Model for each valve) is contained in the first column and formatted as Text. The worksheet containing the data can also be renamed from Sheet 1 to something more meaningful or easier to identify. In this example, Sheet 1 has been renamed Properties. Figure 1. “Formatted Excel Data Table” Figure 2. “Selections Under Format Cells”

Upload: others

Post on 24-Nov-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

TECHTIP 60102ODBC Data Management under DASYLab® 9.0

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

www.iotech.com

INTRODUCTION

Data Acquisition System owners and users often store datawithin an Excel Spreadsheet environment regarding the sensorsand actuators that they use in various systems. The list is a“database” frequently used to inventory components such asvalves, accelerometers, and other sensors and actuators andschedule them for periodic calibration or maintenance. Inaddition, the critical specifications are frequently listed so theyare easy to select at a glance. Some spreadsheets may containonly a few devices, while larger company inventories maycontain thousands of devices.

Such Excel Spreadsheet data are easy to import into DASYLab asa database to build a custom system configuration or conducttests. In addition, these variables can be used to configure thetest parameters such as setting full-scale ranges and gains. Thisdata may also typically be printed out as a part of a test reportdocumenting the process.

DISCUSSION

Start the process by formatting the Excel worksheet containingyour data. First, enter a title for each column in Row 1. Formatthe content of the cells as Text or Number. The precision of thedata also may be specified now if desired.

PROCEDURE

For the following example, the “search data” (the Model for eachvalve) is contained in the first column and formatted as Text.The worksheet containing the data can also be renamed fromSheet 1 to something more meaningful or easier to identify. Inthis example, Sheet 1 has been renamed Properties.

Figure 1. “Formatted Excel Data Table”

Figure 2. “Selections Under Format Cells”

Page 2: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

The Excel Data File may be saved to any location on thecomputer’s hard drive, but here, the file is saved in the Datafolder under the DASYLab 9.0 directory to make it easier tomanage and locate.

The User DSN for the source data must now be defined. Click Addand select the appropriated source file type from the listing. Inthis example, the data file has been generated in Excel, thereforethe correct driver is Microsoft Excel Driver(*.xls). Click Finish toaccept the selection.

Figure 3. “File Saved to Data Folder”

The data file must now be defined as an ODBC data source. Thisis accomplished by opening Control Panel/Administrative Tools/Data Sources (ODBC) on your computer.

Figure 4. “ODBC Setup Access”

Figure 5. “ODBC Data Source Admin Utility”

Figure 6. “Data Source Driver Selection Dialog”

The source data file will now be selected. A Data Source Namemust be established. This name will be linked to the file and usedto identify the source data in subsequent steps, so select a logicaland easily identifiable name. A Description can also be entered tohelp keep it organized.

Figure 7. “ODBC Microsoft Excel Setup Dialog.”

Click Select Workbook and “browse” to the folder containing thedata file. All .xls files in the selected folder will be visible in theleft pane of the dialog box. Select VALVE TEST DATA TABLE.xlsand click OK to exit the dialog box.

Figure 8. “Select Workbook Dialog”

2

Page 3: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

3

The selected data file should now be listed in the ODBC DataSources as shown in Figure 9. Click OK to exit the dialog box.

Next, click Browse to select the desired table in the source datafile. The renamed Properties worksheet is easily identified in thelisting. Select this and click OK to exit the dialog box.

Figure 9. “Valve Data Table in the User DSN Listing”

Now the source data are available to DASYLab. Start the DASYLabapplication and insert an ODBC Data Input module.

Figure 10. “ODBC Input Selection”

Double click on the worksheet icon to access the ODBC InputProperties. In the Data Source selection entry field, click Browse.The Valve Data Table defined in the previous steps will be in thelisting. Select this file as the source and click OK to close thedialog box.

Figure 11. ”Browse Data Source Selections”

Figure 12. “Browse Table Selections”

When using the Excel source data files, the checkbox for UseQuotes for Names in SQL Statements should be checked. Selectionsfor User Name and Password are available to permit secure accessto source data files that may be protected. In this example, theseentries are not required.

Click on the Get Columns button to import the worksheetinformation. The titles from row 1 of the Excel sheet are nowavailable to identify the columns, and the data format is alsolisted. Note that there is a mix of VARCHAR and NUMBER datatypes reflecting the format assigned in the Excel worksheet.

Figure 13. “Imported Column Information”

Page 4: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

Global variables can now be assigned to each of the numericcolumns. Click on the first numeric column assignment toselect, then “right click” in the Variable entry box. The screenshown in Figure 14 will be displayed. Select Global Variable andthe Select Global Variable dialog box will be displayed.

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

4

Click Define to establish how DASYLab will work with thevariable. You can define the number of characters in the vari-able, the precision, and a default value if desired. For additionalinformation on the options available for Global Variables andStrings, refer to the Help Files for DASYLab. In this example,options for Write to Data File Header and Show Global Variablesin Window are selected. Precision has been reduced to 1 decimal.

Figure 14. “Global Variable Selection for the First Numeric Column”

Figure 15. “Global Variable 1 Selected”

Figure 16. “Defining the Global Variable”

Repeat the process for the remaining numeric variables, assigningeach to an incremental Global Variable number.

Figure 17. “All Numeric Variables Assigned”

Page 5: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

The Model is to be used as the look-up for the table data, andthe operator is to be prompted to enter this information at thestart of the run. To accomplish this, a few additional stepsneed to be performed.

Click on the Model listing to select and then “Right Click” on theVariable entry field. Select Global String as the variable type.

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

5

Check the boxes for Write to File Header, Show Global String inWindow, and Type in at Start of Experiment. Text entered in theDescription entry field will be offered to the user at the start of therun, prompting the operator for entry. Checking the box forInput Necessary will prevent the worksheet from executing untilthe operator enters a value at the start of a run.

Figure 18. “Global String Selected for Variable Type”

Click on the first Global String in the listing to select, and thenclick Define.

Figure 19. “First Global String Selected”

Figure 20. “Defining the Global String Parameters and User PromptTest”

Click Save to update the variable and exit the Dialog box. ClickOK to close the Global String Dialog.

The Search Condition must now be defined. The Model Codecolumn entry will be the search criterion. Global String #1defined in the previous step must be entered by the operator andwill be the value the application will search for in the Model Codecolumn of the data table. Enter the Search Condition statementexactly as shown in Figure 21.

Figure 21. “Search Condition Entry”

Page 6: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

The column title is enclosed in quotes and the Global Stringdesignation is enclosed in brackets { } not parentheses ( )enclosing the string required when searching text data.

Click OK to close the ODBC Input properties menu and returnto the DASYLab worksheet so all of your work will be secure.

An Action module will be required to execute the ODBC Read.Add the module to the worksheet and “double-click” to openProperties. For the Event, select Experiment Start, and define theReceiver to be the ODBC Input Module. The action will default toRead From database. Click OK to apply the changes and exit theproperties dialog box.

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

6

Figure 22. “Action Module Parameters”

An Action Module requires a connection on its input to func-tion. Although our condition has been defined as ExperimentalStart rather than some active, changing signal, an object needsto be attached. For example, add a switch to the worksheet asshown in Figure 23.

Figure 23. “Tie a Switch to the Open Action Module Input”

Now check to see how it works. Click on the Start button and theStartup Parameters dialog box will appear. The text enteredpreviously for the Global String appears as a user prompt in thedialog box. Enter a valid Model and click on Start.

Figure 24. “Type in Startup Parameters”

If the Global Variable Content window does not appear, it isprobably minimized at the bottom of the desktop screen.

Figure 25. “Global Variables and Strings Display Window.

Page 7: ODBC data management under DASYLab 9 · 2007. 4. 19. · to the DASYLab worksheet so all of your work will be secure. An Action module will be required to execute the ODBC Read. Add

www.iotech.com • IOtech • 25971 Cannon Rd • Cleveland, OH 44146 • (440) 439-4091 • Fax (440) 439-4093 • [email protected]

7

Final TouchesTo make this demonstration more exciting, add a Global VariableRead module to the worksheet and tie in some digital displays asshown in Figures 26, and 27. Following these basic steps will let youaccess a data table to import multiple variables into any DASYLabapplication. When using Excel as the source database, variables for65,000 different valves can be accessed easily.

Figure 26. “Select Global Variable Read”

Contact InformationIOtech25971 Cannon RoadCleveland, Ohio 44146Phone: 1-440-439-4091Fax: 1-440-439-4093Email: [email protected]

Figure 27. “Read current/Value”

Note: This application was developed and submitted by David McFate,Application Engineer at IOtech, Inc.