From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Failing connection using LINX to connect to Arduino

Hello, 

 

I'm currently having issues with getting an Arduino Leonardo to properly connect and function via the Linx "Open vi" control. (File: "DOESNT WORK...") Sometimes upon running the program the Linx spits out an 5003 error which, as far as I can tell, is just a communication failure. Other times, the link enters the while loop without issue, but then boolean controls that follow in the Linx chain have incredibly slow response times (10-20s, if they respond at all). The NI DAQ that also exists in this vi often times out and can't keep with up the software, causing a failure of a different kind but which is surely related. I've tried various combinations of acquisition mode, # of samples to read, and sampling rate, to try and ease the load on it but nothing has helped. 

 

I've tried several time to follow the Tools -> MakerHub -> Linx -> Linx Firmware Wizard and re-upload the Arduino firmware, but this also leads to a connection failure and I don't think it helps anything. 

 

I have another vi ("WORKS...") that contains only the Linx chain (reading off the same COM port) and DAQ assistant (and associated items) that works perfectly, with no Arduino connection or DAQ issues to speak of and very quick boolean control response time. 

 

Why would the other vi work without issue but when I try to run this one it rarely completes the connection, let alone functions as a vi properly? Any advice to sort it out? 

 

Also I'm rather new to LV and almost certainly haven't done everything in this vi as efficiently and cleanly as possible, so if you see something blatant that could be better please point it out. However, the Linx and DAQ are my main concerns. 

 

Devices/systems are: LabView 2020, cDAQ-9171, Arduino Uno

 

Thanks in advance, 

Drake 

0 Kudos
Message 1 of 4
(1,787 Views)

Hi Dreggy,

I am no expert myself and I also can't open your files as I am using LV18.

It sounds like I am having what sounds like the same issue.

 

My sequence:

Run FW wizard

Start my VI, it works...until I stop it.

I then try to start the VI again and it no longer communicates.

I have to run the FW wizard again...this is very time consuming and irritating. 

 

I am not sure why this happens, but if I figure it out, I will circle back to this forum. Please let me know if you find anything as well.

Thanks!

0 Kudos
Message 2 of 4
(1,683 Views)

I have fixed my issue, not sure if it is exactly what you're looking for, but worth a shot.

 

When you open the com port to arduino, it actually resets the board. So, if your LV program starts executing before Arduino fully initializes, you lose comms. So, if you add a delay in LV after initializing, it gives arduino time to set up. Then when it goes to execute your while loop code, it is happy.

 

Also, I found in my code that it works much better to use the "Run" button, not the "Run continuously" button. If you use "run" and then only press the stop button in your VI (not the abort execution button), it will close down the comms correctly and wait to be started again.

 

I've attached screenshots, I hope it helps.

 

 

 

 

Download All
0 Kudos
Message 3 of 4
(1,676 Views)

Your observations make sense.

 

The Arduino uses the  DTR pin on the serial port as reset input. The VISA driver that is used for serial port communication in LabVIEW does initialize all modem handshake lines when you open the port and that can not be disabled. This initialization causes the DTR line to briefly toggle and that is interpreted by the Arduino to reset itself. After that the Arduino firmware needs a bit of time to startup and initialize everything again. And depending on the type of Arduino this can go fairly rapid or take several seconds (e.g. Arduino Mega are known to take longer to startup).

 

As to running your VI, NEVER use the Run continuously button. It is basically always the wrong one and can indeed only be terminated with the abort button, (well it can be also clicked again to disable the Run continuous mode and then the VI will run to completion as with the normal Run button), but abort closes the serial port and causes it to be reinitialized the next time you start your VI.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(1,668 Views)