LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Static Com Port Assignment

I have an application where I am using a few stepper motor drivers that will have an RS-485 to USB adapter, which will be used to commuicate via VISA and LabVIEW. The problem I am having is that my computer is auto allocating the COM port differently each time I plug in my device and I was curious as to whether or not there is a way to assign a COM port/USB port as static so it does not change when I plug in a device to a certain designated port. Is there a way to do this in Windows settings or a way to search for the USB connection and write to its port whenever it changes?

0 Kudos
Message 1 of 10
(7,173 Views)

In MAX, you can create a virtual port, bind it to a physical port and then assign it an Alias that means something to you.  Then in your program, you can select that alias.  That doesn't guarantee that the instrument gets assigned the same physical port everytime,however.  But if it gets assigned the wrong port, it's easy enough to go into MAX and reassign your alias.  I know it's still a hassle but I don't think serial is smart enough to autodetect the instrument and assign it a previously assigned port. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 10
(7,160 Views)

I always try to avoid hardcoding a port number in my LabVIEW applications. I guess you have some avaliable VISA commands to interact with these motor drivers, yes? You could have a FOR loop where you try some sane range of port numbers, like from COM1 to COM8... Using some not too high timeout, you can check for error (no connection, blabla), and handle the error:  move to the next com port number and test it as well. After a while your code will find a valid com port to communicate with your hardware.

 

Extension of this technique, when I have to initiate connections to multiple RS232 devices (but same types!). I request an ID number of each device, and I reserve the actual COM port to the actual ID. In this way, even if the operator mixes up the serial cables, the LabVIEW applicaton will always know what to do with each devices (like I have several pressure sensors connected to the PC via serial cables), since the code dynamically using the proper COM port(s).

 

These ID numbers can be stored in a human configurable config file, and the application warns the operator if an ID was not discovered / so an unknown ID is discovered. In this case a new ID can be typed in at runtime, and saved to config file (example if a pressure sensor gets replaced).

0 Kudos
Message 3 of 10
(7,145 Views)

Blokk thank you for your response. Can you elaborate more on exactly how you would go about doing this or if you have some example program that I can reference. There will be several different motor drivers with RS485-USB adapters that will most likely go directly into the computer or through a powered USB port. The idea is similiar that we want to scan for the specific motor driver via ID or S/N and send command actions over.

0 Kudos
Message 4 of 10
(7,112 Views)
I should see the LabVIEW driver of these motor HWs, or at least a manual from the manufacturer to see the available serial commands. I could then make an example code which auto discovers all these devices, and reserves VISA references to the required IDs if there are any...
0 Kudos
Message 5 of 10
(7,108 Views)

Blokk,

Here is the link to the motor driver itself. It takes serial commands via VISA and has a LabVIEW example for doing this under the Downloads tab.

Driver:
http://www.linengineering.com/products/drivers-controllers/r356/

0 Kudos
Message 6 of 10
(7,104 Views)

You can search for the COM port if you have one different name as seen in device manager.

 

When user will aks for communication then you can search for all availble COM port and if you found the required COM port you can terminate the search and connect the port accordingly.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 10
(7,098 Views)

RS232 was in my mind, but your case is just easier: you have an RS485 interface which has more advanced features compared to simple RS232 interfaces. You can just use a single USB-RS485 connector between the PC and the multiple motor drives. The user manual ( http://www.linengineering.com/wp-content/uploads/downloads/R356/documentation/R356_Manual_V1.09.pdf ) explaines such case scenario at page 15.

Then, page 16 tells you how to assign an individual "address" to each of your motor drives (each of your drives should have different addresses!). Remember, this address is NOT the COM port which is the port where your interface connects to your PC. This address is the "ID" of a motor drive.

 

After this you have to wire all your units on a cable chain (follow instructions), and you can address your devices individually from LabVIEW...

 

Edit: about the COM port changes: just check for timeout error, and handle it, tell the user to chose another COM port from the available list. You can also automatize this search using timeout error and the "VISA Find Resource" function...

 

Edit2: So I hope you did not buy already multiple RS485 adapters, since you need only one (based on the manual, you can connect 16 motor drives to a single RS485 interface --> address range is from "0 to F").

 

EDIT3: The available commands can be found here: http://www.linengineering.com/wp-content/uploads/downloads/R356/documentation/Silverpak23C_R356_Comm... See the provided example VI how to send a string command to the units. This pdf command list explains how to address specific motor drive units when you have multiple ones, see from page 5. Everything looks very wel documented, it should not cause any difficulty...

Message 8 of 10
(7,097 Views)

That sounds like a viable options as we have looked into the daisy chain for the RS485 communication. I am relatively new to VISA and how exactly it functions other than knowing it can communicate serial commands over. Using the VISA Find Resource from what I understand you would locate one of the two COM ports and select one to send information and wait on a feedback? If there is no feedback feed the information into the other COM port and if there is a feedback you would assign this to a boolean or trigger to send it into a loop to send information out? If you have any examples if this or further documentation I would really appreciate it

0 Kudos
Message 9 of 10
(7,081 Views)

Well, I think you could get the valid list of avaliable COM ports on the PC first, and using this port array you could try to perform some Write + Read VISA operation to see if you get any valid response from a motor drive. Of course I cannot test the code since I do not have your HW, so you should figure out what kind of command string you should send and to which valid address (set on the motor drive), and what you can expect as response (refer to the documentation in pdf).

 

If you read through the command list manual, you can find more sophisticated ways to check for responses, error codes and how to parse these codes. But as a brute presence check, I think the simple Timeout error should work. Test it.

 

Something like this in my mind now (this png is a snippet, you can drag&drop into an empty block diagram):

 

Serial_example1.png

 

 

 

Message 10 of 10
(7,067 Views)