NI-DAQmx: Using Counters to Time Program Execution
Downloads
Filename: time_with_counters.vi
Requirements: View
This VI measures the time it takes for a particular segment of code to execute by using the counters on an E-Series board. The example in the code is a for loop that executes for a user-definable number of iterations. This is marked as "EVENT TO TIME". You can delete this for loop and replace it with whatever you want to time, but be sure to wire the error cluster and task ID "through" your code or sub-vi so that it properly enforces order of execution.
Since the DAQ-STC has a 24-bit counter and a 20 MHz timebase, the 24-bit counter will overflow more than once per second. This 20 MHz timebase is highly stable internal clock that is used as the time reference for this example so we must accomodate for the rollover. The rollover calculation looks like this: 2^24 = 16,777,216 (maximum count) and with a 20 MHz timebase, we get 20,000,000 edges per second. We then monitor this rollover (terminal count or output pulse) and keep track of how many times it has occurred using a second event counter. This gives us effectively a 48-bit (DAQ-STC) counter to count the events. On the DAQ-STC with a 20 MHz timebase it will be 160 days before timer roll-over (20 MHz resolution).
Requirements
Filename: time_with_counters.vi
Software Requirements
Application Software: LabVIEW Full Development System 7.1
Language(s): LabVIEW
Hardware Requirements
Hardware Group: Multifunction DAQ (MIO)
Hardware Model: DAQCard-6023E
Driver: NI-DAQmx 7.2
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program 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 program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM 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/).
