Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

NI-DAQmx: Using Counters to Time Program Execution

5 ratings | 4.80 out of 5
Print

Downloads

Filename: time_with_counters.vi
Requirements: View

Tick Count (ms) VI in LabVIEW uses the Windows clock to get a millisecond time reading. In cases where you need a more precise and NIST-traceable method for timing a portion of your LabVIEW code, use the Time with Counters VI (below). These VIs use two counters on an E Series device for timing program execution.

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

 
5 ratings | 4.80 out of 5
Print

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/).