Calling Arduino from LabView: Set up and simple analog read.

Generally, I prefer to do tutorials about open hardware and software, but this one is different.  The number of people using LabView and Arduino is so big that it starts to be interesting being able to use both together.

So, do you remember our last post about Arduino?

maths with Python 7: Data logging from Arduino

Today we are going to repeat it but with Labview

200px-LabVIEW_Logo_Vertical_4c

communicating with the Arduino UNO board.

ArduinoUno_r2_front450px

 

0 Step. You have a copy of Labview 2013 or newer version installed.

1 Step. Install Arduino Toolkit in Labview. To do that, we can simply follow the indications from National Instruments listed here.

2 Step. Install VI Package Manager (VIPM) from it’s webpage. Simply follow the installing default steps. This software will help you manage different toolkits for LabView.

3 Step. Run VIPM. Since it is the first time, it will take a while to detect all the packages from Internet. Once it is finished, look for the LabView to Arduino and click Install.

Labview Interface for Arduino

simply follow the steps and it will be installed without any problem.

Labview Interface for Arduino

4 Step. Connect your Arduino to the USB port. If you don’t have it yet, at this point you need to have installed the Arduino IDE and drivers.

5 Step. Upload into the Arduino board the new firmware that will allow it to communicate with LabView. (NI tutorial here). The file you need to load into the Arduino will be in a folder created when you installed the Arduino-LabView toolbox. Open and browse to LIFA_Base.ino found in C:\Program Files\National Instruments\LabVIEW 201x\vi.lib\LabVIEW Interface for Arduino\Firmware\LIFA_Base

Labview Interface for Arduino

Make sure you select the UNO board and the correct COM port.

Now the Arduino is ready to comunicate with LabView and Labview has the palette with VIs to send and read instruction from the Arduino. Let’s do something.

5 Step. Start LabView and open a new VI.

Labview Interface for Arduino

You will notice now that in the block diagram view, there is an Arduino palette.

6 Step. Drag and drop Init and Close. This will be necessary to initialize the communication and VERY IMPORTANT to close the port once we finish using it.

Labview Interface for Arduino

7 Step. Add a constant for the “Bits Per Packet” input of the Init (Right click Create>Constant), and add controls for the rest of them (Right click Create>Constant). Remember to arrange them in the Front Panel.

Labview Interface for Arduino

8 Step. Now create a while loop (Remember to create a buttom to stop the loop). This loop will run continuously taking values from the Arduino. (I also placed an indicator on the Error Output of the Close VI).

Labview Interface for Arduino

Inside the loop we put the Low Level “Analog Read Pin” and a waveform chart. Edit the properties of the waveform as you prefer. In my case, I remove the autosizing of both x and y axis.

Labview Interface for Arduino

9 Step. You might notice the constant “0” attached to the read VI, it indicates we are using pin A0. Next step is to connect something into the pin A0 that generates a voltage. In our case we can use the photodiode from the last tutorial (one pin to A0 another one to GND).

10 Step. Now everything is ready to run. Make sure you select the correct board, the baudrate and the correct COM port (you can check in the Arduino IDE if you don’t know the port). And Voilá!

Advertisements

One thought on “Calling Arduino from LabView: Set up and simple analog read.”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s