LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

com port detection

Hi everybody,

        

                   I am trying to detect the externally connected comport to the pc,automatically.

I am unable to detect the correct port. Some port which is not required is being shown.

Can anyone of u all suggest me something.

0 Kudos
Message 1 of 9
(4,501 Views)

How are you trying to detect it? With the VISA Find Resource? After finding all of the ports, what do you do to detect a specific instrument is connected to one of them?

 

Attach your code.

0 Kudos
Message 2 of 9
(4,495 Views)

Hello,

        First of all thank you for the reply. I have developed a small vi through which we can detect on which port the data has been written,may be the application may be wrong but here the problem is it is detecting the wrong port.

0 Kudos
Message 3 of 9
(4,453 Views)

hi,

   Here i am attching my code to detect the port automatically once it is connected. Suggest me if there are any mistakes.

0 Kudos
Message 4 of 9
(4,451 Views)

Several things.

  1. You are relying on VISA aliases, so this assumes you've created the aliases in MAX. If you did not do so then the VI won't work.
  2. I don't see any serial port configuration.
  3. You are assuming that some other serial port instrument isn't going to respond back with an error message when you send it whatever string you are sending. If this other instrument happens to be connected to a low COM port number and it returns an error message your VI will think that's the right one because you're only looking to see if the VISA functions are generating an error code. You need to also verify the returned characters.

 

0 Kudos
Message 5 of 9
(4,434 Views)

Also, you will want to add a small delay in the while loop.  You can put the delay between the write and read VI functions.  This will give the com port time to receive the data, plus add a needed wait to the while loop. 

Your first Visa resource name is Com 0.  So it is checking COM 0-9.  Is this what you want?

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 9
(4,427 Views)

hi everybody,

 

 

                   Thanks for the reply. Actually what i am trying to do is,the vi which i sent before,i am using it only to detect the port number to which the port is connected externally. And ofcourse i used the delay inbetween the read and write,but i still dont find any difference in the outcome. Secondly after the port has been correctly configured then the output of this is being connected to the serial port read and write resource name(which is there in the example finder).

                   So finally i am trying to figure out to detect the port number correctly by sending 3 bytes of data and trying to match to which port it is been written to.

0 Kudos
Message 7 of 9
(4,402 Views)

@dtwtwetw wrote:

[...]...

                    So finally i am trying to figure out to detect the port number correctly by sending 3 bytes of data and trying to match to which port it is been written to.


Once your program has found existing com ports, try sending 3 bytes to each one consecutively, then Visa Read exactly 3 bytes, but use a very short timeout. The port that does not timeout is the winner.

 

BTW, here's a VI example that'll find the ports using ASRL names - been working fine for me these last 6 years or so.


 

Richard






Message 8 of 9
(4,400 Views)

Your example seems to do pretty much what I want to do 🙂

0 Kudos
Message 9 of 9
(3,846 Views)