Serial Communication Using Visa Labview Driver

Motor Driver ICs. Power Switching. 2-Wire Communication Using LabVIEW. This application brief describes how to use LabVIEW, via a PC serial port to control a 2.

  1. Labview Visa Drivers
  2. Arduino Labview Serial Communication

Hi Everyone, I hope you are good and doing well in your life. Today I am going to start a series of tutorials on Arduino interfacing with Labview. I have already posted a project on labview with arduino for getting different sensors data on labview. This project is called remote monitoring system using Labview and Zigbee. You can check more details about this project by clicking on this link: Remote monitoring system using Arduino and Xbee. In this getting started tutorial on Labview with Arduino, you will learn how to interface Arduino with lab view or you can say how to get Arduino data through serial communication on Labview graphical user interface. you should have basic knowledge have basic knowledge of Labview software before starting this project. So let’s start with this tutorial.

There are many people online looking for how to get Arduino get serially on labview. So I decided to write this article. Labview also provided a tool for Arduino which we can use to program arduino directly from Labview. You just to need to install arduino interfacing with Labview tool in Labview software. I will also write article on it but in this tutorial, we see how to get Arduino date on Labview without using Labview tool for arduino. It can be used in many industrial application. For example it can be used in data acquisition system, real time monitoring system, home automation systemetc.

First of all you should have installed any version of Labview installed on your PC, if you do not have, you can download and install this software from after downloading from this link : Download Labview. This software is not free of cost. But you can still use demo version for 45 days or you can get it from other sources. To get data serially on Labview, we need one more driver . This driver is used for serial communication with arduino and Labview VI. you will not able to get data on Labview without installing driver. Labview also provides other drives for example labview server drivers, labview web services which is used to send labview data to web servers. Follow the following steps:

  • First we all you need to download NI VISA driver.
  • After downloading install this driver.
  • After you done with the installation, NISA driver will automatically create a tool in with the name of COM port as shown in VI below.
  • After installation when you run the Labview first time, this tool will automatically start appearing in labview components window.
  • After install simply run the labview and following window will appear
  • Now we need to design VI in Labview. To make VI click on create project after that following window will appear.

Labview Visa Drivers

  • Now select blank VI and click on Finish. When you click on finish, a blank VI will open, which we used to create our project.
  • Labview has two types of consoles. One is called block diagram where we place all components and other is called front window. Front window is used as graphical user interface and it is where user get its data and make changes in data. Block diagram and front panel is shown below:
  • Now you need to design a VI. In this VI we will use VISA resource to get data serially. I have designed a VI which is shown below. In this VI we are getting data from serial port. Arduino will be connected to computer serial port and date received from Arduino will be displayed in response window.
  • VI which I made in labview is shown below.
  • In this VI we are using Loop to get data continuously from Arduino. Response component is used to display data. Block diagram of VI is shown below.
  • You need to select COM port to which Arduino is connected. In my case it is connected with COM4 port. So I selected COM4 port.
  • After that click on start reading and you will getting date in response window.
  • To stop simulation just click on stop simulation and you will stop getting data on response window.

Arduino with lab view to get data serially

So I have explained all the things above you need to get data on labview from serial port. Now you just need to send data from data to labview through serial port. Connect your Arduino board with your computer and check the COM port to which Arduino is connected. You can check it through device manager of your computer. you can send any data you want. For example, you have connected four sensors with Arduino and you want to measure values of these sensors and want to send sensor values to Labview. For example you have connected temperature, humidity, light and hear beat sensor with Arduino. Arduino will measure these sensors values and send data to labview using serial communication. I have used this example code to send values of temperature , humidity and light sensor to arduino. from Arduino to labview. you can use this code for checking purpose.

Arduino code to send date to labview

So this is all about how to send data serially from Arduino to Lab View. If you face any issue let me know with your comments.

1. Overview of Serial Bus

Serial is a common device communication protocol for instrument control because most computers and many remote instruments include at least one serial port. Single applications can be used across a variety of instruments with few modifications, reducing programming and test time.
For more information on the serial protocol, including information on transfer speeds and important parameters, please refer to Serial Communication Overview.

Arduino Labview Serial Communication

2. Connecting and Setting up a Serial Instrument Control System

Engineers typically use serial to transmit American Standard Code for Information Interchange (ASCII) data. All data types are converted to strings of ASCII characters and then transmitted bit by bit across the serial bus. For two ports to communicate, both the instrument and the controlling computer must have the same baud rate, data bit size, stop bits, and parity.
A basic serial instrument control system consists of three parts:
1. PC (or controller) with a serial port
2. Serial cable
3. Serial instrument
As mentioned, most computers include a serial port. The only hardware setup required is connecting the serial cable to the serial port on the PC and the serial port on the instrument. The serial instrument may include some hardware drivers or software utilities for communication, and should include documentation on the baud rate, packet size, stop bits, and parity bits that the instrument will use. Additionally, check the National Instruments Instrument Driver Network to see if LabVIEW drivers already exist for your instrument, as well has tutorials on how to use them.
To confirm that the serial port on your computer is working properly, refer to Serial Communication Starting Point, to see how to perform a serial loop back test.

3. How to Create a VISA Resource for the Instrument in MAX


With NI-VISA, communicating with your serial instrument is easy. To confirm that you are able to communicate with your instrument, open Measurement & Automation Explorer (MAX) found at Start>>Programs>>National Instruments>>Measurement & Automation.

Serial


Figure 1. MAX Main Menu


Expand the Devices and Interfaces subdirectory below My System. Below it you should see all the serial and parallel ports on your computer. In this example the computer has one serial port (“COM3”). Figure 2 shows the directory path to the serial port and the configuration window when COM1 is selected.


Figure 2. Serial Port Configuration Window


From this configuration window you can change the VISA Alias for easier identification and you can also communicate with your instrument through a VISA Test Panel by selecting Open VISA Test Panel. Your instrument should have specific commands for collecting and transmitting data and you can use the VISA Test Panel to test these functions and verify that they are working properly.
Using NI-VISA to Communicate with Your Serial Instrument
NI-VISA makes serial instrument programming fast and easy. VISA Open, VISA Read, VISA Write, and VISA Close are the basic VISA functions in LabVIEW used in the example VI in Figure 3. This example opens a VISA session to a serial device. A command is written to the device, and the response is read back. In this example the specific command being sent is the ID query for the device. Check with your device manufacturer for your device command set. After all communication is complete, the VISA session is closed.


Figure 3. LabVIEW Serial Program Using NI-VISA

NI-VISA provides built in serial examples to assist users with application design and development.

  • Serial examples for LabVIEW can be found the in LabVIEW Example Finder by navigating to Help>>Find Examples>>Hardware Input and Output>>Serial. The Readme file for each NI-VISA version provides more information on where to find LabVIEW Serial examples.
  • Serial examples for .NET, C and VB6 can be found by navigating to Start>>All Apps>>National Instruments>>NI-VISA Examples.

4. Related Resources