LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop through COM ports

Solved!
Go to solution

Hey guys,

 

I am trying to loop through my available COM ports to see which serial port my device is connected to. When I run my VI, it stays at COM1 and never goes to the next COM port. Am I at least on the right track?

 

Any help is appreciated.

 

Eric

0 Kudos
Message 1 of 11
(4,332 Views)

You do not have any code that changes the port you set with the front control.

The shift reg does not automatically change to the next comport

 

Use the VISA Find resource and a FOR LOOP to go through the Array of com ports that it find.

 

Use the conditional terminal of the FOR LOOP to stop the for loop when your device is found.

 

Omar

Omar
0 Kudos
Message 2 of 11
(4,326 Views)

You are passing in a single Com port VISA reference through a shift register and never changing it.

 

Try passing in an array of VISA references set for each possible comport and use autoindexing to try each one in turn.  You could also programmatically build the reference as a string "Com1","Com2", etc.

 

Don't forget to close your VISA reference after each attempt so that LabVIEW doesn't open a valid com port that doesn't have your device and then leaves it open because it never bothered to close it.

0 Kudos
Message 3 of 11
(4,324 Views)

OK, I've gotten the VISA Find Resource and created a indicator off of the 'find list' wire. I'm lost from here.

 

I've only used LabVIEW a handful of times and not used to this interface quite yet. Smiley Sad

0 Kudos
Message 4 of 11
(4,313 Views)
Solution
Accepted by topic author BadAzzS10

Just auto-index a for-loop:

 

EDIT: Saw the requirement to stop once you got a connection. In that case, just use the conditional terminal.

 

0 Kudos
Message 5 of 11
(4,308 Views)

I would check for a correct reply from your insturment instead of a error on the Visa Read if there are other devices on other com port.

The other devices that you are not looking for might still reply to your "P" if only to reply with an "Invalid command reply".

Omar
0 Kudos
Message 6 of 11
(4,293 Views)

One more question...

 

In your For Loop, how did you get the small red corrision(sp) dot to appear? I've tried to duplicate it but I can't seem to figure this out.

 

Thanks.

0 Kudos
Message 7 of 11
(4,232 Views)

I still have the little red dot going into the VISA Open on my code

 

But you type case the string to VISA ref to get red of the red dot if you like.

I would not worry about it. 

Omar
0 Kudos
Message 8 of 11
(4,229 Views)

Having a similar problem. when I use the Code provided I get active comport but not their "windows description"

 

IE..

I run the code I can see

Com 1

Com 3

ect..

or I can change to ASRL and see

ASRL1::INSTR  

ASRL3::INSTR

 

but when I look in "Ports and coms" (Device manager) I see a description like

USB-SERIAL CH340 (COM1) 

 

this is the info I need to find the instrument I'm looking for.. any idea how to get labview to display that list?

Thanks

 

 

0 Kudos
Message 9 of 11
(3,580 Views)

Drop a VISA Property Node on the block diagram and select the property Interface Information -> Interface Description.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 10 of 11
(3,571 Views)