LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle events inside a timed toop

Solved!
Go to solution

Dear LabVIEW community,

 

I have a question that I did not find an answer for using Google or the forum search.

 

My VI consists of a single timed loop running at 200 Hz, and I wish to handle a control value change event inside that loop without messing up the timing. (To be precise, I want to update the maximum range [property node] of another control equal to the new value of the control that generated the event.)

 

Placing an event structure inside the timed loop causes the entire timed loop to stall. I also tried removing the timeout case from the event structure, but it did not make a difference.

 

Placing the event structure outside the timed loop also does not really work:

- Selecting "Lock front panel until the event case for this event completes", the event case triggers once but locks the entire UI indefinitely.

- Deselecting the "lock" option, the event case also triggers only once, at least without locking everything.

 

So here's my question: How do I achieve my goal? Is my approach of nesting the timed loop / event structure completely wrong? Is something preventing my events from completing?

 

Best regards

Paul W.

 

 

0 Kudos
Message 1 of 4
(1,976 Views)
Solution
Accepted by topic author PaulWilhelm

Hi Paul,

 

Placing an event structure inside the timed loop causes the entire timed loop to stall.

Why do you need to place the event structure inside this timed loop?

 

I also tried removing the timeout case from the event structure, but it did not make a difference.

Removing the timeout event will make things go worse. Use the timeout event and set it to wait at max 1ms.

 

Placing the event structure outside the timed loop also does not really work:

Placing the event structure outside that timed loop will definitely work - as soon as you place a (while) loop around the event structure!

 

Did you read the help for the event structure and the related Caveats article?

 

Is my approach of nesting the timed loop / event structure completely wrong?

Using that timed loop is questionable, when you are using a default WindowsOS computer…

 

Is something preventing my events from completing?

To answer that you should attach your VI!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(1,971 Views)

Hello GerdW,

 

thanks for your rapid reply! I'm still a beginner (especially when it comes to parallelism) and your response cleared things up for me.

Indeed, after adding the while loop around the event structure [with timeout] (everything outside of the timed loop) everything works as expected. 🙂

 

I understand your concerns about the general implementation of a timed loop in a non-realtime OS. So far it works (on my machine™) but it may not be the most portable thing.

 

Best regards

Paul W.

0 Kudos
Message 3 of 4
(1,964 Views)

@PaulWilhelm wrote:

I understand your concerns about the general implementation of a timed loop in a non-realtime OS. So far it works (on my machine™) but it may not be the most portable thing.


The real problem with Timed Loops is they add all kinds of overhead for very little gain.  Everything inside of it must run serially (you lose parallelism inside of the loop), so you can potentially hurt your loop performance.  It also messes with the priority in the OS, which I have had little success on with Windows.  So unless you are on an RT system and you have a time critical loop or you are on an FPGA, timed loops should really be avoided.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(1,937 Views)