LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Restart" visa

Solved!
Go to solution

Hi,

I have written a VI resp. an EXE for controlling of PowerSupply PL303-P. It is connected to the host by means of the USB acting like a serial interface, for this reason I use VISA for read and write operations. I work with LabView 2010 professional development system, Windows 7.

Normally the VI works as following:

- the device is switched on, then the VI is started

- the VI finds the device and controls it

- the user switches the device off, the VI brings an error and stopps. It shall be closed.

- to "reconnect" the device, the user has to switch on the device , restart the VI and continue the work after the VI has located the device,

The user ask me if it is possible to switch off-on device while the VI is still running and to reconnect the device without stopping the VI.

I tried to simulate this situation by means of VISA terminal of MAX. Even there I have to close the terminal (current VISA session) and open a new one.

Is it possible to close a VISA session programmably (e.g. if break occurred) and restart a new one ?

Does anybody try to do such a thing, or is it not possible in principle?

Best regartds and many thanks in advance

0 Kudos
Message 1 of 8
(9,564 Views)

Yes it is. Call VISA Close when you detect an error and attempt to reopen the connection using VISA Open. You will want to monitor the state of teh open to retry to connect to the device after some period of time if the open fails.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 8
(9,555 Views)

Thank you, I'll try it just now.

0 Kudos
Message 3 of 8
(9,553 Views)

Hi, Mark,

the "raw" solution looks like that:

1) when the device is properly found and works (green case "No error") I open VISA before every WRITE operation and close it after READ operation

2) when the device is off, (red case "Error occurred") , I delete the error and try to open Visa and send "*IDN?".

During this phase it is necessary to disconnect the USB cable, make "refresh" (so that VI "forgets" it), connect and make "refresh" again.

 

 

Even if it doen't look quite perfect it is a way to go :-). I'll try to make it better. Thank you for your help

0 Kudos
Message 4 of 8
(9,542 Views)

It would be helpful to see your code. You shouldn't need to open and close the connection every time you Write/Read from the device. If you place your communication in a state machine you should be able to open only when necessary. Again, seing the code would be helpful.

 

Depending on the device itself some devices do not handle resets well and teh OS itself does not detect that the device is connected. If this is the issue you are encountering you may be forced to either power cycle the device or unplug it. However, your code should be able to be written so that it can continue running and detect the change in device state.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 8
(9,535 Views)

It is very simple and will be used for creation of a SubVi for a larger one, here it is! I removed Open/Close by normal reading, it went well on a remote machine. Supprisingly its behaviour on a local machine differs from that of the remote one. It is not easy to detect it on the local machine, though it works well remotely. The local machine runs Windows7, remote - Windows Server 2008. I suppose, that VISA may be different: on the remote machibe I have MAX 4.7, locally - 5.3.

0 Kudos
Message 6 of 8
(9,522 Views)
Solution
Accepted by pericles

First, you should take a look at the LabVIEW Style Guide.To be blunt your code is a mess. Wires going every which way, bends all over the place, stuff sitting on top of other items and local variables used quite a bit. These are just to name a few items that can be cleaned up. Secondly, why do you have two inputs for the resource name? Are you actually using two different devices? This code sn't a state machine like I had suggested. Also, are you using serial communications? You had mentioned USB earlier. If you are using only USB there is no reason to call the serial init.

 

Here is something more in line with what I was talking about.

 

Simple Connection Handler.png

 

You may also want to look at the JKI state machine for a more robust state machine framewaork.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 8
(9,506 Views)

Thank you for corrections, I'll try to implement that.

0 Kudos
Message 8 of 8
(9,490 Views)