LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timed tasks inside loop

Solved!
Go to solution

I have a program that has multiple tasks and i would like them to run at different frequencies inside of the loop.  I am wondering what the most efficient way of doing this is?

 

I have read about multiple tasks running based on button pushes, or events, but have not found much on timed tasks.

 

Is the timed loop the best way to go with this?  Having a timed loop for each task required? 

 

I have attached an imcomplete vi that demostrates what i am trying to do.

 

I am sure there is an easy fix, but want to find the most efficient way to to this.

 

Thanks 

0 Kudos
Message 1 of 21
(4,958 Views)
0 Kudos
Message 2 of 21
(4,957 Views)
for some reason it won't let me attach the file using the add attachment function.  Says unexpected error.......
0 Kudos
Message 3 of 21
(4,956 Views)

fvnktion wrote:
for some reason it won't let me attach the file using the add attachment function.  Says unexpected error.......

 

This is a known problem with safari and google chrome. Try a different browser or place the VI inside a zip archive before attaching.

 

(Your link above points to your local filesystem, so it won't work for any of us.)

 

 

0 Kudos
Message 4 of 21
(4,951 Views)

fvnktion wrote:

I have a program that has multiple tasks and i would like them to run at different frequencies inside of the loop.  I am wondering what the most efficient way of doing this is?


How long does each task take?

Are the rates integer multiples of each other?

0 Kudos
Message 5 of 21
(4,950 Views)
I see.  Attached is the vi that will display what i am trying to do.
0 Kudos
Message 6 of 21
(4,943 Views)

Here is another that i tried that clearly doesnt work correctly.  It's pretty obvious that I the higher frequency tasks are being limited by the longer task. 

 

How would you set something like this up to get it working?

0 Kudos
Message 7 of 21
(4,940 Views)
Solution
Accepted by topic author fvnktion

For simple task such as this, just spin the loop at the fastest rate you need and do the other tasks at interger multiples of it.

 

Here's a simple draft (LV 8.6)

 

 

(Of course you have serious problems with memory thrashing, since you are growing infinite sized arrays in uninitialized shift registers. That needs to be fixed too).

Message 8 of 21
(4,924 Views)

Perfect,  thanks.

 


(Of course you have serious problems with memory thrashing, since you are growing infinite sized arrays in uninitialized shift registers. That needs to be fixed too).


Speaking of the memory thrashing,  what is a good method of dealing with this.  In the example you modified, you initialized the array.  What if the program is running for a long period, but you want to keep the data, but not "thrash" the memory?  Would it be best to reinitialize the memory after n iterations and store the data somehow? 

 

Thanks for the great input!

0 Kudos
Message 9 of 21
(4,895 Views)

Typically, the best way is to initialize the shift registers with fixed size arrays (e.g. all NaN) and then use replace array subset to fill the data. Each array resizing causes a reallocation and is this expensive.

 

You could also graph your data in charts (with a reasonable history size). At the same time, you can stream the data to disk where you have infinite cheap storage.

Message 10 of 21
(4,878 Views)