LabVIEW With Arduino(Installation Guide)
LabVIEW With Arduino(Installation Guide)
(4th Class)
OBJECTIVE
In this Lab, you will learn how to hook up LabVIEW and Arduino. We will guide you
learn how to connect an Arduino board to a computer by installing a special package for
LabVIEW, and then controlling the Arduino board directly from LabVIEW. In this
experiment, as an example, we will simply light up the on-board LED of the Arduino
Uno board from the LabVIEW interface.
1
You can get it at the following URL:
http://sine.ni.com/nips/cds/view/p/lang/en/nid/212478
On this page, you will find a link to download the package.
Follow this link, and you will be taken to another page with the direct link for the VI
package manager. Click on the Download Toolkit button to start the installation process:
The VI package manager should open automatically and install the LINX package.
2
If this does not work and you get an error, it may be linked to the download
servers, which may have an issue. In this case, simply retry the procedure,
and it should work.
Setting up LabVIEW and LINX
We will now set up LabVIEW and the LINX package so that any LabVIEW-Arduino
project can work properly with no issues. Perform the following steps:
1. First, start LabVIEW. Here you do not need to create any project just you need to
click on Tools and then on Options.
3
2. You will be taken to the Options window of LabVIEW, where you can set all your
preferences. Then, you have to go to the VI server menu.
3. You can see that there are some options that you can change here. Change all the
options so that they match the options as shown in the figure above.
4
4. After that, you have to do the same on the VI Package Manager so that both
LabVIEW and the Package Manager can talk to each other. Notice that for systems
like Windows, it was automatically done, However, it is not the case on OS X, for
example. To do so, simply open the Package Manager, go to the Tools | Options
menu, and then click on the LabVIEW icon.
5. In this menu, make sure that the Port value next to your LabVIEW installation is
the same as the one you defined inside LabVIEW. Correct it here if it is not the
case, and then confirm.
5
The first thing that you need to do is through going to the main LabVIEW window; then,
click on Tools and then on MarkerHub, which is the link to access the LINX interface.
Then, click on LINX, and finally, click on LINX Firmware Wizard.
This will take you to the LINX graphical interface that we will use to configure our
Arduino board for the project. Note that this step has to be done only one time; once the
right software is loaded into the Arduino board, you no longer need to touch it again. The
wizard starts by asking us which board we are going to use. Configure this first window
by selecting the same settings as shown in the following figure:
6
After that, you will be prompted to select the Serial Port on which you want the interface
to communicate. Since we only have one Arduino board connected at the time, we can
only select the port that Windows calls COM4. However, this entirely depends on your
operating system.
A very simple way to find the COM or Serial Port that corresponds to your Arduino board
is to look at the list of proposed Serial ports. Then, disconnect your board and see which
Serial Port disappeared; this is the one that corresponds to your board.
Finally, confirm your choice of Serial Port, and start uploading the firmware on the
Arduino board.
7
After configuring and finishing all the above steps, now, you are now ready to use the
LINX interface to control your Arduino board. However, if you have an issue at this step,
you may have to install the NI-VISA package, which you can download from this link:
http://www.ni.com/download/ni-visa-4.3/988/en/
At the end of this setup, LINX will offer to open an example program. Accept this
offer, and you will be taken to a new VI.
8
This is called the Front Panel of this example project from that you can use to control
the project. As you can see, this VI is very simple, which allows users to just control the
value of a digital pin of the Arduino by clicking on the green button on the right-hand
side.
There are two things you need to modify here before you can start the VI.
v First, you need to set the correct Serial Port in the Serial Port box. Start just by
typing the name of your port, and it will autocomplete what you are writing.
v Then, you need to set which pin you want to control. You can simply use pin
number 13 here, as it is already connected to the on-board LED on the Arduino
Uno board. If you choose any other pin, you will be able to build a simple circuit
on your board, as shown in the illustration on the left-hand side of the preceding
of the figure illustrated above.
9
Now, you can use the VI, and to do so, simply click on the small arrow on the toolbar.
Then, wait for a while. Indeed, the VI will now try to initialize the communication with
the Arduino board. If you click on something immediately, it can produce an error. You
will know that the initialization process is complete when the Arduino board Serial Port
LEDs (TX & RX) are both turned on. Then, click on the green button; you will see that
the on-board LED on the Arduino board is immediately turning ON or OFF.
To view the block diagram of your project, go to Window and then click on Show Block
Diagram. Note that you can also use the Ctrl + E shortcut to switch between Front Panel
and Block Diagram. This will open the following window:
The above is the Block Diagram window for the project, which is basically what is going
on behind the scenes. Some of the components are linked to elements of Front panel,
such as the Serial Port value. You can see that the core of the project is the Digital Write
module that we use to send commands to the Arduino board.
For now, we only provided you with some basic information to get you have an overview
of what can be done with LabVIEW and Arduino. Hence, to build a larger Arduino with
LabVIEW, you can start building such block diagram from scratch to construct your own
project.
10