LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to run DAQ in a loop and get DAQ data in a separate loop

Dear All,

 

I am new to this board. I hope to get some help from here. The problem now i am facing is I have a separate DAQ analog input and Digital input loop, another loop for digital output. In the main loop is a state machine. in each case. we need to use the data passing from DAQ and process and then send output to Digital output to open and close valve. The program i have now it seems not getting any data and not sending the output either. If I am posting the code helps, I would post.

 

Thanks.

0 Kudos
Message 1 of 7
(3,331 Views)
Posting the code would definitely help. I believe you need to implement the Producer/Consumer architecture, a template for which can be found when you navigate to File -> New.. in LabVIEW.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 7
(3,322 Views)

Posting code always helps so that we can see what you have done.

 

Queues or Action Engines are good ways to move the data from from the DAQ loop(s) to the main loop.  I have used both quite successfully.

 

You might look at the Producer/Consumer design patterns which ship with LV for some ideas. 

 

Lynn 

0 Kudos
Message 3 of 7
(3,321 Views)

Thanks for quick response. Which producer/consumer loop should I look at? for data or for other. Anyway please take a look at code I have. What I need to do take DAQ input and read  and display from from another loop. Also i need to have a state machine for the BIT test. Any good suggestions for the structure will be appreciated.

 

 

0 Kudos
Message 4 of 7
(3,305 Views)

Yes.  The Producer/Consumer (data) is probably the place to start.  Your functional global should be OK for moving the data.

 

You can eliminate most or all of the sequence structures and local variables.  The state machine and some shift registers will allow that.  Your upper loop is almost a state machine already.  Rather than typecasting and indexing through the values of the enum, couple it through a shift register and select the value for the next state inside the current state.  Make it a typedef so changes propagate through the constants and the case selection labels.

 

I would move the averaging and writing of data from the DAQ loop to one or more states in the upper loop state machine.  You do not want a slow write caused by the OS allocating file space to delay the next acquisition.

 

Try to keep the diagram to the size of one screen.

 

Lynn 

0 Kudos
Message 5 of 7
(3,294 Views)

Thanks for the reply. I did use statemachine. However I am not sure how to do producer/consumer loop for data. right now this one is working. Is any recommendations.

 

I appreciate your comments.

0 Kudos
Message 6 of 7
(3,256 Views)

I'm sorry, but I'm not real sure what I'm looking at when I open your code up.  There are also a number of missing VIs.

 

The Producer/Consumer Design Pattern addresses the proper way to share data between multiple threads.  Become familiar with the various tools available in the Synchronization tool set. It sounds like you need either a Queue or a Local Variable.  Local Variables are good when you want decisions made on only the most recent data.  I tend to use Local Variables in State Machines and PID controllers because only the most recent data is relevent.  Some people on this forum will argue not to use Shared Variables as a matter of principle and I won't argue with them.

 

For data processing and save routine threads, I use Queues because I want all the data in the Queue to be processed.

 

One tip in getting more bang-for-your-buck on this forum: simplify your problem when you present it on this forum.  Posting a .zip file that contains a number of VIs means that in order for anyone to help you they have to take the time to load in into LabVIEW (if it will load and isn't missing anything) and make heads or tails out of it all.  Even if your code did load correctly, I probably wouldn't be able to run it without your hardware so the complete code package is useless to me.  What does work, and helps us all help you is to make a simple example of the problem (conceptual or otherwise) that you have and post a picture of the block diagram (take a screenshot or make a Snippet if you are using LV9.0).

0 Kudos
Message 7 of 7
(3,247 Views)