LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA (Serial port) commands fail in the VI, but work in VISA test panel

Solved!
Go to solution

Hi, I have an instrument which has a usb connection. When I connect it to a Windows 7 PC, it automatically picks up the driver and shows up as a "USB Serial Port (COM7) (Manufacturer is FTDI). 

 

When I open up NI MAX, this device shows up as COM7 (ASRL7::INSTR) under "Serial and Parallel". And, when I click on Open VISA Test Panel, and try the "*IDN?" command, it works OK.

 

However, the VI (which just sends a VISA command "*IDN?") gives me a time out error (0XBFF0015) or a device/resource not present error ( 0XBFFF0011). Attached is a screenshot of the VI. 

 

Any ideas why?

 

Thanks. 

PS: I went through the process to create the VISA-USB driver, but that has some other issue, but I am trying to understand why this occurs. This device also has a GPIB port and when I use a USB-GPIB adapter, it works very well. 

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

@SysB1 wrote:

Hi, I have an instrument which has a usb connection. When I connect it to a Windows 7 PC, it automatically picks up the driver and shows up as a "USB Serial Port (COM7) (Manufacturer is FTDI). 

 

When I open up NI MAX, this device shows up as COM7 (ASRL7::INSTR) under "Serial and Parallel". And, when I click on Open VISA Test Panel, and try the "*IDN?" command, it works OK.

 

However, the VI (which just sends a VISA command "*IDN?") gives me a time out error (0XBFF0015) or a device/resource not present error ( 0XBFFF0011). Attached is a screenshot of the VI. 

 

Any ideas why?

 

Thanks. 

PS: I went through the process to create the VISA-USB driver, but that has some other issue, but I am trying to understand why this occurs. This device also has a GPIB port and when I use a USB-GPIB adapter, it works very well. 


Look up the examples that ship with LabVIEW.  What you have there isn't quite complete - for serial VISA.  While GPIB will work great with what you have, serial VISA requires you to configure your serial port and is a little more complicated to read.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 10
(7,299 Views)

I'm with Billko.  It is very likely you need to configure your serial port in the LabVIEW program.  There is a Configure Serial Port in the VISA palette.


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 3 of 10
(7,285 Views)

Do you need to send a termination character after the *IDN?  ?

0 Kudos
Message 4 of 10
(7,278 Views)

Thanks, I missed the configuration block, however, even when I add that, I am getting a timeout while reading back. I am using this example http://zone.ni.com/devzone/cda/epd/p/id/2669 . The settings seem to be fine. Attached are the JPEGs showing my settings. I tried MATLAB and it worked fine, so it is not the communication, but something that I am doing in the VI.

 

Thanks.

Download All
0 Kudos
Message 5 of 10
(7,254 Views)

That looks like a lousy example.  It doesn't match the Basic Serial Write and Read example you find using the example finder in LabVIEW.

 

The string to write is just *IDN?   not *IDN?\n like the real LabVIEW example has.  So that goes back to my question, "Do you need to send a termination character?"  With your VI, it looks like you did not.

 

I suggest adding \n (while the string control is in \codes display) to the string to write and try again.

Message 6 of 10
(7,244 Views)

@RavensFan wrote:

That looks like a lousy example.  It doesn't match the Basic Serial Write and Read example you find using the example finder in LabVIEW.

 

The string to write is just *IDN?   not *IDN?\n like the real LabVIEW example has.  So that goes back to my question, "Do you need to send a termination character?"  With your VI, it looks like you did not.

 

I suggest adding \n (while the string control is in \codes display) to the string to write and try again.


Whew, then it's not just me that thought it was a terrible example?  The serial read part of it was almost dysfunctional to me.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 10
(7,238 Views)

@RavensFan wrote:

 

The string to write is just *IDN?   not *IDN?\n not.

 

I suggest adding \n (while the string control is in \codes display) to the string to write and try again.


Thanks for your time and the response. Was the above a typo (it is confusing). Regardless I am using the "\n".

 

Question:

1. I looked at the example fromthe Labview installation and that's all I need. However, I am wondering why it wasn't working in the first place. Attached is a VI which has two serial reads. The first one doesn't work and the 2nd one works. Both look exactly the same. 

 

Thanks.

 

0 Kudos
Message 8 of 10
(7,224 Views)
Solution
Accepted by topic author SysB1

No.  Your first string to write is sending a literal backslash and a literal n.  Your control shows \n, but it is in Normal display mode.  Change it to \codes mode and delete the extra backslash there.

 

Your second string to write is properly set for \codes mode.

 

Since the wrong string is being written, the timeout error occurs, and that prevents the downstream VI's on that same error wire from running.

Message 9 of 10
(7,220 Views)

Thanks. That was it. Thanks so much for your time. 

0 Kudos
Message 10 of 10
(7,211 Views)