LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using case structure inside while loops

Hi all,

 

I am currently building a VI (using 8.5.1) to monitor and control a pressure tank system.  It mainly uses a while loops to retrieve the pressure data and export commands and signals using a DAQ.  I am running into a problem when trying to record the data.  Recording is done at a much slower rate than the sampling, so I used a timer to trigger a case structure.  This then retrieves all of the readings and writes them to an excel spreadsheet.  The problem is that while the recording is taking place, all other sampling has to wait for the recording to finish.  Is there any way to make the while loop continue to run simulataneously with the case structure?  Or am I approaching the entire recording process in the wrong manner?  I'm new to Labview, and this seemed to be the simplest way to accomplish the task.  Any feedback would be much appreciated.  Thanks - Dan

0 Kudos
Message 1 of 7
(2,909 Views)
Can't look at your code right now, but it sounds like you need 2 loops. One loop collects the data. The other loop does the writing to file. This way when you write the data it will no interrupt the data collection. Look at the producer-consumer architecture.
Message 2 of 7
(2,897 Views)

Hello Dan,

 

You should look into a Producer Consumer architecture.  You can find a template for how to set this up under File>>New>>VI>>From Template>>Frameworks>>Design Patterns>>Producer/Consumer...

 

Feel free to ask any questions!

Message 3 of 7
(2,896 Views)
I think the producer-consumer architecture may help.  However, I will be taking pressure readings at a high rate (around 600hz).  I need to also record some optical power readings via a serial port.  But the serial port process takes around 3 seconds to write and read all of the data (I can't continously sample this data).  So I'm looking for a way to constanly monitor and control the pressure, but retrieve the optical power after a certain interval (say 1 minute).  The problem is anytime I use the event structure to sample the optical power, it makes the other loop wait until it is complete.  I will definitely look into the producer-consumer topics.  In the meantime, any other ideas?
0 Kudos
Message 4 of 7
(2,891 Views)

Hi DrPhunk,

 

other ideas:

- using a subvi for parts of code used more than once? See attachment...

- cleaning up your logics for the boolean part in the upper right corner of the big loop? Look at my comments (from simple replacements to wel-known Rube-Goldberg!)

 

For your problem:

Put independent DAQ parts into seperate loops. Use consumer-producer pattern :smileywink:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(2,874 Views)

Hi DrFunk,

 

forgot to say:

after removing this huge sequence structure you can further mnimize the block diagram by putting all those Visa-R/W into a for loop using autoindexing over an array of device commands...

Message Edited by GerdW on 08-15-2008 08:03 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(2,853 Views)
Thanks again guys.  I'm going to try to implement all of the suggestions you mentioned.  I'm sure I'll be checking back as I run into problems.
0 Kudos
Message 7 of 7
(2,825 Views)