12-17-2008 04:27 PM
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
Solved! Go to Solution.
12-17-2008 04:29 PM
12-17-2008 04:29 PM
12-17-2008 04:40 PM
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.)
12-17-2008 04:43 PM
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?
12-17-2008 05:29 PM
12-17-2008 05:38 PM
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?
12-17-2008 06:06 PM
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).
12-18-2008 09:18 AM
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!
12-18-2008 10:56 AM
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.