LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Arduino Via Serial

Solved!
Go to solution
Highlighted

Hello,

 

I am trying to control an Arduino UNO via LabView. I used NI's instructions on how to get started with this. However, it seems that although I created the driver files and "identified" the connection, I get the following error when I run my program (This is pretty much almost the exact same program the instructions show as an example):

Capture2.PNGCapture3.PNG

So I assume this means that it does not identify the port. The port in my NI Max window shows the usb symbol and the name:

Capture1.PNG

However, it does also have an "Unknown" in front of the name so I assume that even though it recognizes that it is usb, it doesn't know what port to associate it with? No idea what is happening here so it's just my guess. If it helps when I select the device, the settings page shows this:

Capture4.PNG

0 Kudos
Message 1 of 6
(265 Views)

Hello Tkeaton,

 

I have faced similar issues when I was getting started with Arduino Serial communication.For anybody new to Arduino -LabVIEW serial communication, I recommend to use toolkits like LINX by Digilent/Makerhub. It has VIs that makes your job easier. You can find the toolkit in VI Package Manager (VIPM) in the name of Digilent LINX. The UART Folder in the functions palette will help you I guess. PFA of the screenshot.

EDIT : If you are still curious to know how it is done. I think you can open the VIs in the toolkit and checkout.

Hope it helps

-Rahul

Hit KUDOS to convey Thanks

0 Kudos
Message 2 of 6
(212 Views)

I'd generally recommend using "Configure VISA Serial Port" rather than VISA Open, which may solve your problem.

 

That aside, perhaps restarting your computer will reset whatever "inconsistent" attributes have been set.

 

Note, that the 9600 you've wired to VISA Read looks suspiciously like it should have been a Baud rate (which is an input to Configure VISA Serial Port, but not VISA Open, and should be a property of the connection). Here it's wired to the Bytes to Read, and whilst it's a valid value for that, the specific value makes me think maybe there was a small mistake when copying the example...

 

Edit: I looked at the guide you linked and it's fairly terrifying. I strongly recommend instead looking at some of the VISA examples using the Example Finder in LabVIEW (Help > Find Examples...) and avoiding this configuration as a task type thing (your "Arduino Controller" input).

Doing it the way that you and the guide have done prevents a viewer from understanding the necessary information using only the block diagram (because we'd need to see the configuration stored in the "Arduino Controller" setup) and makes it harder to change values for testing (because the values are in some drawn-out dialog chain, rather than just constants or controls in the VI).

Message 3 of 6
(196 Views)
Solution
Accepted by topic author tkeaton

Well first off there a a couple of ways to use an Arduino with LabVIEW

 

  1. Use LINX
    1. LINX basically turns an Arduino into a USB DAQ device with access to all of the Ardunio's analog and digital I/O and lots of support for various peripherals, but the Adruino must always be connected to the PC to operate
  2. Use the Arduno's native language and communicate with it the same as any other serial device
    1. I prefer this method as the Ardunio can run "stand alone" or communicate with LabVIEW depending on my application.

If you chose method 2 here's a couple pointers...

Forget the NI USB tutorial that is not how an Arduino works.

An Arduino should install a virtual serial port when it is first plugged into your computer

You use that serial port and NI-VISA to communicate with the Arduino just like any other device on a serial port

You have full control over the serial protocol since you will be writing the Arduno code

Get your Arduino code to work with the Arduino Serial Monitor, then work on the LabVIEW to talk to it

Send data using the Arduino PrintLn function as it appends a LF to the end of the data. You can use that LF as a Termination Corrector in your VISA Reads 

Separate data by comas (data1,data2,data3) then you can use "Spreadsheet string to array" with the Delimiter set to a comma to parse the data from the string right into a numeric array.

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 4 of 6
(170 Views)

Thanks to everyone that has provided an answer thus far. If I cannot fix this issue with this instance of the code I will start over and use what many are recommending (LINX) over NI's default recommendation. The only thing I am concerned about is that with the tutorial I linked, I used the manager to create and install driver files so that this software can communicate with the usb and I am concerned that those files will confuse the system when moving over to using LINX. Maybe something I will just have to figure out when I get there.

0 Kudos
Message 5 of 6
(157 Views)

Worst case you might have to remove anything you setup in Ni-MAX (Measurement and Automation eXplorer) for that USB tutorial.

 

As I said before the Arduino should have installed a virtual serial port. 

That serial port should show up in Ni-MAX as just a serial port (NI-MAX will NOT "discover or find" the Arduino itself)

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 6 of 6
(154 Views)