« Close

Datasheets and User Guides

App Notes

Software & Driver

 

5.1 - Logging to ASCII files

Next we will learn how to store this data to disk so that it can be opened with another program for analysis. In this example we will create a simple comma delimited file with our pressure data.

1. Click on LOGGING: in the workspace.

This will display the logging set summary view. Here you can see all your logging sets displayed and their running status. A logging set is a group of data values being logged in a particular way to a particular file. You can have as many logging sets as you need, and they can run concurrently.

2. Click on the Add button in the logging set and when prompted for the new name, type in MyLog and click OK.

Like channels and all other DAQFactory names, the logging set name must start with a letter and only contain letters, numbers or the underscore. Once you click OK, the logging set view will be displayed for the new logging set. You can also get to this view by clicking on the logging set name listed under LOGGING: in the workspace. You may have to click on the + sign next to LOGGING to see your logging sets listed in the workspace.

3. Next to Logging Method, select ASCII Delimited, which is actually the default.

ASCII Delimited is probably the most common method for data logging as it can be read by most other programs such as Excel. Unfortunately, it is not as space efficient or fast as the binary methods. But unless you have strict space constraints or you are logging more than about 50,000 points per second (depending also on your computer / hard drive speed), we suggest ASCII.

4. Next to File Name enter c:\mylogfile.csv

It is usually best to fully specify the path to your file, otherwise the data will be stored in your DAQFactory directory. The .csv is a windows standard designation for comma delimited values, which, unless you change the delimiter on the details page, is the type of file that will be created.

5. In the Channels Available table, click on the row with Pressure, then click on the >> button to move it to the Channels to Log table.

Each logging set can log any combination of channels. In this case, we will just log the input channel.

6. Click on Apply to save the changes.

7. To start logging, click on the + next to LOGGING to display the new logging set, then right click on the logging set MyLog and select Begin Logging Set.

Once started, the icon next to MyLog will change and the red stop sign will be removed to indicate that this logging set is running.

8. Wait at least 10 or 15 seconds to log some data and then right click on the logging set again and select End Logging Set to stop logging.

There are other ways to start and stop logging sets, including the Action page of some components such as the variable value component that we used earlier.

9. Now start Excel or Notepad and open the file c:\mylogfile.csv.

You will see two columns, time and data. By default the time is given in Excel / Access format which is decimal days since 1900. You can also have DAQFactory log in its standard format of seconds since 1970. If you are using Excel and logging the time in Excel format, you can format the first column as date / time and the numbers displayed will be properly displayed as date and time.

Hint: if you cannot find the mylogfile.csv file, check to make sure that you selected Pressure to log and not Output. Since Output is an output channel, it only gets new values to log when you actually set it to something.

Sample file: LJGuideSamples\LogASCII.ctl

2 comments

Hi,

I am logging 3 voltages and 3 currents using U3-HV once a second. Now I need to save those data in a csv file(file stored in any partition of the hard drive). The file should look like column 1(date&time),column 2(voltage1),column 3(current1),column 4(voltage 2), column 5(current 2),column 6(voltage 3) and column 7(current 3).

I am using python on Ubuntu 12.04. Now I need the code so that once I start logging, the logged data will be automatically saved to corresponding columns until I stop logging.

I tried a lot, but I can't find the exact codes.

The Python standard library contains a csv module which will help with saving data to a csv file:

http://docs.python.org/2.6/library/csv.html