110 likes | 235 Views
EET 2259 Unit 6 Shift Registers. Read Bishop, Section 5.3. Midterm Exam this week. Lab #6 and Homework #6 due next week . Shift Registers and Feedback Nodes. When programming with loops, you may need to access data from previous iterations of the loop.
E N D
EET 2259 Unit 6Shift Registers • Read Bishop, Section 5.3. • Midterm Exam this week. • Lab #6 and Homework #6 due next week.
Shift Registers and Feedback Nodes • When programming with loops, you may need to access data from previous iterations of the loop. • LabVIEW provides two ways to do this: • Shift registers • Feedback nodes (Bishop, p. 227) • I recommend not using feedback nodes; use shift registers instead.
Shift Registers • Shift registers transfer values from one iteration of a For Loop or While Loop to the next iteration. • To create a shift register, right-click on the left or right border of a loop and select Add Shift Register. (Bishop, p. 227)
Shift Registers (Continued) • A shift register appears as a set of arrows on the borders of the loop: an up arrow on the right border, and one or more down arrows on the left border. • These arrows are terminals that can be wired to other items inside or outside the loop. (Bishop, p. 228)
Using a Shift Register • The terminal on the right border receives and stores a data value as each iteration of the loop finishes. • This value then becomes available from the terminal on the left-hand border during the next iteration. (Bishop, p. 228)
Using a Shift Register (Continued) • The shift register’s initial value is set by wiring the left terminal to a constant or a control or another element outside of the loop. For consistent results, always initialize your shift registers. • The shift register’s final value can be used by wiring the right terminal to an element outside of the loop. (Bishop, pp. 228-231)
Example Program • Write a program that finds the sum of all integers from 0 to 9. (Can easily extend this to find the sum of all integers from 0 to any positive integer). • They key is to use a shift register to keep track of the running total as we add each new integer.
Feedback Nodes • Feedback Nodes offer another way to transfer values from one iteration of a loop to the next iteration. • Shift registers are more powerful because they can remember as many of the previous values as you want, while feedback nodes can only remember one previous value. (Bishop, p. 233)
Feedback Nodes (Continued) • A Feedback Node appears as an arrow inside a rectangle, along with an associated Initializer Terminal on the loop’s left border. (Bishop, p. 234)
Converting Between Shift Registers & Feedback Nodes • A Feedback Node can be converted to a shift register (or vice versa) by right-clicking and selecting “Replace with Shift Register” (or “Replace with Feedback Node”). (Bishop, p. 234)
Creating Feedback Node by Wiring Output to Input • A Feedback Node will appear automatically if you wire the output of an element or group or elements to the input of that same element or group.