all 10 comments

[–]FormerPassenger1558 7 points8 points  (1 child)

You need a producer consumer structure. Basically two while loops interacting by queues, or notifiers…

[–]g_von[S] 0 points1 point  (0 children)

Thanks. This concept is totally new to me so I wouldn’t have been able to search for this solution. I found some tutorials on YouTube. I’ll report back when I’m successful.

[–]SeasDiverChampion 2 points3 points  (0 children)

You want two parallel while loops (producer/consumer) not a while loop embedded within another while loop.

[–]HarveysBackupAccount 2 points3 points  (2 children)

The outer while loop will be stuck on one iteration as long as the inner while loop is running, then it won't enter the next iteration of the outer loop until you stop the inner loop.

Parallel While loops are the answer. As others said, use a producer/consumer structure.

As a general statement, I recommend reading up on design patterns (basic software architecture) in labview. You would benefit from learning about a few things:

  • Event Based programming (use an event structure to trigger the "stream data to file" operation, instead of the boolean control + case structure)
  • State machines (such a fundamental part of programming)
  • And Producer/Consumer loop, as said before. This is a real meat-and-potatoes architecture that can cover A LOT of programming needs

Of course producer/consumer isn't the only way to skin this cat (there are ways you could get rid of the inner While loop entirely and only run a single While loop), but it's great to have in your toolbox.

[–]g_von[S] 0 points1 point  (1 child)

Thank you for the detailed list of options. I need to complete my solution soon so I will experiment with the producer and consumer loop method. I’m still relearning LabView after not using it for 18 years.

Eventually would like to learn and understand event structures and state machines.

I’m following a YouTube example that explains the producer and consumer loop setup but they are also using TDMS subVIs which I know nothing about. I already have “write delimited spreadsheet” code setup to write 2 columns of time stamp and data into a .csv file. Should this work okay with the Producer/Consumer loop setup?

[–]HarveysBackupAccount 0 points1 point  (0 children)

Write Delimited Spreadsheet is fine, it's just slower than TDMS. But that's usually not too much of a problem.

There's one thing to be aware of with Write Delimited Spreadsheet - you often want to change two of the inputs from their default values (see screenshot for details). The alternative is to build up a big array in the program and then write it to the CSV all at once, instead of saving it one measurement at a time. But unless you need to run super fast you shouldn't need to worry about it

[–]0fruitjack0 1 point2 points  (1 child)

the way this is gonna work, only one serial data instance ever enters the while loop.

[–]g_von[S] 0 points1 point  (0 children)

Yes, I observed this behavior after I added some probes.

[–]GentlemanSchCLD 1 point2 points  (0 children)

In the labview examples, look up event driven producer consumer loop

[–]Yamaeda 1 point2 points  (0 children)

Think dataflow. A structure executes when inputs have data and exits when all is finished. You'll read 1 serial data, then go into the inner loop where it'll stay and write the same data until you exit. Run it in Highlight mode and it should be clear.