LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Loop stops respoding

Solved!
Go to solution

Hello guys, me again

 

This time i have a weird bug with timed loops.

 

The vi (attached, unfortunately i can not post the whole application) worked fine. I then changed something in event loop and the timed loop stopped working. I reverted the change to event loop, but the timed loop is still broken.

 

What i tried to far:

- changed timed loop to while loop and back (found a guy with similar problem, where this helped because it renamed timed loop)

- replaced timed loop completely with while loop and a wait until next ms multiple set to 1 second

- manually named the timed loop

- wired error indicator to input and output of timed loop (both remained blank, even after the loop froze)

- restarted Labview, my computer and the computer on which this application is supposed to run

 

What is the weirdest to me is that it seems to work fine until i click any button that interacts with "Idle" statement, so if i press Auto Optimize Protocol the loop freezes (i can tell this because the Current Temp indicator stops updating).

As said, it all worked fine until i changed event loop and now it's just broken.

 

Help!

0 Kudos
Message 1 of 16
(2,539 Views)

Hi AeroSoul,

 


@AeroSoul wrote:

This time i have a weird bug with timed loops.

 

The vi (attached, unfortunately i can not post the whole application) worked fine. I then changed something in event loop and the timed loop stopped working.

 

What is the weirdest to me is that it seems to work fine until i click any button that interacts with "Idle" statement, so if i press Auto Optimize Protocol the loop freezes (i can tell this because the Current Temp indicator stops updating).


  1. That VI block diagram is way too large!
  2. You should not have an event case last for more than a couple milliseconds!

I guess the problem is not the timed loop, but the event structure blocking code execution…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(2,492 Views)
Solution
Accepted by topic author AeroSoul

If there is no FracID=8, your inner while loop will never complete, stalling the code forever. Hard to tell if that can occur.

 

(I think you have 80% too much code. for example why aren't the property nodes (right after that mentioned while loop) after the case structure? 9x fewer nodes here!!!)

Message 3 of 16
(2,488 Views)

But it was this large before and it worked fine. Also event structure still works fine, but the timed loop fails, even if i wait for the event to end. Or if i don't even trigger an event when entering the VI.

0 Kudos
Message 4 of 16
(2,483 Views)

Once it stalls, switch to execution highlighting to see where it is stuck.

 


@AeroSoul wrote:

But it was this large before and it worked fine. 


The existence of a value=8 depends on data, not on the code. Did the data change? What is the size of the "protocol details" cluster array?

Message 5 of 16
(2,476 Views)

@altenbach wrote:

If there is no FracID=8, your inner while loop will never complete, stalling the code forever. Hard to tell if that can occur.

 

(I think you have 80% too much code. for example why aren't the property nodes (right after that mentioned while loop) after the case structure? 9x fewer nodes here!!!)


As an example, you have two case structures as shown. One with 9 cases and 72 local variables and one with 9 cases and 81 "visible" properties, all to simply display progress for a variable number of stages.

 

altenbach_0-1611950796212.png

 

 

All you really need is an array of booleans to show the value and a transparent array container where you can set the number of displayed elements according to the number of stages. (Another option would be to use a numeric progress bar indicator)

 

See attached for a quick proof of concept. 2% of the code!

0 Kudos
Message 6 of 16
(2,457 Views)

@AeroSoul wrote:

But it was this large before and it worked fine. Also event structure still works fine, but the timed loop fails, even if i wait for the event to end. Or if i don't even trigger an event when entering the VI.


You got lucky. Whyis there so much cod einside your timed loops. Lots of that code is not determinisric and I suspect your are not getting the timing you think you may be getting. For example, writing to a DB inside a while loop. All of the UI interaction via property nodes. This swithces your code to the UI thread. Updating the graph inside the timed loop. This code should be refactored so that only th etime critical items are inside the timed loops and the non-deterministic stuff (DB interactions) and UI updates occur in separate tasks.

 

Also, as already stated, if you need a 100" monitor to display your block diagram fully, it is too big.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 16
(2,449 Views)

If i understand correctly, you are suggesting i remove database interactions from timed loop and event case and put them in a separate while(?) loop. The updating of graph inside timed loop was mostly done because the temperature is already taken out of the AE and i didn't want to do multiple reads. 

 

The thing is that what this code does is highly time sensitive, so i thought best to keep it timed properly with timed loop, rather than while loops.

 

To answer some other questions:

- the ProtocolDetails cluster usually contains up to 12 "fractions" and each fraction has 14 values, basically it's a cluster of up to 12x14

- fraction number 8 is always part of the protocol, it signifies END fraction.

0 Kudos
Message 8 of 16
(2,436 Views)

As has been said, if the code is time sensitive, don't burden it with heavy lifting. Once you hook a camper trailer to your Formula 1 race car, it is no longer competitive. 🙂

Message 9 of 16
(2,429 Views)

@AeroSoul wrote:

If i understand correctly, you are suggesting i remove database interactions from timed loop and event case and put them in a separate while(?) loop. The updating of graph inside timed loop was mostly done because the temperature is already taken out of the AE and i didn't want to do multiple reads. 

 

The thing is that what this code does is highly time sensitive, so i thought best to keep it timed properly with timed loop, rather than while loops.

 

To answer some other questions:

- the ProtocolDetails cluster usually contains up to 12 "fractions" and each fraction has 14 values, basically it's a cluster of up to 12x14

- fraction number 8 is always part of the protocol, it signifies END fraction.


Writing to a DB, updating the UI, writing data to files are all non-deterministic actions that should NOT be done inside time critical/sensative loops, whether a timed or a for/while loop. All of the actions mentioned may take longer than expected due to the OS, file system, DB or network communications (if applicatable in the case of a DB) and therefore impact your time sensative actions. These operations should be handled in separate parallel tasks. Look at examples of a producer/consumer framework. You have so much stuff jammed into your main processing it would be very easy for your timing to be affected.

 

The code as written is very difficult to follow and looks very inefficient. If it truly is time critical it needs come work to ensure proper operation.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 16
(2,425 Views)