Innovative Interface Techniques -- Using a Dual Progress Bar and Seeded Random Number Generator
Overview
In one of our recent LabVIEW projects, we were controlling an instrument that scanned hundreds of telecommunications channels, searching for any channels with errors. Because the scan time could be a few minutes, we elected to add some kind of progress indication.

Figure 1: Initial Three-Indicator Interface
To correct these shortcomings, a new type of indicator was devised, dubbed the Dual Progress Bar, to show the progress of two items at once (see Figure 2). For our application, the larger outer bar represents the number of channels that have been scanned, while the smaller inner bar represents the number of channels with errors. Because the number of channels with errors can never exceed the number of channels scanned, the inner bar can never protrude past the end of the outer bar. The scale is now more useful because it shows the total number of channels to be scanned. The relative percentage of errors is easily discerned by visually comparing the lengths of the inner and outer bars. Best of all, this dual progress bar requires much less front panel real estate than does the previous three-indicator approach.

Figure 2: Dual Progress Bar Interface
Initially, this Dual Progress Bar was created using two overlapping Classic Horizontal Fill Slides, and the relative size and positioning was accomplished through a great deal of property node manipulations. Subsequent refinement achieved the Dual Progress Bar functionality through a single Classic Horizontal Fill Slide with two sliders. Using LabVIEW’s control customization capabilities, the height of the inner slider’s fill bar can be reduced so that is fits within the outer bar, and the result saved off as a .ctl file.
When testing a program with numerous asynchronous inputs, it would be ideal to test all possible combinations of inputs in all possible orders and timings. Unfortunately, with some programs, such an exhaustive test could take months or years. An alternative approach is to use a random number generator to simulate the various inputs, run the test for several hours, and hope that enough cases were tested to expose a bug in the program. Suppose you run such a test for several hours and an error occurs. After making the necessary program modifications, it would be nice to run exactly the same "random" sequence of events to ensure that the error has indeed been corrected. If the program generating the events uses LabVIEW’s built-in random number generator, there is no way to recreate the same sequence of numbers.
![]() | The answer is to use a "seeded" random number generator, which means the generator is initialized with a seed number before the generator is first called to produce the random numbers. The output of such a generator will always appear random, but the particular sequence of numbers is determined by the seed. If a given seed is loaded into the generator twice, the generator will produce the exact same sequence of random numbers. The random number generator I created is based on a linear feedback shift register to produce maximal |
length sequences. When the feedback taps are defined correctly, a shift register with N stages will produce a pseudo-random bit stream that is (2^N)-1 bits long before the stream repeats itself. My seeded generator can produce pseudo-random Number (PN) sequences with six different shift register lengths (PN7, PN9, PN15, PN20, PN23, and PN31) and the default is PN31. Because this VI outputs the PN sequence in chunks of 16 bits and 16 does not divide evenly into (2^N)-1, the PN sequence of words will not repeat until 16*((2^N)-1) words have been extracted.
The Random Number with Seed VI has two inputs, the seed value and an enum defining the shift register length. When a nonzero seed value is wired in, that seed is loaded into the shift register, the register is cycled 1600 times to scramble the bits, and then cycled 16 more times to produce a pseudo-random U16 word. If the seed input is unwired, or a zero is wired in (the only illegal seed value), the shift register is simply cycled 16 times to produce the U16 word. The PN sequences generated by this VI are exactly the same PN sequences that are often specified in telecommunications standards. For compatibility with the built-in LabVIEW function, this new VI also outputs a double in the range [0...1).
The example VI (see Figure 3) demonstrates the use of both the Dual Progress Bar and the Random Number with Seed.
The seeded random number generator simulates flipping a coin 150 times. The dual progress bar graphically depicts the total number of flips with the outside bar and the number of heads with the inner bar. This example allows you to adjust the chance of the coin coming up as a head, with a default of 50%. This example also lets you define the seed value for the random number generator.
For your experimentation with this sample VI, notice that you can repeatedly run the VI with the same seed value and the number of heads will always be the same. A different seed will likely give you a different number of heads, and that number will be equally repeatable.
LabVIEW Technical Resource (LTR) is the leading independent source of LabVIEW-specific information. Each LTR issue presents powerful tips and techniques and includes a Resource CD packed with VIs, Utilities, Source Code, and Documentation.
Tim Quilici is the Manager of the Application Software Engineering group at the Anritsu Company in Richardson, Texas. Anritsu designs and manufactures test instruments for the telecommunications industry. Tim can be reached at tim.quilici@anritsu.com.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


