LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Parallel timed loops on Demand but they only run once

I've read all the posts on here regarding this topic, but can't seem to get my code to work.  I have 3 tests that I want to run on demand.  I have a setup VI that dynamically loads a data display window.  The launched display loads data onto the graphs that were setup (you have to put in a job before hitting start in the setup VI).  Everything seems to work fine, but if I didn't start the 3rd test I would like to be able to hit start again on the setup VI, but it does not respond.  I can tell from the global that the status is changing, but it seems like the while timed loops will only execute once at the beginning of the launch until complete.  I may be going about this whole thing completely wrong.  Any and all help will be appreciated.  Thank you.

0 Kudos
Message 1 of 8
(4,564 Views)

This thing looks buggier than an ant farm, so it is not trivial to troubleshoot.

 

First of all, there are race conditions everywhere, for example you read the same global in parallel inside and outside event structures, so once the event structure completes, the value at the stop terminal might be stale and unexpected. LabVIEW does NOT execute left to right!

 

What is up with all these value properties everywhere? Why not keep things in shift registers instead?

 

If you would use "stop if true" for the loop termination, you would not need to invert first. All the boolean logic seem more complicated that it needs to be.

 

Maybe if you would clean up the race conditions, things will fall into place, maybe not. Try it!

Message 2 of 8
(4,530 Views)

altenbach,

          Thanks for the advice (slap upside the head).  I had gotten lost many hours before this and I just started digging making things worse.  Once I started trying to simplify things, I realized I didn't need the event structures at all.  Everything seems to be working exactly as I wanted now.  Thank you very much.

0 Kudos
Message 3 of 8
(4,513 Views)

Your 3rd loop will spin wildly if Data display 3 is false.

I personally prefer normal normal loops with a separate wait command instead of timed loops.

Some wiring could need some clean up, but it's definatly in the right direction!

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 8
(4,495 Views)

Thanks.  I actually posted the wrong data display VI last time.  My actual result is attached here.  I did add a small wait to keep the loops from spinning wildly when the individual displays are false.  Thank you.

0 Kudos
Message 5 of 8
(4,482 Views)

Your code is still exceedingly complicated. Let's look at the code in the timed loop:

 

 

  • Why do you write the start time every 25ms? Since it never changes, writing once before the loop is enough.
  • Instead of shuffling the xy graph through a shift register and reading the data cluster from a value property node, keep the data cluster in a property node.
  • You could use the "in place element" structure to update the xy graph (not shown below).
  • Since your data is spaced equally in x, a plain waveform graph is sufficient. No need for the complicated xy data structures. You can even set x0 as your starting time and dx at 0.025s for a correct time axis display. (not shown below)
  • Use "built array" instead of "insert into array" to built an array.
  • ...
  • ...

 

 

Message 6 of 8
(4,473 Views)

Thank you very much for your feedback...

 

I now only write the start time once

I got rid of the extra data shift register and property node

I replaced the insert into array's with build arrays

I looked into the "in place element" but I was worried I might re-over-complicate things by changing to that now.

 

Questions...

 

I've changed my first graph to an plain waveform graph.  I didn't realize that was more efficient.  (I guess that's not really a question, but a prompt for comment.

 

I was also curious about "..." and "..."

 

Thank you very much,

0 Kudos
Message 7 of 8
(4,442 Views)

 


@asb9ab wrote:

 

I've changed my first graph to an plain waveform graph.  I didn't realize that was more efficient.  (I guess that's not really a question, but a prompt for comment.


 

An xy graph has at least twice as much data.

 

No, you changed it into a waveform chart, something entirely different. If you use a chart, you would wire the scalar random number directly. No need to keep the shift register at all because the chart has its own data buffer (which you configured for 50000 samples, a bit high for my taste). I meant a waveform graph as in the attached draft.

 

 

 

0 Kudos
Message 8 of 8
(4,431 Views)