LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically Select Arduino from list of serial devices

Hello -

 

I am looking to do some automated testing with an Arduino Uno. The main goal is to use the Digital Pins to activate/deactivate relays with the LINX tools. In NI MAX, it shows up with its respective COM port and its port description is Arduino Uno.

 

I currently have a VI written that uses some of the VISA commands to find the connected serial devices and it finds the Arduino Uno just fine. My end goal is for the program to search the serial devices, find the Arduino, select it for it's COM port, perform the testing as necessary, not giving the user the ability to select it manually. 

 

Is there a VI or combination available that I can use that will return a COM Port (given a set of commands to narrow down to the Arduino)to use with the LINX commands? 

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

I've done this before and just set up my Arduino to return a specific command if queried properly. This allowed me to go through each COM port, send a command, and stop on the COM port that replied properly. This was especially helpful when I had multiple Arduinos and I had each return it's own name, so I could distinguish between them.

 

Just make sure whatever command bit you send isn't something that could mess up any other devices. You'll have to check for COM errors like ports already opened by another application, etc, as well.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 4
(2,155 Views)

Another option might be to just use the LINX open on each COM port on the system, and when the open doesn't return an error, end the for loop and assume that you found your device.  One issue with this is I bet the open command has a long timeout and it might take a long time.  I'd suggest using a stripped down VISA open, followed by a read that that the open does, that way the timeout can be reduced.

0 Kudos
Message 3 of 4
(2,116 Views)

Frankly with today's Windows (7+) USB devices are always be on the same virtual com port.

 

As Windows finally remembers the UUID of the device and what virtual com port it assigned, and will assign it the same port every time and shouldn't assign any new devices that same virtual com port. 

 

While I see the point of your application it's really not critical unless you are moving the Arduino and code from computer to computer a lot. 

 

I have several Arduino's and each individual Arduino always shows up on a different com port from each other, but each individual Arduino is always on the same com port it was first given. That is I have one Arduino that is always Com 7, one that is always com 9, etc...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 4
(2,112 Views)