Vous êtes sur la page 1sur 26

SHIFT REGISTERS

Static variable in text based program. To access data from previous iterations of the loop. Two ways feed back node & shift registers. While loop produce default data when the shift register is not initialized.

8/12/12

Shift register

8/12/12

Stacked shift registers

To access multiple previous iterations. Replacing tunnels with shift register or shift registers with tunnels by rt.click.

8/12/12

Feed back node

Like shift register feed back node stores data when the loop completes an iteration. Avoid unnecessary long wires. Arrow indicates direction of data flow. Direction automatically changes if data flow direction changes.
8/12/12

Feed back node initialization

Not initialized it passes last value written to the node. To initialize rt.click feed back node -> select initialize terminal.

8/12/12

Control timing

When loop finishes executing an iteration it immediately begins executing the next iteration unless it reaches stop condition. Wait until next ms Multiple function used for synchronization activities. Placed within the loop to control the loop execution rate. Execution rate for the first iteration 8/12/12 of the loop is indeterminate.

8/12/12

8/12/12

Structures

Graphical representation of loops. Section of block diagram inside the structure border is called subdiagram. Case structure contains multiple sub diagrams, depending on the input value passed to the structure. Sequence structure contains one or more sub diagram that executes in 8/12/12 sequential order.

Structures

Event structure depends on how the user interacts with the VI. Timed structure executes with time bounds and delay. Diagram disable structure which only enabled sub diagram executes conditional disable structure depends on configuration
8/12/12

Case structure

8/12/12

Building an array using shift registers. This example demonstrate a program that acts somewhat like a lottery. A random number is chosen and put into the range of zero to one hundred. The number is only added to the results array if the user presses the pick button. Seven numbers must be chosen before the loop quits. 8/12/12

Event structure

8/12/12

Timeout event. The event structure executes the timeout event every thousand milliseconds (one second). The timeout event simply increments a counter and displays it on the front panel. Another event stops the VI when the stop button is pressed.

Event structure

8/12/12

Event structure

Repeated event monitoring. The event structure is continually used to check for button press events. Only when the red button is pressed is the loop stopped. All button pressed update a color indicator with the color matching the button name. Note that only the frame for the red event is shown here. 8/12/12

Event structure

Simple event monitoring. The event structure looks for a change in value of the stop button. The program occupies no CPU time while the event structure is waiting for the button pressed. When the button is pressed, the event structure executes the code in the stop valued changed frame. In this case, the VI just stops because there is no code left to execute after the button is pressed and the event structure quits.

8/12/12

Event structure

Timeout event. The event structure executes the timeout event every thousand milliseconds (one second). The timeout event simply increments a counter and displays it on the front panel. Another event stops the VI when the stop button is pressed.

8/12/12

indexing

Indexing is a feature that can be enabled for input and output tunnels of both while-loops and for-loops by right clicking on a tunnel. It provides an automatic method for looping over all of the elements in an array sent into a loop through a tunnel with each element corresponding to one loop iteration. Indexing also provides an automatic

8/12/12

indexing

Input indexing : The top for-loop uses indexing to show all of the elements in the input array one by one as the loop runs in a numeric indicator. The bottom for-loop simply shows the entire contents of the array in an array indicator ten times. In effect, the bottom loop functions just as if the input array control is wired directly to the numeric array indicator.

8/12/12

indexing

Output indexing. The top loop uses indexing to build an output array with the numbers zero through nine in it. The bottom loop does not use indexing so that only the last value of the loop iterator, in this case nine, is shown in the numeric indicator. 8/12/12

Timing control

Select ProgrammingTimingWait from the functions palette and place it on the block diagram inside of the while loop. Right click the milliseconds to wait input of the Wait function and select CreateConstant. Set the value of the constant to 1000.
8/12/12

8/12/12

Tunnels.vi

8/12/12

tunnel

8/12/12

8/12/12

8/12/12

Vous aimerez peut-être aussi