08-07-2008 03:29 AM
08-07-2008 03:48 AM
Hi B.B.S,
Firstly thanks for a very well written question!
I am just having a look at your problem and trying to find out exactly what the VISA close is doing that might explain this behaviour.
In the mean time with regards to general architecture I wondered whether you could avoid the problem by only closing the connections at the end of the running of the program, do you need to close and then re-open the session in the program? or could you just use a shift register and state machine architecture to re-use the current session.
In the mean time I will try and find out why you should need to do this anyway.
Regards,
08-07-2008 04:39 AM
Hi B.B.S,
I have been trying to recreate your problem with some success. What seems to be happening is by closing the connection VISA is telling Windows to close the connection to the USB device, akin to using safely remove device for a USB drive. So when the second scan is done for USB devices as far as Windows is concerned the device is no longer plugged in.
The best solution is to keep the session open, it should be possible to architect the program in such a way that you can keep the session open for the duration of the program. Generally I would say a good place to start would be to look at a state machine architecture (you can find this as one of the templates in LabVIEW) and you can use a shift register on the while loop to pass the session ID to the next state. This is how the examples have been produced that you can find in the LabVIEW example finder at hardware input and output>>VISA>> USB RAW- xxxxxxx.vi
Hope this helps.
08-07-2008 07:14 AM
08-07-2008 07:17 AM
Not sure why the posting suddenly was sent... 🙂
to summary. it should be operated by a lot of people that will probably start and stop the application. they will change the 15 units three times per day.
I must have 100% control over the USB connections.
And i am not quite there yet .-(
Thanks for the support so far.
BR Bjarne
08-07-2008 08:10 AM - edited 08-07-2008 08:10 AM
Hi Again,
I have tried to recreate the issue when using multiple runs of the same program but this time I have been unable to. Mine does manage to find the device again.
I have had a word with a few people and they have proposed a solution that would involve writing the references to the registry or a configuration file. They suggest:
First Run: The program will look to the registery/file to try and find the references. It wont find any so it will open the VISA references and write them to the registry. This should not close the references at the end of execution.
Run n : The program will look to the registry/file and find the references and use these for VISA operations.
First Run after Reboot: The program will look to the registry/file and find the references but will find that they are invalid so it will open new references and write these to registry for subsequent runs.
Functions for writing to the registry are under connectivity>>windows registry access VIs and have all the usual LabVIEW help files associated with them.
I hope this helps! let me know how it goes.
08-08-2008 04:41 AM