Data Set Logger Tutorial for LabVIEW DSC Module
Table of Contents
Overview
With the LabVIEW Datalogging and Supervisory Control (DSC) Module, you can organize your historical data into data sets. A data set is group of tag values that are logged together during some finite time period. A data set might cover a batch of some sort and contain all the values generated during a single execution of a batch process. For example, on the picture below, three tests were performed on a motor to measure the motor response on a triangle-like setpoint function. The red graph represents the setpoint value; the white line is the motor response.

There are two tags configured in the .scf file. MotorRPMSetPoint holds the setpoint value, and MotorRPMSensor represents the motor response. In the DSC Module, both tags are logged to the historical database, and all their values can be retrieved by either the Historical Data Viewer in MAX or the historical data VIs. So, how does the Data Set Logger, shipped with the DSC Module, make it better?
The Data Set Logger marks the beginning and the end of each test with special markers. The data between the start and end points is called a run. Each run is identified by its ID. In our motor example, one test corresponds to one run. As you can see from the picture, there are three runs stored in the database. Their IDs are Run 1, Run 2, and Run 3. The DSC Module provides functionality to retrieve data from the database based on a run ID. This means that you don't have to remember what time the tests were executed. You don't even have to remember how many tests have been executed. All this additional information is logged by the Data Set Logger to the historical database. With a single VI, you can retrieve the list of runs. With another VI you can retrieve data from that run.
Data Set Logger Fundamentals
Don't skip this section. It can save you a lot of time.
The Data Set Logger is implemented as a VI-based server. The following bullets explain what that means to you as a developer:
-
The server is a stand-alone entity. That means the data set support is not integrated in the Tag Engine. All the hard work is done by the server. For the LabVIEW DSC module, the Data Set Logger is just one of the many VI-based servers. Before you start, make sure the server is registered. Launch the Configuration Wizard in the Tag Configuration Editor and check if the Data Set Logger is among the listed servers. If not, then you have to register it. Exit the Tag Engine and the Tag Configuration Editor. Open the DSCDS_RegServer.vi from the LabVIEW\vi.lib\lvdsc\servers\Data Set Logger\DSCDS_Server.llb library and run it. Then open the DSCDS_Server.vi from the same library. If the VI is giving you a dirty bit (asterisk in the title bar), save it. You can try to run the VI, but you will have to manually close it, in order to stop it.
-
Because the functionality is not supported directly by the DSC Module, the data set configurations are not saved in the .scf file. They are saved in a separate .ini file: LabVIEW\vi.lib\lvdsc\servers\Data Set Logger\dscdatasets.ini. Make sure you include this file in your distribution, if you need to deploy your application.
-
You must make sure the Data Set Logger configuration always matches the .scf configuration. For example, if you change a name of a tag used in a data set, you have to make the same change in the data set configuration. If you start a new .scf file with a new set of tags, you might want to delete the dscdatasets.ini file.
-
You have to make sure the Data Set Logger is launched by the Tag Engine when you start the Tag Engine. The most elegant way to ensure the Tag Engine will start the Data Set Logger is to include at least one Data Set Logger item in the tag configuration file. You will learn how to do that later in this document.
If you are still unable to get the Data Set Logger to log data, even after reading this document, refer to the knowledgebase below for additional troubleshooting hints.
See Also:
KnowledgeBase: Why Can I Not Create Runs with Data Set Logger in LabVIEW DSC Module?
Configuring the Data Set Logger
To create a data set for our motor test example, follow these steps.
1. Open the Tag Configuration Editor (Tools»DSC Module»Configure Tags in version 7) and create a new .scf file (File»New).
2. Launch the Configuration Wizard from the Edit menu.
3. Browse to National Instruments.OPCDemo and select the MotorRPMSensor and MotorRPMSetPoint tags as shown in the following picture. Click OK.
Note: We will use the OPCDemo to simulate the device. The OPCDemo reads the value of the setpoint and tries to adjust the sensor value to it, with some time delay. The delay creates an impression of a real device.

[+] Enlarge Image
4. Create two additional tags: an ID tag and a control tag.
- Create a text-only string memory tag called Set1 ID Tag. In our example we will identify the run by a string with the following format: 'Test HH24:MM:SS' (for example, 'Test 14:58:33'). The timestamp is taken the time the test starts. The ID can be anything, but we have chosen to add the timestamp to the field to make it unique. An ID tag is a string or analog tag from your active .scf file. When you start logging a data set, the value of the ID tag at that time becomes the identifier of that data set run. For example, an ID tag might be the serial number of a unit under test, and the data set for that serial number might consist of the traces logged during testing of that unit. Because the same unit might be tested more than once, that ID tag might be used more than once. The Data Set Logger handles this case by creating a unique internal ID for every run. However, you might want to assign a unique ID tag for each run. For example, you could combine a serial number with a timestamp.
- The control tag in our example is called Set1 Run Tag. Create this tag as a discrete memory tag. A control tag is a tag that determines the start and end timestamps of a run. The control tag is associated with start/end conditions. When a condition is met, the Data Set Logger logs the start (or end) marker. When the start condition is met, a new run starts, provided that the previous run has ended. When the end condition is met, the run ends.
The complete list of tags is shown in the picture below:

5. Save your .scf file. Otherwise, you won't see the changes in the Data Set Logger configuration window.
6. Select Servers»Data Set Logger Configuration. The following dialog box appears. If the dialog box opens with existing data set values, you can edit that data set or select File»New to create a new data set.

7. Enter values on the Definition tab as shown on the picture above. The Data Set Name is a string that identifies the data set. The ID Tag in our case is Set1 ID Tag. Our control tag is Set1 Run Tag. When its value goes ON, the Data Set Logger will log the start marker. When it goes OFF, the Data Set Logger will log the end marker.
Note: The control tag does not control the logging itself. The tag values are continuously logged to the historical database, regardless of the control tag value. The Data Set Logger's job is to log the start and end markers for the traces in the set. The control tag controls this start/end marker logging.
8. Click the Tags tab, and click Add to select the tags you want included in your data set. All tags/traces to which a data set refers must be logged in the same database. For this example, add the MotorRPMSetPoint and MotorRPMSensor tags to the set.
Note: You should use a data set configuration only with the .scf file you used to create it. Additionally, if you change the name of a tag in your .scf file, and that tag is used in a data set configuration, you must edit the data set configuration separately.
9. Click OK to close the configuration window.
Important: At this point the configuration itself is done. However, you must make sure the Data Set Logger gets launched when you start the Tag Engine. The most elegant way to ensure the Tag Engine will start the Data Set Logger is to include at least one Data Set Logger item in the tag configuration file, as follows.
10. Launch the Configuration Wizard from the Edit menu.
11. Browse to the Data Set Logger server and add its active item to the .scf. Go back to the editor and rename the item to Set1 Active.

[+] Enlarge Image
The complete list of tags should look similar to this one:

12. Restart the Tag Engine if it is running, so that your changes take effect.
Here is the complete .scf file and the Data Set configuration (LabVIEW\vi.lib\lvdsc\servers\Data Set Logger\dscdatasets.ini):
To make sure the Tag Engine will load this file, select it in the Tools»DSC Module»Options dialog box.
Logging Test Data (Runs)
This section describes how to create a VI that executes the motor tests. The example VI has a Start Test button that is used to start a test. Once started, it runs a predefined setpoint waveform, represented by the red line on the trend. The motor tries to follow the setpoint. The motor response is measured via an RPM sensor and is represented by the white line on the trend.
The complete test runs for about 10 seconds. Once the test is done, you can start the next one.

The core part of the VI is a sequence structure. The structure is executed when an operator clicks the Start Test button. The first frame (on the picture below) generates a unique string. The string has the following format: 'Test HH24:MM:SS' (for example: 'Test 14:58:33'). The string becomes a run ID when it is written to the ID tag (Set1 ID Tag).

The second frame starts a new run by writing ON to the control tag (Set1 Run Tag). At this time, the Data Set Logger creates the start marker in the database. The Run ID is whatever the current ID tag value is. This is why it is important to initialize the ID tag before the run starts.

The next frame generates an array of values (waveform) and drives the setpoint tag. In response the OPCDemo sets the value of the MotorRPMSensor. Both values are displayed on the trend.

Frame #3 just contains a wait VI, to allow some settling time.
The last frame ends the run by writing OFF to the control tag.

Note that no special VIs were used to manipulate the set. All manipulation is done via the ID tag and the control tag.
Here is the complete VI:
DSC Module version 7 includes a similar example: Motor Response Test Using Data Sets.vi
Retrieving Data with Data Set VIs
The DSC Module comes with several VIs to support the data set retrieval. All the VIs are located in the Historical Data»Data Set Logger VIs subpalette. Basically, one VI is used to get a list of sets, another is used to get the list of runs within a set, and the last one is used to get data within a run. The following connector panes show the VIs as they appear in version 7 of the DSC Module.

Note: List Data Sets VI isn't used in our example, simply because the example only contains one data set - Set1. If you have used a different name, modify the value on the example's front panel.


Note: For more information on these VIs, refer to the LabVIEW Help. Or, use the context help by pressing <Ctrl-H> then moving the mouse over the Data Set Logger VIs palette.
Our motor example uses the List Data Set Runs VI to retrieve all runs (tests) stored in the database. These runs are displayed on the front panel in a list box. The VI waits for the user to select a run. When the user selects the run, the VI reads the historical data of the run and displays it on the graph. In order to position the data on the graph correctly, the VI sets the start and end time of the graph, through the graph XScale.Minimum and XScale.Maximum attributes.
HINTS:
- Steps to create the reference for MulticolumnListBox
: Create a multicolumn listbox on the panel, go to its pop-up menu and select Create»Reference. Wire the reference to the List Data Set Runs VI. You can learn more about control references from the Control References: Overview in the See Also links below.
- Graph hints: Use XYGraph. Make sure you deselect the AutoscaleX (pop up on the graph and go to the X Scale submenu). Format the graph X Axis to use time scale (X Scale»Formatting).

[+] Enlarge Image
If you are looking for more a complex and sophisticated example, refer to the Data Set Logger Viewer link below.
DSC Module version 7 includes a similar example: Data Sets Viewer.vi
See Also:
Control References: Overview
Data Set Logger Viewer
Retrieving Data with the Historical Data Viewer
To retrieve historical data, use the Historical Data Viewer in MAX (Measurement & Automation Explorer). The Historical Data Viewer is a tool for historical data management. This tool is embedded in MAX and can be programmatically launched with the following VI (located in the Historical Data pallette). It also can be started manually by selecting Tools»DSC Module»View Historical Data.

To view data in the Historical Data Viewer (DSC Module version 7):
1. Locate your database under the Historical Data folder. Because the DSC Module automatically registers every new database, your database should already have a corresponding entry in MAX. In fact, if you launch the Historical Data Viewer with the VI above, it will automatically locate the database entry for you. If for some reason the entry is not present, you can still create it. Follow the steps in the help, on the right pane.
2. Create a new trace view: right-click Citadel 5 Universe and select New»Trace View.
3. Select the Trace Properties tab (at the bottom of the right pane). An Add/Remove dialog box appears.
4. Select the data set(s) you want to view and click Add.

[+] Enlarge Image
5. Click OK.
6. Switch to the Display tab.
7. Pop up on the graph and select Autoscale Y. With the End of Data button
8. To choose a specific data set to be viewed with its start and end time set, click on View Data Set Run... button

9. Select one of the data sets

[+] Enlarge Image
10. Click OK.
You should see historical data for the selected run.
To view data in the Historical Data Viewer (DSC Module version 6.x)
1. Locate your database under the Historical Data folder. Because the DSC Module automatically registers every new database, your database should already have a corresponding entry in MAX. In fact, if you launch the Historical Data Viewer with the VI above, it will automatically locate the database entry for you. If for some reason the entry is not present, you can still create it. Follow the steps in the help, on the right pane.
2. Create a new trace view: right-click on the database entry and select New View»Trace.
3. Select the Trace Attributes tab (at the bottom of the right pane).
4. Click the Add new traces button. A new window with a tree view comes up.
5. Expand the tree view to locate Set1.
6. Highlight the Set1 entry and click the ">>" button.

[+] Enlarge Image
This adds the traces configured in Set1 to the view. In fact it will also add the list of runs to the view. This is not visible information (you won't see the runs) in this window; however, it is available elsewhere and we will use it later. Note that you can also add these two traces to the view by directly adding the traces. However, in this case the additional background information about the runs won't be added to the view.
7. Click OK.
8. To select a run, pop up on any of the two traces and select Set view range. A new window comes up.

9. In the window that lists all runs and their start and end times, select any of the runs and click OK.

Notice that when you get back to the attribute window, the view Start and End times at the top of the window are set to the selected run times.
10. Switch to the Display tab.
11. Pop up on the graph and select Autoscale Y.
You should see historical data for the selected run.
Reader Comments | Submit a comment »
A good documentation for tech reference
The steps are easy to follow because of
shipped examples used and good explaination.
- hslin1976@yahoo.com - Jul 23, 2005
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/).
