FPGA Get Loop Time

Publish Date: Jan 13, 2010 | 1 Ratings | 3.00 out of 5 | Print | Submit your review


A small VI useful for benchmarking and monitoring loop rates of a VI.

A common way to monitor the speed of a loop in LabVIEW is to use a tick count function fed back through a shift register and then a subtract function to difference the two loop tick counts to get a overall loop time, similar to the method shown in Figure 1.  A drawback of this method is that if you are benchmarking a large loop , you end up with lots of extra wire for a simple loop timer.

Figure 1. Traditional loop speed monitor method.

A another approach that is more compact can be created with a feedback node, similar to the method shown in Figure 2.  This method is compact and simple, and avoids tracing wires across the entire loop.  The drawback of this method prior to LabVIEW 8.5 is that it couldn't be encapsulated in a simple subVI.  Prior to LabVIEW 8.5, feedback nodes could only be implemented within loops at the top level.

Figure 2.  A more compact method for monitoring loop speed.

LabVIEW 8.5 introduced a feedback node that is more flexible than previous versions. This feedback node can be placed within case structures and subVIs that don't have loops.  This new feature was the enabling technology for the loop time subVI.  Figure 3 shows a subVI that encapsulates the get loop time functionality into a single subVI.

Figure 3. Monitoring loop speed with a subVI.

This example is bundled in a zip distribution.  The zip distribution contains a polymorphic VI with instances for mSec, uSec, and Tick versions of the loop time in the FPGA target context.  The distribution also contains mSec loop time subVI that only works in the My Computer and real-time contexts.  Extract the "loop time" folder from the zip distribution and place the "loop time" folder in the [LabVIEW 8.5]/user.lib directory.  Placing it in user.lib will put the VIs in the User Libraries palette.  Unfortunately, the User Libraries palette is not accessible when targeted to an FPGA target.  You must edit the palette set to make this VI accessible in the FPGA palette set.  For more information on this, check out Editing a Palette Set in the LabVIEW 8.5 help.  You can edit your FPGA palette set so that this VI is as easily accessible as the rest of the FPGA timing VIs. 

Figure 4.  Get Loop Time polymorphic VI added to the FPGA Timing palette.

Back to Top

Bookmark & Share





Rate this document

Answered Your Question?
Yes No