Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Two Arduino control with same .Vi

Hi all, 

I'm new in the community, LINX is very usefull!

In my project i would like control two arduino (one connected via USB to PC and other one via Bluethoot to PC), and both controlled by same UI.

The one connected via USB will be an SWR meter, that capable to read the Antenna matching and tuning it automatically moving a stepper motor connected a capacitor. I don't know how see if the movement of motor is correct in one direction or not..

More over, how can i install the same Vi on two arduinos and recognize one from other?

Please, someone can help me?

in attachment the draft Vi.

Thank you in advance and happy new year!

Giorgio

0 Kudos
Message 1 of 8
(891 Views)

Based on my understanding of LINX and Arduino control you cannot deploy LabVIEW code to the Arduino to run independently of the PC the targeting of the Arduino is through the LabVIEW project.  I do not believe it is possible to target 2 Arduinos through the same project, though I am not positive of this.

 

What you might be able to do is create 2 separate projects each of which target 1 of the Arduinos and another VI which would be your interface.  Then you could use a messaging structure to communicate between your 2 Arduino VIs and your interface VI.  You could use queues or some other method to pass these messages all around.

 

 This is one idea but maybe someone else who uses Arduinos can provide a different suggestion.

David Wilt
The New Standard LLC
0 Kudos
Message 2 of 8
(878 Views)

I haven't done anything with Arduino so far with Linx. But as far as I know you can have Linx installed on the Arduino. This is NOT like on the Raspberry Pi or BeagleBone Black where an entire LabVIEW runtime environment is installed on the device and you can directly deploy your VIs from a LabVIEW project to it. Instead it runs the liblinxdevice shared library as a serial and//or TCP/IP server and then you can connect to it from another device that can run the Linx VIs, including a Raspberry Pi, Beaglebone Black device, or of course your computer with LabVIEW on, by targeting the Arduino device through its IP address or connected serial port.

I'm not sure if there are other ways to target Arduinos in a LabVIEW project. It would seem unlikely to me that you can add them to a project like a Raspberry Pi or Beaglebone Black target, but you certainly should be able to communicate to them through the Linx VIs from a project in your My Computer target.

 

Basically you use the according Linx VIs to open a connection to the Arduino device through either the serial port or its TCP/IP address and then use the other Linx VIs to access the resources on that device, just as you would use them if you were accessing local resources on a Raspberry Pi or Beaglebone Black. The Linx VIs transparently pass the data over the chosen communication link to the device and receive the response back.

 

 

Rolf Kalbermatter
Averna BV
0 Kudos
Message 3 of 8
(845 Views)

And you can definitely communicate with more than one Arduino device (or any other Linx device for that matter) through the Linx VIs, by opening a seperate connection for each.

 

And you can also have more than one Raspberry Pi and Beaglebone Black target in the same project.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 4 of 8
(838 Views)

Hallo, I hope that you can help me. I am trying to communicate with two exactly the same arduinos wia USB, both of them are Arduino Mega 2560, from LabView using LINX. I can open connection with both of them at the same time, but the problem is, that they interference with each other. They slow each other. They are on different COM ports, but both of them have the same name: Arduino Mega 2560 in the Device Manager in Windows 10. Can the same name be a problem? If so, is there any way to change name to the one of them?

 

Thank you for responce.

Greetings.

0 Kudos
Message 5 of 8
(612 Views)

Hi,

the name should not be a problem. As long as Windows recognizes each with its own specific COM port you should be fine. So check in the device manager that the 2 Arduinos are assigned different COM ports, then in your code make sure that when a connection is open to a specific port you use the same connection reference for the associated device. So make sure connection references are not mixed. 

I did not specifically try with 2 Arduinos. The above is in the context of serial connections in general. And I would assume for the time being that LINX does not break this.

L.

 

PS: I do have a hunch though that at the low levels there may be some issues , see this FAQ entry on LINX. I know branching wires is not what you should have with 2 Arduinos, but I am wondering if at the low levels the core LINX functions are the source of the problem not being called "serially"

0 Kudos
Message 6 of 8
(610 Views)

Hi, thank you very much for your replay. Thanks to you I was able to find a solution for my problem. The problem was in Linx, because it uses a lot of subVis, and almost all of them were set to work as Non-reentrant execution. I changed them in Preallocated clone reentrant execution in their VI properties. And now I can communicate with two arduinos completely independent. 

 

Thank you once again.

 

Greetings.

 

Misa Tomic.

0 Kudos
Message 7 of 8
(583 Views)

Great to know. Let us know in this thread if the re-entrancy doesn't lead to other issues down the road.

Regards,

L.

0 Kudos
Message 8 of 8
(578 Views)