Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual com port (usb) reconnect

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.

LV-2017
0 Kudos
Message 1 of 11
(4,879 Views)

Did you switch off in Windows that usb devices can be switched off for power savings?

Windows is completely idiot in this. You have to be sure in advanced power settings that the power always stays on.

greetings from the Netherlands
0 Kudos
Message 2 of 11
(4,864 Views)

Thanks for your reply. Unfortunately, yes that was the first thing I tried.

LV-2017
0 Kudos
Message 3 of 11
(4,853 Views)

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? 

 

 

 

0 Kudos
Message 4 of 11
(4,842 Views)

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.

CLA
0 Kudos
Message 5 of 11
(4,812 Views)

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.

LV-2017
0 Kudos
Message 6 of 11
(4,804 Views)

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.

CLA
0 Kudos
Message 7 of 11
(4,796 Views)

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.

LV-2017
0 Kudos
Message 8 of 11
(4,759 Views)

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.

lakeshore648psu_monitor.png

 

 

 

0 Kudos
Message 9 of 11
(4,749 Views)

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.

LV-2017
0 Kudos
Message 10 of 11
(4,743 Views)