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. • For loop produce default data if you wire 0 to the count terminal. • Can use multiple shift registers. • When 0 is initilized it starts from 0 , for next iteration it starts from previous iterations.

Shift Registers

Embed Size (px)

DESCRIPTION

ppt for shift register

Citation preview

Page 1: Shift Registers

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.• For loop produce default data if you wire 0 to the

count terminal.• Can use multiple shift registers.• When 0 is initilized it starts from 0 , for next iteration it

starts from previous iterations.

Page 2: Shift Registers

Shift register

Page 3: Shift Registers

Stacked shift registers

• To access multiple previous iterations.• Replacing tunnels with shift register or shift

registers with tunnels by rt.click.

Page 4: Shift Registers

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.

Page 5: Shift Registers

Feed back node - initialization

• Not initialized – it passes last value written to the node.

• To initialize – rt.click feed back node -> select initialize terminal.

Page 6: Shift Registers

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 of the loop is

indeterminate.• Wait ms function – adds wait time to code execution time• Wait to an amount equal to the i/p you specify.• Function ->execution control palette->Time delay express VI

Page 7: Shift Registers
Page 8: Shift Registers
Page 9: Shift Registers

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 sequential order.

Page 10: Shift Registers

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

Page 11: Shift Registers

Case structure

Page 12: Shift Registers

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.

Page 13: Shift Registers

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.

Page 14: Shift Registers

Event structure

Page 15: Shift Registers

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.

Page 16: Shift Registers

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.

Page 17: Shift Registers

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.

Page 18: Shift Registers

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 method for constructing an array output from a loop tunnel with each element corresponding to one loop iteration.

• When an array wire passes into a loop through a tunnel that does not have indexing enabled, the entire array is placed on the wire and can be accessed during each loop iteration. When indexing is enabled, only the array element at the index corresponding to the current loop iteration is available from that tunnel.

Page 19: Shift Registers

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.

Page 20: Shift Registers

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.

Page 21: Shift Registers

Timing control

• Select Programming»Timing»Wait 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 Create»Constant.

Set the value of the constant to ❑ 1000.

Page 22: Shift Registers
Page 23: Shift Registers

Tunnels.vi

Page 24: Shift Registers

tunnel

Page 25: Shift Registers
Page 26: Shift Registers