Manage Execution Rates with FPGA Timing Functions (FPGA Module)

LabVIEW 2018 FPGA Module Help


Edition Date: March 2018
Part Number: 371599P-01
View Product Info

DOWNLOAD (Windows Only)


LabVIEW 2016 FPGA Module Help
LabVIEW 2017 FPGA Module Help
LabVIEW 2018 FPGA Module Help
LabVIEW 2019 FPGA Module Help
LabVIEW 2020 FPGA Module Help

Creating Timed I/O Applications

Applications often require the I/O to execute at a specific frequency. For example, the algorithms used in control loops typically require the inputs to be sampled at a known rate. Use the Loop Timer Express VI in a While Loop to control the execution rate of the I/O, as shown in the following block diagram.

To use the Loop Timer Express VI to control the execution rate of the I/O, place a Sequence structure inside a While Loop. Place the Loop Timer Express VI in the first frame of the sequence structure. Configure the Counter Units and Size of Internal Counter in the Configure Loop Timer dialog box that appears. Place the LabVIEW code for the I/O in subsequent frames of the sequence structure.

Tip  You can save space on the FPGA target by choosing the smallest Size of Internal Counter appropriate for the application.

The first call of the Loop Timer Express VI does not result in any wait or delay because this call establishes a reference time stamp for subsequent calls. After the first call of the Loop Timer Express VI, subsequent calls of the Loop Timer Express VI do not return until the time specified by the Count parameter has elapsed since the previous call. If the time specified by the Count parameter is less than the time it takes the FPGA target to execute the code in the While Loop, the Loop Timer Express VI does not affect the timing of the While Loop.

Creating Delays between Events

Use the Wait Express VI to create a delay between events in an FPGA VI. For example, you might want to create a delay between a trigger and a subsequent output. You can place the LabVIEW code for the trigger in the first frame of a sequence structure. Then place the Wait Express VI in the following frame. Finally, place the LabVIEW code for the output in the last frame of the sequence structure. You also can create a series of delays using multiple Wait VIs in a sequence structure, as shown in the following block diagram.

Measuring Time between Events

Use the Tick Count Express VI to measure the time between events such as edges on a digital signal. You can use this Express VI when you need to determine the period, pulse-width, or frequency of an input signal or if you want to determine the execution time of a section of LabVIEW code.

For example, to determine the amount of time it takes a function or a section of LabVIEW code to execute, use a Sequence structure with two Tick Count Express VIs, as shown in the following block diagram.

Place one Tick Count Express VI in the first frame of the Sequence structure. Then place the LabVIEW code you want to measure in the second frame of the Sequence structure. Finally, place the other Tick Count Express VI in the last frame of the sequence structure. You then can calculate the difference between the results of the two Tick Count Express VIs to determine the execution time. Subtract one from the result of the calculation to compensate for the execution time of the Tick Count Express VI.

The Tick Count Express VI has an internal counter to track time. The internal counter for each Tick Count Express VI you place on the same block diagram shares the same start time. Therefore, every Tick Count Express VI that uses the same values for the Counter Units and Size of Internal Counter options tracks the same time. For example, if you call two Tick Count Express VIs that use the same Configure Tick Count options at the same time, they return the same Tick Count value.

The Tick Count Express VI returns an integer value in Counter Units. The Tick Count value cannot represent any fractional time periods that might occur when Counter Units is configured for uSec or mSec. Configuring Counter Units for uSec or mSec can result in timing measurements that have an accuracy of ±1 Counter Unit value. For example, you can configure the Tick Count Express VIs in the block diagram above to measure time in milliseconds. If the first Tick Count Express VI executes at 47.9 milliseconds, Tick Count returns a value of 47. If the second Tick Count Express VI executes at 53.2 milliseconds, Tick Count returns a value of 53. Although this example has a 5.3 millisecond delay, the difference between the returned values is 6 milliseconds.

WAS THIS ARTICLE HELPFUL?

Not Helpful