Continuous Measurement and Logging
LabVIEW 2012
The Continuous Measurement and Logging sample project acquires measurements continuously and logs them to disk. It executes five loops in parallel:
- Event handling (Main.vi)—The Event Handling Loop (EHL) that produces messages based on front panel events, such as the user clicking Start or Settings.
- User interface messaging (Main.vi)—A Message Handling Loop (MHL) that receives messages from the EHL and responds by sending messages to the other MHLs.
- Acquiring data (Acquisition.lvlib:Acquisition Message Loop.vi)—An MHL that continuously acquires data. By default, this template simulates acquired data.
- Logging data (Logging.lvlib:Logging Message Loop.vi)—An MHL that continuously logs acquired data.
- Displaying data (Main.vi)—A While Loop that updates the waveform chart with acquired data.
This sample project also features a Settings dialog box (Settings.lvlib) you can use to configure the application.
This sample project is based on the Queued Message Handler template. Refer to the Queued Message Handler template and its documentation, available from the Create Project dialog box, for information about how this template works.
Developer Walkthrough
Refer to ni.com for a developer walkthrough of the Queued Message Handler template.
System Requirements
LabVIEW Base, Full, or Professional Development System. This sample project is designed for use with NI-DAQmx, an instrument driver, or other driver software.
Use Cases
The Continuous Measurement and Logging sample project is designed for a continuous measurement application that requires a responsive user interface; that is, users should be able to click buttons even while the application is executing another command.
Running this Sample Project
- In the Project Explorer window, open and run Main.vi.
- Click Start. The program begins acquiring simulated waveform data.
- Click the other front panel buttons to explore the sample project.
Modifying this Sample Project
Adding Data Acquisition Code
You must modify the sample project to acquire data from hardware. Complete the following steps to make these modifications:
- Add hardware refnums to Acquisition.lvlib:Hardware Configuration.ctl. For example, you can use the following objects here:
- DAQ tasks
- DAQ channels
- VISA sessions
- Add hardware initialization code to Acquisition.lvlib:Initialize Hardware References.vi. For example, you can use the following objects here:
- DAQmx Task Name constants
- DAQmx Create Virtual Channel VI
- (Instrument Driver) Initialize VI
- Add hardware configuration code to Acquisition.lvlib:Configure Hardware.vi For example, you can use the following VIs here:
- DAQmx Timing VI
- DAQmx Trigger VI
- (Instrument Driver) Configure Measurement VI
- (Instrument Driver) Configure Autozero VI
- Add data acquisition code to Acquisition.lvlib:Acquire.vi. For example, you can use the following VIs here:
- DAQmx Read VI
- (Instrument Driver) Read VI
- Add code that stops data acquisition to Acquisition.lvlib:Stop Acquisition.vi. For example, you can use the following VIs here:
- DAQmx Clear Task VI
- (Instrument Driver) Close VI
Customizing Data Logging Code
If the default logging behavior does not meet the needs of your application, you can modify this sample project in the following ways:
- To specify where data is logged, run Main.vi, click Settings, and use the Log File Path control. By default, this template logs data to LabVIEW Data\Logged Data.tdms, where LabVIEW Data is the LabVIEW Data folder.
- To change the data logging mechanism, modify Logging.lvlib:Logging Message Loop.vi. For example, you could modify this VI to stream acquired data across a network or to disk.
- To change the code that writes data to disk, modify Logging.lvlib:Log Data.vi. For example, you could use the Export Waveforms to Spreadsheet File or Write to Spreadsheet File VIs. By default, this template uses the TDMS functions to log data to a .tdms file.
- To change or add path and file refnums that are needed for data logging, modify Logging.lvlib:Logging Configuration.ctl.
LabVIEW Features and Concepts Used
Important Information
Copyright
© 2012 National Instruments. All rights reserved.
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
End-User License Agreements and Third-Party Legal Notices
You can find end-user license agreements (EULAs) and third-party legal notices in the following locations:
- Notices are located in the <National Instruments>\_Legal Information and <National Instruments> directories.
- EULAs are located in the <National Instruments>\Shared\MDF\Legal\license directory.
- Review <National Instruments>\_Legal Information.txt for information on including legal information in installers built with NI products.
Trademarks
LabVIEW, National Instruments, NI, ni.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other National Instruments trademarks.
Other product and company names mentioned herein are trademarks or trade names of their respective companies.
Patents
For patents covering the National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.