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

Timed Loop and Timed Sequence Structures

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Use a Timed Loop or Timed Sequence structure on the block diagram to execute code with time bounds and delays. A Timed Loop repeatedly executes code until a stop condition is met. A Timed Sequence structure executes code once in a specific order. To execute code repeatedly in a specific order with time bounds and delays, use a Timed Loop with frames.

Timed Loop Structures

A Timed Loop executes a subdiagram, or frame, at a period you specify for each iteration. Use a Timed Loop when you want to develop VIs that execute repeatedly with multirate timing capabilities, precise timing, feedback on loop execution, timing characteristics that change dynamically, or several levels of execution priority. Unlike in a While Loop, you do not have to wire the conditional terminal in a Timed Loop. However, if you do not wire anything to the conditional terminal in a Timed Loop, the loop runs interminably.

A Timed Loop executes in the data flow of a block diagram ahead of any VI not configured to run at a time-critical priority. You can change the priority of a Timed Loop to change the order in which it executes relative to other timed structures on the block diagram.

Note  Adding a VI configured to run at time-critical priority and a Timed Loop on the same block diagram can lead to unexpected timing behavior.

A Timed Loop includes four nodes, as shown in the following illustration. By default, nodes of a Timed Loop do not display all of the available input and output terminals. You can resize nodes or right-click a node and use the shortcut menu to display hidden node terminals.

1 Input node
2 Left Data node
3 Right Data node
4 Output node

You can wire values to the inputs of the Input node to configure a Timed Loop, or you can right-click the Input node and select Configure Input Node from the shortcut menu to display the Configure Timed Loop dialog box and enter values for the options.

The Left Data node of a Timed Sequence structure frame returns configuration option values and provides timing and status information about the current and previous frame, such as the expected start time, actual start time, and if the previous frame completed late. You can use the Configure Next Iteration dialog box, available by right-clicking the Right Data node and selecting Configure Input Node from the shortcut menu, to enter values for the options. You also can wire values to the inputs of the Right Data node to configure the options of the next loop iteration dynamically.

The Output node returns error information received in the Error input of the Input node, error information generated by the structure during execution, and error information from the subdiagram that executes within the Timed Loop. The Output node also returns timing and status information for the loop.

Timed Loop with Frames

You can add frames to a Timed Loop to execute multiple subdiagrams sequentially each iteration of the loop at the period you specify. A Timed Loop with frames behaves like a regular Timed Loop with an embedded Sequence structure. If you want each frame to execute only once, right-click the Timed Loop structure border and select Replace with Timed Sequence.

Right-click the structure border to add, delete, and merge frames.

Each frame of the Timed Loop with frames includes a set of nodes, as shown in the following illustration. By default, nodes of the Timed Loop do not display all of the available input and output terminals. You can resize nodes or right-click a node and use the shortcut menu to display hidden terminals.

1 Input node
2 Left Data node
3 Right Data node
4 Output node

You can wire values to the inputs of the Input node to configure a Timed Loop with frames, or you can right-click the Input node and select Configure Input Node from the shortcut menu to display theConfigure Timed Loop with Frames dialog box and enter values for the options.

The Left Data node of a Timed Loop frame returns configuration option values and provides timing and status information about the previous loop iteration or frame. You can use the Configure Next Frame Timing dialog box, available by right-clicking the Right Data node and selecting Configure Input node from the shortcut menu to enter values for the options. You also can wire data to the Right Data node of a frame to configure the next frame dynamically.

The Output node returns error information received in the Error input of the Input node, error information generated by the structure during execution, and error information from the subdiagrams that execute within the Timed Loop frames. The Output node also returns timing and status information for the final frame.

Refer to the labview\examples\general\timedloop.llb for examples of using timed loops.

Timed Sequence Structures

A Timed Sequence structure consists of one or more subdiagrams, or frames, timed by an internal or external timing source that execute sequentially. A Timed Sequence structure executes each frame only once and, unlike a Timed Loop, does not repeat iterations. If you want each frame to execute more than once, you can right-click the Timed Sequence structure border and select Replace with Timed Loop. Use the Timed Sequence structure when you want to develop VIs that execute only once with precise timing, execution feedback, timing characteristics that change dynamically, or several levels of execution priority.

A Timed Sequence structure executes in the data flow of a block diagram ahead of any VI not configured to run at a time-critical priority. You can change the priority of a Timed Sequence structure to change the order in which it executes relative to other timed structures on the block diagram.

Note  Adding a VI configured to run at a time-critical priority and a Timed Sequence structure on the same block diagram can lead to unexpected timing behavior.

Right-click the Timed Sequence structure border to add, delete, and merge frames. Unlike in a Flat Sequence structure, every frame of a Timed Sequence structure must have all of its inputs before the structure can execute. An input for one frame cannot depend on an output for another frame.

Each frame of the Timed Sequence structure includes a set of nodes, as shown in the following illustration. By default, nodes of the Timed Sequence structure do not display all of the available input and output terminals. You can resize nodes or right-click a node and use the shortcut menu to display hidden terminals.

1 Input node
2 Left Data node
3 Right Data node
4 Output node

You can wire values to the inputs of the Input node to configure a Timed Sequence structure, or you can right-click the Input node and select Configure Input Node from the shortcut menu to display the Configure Timed Sequence dialog box and enter values for the options.

The Left Data node of a Timed Sequence structure frame returns configuration option values and provides timing and status information about the current and previous frame, such as the expected start time, actual start time, and if the previous frame completed late. You can use the Configure Next Iteration dialog box, available by right-clicking the Right Data node and selecting Configure Input Node from the shortcut menu, to enter values for the options. You also can wire values to the Right Data node to configure the options of the next frame dynamically.

Note  The Right Data node of the last frame of a Timed Sequence structure does not include configuration options because you do not have to configure another frame or iteration.

The Output node returns error information received in the Error input of the Input node, error information generated by the structure during execution, or error information from any subdiagram that executes within a frame of the Timed Sequence structure. The Output node also returns timing and status information for the final frame.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit