Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto shut off when serial cable is unplugged and detection of number of serial cables plugged in.

I have a program running two indpendent visa sessions. At the end of the day a technician comes by and unplugs the serial cables from the device they are attached to. This is sadly unavoidable. which means that my VI hangs and waits for the timeout then loops, recording bunk data in the process. How can I avoid this from occurring? I would like the program to safe itself if one or both the serial cables are unplugged. Is it enough to put an event loop in teh while loop with the conditoin that if timeout is reached X number of times (for redundancy so that it does not accidentally shut off mid session on its own for another error) then True is sent to the stop button? How would this effectively close my visa session if the cable is forcibly unplugged?

 

As for part two of my question, if I have two devices connected under normal operations, but for some reason only want to connect one, or only one is unplugged during a session, how can i skip over the one that is unplugged automatically? is there a way to dynamically "comment" out a portion of the code if it detects that there is no actual device connected to that particular com port?

0 Kudos
Message 1 of 2
(3,367 Views)

the 'comment out' functionality is commonly called case structure 😉

 

for each of you two ports you can create a state MC that outputs the data and handle its own init,read,timeout, retry, retry later, ignore, close,...

 

if one or both ports send an ignore status you can close you program,   in case of an timeout activate the sound output with a sample of your choice 😆 😄

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 2
(3,362 Views)