03-18-2015 09:43 AM
I am currently building an application on a cDAQ unit which involves the use of a scale. The scale uses RS232 communications, but is connected to an RS232-to-USB adaptor and plugged into one of the cDAQ's USB ports (COM 10). I am communicating with the scale using the basic VISA Functions: VISA Open > VISA Read > VISA Clear > VISA Close. I built one application using the scale that worked correctly, but now every time that I attempt to access the scale- be it through MAX, a VI, or a rebuilt version of the same application- I get the error "the resource is valid, but VISA cannot currently access it."
The scale has three options for data transmission: "No Data Output" "Continuous Data Output" and "Normal output when the Print Key is pressed." I have it set for "Continuous Data Output," I don't know if this information helps.
The c-DAQ is an NI cDAQ-9138
I have tried several things to get rid of this error:
-Restarting the cDAQ
-Repeatedly running "VISA Close" functions on the COM Port
-Completely unplugging and powering off the scale
-Plugging the scale into a different COM Port
-Repeatedly running "unlock port" VISA functions on the COM Port, as a colleague suggested that may be the problem
None of these have worked.
Does anybody have any suggestions for reliably getting rid of this error?
I have attached a vi showing how I am attempting to read from the device. Any help would be appreciated.
Solved! Go to Solution.
03-18-2015 10:36 AM - edited 03-18-2015 10:40 AM
"MB Serial init" subVI is missing, so I cannot look inside what is going on. Can you attach this subVI?
Remove the sequence structure, it will not help with your recent problem, but you do not need it. Use the error wire to specify execution order.
edit: you wrote a comment in the block diagram that you get the error at the second "MB Serial init" subVI call. Are you sure the first does not generate one already? Connect the error wires properly. The situation is not clear to me...
03-18-2015 12:40 PM
"MB Serial Init.vi" is a VI in the Modbus library that is downloadable in multiple places on ni.com. I have attached the digital library containing the vi as well as an image of the vi's block diagram to this response.
Yes, the first instance of the "MB Serial Init.vi" also outputs the "resource is valid but VISA cannot currently access it" error. Sorry for the confusion.
03-18-2015 07:04 PM
Do you have a program open elsewhere that is also trying to access the serial port? Are you still running something in MAX while simultaneously trying to use it in LabVIEW?
Also, it doesn't seem like your device is communicating in Modbus, so why are you using Modbus Serial Init? You should be using the Serial Configure VI.
03-19-2015 10:04 AM
All other programs are closed when I attempt to access the scale with the VI that I am programming. I close MAX completely and I close any other programs that were running; the only program running when I attempt to access the scale is the vi that I'm programming.
I replaced the Modbus Serial Init.vi with the VISA Serial Init.vi, but it also experiences the same error.
03-19-2015 10:46 AM
Something, somewhere must have that port open. Is it possible that any other software you might have used starts up a service and is keeping the port open. Or there used a .dll that could have opened the port and failed to close it when the software shutdown?
Have you tried shutting down everything including the PC, then tried?
03-19-2015 10:54 AM
03-24-2015 12:50 PM
A colleague from the company's electrical engineering department has resolved the issue. The scale has a hardware flaw that will cause it to continuously attempt to communicate with a VISA session even if the session has long since closed on the computer. Essentially, the VISA session on the scale doesn't end, even if it ends on the computer. He said it's an error that he hasn't seen in 3-4 years.
The way to fix the error is to unplug everything from the scale and leave it unplugged for at least 30 seconds to make sure that all of its hardware powers down completely. When you plug the scale back in, it will be responsive to a new VISA session. I have tried it and the scale is working through VISA again.
03-24-2015 01:15 PM
Technically, there is no such thing as a VISA session on the scale. The VISA drivers are only something that exist on the PC side of things.
I don't understand why closing and opening a VISA resource on the PC would affect how the scale behaves. The scale wouldn't know whether the PC has done anything with opening or closing the port within software.
But there could be a hardware error on that scale that is a pretty bad bug considering serial port technology has been around for decades. Perhaps the scale detects a change in one of the handshaking lines and the UART locks up.
03-24-2015 01:41 PM