Using uninitialized shift registers, Using uninitialized shift registers -15, End of activity 11-5 – National Instruments BridgeVIEW User Manual

Page 254

Advertising
background image

Chapter 11

Loops and Charts

© National Instruments Corporation

11-15

BridgeVIEW User Manual

Wait Until Next ms Multiple function (Functions»Time & Dialog)

—This function ensures that each iteration of the loop occurs no faster

than the millisecond input. The input is 500 milliseconds for this
activity. If you pop up on the icon and choose Show»Label, the label
Wait Until Next ms Multiple appears.

6.

Pop up on the input of the Wait Until Next ms Multiple function and
select Create Constant. A numeric constant appears and is
automatically wired to the function.

7.

Type

500

in the label. The numeric constant wired to the Wait Until

Next ms Multiple function specifies a wait of 500 milliseconds
(one half-second). Thus, the loop executes once every half-second.

Notice that the VI initializes the shift registers with a random number.
If you do not initialize the shift register terminal, it contains the default
value or the last value from the previous run and the first few averages
are meaningless.

8.

Run the VI and observe the operation.

9.

Save this VI as

Random Average.vi

in the

BridgeVIEW\Activity

directory.

Note

Remember to initialize shift registers to avoid incorporating old or default data
into your current data measurements

End of Activity 11-5.

Using Uninitialized Shift Registers

You initialize a shift register by wiring a value from outside a While Loop
or For Loop to the left terminal of the shift register. Sometimes, however,
you want to execute a VI repeatedly with a loop and a shift register, so that
each time the VI executes, the initial output of the shift register is the last
value from the previous execution. To do that, you must leave the left shift
register terminal unwired from outside the loop. Leaving the input to the
left shift register terminal unwired preserves state information between
subsequent executions of a VI.

The following illustration shows an example of a subVI that calculates the
running average of four data points. The VI uses an uninitialized shift
register (with three additional elements) to store previous data points.

Advertising