How to Read Serial Data from Arduino Using Labview Visa

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

Are you looking for a way to read serial data from Arduino using Labview visa? You are in the right place. A lot of people are searching on the web about the best methods that they can use to read data from Arduino and one of the ways is what we are going to discuss in this post.

x
What is Arduino?

We’ll focus on sending a string and receiving data found in the USB port. However, for this project you will need a bit of knowledge in C programming language and labview diagram block.

How to Read Serial Data from Arduino Using Labview Visa

Below are some of the other things that you need:

  • A sensor such as the LM35
  • The labview software together with the visa driver
  • Arduino Uno

Labview stands for Laboratory Virtual Instrument Engineering Workbench. It is a visual programming language that was developed by the National Instruments, and is quite useful for the acquisition of data, control of instruments, and the automation industry.

On the other hand, Arduino is the open-source computer hardware that is used for developing interactive objects and also taking inputs from various sensors or switches. It also controls various lights, physical outputs, and motors.

The benefit of Arduino projects is the fact that they can be stand-alone or even communicate with any software that is running on a computer. You can assemble the boards with your hands or even buy pre-assembled boards. You can download the open-source IDE free of charge from Arduino.

Steps you need to follow

1. Labview VI

First of all, you need to create a new file through File > New VI, and then head over to the block diagram window at the data Communication and then Protocols and Serial. Then select any VI. When you get to this point, you need to take the serial port of the visa to configure which helps to set up the port.

You also have to choose visa to write two times which can write the information to the connected device. Choose visa read which can help you read the available data from the serial port of the connected device. Visa close, on the other hand, helps to close the established connection. Lastly, you have to pick bytes at the serial port because it helps to analyze whether there’s any available data.

2. Making the Structures and Connecting the Dots

In this second step, this is where you make the structure by joining the dots. You have to create a While Loop in Programming > Structures > While Loop.

Come up with a 3-case structure right inside the while loop such as Programming > Structures > Case Structure. Writing the string happens in the first 2 cases because the last one is used for reading.

The visa close and the serial port of the visa configure normally happen outside of the while loop. However, you have the option of including the serial port of the visa configures right in the while loop. We recommend selecting the COM port before you run the VI, although if you happen to include it inside the loop you can freely select the COM port whenever you want.

The visa bytes at the port are supposed to go into the while loop. When you want to activate the reading case, it is imperative to check whether the serial port’s bytes are higher than 0 using this method:

  • Programming > Comparison > Greater than 0 VI.

In case you happen to find that the bytes are higher than 0, it will activate the True Case Structure and the read bytes will be returned by the “Visa Read.”

The serial configure port from visa needs to allow the user to select their preferred serial port for using, and also set up the baud rate. Therefore, the VISA RESOURCE NAME, as well as BAUD RATE needs to be in control. You should note that 9600 is the default baud rate.

The other thing that you need to do is to develop a command in visa write > write buffer. This is the string that will be written in the USB port. However, in case you want to use the keyboard to send commands, you only have to use a single visa write and develop a control for the input string.

To develop a user interface, you have to head over to the front panel window. When you want to see the received data, we highly recommend having just a single numerics > thermometer and also graph indicators > charts.

You can add more buttons through buttons > Ok button to activate or shut off the sensor. You also have to change the mechanical action to “switch until released,” and then add NUM INDS like this: NUM INDS > NUM INDICATOR.

There is also the option of adding some captions such as USB control or LM35. When it comes to setting the graph, buttons, NUM INDS, and thermometer, you have to return to diagram block window.

To see the data gotten from the USB port, you have to convert it to number from string. Below is the process.

  • Programming > string > number conversions > exp string number. This process converts the string into number. However, you still have to add the “read case structure’ inside so that you can ensure you’ve received all the data that needs to be converted.

You also have to connect the string input of the VI to “read buffer of the visa read.” After doing that, you need to connect the first case structure to the “turn on” button and the second case to the “turn off” button, plus the “stop” button to the while loop condition.

However, to receive the data you have to wait at least 600 ms because of various delays. When it comes to using the Arduino code, you have to ensure that you’ve defined all the pins and variables that you’re using.

Conclusion

This article exhaustively illustrates how easy it is to read serial data from Arduino while using Labview visa. Every important detail has been highlighted such that you do not get lost. It goes without saying that using Labview visa to read serial data from Arduino is a simple process when you have the right information.

Special offer for our visitors

Get your Soldering Iron Guide For DIYERS

We will never send you spam. By signing up for this you agree with our privacy policy and to receive regular updates via email in regards to industry news and promotions