“Why is LabVIEW so weird?”

Those of us who may already have experience programming C, C++, Visual Basic or other text-based, procedure oriented programming languages may feel stymied by the seemingly strange way of constructing programs in LabVIEW.  Your work with the First Robotics FRC code is likely your first exposure to LabVIEW – and it probably feels a little strange if you’ve already been working with conventional programming languages.

Truth is, LabVIEW does use a different programming model – called data flow programming – rather than our more common procedure oriented programming model (which technically is imperative programming, based on the von Neumann (pronounced “von noy men”) computer model).

Once you get your mind wrapped around how things work in LabVIEW – you will still get to apply your general knowledge of programming and programming concepts. So all is not lost!

In conventional programming, we model our program as a sequence of steps or procedures – do this, do this, do that, if that condition occurs do that thing otherwise do this other thing. In many ways a program appears similar to a set of instructions that we might write to tell someone how to do something.

Data flow programs are viewed as a sequence of boxes (in LabVIEW a box is a virtual instrument (VI) or a sub VI) that have inputs and outputs. The code within the box executes just as soon as it has valid data available on its inputs.

The order of execution is determined by the availability of the data from one VI to others. This has the interesting property that when one VI finishes, if its output is connected to multiple VIs, and all of their data input is available, then those VIs will all begin executing at the same time! As you might be thinking, data flow programming is great for multiple processor systems. Creating a multiple processor programming model in a traditional language can be quite complex – with data flow programming, support for multiple processors comes automatically.

A good way to see this in operation is to create some small programs in LabVIEW, such as the simple exercise I suggested in an earlier tutorial.

Then, click on the light bulb icon to illuminate program execution. You’ll actually see indicators showing when the data is ready and how it flows to other VIs in your program.

LabView is weird, but in a good way – and only weird to those who have done other types of programming. Many who have not had their minds polluted(!) with traditional programming learn LabVIEW quickly and find that it seems to make a lot of sense to them!

1 Comment

ToddJanuary 19th, 2009 at 9:44 am

Good overview! You can find more resources for LabVIEW programming here.

Leave a comment

Your comment