LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time out for While Loop

Hi,

 

is there any option to stop a while loop (or force it to start the next iteration) if the the execution time of the VIs in the loop exceeds a certain value?

 

The methods I know to stop a loop after a certain time only work if the loop continuously starts new iterations (since the condtions are only checked at the start of an iteration) but don't work if the program gets stuck in one iteration.

0 Kudos
Message 1 of 11
(4,327 Views)

First of all you need a tool to interrupt the work of the subVI.
After this, you can do a runtime check.
What kind of function are you calling?

0 Kudos
Message 2 of 11
(4,318 Views)

The program is doing some doing some test and calibrations of a device, so it is mostly sending and receiving date to and from the device. It is quite complex and was written by someone else who is not available anymore. So I have only a very rough idea where the problem is.

 

Therefore I'm looking for a quick and dirty solution, since everything else would be to time consuming.

0 Kudos
Message 3 of 11
(4,307 Views)

I'm afraid brute force will not help here. Interrupting the operation with the equipment can lead to malfunctions, so the next iteration of the loop will end with an error and will have to restart the system.
You need to add timeouts into the function of working with the equipment

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

Thats not really a problem, since if this problem occurs the device has anyway failed the test.

0 Kudos
Message 5 of 11
(4,297 Views)

Since there is no code to look at I am guessing that if your UUT fails then it will stop communicating (or no comms is a fail)?

 

Are you setting a timeout for your VISA Reads? You can adjust this timeout with the VISA Serial Setup or a VISA property node.

 

Connect the error cluster to the loop's stop terminal (OR it if necessary) and the loop should now stop if there is a serial communication timeout.

 

Does that help?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 11
(4,288 Views)

BTW: There is no way to stop and abort a While Loop in the middle of its execution. All of the code in the loop must execute before the loop can complete an iteration. So if one VISA Read deep in your loop hangs up because the UUT is not responding. Your program is going to just sit there until the VISA timeout expires. 

 

LabVIEW is based on the dataflow paradigm, turn on the trace (the light bulb) on your block diagram and watch your program run, you will see what I mean.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 11
(4,279 Views)

There seems to be a timeout set for the Visa communication.

 

Connecting an error cluster doesn't really work, since the error would only stop the loop in the next iteration.

 

The general Problem for me is that for the test our technicians usually use a version of the vi that is compiled to be used as a stand alone executable, which make it hard find out what really happens when the problem occurs.

 

 

0 Kudos
Message 8 of 11
(4,252 Views)

Not thinking much, the very first idea strikes is "How about replacing For Loop with While loop (Decide your loop stop based on your requirement)"

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 9 of 11
(4,250 Views)

@GMAch wrote:

There seems to be a timeout set for the Visa communication.

 

Connecting an error cluster doesn't really work, since the error would only stop the loop in the next iteration.

 

The general Problem for me is that for the test our technicians usually use a version of the vi that is compiled to be used as a stand alone executable, which make it hard find out what really happens when the problem occurs.

 

 


Without seeing your code I can only make uneducated guesses from here on out....

 

But It sounds like you need to completely rewrite that section of code, maybe a simple state machine inside the while loop would work better as that allows you to jump around between states as needed.

 

  • Send command
  • Wait for response or timeout
    • IF response is good
      • Goto Next Test
      • Else Goto Error State
  • Error State 
    1. Display error message
    2. Abort or Retest?
  • Next Test
  • Etc...
  • Etc...
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 11
(4,236 Views)