LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parallel events occuring at different intervals ...

Greatings all,

I would require some help with respect to an application I am writing.

I am trying to have a VI that would perform simultaniously two tasks in parallel (control/adjust current and perform/process readings) on two different intervals.

The control/adjust current process would adjust a specific parameter (in this case current) on a specific interval. If the algorythm does not allow convergence of the current after a certain delay, both process need to stop.

The perform/process readings process would sample, perform calculations and display data from a test equipment on a user programmable interval. This process also has to keep track of the actual total time spent doing this process.The structure would have to consider a series of exit condition such as a quit command from the user, a user programmable timeout and data convergence based on calculations made on sampled data.

A pause request could also be dictated by the user. In such a case, the control/adjust current process would have to pause and place relevent equipment into a specific mode, the perform/process readings process would have to pause (stop sampling, processing data and calculating the elapse time performing this task) until the user decides to continue.

I have tried a few things. The most promissing thing (at the time) was to use tree while loops whithin a fourth one: one for the control/adjust current process with its own wait function, one for the perform/process readings with it's own wait function, one for the pause and one to contain the other tree.

That seemed to work, but I was not able to get instantanious action on pause or quit request. It is as if the program was only taking the two first while loop into consideration. Furthermore, the sampling rate can vary from a short (1 minute) to a long period of time (120 min) and the timout could be as long as a full week. After reading that those time function were not too precise, I got a bit worried since a need a good time precision... After a full week, a few miliseconds error add up.

Do you have any ingenious and elegant ways of performing those tasks.

Thanks for your support.

Kind regards,

Roger
0 Kudos
Message 1 of 2
(2,558 Views)
Hi Roger!

As far as the precision of the Wait.vi function, you're right, the timing will become off over an extended period of time. An improvement on this is the Wait Until Next Ms Multiple.vi function. What this does is make sure the amount of time between the start of each iteration is a specific amount apart (as opposed to just having a delay after the iteration of the loop). However, due to the non-deterministic nature of Windows, even this will deviate from the true timing after an extended amount of time.

So, if you're trying to execute an iteration once every 10 or 15 minutes or so, I would recommend polling the Get Date/Time String.vi function for the current time. This is not a wait function, however you could program your while loop to continuously poll the function and only execute a portion of the code every X minutes. See the attached VI below for an example of what I am talking about (written in LV 7.0). Keep in mind that this is just an example and can be programmed much differently to be customized for your application.

Also, I'm not sure I completely understand what you mean by "It is as if the program was only taking the two first while loop into consideration." This sounds like just a debugging situation. I would look over your code to determine if there are any dependencies between the loops or if one loop is hogging the processor (by having no wait).

I hope these suggestions help!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 2
(2,534 Views)