LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop iterations end early


@iskrazaf wrote:

Thanks for your responses guys, really appreciate the help.

.....

dkfire: I was setting the dt and mode in every iteration as a frustrated attempt to fix it, it was a bit of a last ditch effort that I knew was probably unnecessary. To be honest I'm tearing my hair out here over this, I just can't see why it's not timing properly. The sequence structures are there so that I can force execution onto different CPU cores, I got a new computer so I just was playing around to test the performance.

 

Again I am still very much in the development stage, I haven't cleaned up my code, it's messy, I'm very sorry about that. I swear I'm usually a lot neater 🙂

 


That is not the case for the sequence structures. They only "helps" you inforce the execution order of the program.

A while loop or/and a dynamic launched vi can run on different CPU cores or threads, but that dependt on how you have programmed the code.

Take a look at the Producer/consumer pattern.

0 Kudos
Message 11 of 16
(671 Views)

All in all, i have to agree with altenbach: Your block diagram is way too big.

 

One question:

This VI has to run on Windows, does it?

 

Regardless, your absolute overuse of timed structures and your arbitrary core assignment of those show that you have no understanding of resource management in computer systems.

My experience is that in most cases, when developers start to meddle with timed structures, they make performance worse compared to "letting the system optimize itself".

The most terrible mistake you do is:

You use core assignment but fail to provide a proper concept for priorities, which could enable your system to maintain timings for the most important parts.

Additionally, running the code on Windows can starve complete parts of your application as Windows might assign the core to other applications for an extended time, so your application will NOT load balance in order to account for "the missing core", but it will simply wait for the core to become available.

 

just my 5 cents,

Norbert

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 12 of 16
(639 Views)

Someone mentioned that you set dt every loop. It could be that setting a new dt performs a 'reset' and treats the subsequent loop as the 'first' loop and just executes it immediately. That's what it looks like. Generally it's considered bad practice to continually set values that never change in a loop.

0 Kudos
Message 13 of 16
(623 Views)

I am sorry for my last post as i seem to rant a lot without giving any constructive feedback. This is not very nice, hence my apology.

 

Therefore, i simply recommend you:

Remove ALL timed structures. Period.

 

To replace timed loops, use standard while loops and insert a Wait Until Next ms Multiple functions with proper timings.

Timed sequences can be removed quite safely without any replacement in most places. Remember to use the error cluster wire to define dataflow execution order. If necessary, you can add Wait functions to delay execution on specific locations by inserting wait in a single sequence frame (use error cluster feedthrough to determine WHEN wait should execute) or the Time Delay expressVI.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 14 of 16
(599 Views)

OK everybody thank you for all of your feedback. Apologies for my late response but I have been out of town in the last week.

 

I will take these new approaches on board and clean up my diagram. It definitely seems that my timed loop structures are causing the issues.

 

One more question: if I use while loops with a wait function, how can I be assured of the iteration times? Is there a similar measure like in the timed loops? Timing is very key to my project.

0 Kudos
Message 15 of 16
(562 Views)

If you require determinism, you must not use Windows.

End of story.

 

That being said, you can use Windows for "semi-determinism" if you configure it the right way (e.g. disable screensaver, virusscan and harddrive indexing). Still, that "semi-determinism" is way less than 1ms (i would say a couple of 10th of ms) and nobody grants you any garantee on that. If that is sufficient for you, you can use normal while loops including "Wait until next ms multiple" as this will result in a behavior similar to a timed loop.

You will not get any direct information about late iterations, but if necessary, you can include code to detect and react on that (therefore, Wait and Wait until have an output "timer tick").

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 16 of 16
(538 Views)