Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW CPX400DP USB port detection

Hello, 

 

I'm trying to create a VI to auto detect the USB port were I have my PSU connected and control the PSU output.

 

There is no issue with the output control if I select the connected port manually. Nevertheless, if I use my VI to detect the port and forward it to the PSU control it does not work.

SnippetPSU.png

 

The VI detects the correct usb port but it's not forwarding the correct information to the next step of the VI. 

The issues is on the "Find the correct instrument handle Resource Name" part.

Can you guys help me find the issue? 

Thank you.

 

Best regards,

Luis P.

0 Kudos
Message 1 of 4
(1,424 Views)

DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

 

You are sending a command and instantly expecting a full response.  That does not happen.  It takes time for things to be sent, processed, and reply.  Instead of using the Bytes At Port, just tell the VISA Read to read more bytes than you ever expect in the response.  I tend to use 50 or 100.  The instrument's termination character will stop the read.

 

There is also no need for the Coerce To Type functions in there.  Just let the string auto coerce to the VISA Session.  And you definitely do not need to convert to a string just to instantly convert back to a VISA session.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(1,389 Views)

Hello Crossrulz,

 

Thank you for the reply.

I'm new programming on LabVIEW, so I'm expecting a lot of mistakes in this VI 😉

 

Regarding this suggestion "There is also no need for the Coerce To Type functions in there." 

This was a desperate attempt to have a correct format. Leaving it to auto coerce gives this error (please see the image):

lcspereira_0-1640011714381.png

Regarding this suggestion:

"Instead of using the Bytes At Port, just tell the VISA Read to read more bytes than you ever expect in the response"

 

I think that I didn't understood your suggestion correctly I'm now getting this error:

lcspereira_2-1640012167484.png

 

Can you point me in the right direction?

thank you.

0 Kudos
Message 3 of 4
(1,378 Views)

@lcspereira wrote:

Regarding this suggestion:

"Instead of using the Bytes At Port, just tell the VISA Read to read more bytes than you ever expect in the response"

 

I think that I didn't understood your suggestion correctly I'm now getting this error:

 

Can you point me in the right direction?

thank you.


You will get a timeout error if you are trying to talk to a port with nothing on the other side or an instrument that does not understand the *IDN? command.  I would just clear that error as we know that port will not be what we are looking for.

 

 

Now to your real issue:  You are using an IVI driver.  I'm not a fan of using IVI and do not use it.  VISA resources will not be the same as an IVI session.  I would have to do some digging to figure out how to initialize the IVI session.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(1,369 Views)