Use timed structures on the block diagram to repeat blocks of code and to execute code in a specific order with time bounds and delays. Each timed structure has a distinctive, resizable border to enclose a section of the block diagram that executes according to the rules of the structure. The section of the block diagram inside the structure border is called a subdiagram. A timed structure has Input and Output nodes that feed data into and out of the structure to provide configuration data and return error and timing information. Timed structures can also have terminals on the structure border that feed data into and out of the structure subdiagrams. Use the following structures located on the Timed Structures palette to control how a block diagram executes with time bounds and delays:
● Timed Loop—Executes a subdiagram until a condition is met or interminably.
● Timed Sequence—Executes multiple subdiagrams in sequence.
● Timed Loop with Frames—Executes multiple subdiagrams in sequence until a condition
is met or interminably. Add frames to a Timed Loop to create a Timed Loop with frames. Use a Timed Loop and Timed Sequence to repeat a block of code and to execute code in a specific order with time bounds and delays. Use a Timed Loop with frames to repeatedly execute code in a specific order with time bounds and delays.
8.5.1 Timed Loop Structure
A Timed Loop executes a subdiagram, or frame, each iteration of the loop at the period you specify. Use the Timed Loop when you want to develop VIs with multi-rate timing capabilities, precise timing, feedback on loop execution and timing characteristics that change dynamically, or several levels of execution priority. Unlike the While Loop, the Timed Loop does not require wiring to the stop terminal. If you do not wire anything to the stop terminal, the loop will run interminably.
A Timed Loop executes below the time-critical priority of any VI but above high priority, which means that 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.
The Timed Loop includes (1) Input, (2) Left Data, (3) Right Data and (4) Output nodes as shown in Figure 8.3. 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 node terminals. You can set the initial configuration options of a Timed Loop by wiring values to the inputs of the Input node, or you can use the Configure Timed Loop dialog box, available by right-clicking the Input node and selecting Configure Input Node from the shortcut menu, to enter values for the options. Refer to the Configuring Timed Loops topic for more information about configuring a Timed Loop.
Figure 8.3 Timed Loop.
The Left Data node of the Timed Loop returns configuration option values and provides timing and status information about the previous loop iteration, such as if the iteration executed late, the time the iteration actually started, and when the iteration was expected to execute. You can wire values to the inputs of the Right Data node to configure the options of the next loop iteration dynamically, or 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.
The Output node returns error information received in the Error in input of the Input node, error information generated by the structure during execution, or error information from the task subdiagram that executes within the Timed Loop. The Output node also returns timing and status information.
8.5.2 Timed Sequence Structure
The timed sequence structure consists of one or more task subdiagrams, or frames, that execute sequentially and can be timed with an internal or external timing source. Use the Timed Sequence when you want to develop VIs with precise timing, execution feedback, timing characteristics that change dynamically, or several levels of execution priority. A Timed Sequence executes below the time-critical priority of any VI but above high priority, which means that a Timed Sequence executes in the data flow of a block diagram ahead of any VI not configured to run at a time-critical priority. Right-click the structure border to add, delete and merge frames.
The Timed Sequence includes (1) Input and (4) Output nodes, and (2) Left and (3) Right Data nodes for each frame as shown in Figure 8.4. By default, nodes of the Timed Sequence 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.
Figure 8.4 Timed Sequence structure.
You can set the configuration options of the Timed Sequence by wiring values to terminals on the Input node, or you can use the Configure Timed Sequence dialog box, available by right-clicking the Input node and selecting Configure Input Node from the shortcut menu, to enter values for the options. Refer to the Configuring Timed Sequences topic for more information about configuring a Timed Sequence. The Left Data node of a Timed Sequence 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 wire values to the Right Data node to configure the options of the next frame dynamically.
The Output node returns error information received in the error in input of the Input node, error information generated by the structure during execution, or error information from any task subdiagram that executes within a frame of the Timed Sequence. The Output node also returns timing and status information for the final frame.
8.5.3 Timed Loop with Frames Structure
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. Unlike the While Loop, the Timed Loop does not
require wiring to the stop terminal. If you do not wire anything to the stop terminal, the loop will run interminably.
Timed Loops execute below the time-critical priority of any VI but above high priority, which means that Timed Loops execute in the data flow of a block diagram ahead of any VI not configured to run at a time-critical priority. Right-click the structure border to add, delete and merge frames. The Timed Loop with frames includes (1) Input and (4) Output nodes, and (2) Left and (3) Right Data nodes for each frame as shown in Figure 8.5. By default, the 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. You can set initial configuration options of the Timed Loop by wiring values to the inputs of the Input node, or you can use the Configure
Timed Loop With Frames dialog box, available by right-clicking the Input node and selecting Configure Input Node from the shortcut menu, to enter values for the options. Refer to the
Configuring Timed Loops topic for more information about configuring a Timed Loop with frames.
Figure 8.5 Timed Loop with frames.
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 wire data to the
Right Data node of a frame to configure the options of the next frame dynamically, or 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 options of the next iteration dynamically, or you can use the Configure Next Iteration dialog box, available by right-clicking the Right Data node of the last frame and selecting Configure Input node from the shortcut menu, to enter values for the options. The Output node returns error information received in the Error in input of the Input node, error information generated by the structure during execution, or error information from the task subdiagrams that execute within the Timed Loop frames. The Output node also returns timing and status information for the final frame.