03-28-2018 06:22 AM
I have a VI (LV-2017) recording the output of four identical instruments permanently that are all connected via their own USB port (virtual com port). Despite weeks of searching, one of the instruments will stop recording (seemingly randomly) and I cannot work out why, as far as I can see all of the settings are the same for all four. Either way, the only way to get it to work again is to completely exit labview, physically disconnect and reconnect the instrument and reload the VI.
Is there a way to get these instruments to reconnect while keeping the program running so I can turn one off > on (if I need to) and have it automatically re-detect? Or perhaps someone can shed some light on why such an instrument would randomly DC?
They are just connected via a standard visa resource dropdown in the VI.
Thanks in advance.
03-28-2018 09:36 AM
03-28-2018 01:24 PM
Thanks for your reply. Unfortunately, yes that was the first thing I tried.
03-28-2018 04:00 PM
Are you sure you disabled USB active suspend? See here for description - https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/viReadSTB-hanging-with-Keithley-2110-over-US...
Other things to try..
Is the issue connected to a specific USB port?
Is it related to a specific cable?
If you plug different instruments into different USB ports on the same PC does the issue change instruments?
03-29-2018 03:57 PM
Are you able to connect/do something/disconnect every time you communicate instead of connecting on start application, use the port, disconnect on application exit?
This slows things down a little but is typically more robust.
03-30-2018 05:59 AM
Thanks all. Reconnecting every reading sounds like the best plan, it's only reading every 30 secs so I don't think it will make much difference. Any chance you could point me towards an example of a VI that does this so I can see how it's done?
I'm off until Wednesday so I'll try these suggestions then and let you know how I get on.
03-30-2018 12:47 PM
Are you using VISA? If so, do a VISA open, execute your write and or read, do a VISA close. Put it into a sub VI that all communication to the port goes through.
04-04-2018 04:05 AM
Ok, so I've tried your suggestions:
1. It's always the same machine regardless of cable or USB port.
2. USB active suspend is disabled.
3. I'm a beginner to labview so I'm sure my block diagram would make most of you wretch. Was the suggestion that I wrap my current VI up as a sub-VI and then get it to execute as part of another VI that opens the VISA resource and then closes it on a loop?
I've attached the VI for anyone interested.
Thanks again for your suggestions.
04-04-2018 12:28 PM
Yeah, that code is wretch worthy. But not nearly the worst I've seen. 🙂
A few comments...
1) You are never properly initializing communications with the instruments. There is an "Initialize.vi" you should call before doing anything else.
2) Why are you putting readings in a loop in a case structure? The "Output Data (Single Reading).vi" returns both current and voltage in one call...so why not read once and separate those two values into the appropriate arrays. You are hammering the instrument bus with successive unnecessary calls.
3) You have no error handling. So if a reading fails you don't have any way recover from that...or find out what went wrong.
4) I have no idea what the loop with the path/filename creation is doing in a For loop! Why run through the loop more often when you have more data? Some sort of added delay step? I think you really just want dataflow to take care of that. But why not just append data to a file you open right at the start of measurements?
Here's how I would approach this. There are many other ways of course. You'll notice I wrote a subvi to initialize+read I&V+close and also get measurement time. The other subvi formats the data and writes to file. The second can be further modified to get the data format you prefer. I didn't implement your scrolling, I left that to the graph itself.
Give it a try.
04-04-2018 02:18 PM
Thanks so much. I'll spend tomorrow trying to implement your suggestions. The reason the file naming was inside the loop is so it would append to file if the file exists and create a new file when the date changes and begin to append to that. This way I have a log file for each day instead of a massive CSV that needs to be mined for a particular day.
This is what happens when you try to learn to think in code +35 years old after being a bench chemist.