LabVIEW with the Linkbot

From LinkbotLabs
Jump to: navigation, search


LabVIEW is a graphical programming language developed by National Instruments. It is used by many universities worldwide for tasks such as data acquisition and scientific computing. This article will show you how you can use LabVIEW to control your Linkbots.

Installation and Setup


  • Windows (Mac version to be released later)
  • Labview 2014
  • Linkbot Labs

Installation Instructions

First, you must install Linkbot Labs. Linkbot Labs comes with drivers and OS services that are necessary for using Linkbots with your computer. You can download and install Linkbot Labs here.

To install additional necessary software to begin controlling your Linkbots with LabVIEW, download and install the latest version of the Linkbot Toolkit available here. Download the file and double-click on it to install the package.


The Linkbot Toolkit installs a set of VIs you can use to control your Linkbots. Here are instructions to create a new simple project that moves a Linkbot's motors and beeps its buzzer.

First, open LabVIEW and create a new VI by clicking on "File -> New VI". A new VI should open.

Click on "Window->Show Block Diagram" to show the block diagram. It should be empty.

The general workflow for controlling Linkbots consists of an initialization step, calling Linkbot functions, and then a deinitialization (closing) step. To accomplish this, we will use a "Flat Sequence". Right-click on the empty block-diagram window to open the LabVIEW Functions dialog and select "Structures -> Flat Sequence". Once you have selected the flat sequence, drag a moderately sized rectangle on the block diagram. Your block diagram should now look like this:

Lv screen1.png

Right click on the border of the flat sequence and select "Add Frame After". Do this twice. You should now have a flat sequence with three frames, like so:

Lv screen2.png

Now let us add the Linkbot VIs used to initialize a new Linkbot. Right-click on the block diagram to bring up the Functions dialog and select "Linkbot Toolkit -> New". (You may have to expand the Functions dialog by clicking on the expansion arrows at the very bottom of the dialog in order to see the Linkbot Toolkit). Drag the "New" block into the left-most frame of the flat sequence. Your screen should now look like this:

Lv screen3.png

Lets go ahead and add a block that lets us move the Linkbot's motors and also close the Linkbot object. Bring up the Functions dialog again and drag the "Linkbot Toolkit -> Move" VI block into the middle frame. Do the same for the "Close" block, except drag the "Close" block into the right-most frame. Your block diagram should look like this:

Lv screen4.png

Now it's time to connect and populate our block diagram. Begin by connecting the top right terminal of the "New" block to the top-left terminal of the "Move" block, and also the top right terminal of the "Move" block to the top-left terminal of the "Close" block. You will notice that all of the Linkbot Toolkit VI's have a "Linkbot" terminal across the top of the VI. This connection transfers a handle to the current Linkbot to the Linkbot VIs. Your block diagram should now look something like this:

Lv screen5.png

Do the same for the "Error" terminals at the bottoms of the VIs. Additionally, right-click on the bottom-right terminal on the "Close" VI and select "Create->Indicator". This will create an error indicator on the front panel. If the Linkbot Toolkit encounters any errors during operation, it will display on this indicator. Your block diagram should now look something like this:

Lv screen6.png

When we create a new Linkbot object in Labview, we must specify the Linkbot's ID. Right click on the top-left terminal on the "New" block and select "Create->Constant". In the string-constant box that's created, type in the ID of the Linkbot you want to control. My Linkbot has an ID of "NJCX".

For this first simple example, I will move motor 1 90 degrees in the positive direction. Right-click on the second-from-top terminal on the "Move" block and select "Create->Constant". In the newly created constant, type in the value "90".

Lv screen7.png

We are now ready to run the VI. Make sure you have a Linkbot or Z-Link Dongle plugged into your computer and click on the "Run" button in the toolbar. Motor 1 should rotate 90 degrees when you run the VI. Congratulations! You have written your first Linkbot Program.

Tutorial Part 2

This next small tutorial builds upon what we started in the first tutorial. In this program, we will modify the program we wrote in the first tutorial to make the Linkbot beep while it is moving its motor 90 degrees.

Insert a "Linkbot Toolkit -> Buzzer" block, a "Linkbot Toolkit -> MoveWait" block, and another "Linkbot Toolkit -> Buzzer" block into the second frame. Adjust the Linkbot and error connections so that they flow from the "Move" block through the "Buzzer" block, the "MoveWait" block, and through the second "Buzzer" block into the "Close" block. Your block diagram should now look something like this:

Lv screen8.png

Next, right-click on the "frequency" terminal on the left buzzer block and select "Create->Constant". Type in the value "440" for the constant. Do the same for the right buzzer block, except enter the value "0" for the constant. Your block diagram should now look something like this:

Lv screen9.png

You can now run your VI. Your Linkbot should turn motor 1 90 degrees and emit a buzzer tone while the motor is moving.


When the VI is executed, the execution of the Linkbot blocks flows from one block to the next. Execution starts with the "New" block which acquires and initializes a Linkbot. Next, control flows to the "Move" block. The "Move" block instructs the Linkbot to begin moving motor 1 90 degrees and then control immediately flows to the first "Buzzer" block. The first buzzer block instructs the Linkbot to begin emitting a buzzer tone at 440 hertz.

Next, the control flow reaches the "MoveWait" block. The "MoveWait" block is a special block that halts the Linkbot's program flow until all motors have finished moving. During this time, the buzzer remains on emitting a tone at 440 hertz. Once the motor finishes its 90 degree rotation, the "MoveWait" block relinquishes control and we reach the second "Buzzer" block which turns the buzzer off by instructing it to emit a tone at 0 hertz. Finally, we reach the "Close" block which deinitializes and closes our Linkbot object.

Additional Help and Documentation

Each one of the Linkbot VI's comes with fairly comprehensive "context help". You may explore the functionality of the Linkbot VI's by placing a Linkbot VI down on your block diagram, clicking on the question-mark icon at the top-right of your Labview window, and then clicking on the Linkbot VI. Context-help will be displayed explaining the functionality of the VI block, as well as how to use the terminals on the VI block.