0% found this document useful (0 votes)
95 views

Introduction To Interfacing Arduino and LabVIEW

- The document discusses interfacing an Arduino board with LabVIEW software for data acquisition and serial communication. - It provides instructions on writing a program in Arduino IDE to read sensor values and send them over serial communication. Then it describes how to set up LabVIEW to receive the serial data using NI-VISA libraries and create a GUI for plotting the data values. - The key steps are initializing serial communication in LabVIEW using VISA Configure Serial Port, reading incoming data with VISA Read Function, and closing the connection with VISA Close Function. Controls and indicators are created on the front panel to select the serial port and view incoming data.

Uploaded by

Hannia Medina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Introduction To Interfacing Arduino and LabVIEW

- The document discusses interfacing an Arduino board with LabVIEW software for data acquisition and serial communication. - It provides instructions on writing a program in Arduino IDE to read sensor values and send them over serial communication. Then it describes how to set up LabVIEW to receive the serial data using NI-VISA libraries and create a GUI for plotting the data values. - The key steps are initializing serial communication in LabVIEW using VISA Configure Serial Port, reading incoming data with VISA Read Function, and closing the connection with VISA Close Function. Controls and indicators are created on the front panel to select the serial port and view incoming data.

Uploaded by

Hannia Medina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN

FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

Introduction to Interfacing Arduino and LabVIEW

OBJECTIVES

− Know about the process of interfacing steps of Arduino and LabVIEW


− Understand the programming principle of LabView and the process of customizing front
panel GUI

INTRODUCTION
LabVIEW is a powerful simulation tool for developing a data acquisition system. It supports
serial communication with other devices. In this report, we have used the LabVIEW 2013
version with the support of NI-Visa version 5.1. for serial communication with the Arduino
board.

INSTRUCTIONS
1.- Process of interfacing
Arduino boards generally interfaced with LabView serially, for example, reading and
plotting the analog sensor value, first, we must write a program in Arduino IDE to read the
sensor value and its conductive voltage as follows:
/*ReadAnalogVoltage from the potentiometer. Reads an analog input on pin 4, converts it to
voltage, and prints the result to the serial monitor. Attach the center pin of a potentiometer to
pin A4, and the outside pins to +5V and ground. The setup routine runs once when you press
reset:*/
void setup()
{
Serial.begin(9600); // to start the serial communication at 9600 bits per second(baud
rate):
}
void loop() // the loop routine runs over and over again forever:
{

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

int PotValue = analogRead(A4); // read the input on analog pin 4:


float potvoltage = PotValue * (5.0 / 1023.0); // Convert the analog reading (which
goes from 0 - 1023) to a voltage (0 - 5V):
Serial.println(potvoltage); // print out the value you read: delay(100); // generating the
delay of 100 miliseconds
}

Just write the above program in IDE and dump it on the board. We can view the data on the
serial monitor of the Arduino IDE. After dumping the program in the Arduino board we are
now going to develop a data plotter using NI-VISA.

2.- LabVIEW Programming


Creating LabVIEW GUI After dumping the Arduino code, on the board now we will start to
build the GUI on the LabVIEW using the application of VISA (Virtual Instrumentation for
Serial Application). For using this application open the LabVIEW software.
The following are the steps required to create a GUI in LabView:
1. Open LabView and click on create the project, it will show the create project window.
2. Now on the lest panel chooses Templates | Desktop, and then from the right panel choose
Blank VI.
3. As we click the new VI, two panels pop up indicating front and Block diagram panel
respectively. We have to do all the LabVIEW programming in the Block diagram panel
only.
4. So click on the Block diagram panel. We can switch to the front to Block diagram panel
or vice versa by pressing the Ctrl + E button. The Block diagram panel having a white
background we have to start the programming.
5. Now we can create the project GUI by taking necessary components from the control
window.
As the data is coming to LabVIEW from the Arduino through serial communication, so at
first, we have to initialize and configure the VISA configuration for starting the serial
communication in the LabVIEW. For this just follow the following steps:
1. Right-click on the Block diagram panel. A pop-up window opens.
2. Expand the pop-up window and click on the Instrument I/O button.

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

3. A new pop-up window opens showing some serial communication options.


4. Click on the Serial option button.
5. A new pop-up window open showing several serial communication options.
6. Select, drag and drop the following options in the Block Diagram panels as shown in the
next figure:

Figure 1.- Selecting and placing the VISA options blocks

VISA Configure Serial Port: Initializes the serial port-specific with the aid of VISA aid call
to the specified settings. Cord records to the VISA aid name enter to determine the
polymorphic instance to apply or manually pick out the instance.

Figure 2.- VISA configuration port

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

− VISA resource name: Specifies the aid to be opened. The VISA resource call
manipulate also specifies the consultation and class. Baud rate: It is the rate of
transmission. The default is 9600.
− Data Bits: It is the number of bits in the incoming facts. The value of bits is between
5 and 8. The default value is 8.
− Parity: Specifies the parity used for every frame to be transmitted or obtained. This
enter accepts the following values:
− 0 no parity (default)
− 1 odd parity
− 2 even parity
− 3 mark parity
− 4 space parity
− Error in: Describes mistakes situations that occur earlier than this node runs. This
entrance affords general errors in capability.
− VISA resource name out: It is a copy of the VISA useful resource call that VISA
capabilities go back.
− Error out: It consists of mistakes statistics. This output presents preferred errors out
functionality.
VISA Read Function: Reads the desired variety of bytes from the device or interface
certainly by means of VISA aid call and returns the data in study buffer:

Figure 3.- VISA read function

VISA resource name: call specifies the aid to be opened. The VISA aid name control also
specifies the consultation and class.

− Byte count: it is the range of bytes to be read.


− Error in: describes blunders situations that occur earlier than this node runs. This
input provides a popular error in functionality.
− Read buffer: it includes the information examine from the device.
− Return count: it contains the number of bytes virtually read.

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

− Error out: it carries errors statistics. This output offers fashionable errors out
capability.
VISA close function: closes a device consultation or event item special by VISA resource
call. VISA useful resource call specifies the useful resource to be opened. The VISA aid call
manage additionally specifies the consultation and sophistication.
Error in: describes mistakes situations that arise earlier than this node runs. With subsequent
exception, this enter affords fashionable blunders in capability. This node runs generally even
if a blunder befell earlier than this node runs.
Error out: carries error statistics. This output offers general error out functionality.
7. Move the pointer at first to the configuration block and right click when the pin shows
the configuration name as in the image below:

Figure 4.- Configuration VISA serial

8. Right click at VISA resource name. A pop-up menu appears; select the option create and
select the option Control. This will allow the user to define the communication port on
the front panel.
9. Similarly, again, at the configuration block make the control of baud rate option as done
in step 8. So finally, the configuration block should be looking as in the next image:

Figure 5.- Configuration serial port

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

10. After the configuration of the initialization of the serial communication, now we have to
configure the serial read palette which will read the incoming data string from the serial
communication. To configure it we have to define the number of bytes that can be stored
in its buffer at an instant of time just like moving the cursor the point showing the byte
count.
11. Right click on the pin Byte count and select the option Create. In this option, select
constant. A blank space box will appear at the pin byte count. Edit it with number 1000
(it means that the palette stores 1000 bytes at an instant of time).
12. Similarly, we must configure the read buffer pin, which will shot the data string stored in
the byte count pin. Right click at the read buffer pin and create indicator option. This pin
shows the value at the front panel which will read the data string coming through serial
communication.

Figure 6.- Configuration of VISA read pallette

13. Configuring the serial close palette. To configure the serial close, just join the VISA read
palette with the VISA initialization palette as shown in the figure:

Figure 7.- Joining all the palettes

This is the basic programming of reading the data serially for a single instant, in VISA close
palette, we have to handle out the error. For this we use Simple error handler palette and is
connected to the VISA close palette.

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

14. For continuous reading the data serially from the communication port, we put the VISA
read palette in the while loop structure. To call while loop structure in LabVIEW, just
right click on the Block diagram panel and expand the pop-up menu. Go to the
programming options and select the block structures. Drag the palette and cover that
palette which you want to be in loop as shown next:

Figure 8.- Select “while loop” structure.

15. The final programming block diagram panel is done and should look something like the
picture below:

Figure 9.- Final block diagram.

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

3.- Customizing the front panel GUI


The first step is to plot the coming data as waveform, for this we need to use a palette in the
block diagram panel named as Fract/Exp String to Number Function. This palette converts
the data string format into corresponding point numeric value.

Figure 10.- Placement of “Fract/Exp String to Number Function”.

After this, we are now ready to customize the front panel:


1. Open front panel (ctrl+E).
2. Add a plotter (right click on the front panel, modern, graph, waveform chart).
3. By selecting the waveform chart, the front panel should look like this:

Figure 11.- Waveform chart.

4. Now we need to add this waveform chart in the programming, so we go back to


our block diagram panel and joint the waveform chart palette to the numeric string
palette:

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

Figure 12.- Connection of waveform chart and numeric string.

5. Again, go to the front panel, and add a gauge to represent the numeric value
graphically (right-click on the front panel, silver, numeric, gauge).
6. Connect the gauge palette with the waveform chart palette in the block diagram.

Figure 13.- Connection of gauge.

7. Now that the basic customization of the front panel is done, the last thing we need
to add is the Stop button, which acts as an external interruption to stop the while
loop structure if needed. To add it, we right click on the front panel and select the
categories button, then we select the stop button.
8. Connect the stop button palette to the red dot in the while loop structure of the
block diagram, as shown below:

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

Figure 14.- Connection of stop button.

Now that the overall basic programming of the plotting data has been done, the final
layout of the front panel and back panel should look something like the next figures:

Figure 15.- Final configuration of front panel

Figure 16.- Final block diagram panel

Semestre Enero – Junio 2021 | Modalidad Virtual


UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN
FACULTAD DE INGENIERÍA MECÁNICA Y ELÉCTRICA

LABORATORIO DE TRANSDUCTORES

9. After completing the programming, we must now select the com port at the visa
resource dropdown menu at the front panel and select the run button to visualize
the real time waveform.
REPORT
Write a report (with screenshots of the physical circuit and the simulation model) that can
answer the following questions:
1. What is the process interfacing steps of LabVIEW?
2. Write the programming principle of LabVIEW.
3. What is the customization process of the front panel GUI of LabVIEW?
Write your personal conclusions, and the references you used to write your report.

REFERENCES
Prakash, Anshuman; Gupta, Dr. Lovi Raj; Singh, Dr. Rajesh; Gehlot, Dr. Anita; Beri,
Rydhm. Biomedical Sensors Data Acquisition with LabVIEW: Effective Way to Integrate
Arduino with LabView (English Edition) BPB Publications. Kindle Edition.

Semestre Enero – Junio 2021 | Modalidad Virtual

You might also like