LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

running a DAQmx VI

Solved!
Go to solution
I have a VI that was written mainly by the "Generate DAQmx code" function, including a while loop, a DAQmx Start Task VI, a DAQmx Read VI, etc.  It runs by pressing the white run arrow on the top toolbar, but I want to control its start with a button on the front panel.  I know this is usually done by putting everything in a Case Loop with a boolean control, but there isn't a terminal to connect the boolean control to run the DAQ, since the computer generated most of the code.  How do I fix this?
0 Kudos
Message 1 of 9
(3,059 Views)
Hi Lnn1, you may need to tell more about this VI.  Is it a top level VI with many user interface demand, or just a lower level VI or subVI be called by some other application?  If it is a top level VI, the best approach is write it in a state machine structure. You can use a start button within an event structure to trigger an event when the button was clicked.  This structure may take you some time at the beginning, but eventually it will save you lots of time.  Also it is better to post your code to get the exact help you need.
0 Kudos
Message 2 of 9
(3,053 Views)
I'm a beginner at LabView... how do I post my code?  It's a really simple VI, it just collects analog voltage through a NI-DAQ card and records it, not much user interface.  I just need the start button because I'm going to put it inside another separate VI, and I want both data collection processes to start at the same time using the same button on the front panel.
0 Kudos
Message 3 of 9
(3,038 Views)

Attaching code is as simple as using the 'Add Attachments' link right below the message body.

 

What you want to do is add a case statement. This is basic stuff and you should look at the free LabVIEW tutorials.

0 Kudos
Message 4 of 9
(3,034 Views)
I am familiar with case statements - my question was where to connect the selector terminal.  I have attached the VI.
0 Kudos
Message 5 of 9
(3,026 Views)

You've got this inside out.  As it is now, the VI will only work if the Start button is pressed before you start the VI.

 

Put the DAQ stuff inside the case structure, then the start button and case structure inside the loop.

 

You should put a small wait statement in the false case so that the loop isn't running at top speed eating CPU cycles when all it is doing is polling the start button when the button is still false.

0 Kudos
Message 6 of 9
(3,021 Views)

Thank you so much, but I tried it and I'm not sure if I'm doing something wrong with that idea, but I couldn't get it to work.  If I put all the DAQ stuff inside the case structure, it does not continually collect data.  But if I leave the case structure on the outside, the selector terminal has nowhere to be wired to. 

 

Let me start from the beginning: the VI (that I have attached below, slightly different than above) simply starts collecting data right away when you press the white run arrow at the top toolbar, and does not stop until you press the "stop" button.  I would like to control its start AND stop with buttons on the front panel, with continuous data collection in between the pressing of start and stop.  I know it involves case structures and while loop(s) but I can't seem to get it wired correctly to work.

0 Kudos
Message 7 of 9
(3,010 Views)
Solution
Accepted by topic author Lnn1
Message 8 of 9
(2,995 Views)
Thank you!
0 Kudos
Message 9 of 9
(2,978 Views)