Showing results for 
Search instead for 
Did you mean: 

a task with timer

Hi buddies
I am programming a task as follows..
In the total time I want to realize two small tasks, task A and task B, in which B could run only when it is chosen.
I need three loops I think, one for the total time, if the time is over the total time, the program supposes to finish immediately.
The other two loops are for task A and task B.
I want to triggle task A in a special period of time Ta, and triggle task B (if it's chosn) in Tb (normally Ta is larger than Tb).

The problem is I could not set the same time base for this important time comparation.
When I use "read the timevalue", the time inside and outside the loop would be irrelative since "read the timevalue" offers only random value which is indepentent of the real time.

...How should I set the timer?
Thank you!

I use LV8.0 full version..(btw German version, it makes language trouble also)....

0 Kudos
Message 1 of 6
ok, is this what you want?
while (total time)
     if (time A)
         task A
     if (B is chosen)
         if (time B)
               task B
if so, try this vi
** the graphs are plotting even when time A and time B are not elapsed yet, that's because you are sending signals to the graph in the false case event.  if you don't want it to plot when time A and/or time B are(is) not elapsed, simpily remove the things inside the false case
0 Kudos
Message 2 of 6
Thanks a lot! Still got some probs.

What I want is as the pic attached.

And just now I made another one...
The bad thing is I could not get the time difference between the processing time and the starting time.

always give the probs...

Download All
0 Kudos
Message 3 of 6
btw, I think I decribe my task a little bit wrongly.
I need task A and B (if chosen) repeat running in the total time.
and they have the respective periods...

So I could find the way to solve these double loops in the same program....

0 Kudos
Message 4 of 6

I'm not familiar with the two inner loops you used, are they timed loops or something?

anyway, (x-y) is only calculated at the first iteration of the loop because during the first iteration, the two inner loops start to run, and never stops (or maybe until a long time later, I wasn't patient enough to wait for it to finish running), and the outter loop doesn't proceed to the next iternation until the two inner finishes running, so (x-y) was never calculated again.  you can duplicate the chunk of code that calculates (x-y) into the two inner loops to make it update.  Also, I wasn't sure if you want to stops the inner loops with that condition (the condition stopping the outter loop) is met.  If you want it to stop, you need to connect the boolean from the duplicates to the stop in the inner loops.

hope this is helping ^_^


0 Kudos
Message 5 of 6

Thank you very much!


I will try.

0 Kudos
Message 6 of 6