LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Loses Connection at Random Times

I have a problem that occurs at random intervals while running my vi (see attached). This is a section of my vi that requests data from sensors connected to my MSP430 microcontroller and then based on the data received, sends commands to turn on and off systems to the same resource. The vi is able to read and write to the MSP430 for a while and it will randomly fail at intervals anywhere from 1 to 14 hours. I have had NI IO Trace running to see when the error occurs and it seems to happen after one of the cases finishes the visa close function and the next case is unable to execute visa open. I think somehow the resource is not properly closed. Is there a way to ensure it does? Also the reason I open and close the cases is due to the fact that power surges happen that turn off the microcontroller and I want to make sure if one case fails, the next will still be able to reconnect when the microcontroller restarts. The resource is a virtual com port on a usb cable.

0 Kudos
Message 1 of 6
(3,449 Views)

There's no need to close and reopen the serial port every time.  The serial port has no way to know - and doesn't care - if there's a device connected on the other end, so even if your microprocessor gets reset it won't affect the serial port.  If the USB<->serial adapter also resets, then you might need to reopen the port, but even then I would recommend that you leave the port open, store the VISA reference in a shift register, and only close and reopen the port if you get an error from one of the VISA functions that indicates that the port is not available.

0 Kudos
Message 2 of 6
(3,446 Views)

Thanks, I'm new to working with VISA. I'll give your suggestion a shot but I'm unsure how to set up the error handling to tell if the visa port is unavailable.

0 Kudos
Message 3 of 6
(3,437 Views)

@zepoljd07 wrote:

Thanks, I'm new to working with VISA. I'll give your suggestion a shot but I'm unsure how to set up the error handling to tell if the visa port is unavailable.


The better solution is to prevent the error with proper set-up.

 

Some while back I wrote a guide to USB problems (They are a lot more common than they should be).

 

Items 1-4 from here are places to start.

 

 


"Should be" isn't "Is" -Jay
Message 4 of 6
(3,434 Views)

@zepoljd07 wrote:

I'll give your suggestion a shot but I'm unsure how to set up the error handling to tell if the visa port is unavailable.


Do you know that you get some sort of serial error when the microprocessor reboots?  Don't try to solve a problem that may not exist.  I'd start simple - open the serial port once when the program starts - and see if that works reliably.  If it doesn't, then start dealing with the errors once you've identified which specific ones occur.

0 Kudos
Message 5 of 6
(3,410 Views)

@nathand wrote:

Do you know that you get some sort of serial error when the microprocessor reboots?  Don't try to solve a problem that may not exist.  I'd start simple - open the serial port once when the program starts - and see if that works reliably.  If it doesn't, then start dealing with the errors once you've identified which specific ones occur.


I set the vi to where it only opens the resource once. After about six hours, the communication was lost. After the error occured I stopped the vi and got the error message "Error 107380743 Insufficient Location Infromation or the Device or Resource is Not Present in This System."The only way to get everything running again was to stop and completely close out of LabVIEW, unplug the usb, plug it back in, open up LabVIEW, and then run the vi.

 


@Jeff Boher wrote:

The better solution is to prevent the error with proper set-up.

 

Some while back I wrote a guide to USB problems (They are a lot more common than they should be).

 

Items 1-4 from here are places to start.


I have implemented items 2-4 so far.

0 Kudos
Message 6 of 6
(3,394 Views)