01-29-2021 07:59 AM
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!
Solved! Go to Solution.
01-29-2021 12:44 PM
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).
I guess the problem is not the timed loop, but the event structure blocking code execution…
01-29-2021 12:47 PM - edited 01-29-2021 12:52 PM
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!!!)
01-29-2021 12:59 PM
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.
01-29-2021 01:12 PM - edited 01-29-2021 01:32 PM
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?
01-29-2021 01:54 PM - edited 01-29-2021 02:10 PM
@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.
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!
01-29-2021 02:09 PM
@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.
01-29-2021 03:51 PM
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.
01-29-2021 04:11 PM
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. 🙂
01-29-2021 04:25 PM
@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.