I am trying to find a way to hide some of the book-keeping associated with VISA references. Take a scope, for example. I would like to create a VI "Get Waveform From Scope". I want this VI to be smart enough to open the VI reference if it is not open and then to be overhead friendly and keep it open as long as necessary. Catch #1: I want this VI to be able to talk to more than one scope. Catch #1: Reentrant is out because I do not want it trying to talk to the same scope at the same time from two places.

I think I have a solution to this problem, but I do not know very much about how the VISA resource is handled (including during execution, when the top level VI finishes, and when the resource is used as part of a built app).

First I write a VI that will grab the waveform (or do any other operation on the scope) and expects an opened reference. Then I put two calls to a "reference manager", on before the grabbing vi and one after. So all of my questions are focused on this "reference manager", which accepts a reference and an error and returns one of each.

***

It uses a USR to store an array of VISA references. On "first call" it uses the instruments "Close.vi" on each element (if any) in the USR. I did this becuase it appeared that I still needed to clean up even after the top level VI completed previously. It then continues as if it could not find that reference in the USR. If this is not the first call it searches for the passed reference in the array in the USR.

If it does not find an open ref (or this is the first call and hence the array is now empty) it calls the instruments "Initialize.vi" on the ref passed, uses build array to add this ref to the USR and then returns that ref and any error from the Init call.

If it does find and open ref it returns that and the error passed in (assuming that is no error).

If there is an error passed in and it found a ref in the USR, it closes that ref deletes it from the USR, and passes it and the error though to the output.

****

This all seems to work well on our GPIB instruments, but I am having a very unidentifiable problem with it and one of our serial instruments (only serial instrument at the time). There are no error messages, but after one or two calls, the serial port appears to release and never reopen. The instrument is connected via an RS-232/ENET.

Can anyone shed light on this situation in particular or on the problem of managing VISA references in particular? Can someone point me to detailed information on exactly what labview is doing with the references and what things the Open and Close primitives are up to?

The main motivation here is that there is a lot of coding on the fly at the beginning of experiments here and many of the scientist are too lazy to take care and always open/close/pass around the references. They are stuck in the old days of the GPIB address string. (which was a very UNsatisfying arrangement IMHO) So I want to make them some very high level VIs like "Get Wavefrom", "Move Motor", "Get Spectrum", etc... but maintain similar efficiency as a VI that passes the reference all over the place. (In other words I don't want to repeatedly open and close the reference in these subVIs). I also want a solution that is relatively easy to apply to new functions... preferably using the wrapper calls I mentioned earlier.

Thanks



George Gatling
Applied Technology Division, SFA Inc.
Space Physics Simulation Chamber
US Naval Research Laboratory
202-404-5405 (phone)
202-767-3553 (fax)

If trees could scream, would we be so cavalier about cutting them down?
We might, if they screamed all the time, for no good reason. --Jack Handy





Reply via email to