Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I simultaneously run 2 while loops or 2 for loops

I need to simultaneously collect analog data and send digital (or analog) signals to control variable speed pumps.  I have a labview program that controls the pumps and a labview program that collects data.  I am trying to integrate these 2 programs and find that labview will not simultaneously run the while loop for collecting analog data and the while loop that controls the pumps.  I have the same problem with for loops.  I cannot put both pump control and data collection commands in the same loop because they need to be executed at different frequencies.  What is the solution to this problem?
0 Kudos
Message 1 of 6
(14,820 Views)
Assuming that you have no data dependency between the two while loops and are not using the same hardware resources, you should be able to do this with no problem. Can you post your VI or an image of it so that someone can look at the code?
0 Kudos
Message 2 of 6
(14,813 Views)
Maybe the problem is that I am using case structure in one of the for loops?
0 Kudos
Message 3 of 6
(14,810 Views)

Maybe the problem is that you have data dependency between the two loops.Smiley Wink You've got a stop button in the top for loop (which does absolutley nothing) wired to the bottom for loop. That means that the bottom for loop will not start until the top for loop finishes. Understanding data flow is basic to using LabVIEW. That is the underlying pardigm. If you have a data source wired to a data sink, the function with the data sink will not execute until the data source is available. That is how you can control execution order with the error in/error out connections. You have some of the error in/error out connections wired but then you don't continue to the next frames. Do the wiring and you can eliminate all of those sequence structures and actually be able to handle any errors that may occur.

Before you continue, you really need to do a lot of cleanup. A good rule of thum is to keep the diagram no larger than the screen size. You have wires going in every direction and some are hidden by other structures. This all makes it very difficult to read and maintain. You are also repeatedly creating a task doing a digital output, and then stopping and closing the task. The create/stop/close takes quite a bit of time and you don't need to do that. Create the physical channel and start the task at the very beginning. Pass the task from frame to frame if you insist on keeping the sequence structure and then stop and close the task at the end.

Message 4 of 6
(14,807 Views)
I used the sequence structure because I need specific pause times between the actions in each frame, i.e.:  1) turn on sample and reagent pumps for 0.5 sec; 2) turn off pumps for 0.5 sec; 3) turn on air pump for 0.5 sec; 4) turn off pump for 0.5 sec; 5) repeat.  Can you suggest a better way to do this?
Message 5 of 6
(14,776 Views)
I understand that but what you have doesn't do that. You have the delay function in parallel with your DAQmx Write functions so you don't really know when the delay is happening. It could be before or after the DAQmx Write. There are error in/error out connections on the delay function and you should have wired those up in order to enforce dataflow which in turn will determine execution order. Here's a quick mod I made to your program. the only thing I changed was the bottom for loop. I pulled all of the start task/stop task,close tasks out of the for loop so that there is no time wasted doing these things with every iteration. You only need to do each one once.
0 Kudos
Message 6 of 6
(14,773 Views)