To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This VI shows you how to use a hardware timer to verify the loop time of any loop structure in LabVIEW.
Description
You will need a multifunction DAQ device that includes a counter. I would recommend a PCI or PXI based card as there is less latency on the single point reads. You need to create a Count Edges task using DAQmx. We then need to set some properties for the task created. These are the "Count Edges Input Terminal" and the "Data Transfer Mechanism". We need to choose a built-in timing source for the count edges input terminal, and "Programmed I/O" for the data transfer. We then start the DAQmx task and take an initial count. Once inside the loop we take another reading of the counter value and compare the previous count to the current count. In the code provided the loop time is being simulated by the wait until next ms multiple function, but this can be any code or analysis routine you have in the loop. Finally, close the DAQmx task and the clear the task. In the front panel picture below you can see the tick count converted to a loop time in seconds and the simulated loop time requested in the milliseconds to wait input.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.