An Introduction To Using LabView - Using A Timed Loop

        In the first LabVIEW note we examined some simple arithmetic operations in LabVIEW.  In this note we will examine how to write a simple program with a timed loop.  After all, it isn't enough just to do arithmetic.  In most applications you need to do calculations over and over again.  Repetitive calculations are best done using a timed loop.

        Timed loops are important because you often encounter situations where you want to take measurements repetitively at a constant time interval.  Timed loops let you take data where you can set the timing between measurements.  Before getting to timed loops, we will walk you through some simple loops, and we will end with some timed loops that generate and display sinusoidal signals.

        In this note - as in the other LabVIEW notes, you could just read through the note, but you will do better if you work along as we discuss what is happening.

        The first thing you are going to do is to construct a simple timed loop.   You need to do the following.

        At this point, your block diagram should look like this.

        That's your first excusion into the world of loops.  The loop you wrote should have executed very rapidly and should have displayed a rapidly increasing number in the indicator on the front panel.  We can now add a timer to the loop to control how rapidly it executes.

        At this point you have a loop that is timed, and since the input to the timer is 1000 (that's milliseconds) it always runs at 1 second intervals.  There are two things we want to do to improve this program.

        We will take care of those two concerns next.
Now, your block diagram should look something like this.


P1      Modify the program above so that you can stop the program using an ON-OFF control.  Here's a hint.  Try replacing the constant the is wired to the conditional terminal with a control.  Right-click the constant (set to TRUE in the block diagram above) and change it to a control.  Then find the control on the front panel.

        One final program - just to end this by producing something that's getting close to useful.  (The next lesson in this series will take you to the world of IEEE-488 (GPIB) measurements, and when you put them in a loop, then you have some interesting things that you can do.)  Anyhow, this last program will compute a sine wave and display it on the dial.  Here is the block diagram.

You should notice the following in this block diagram.


P2      Modify the program above so that you can input the amplitude of the sine wave.

        And that is about it for this lesson.  In the next lesson we'll get you acquainted with some simple IEEE-488/GPIB measurements, and after that we'll do those measurements inside a loop.