LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start - save - stop

Hey,

 

I have created a program which should be able to acquire measurements using DAQmx and display them in a chart.

The program should start logging after pressing the 'START' button.

When the STOP button is pressed, the data logging should be terminated.

When SAVE is pressed, the data has to be saved to a MATLAB file.

When STOP is pressed, the program should end.

 

I've added the vi in attachment. It seems not to work properly. I know that it has something to do with the inner while loop, but I don't really know how to fix it. I would like to keep using the event structure so I don't know how to program this otherwise.

 

Also, is there a possibility for the user to choose the amount of channels he is willing to read with the DAQmx system?
 When changing from 2 to 6 channels, there should also be 6 charts displayed on the screen. I tried to do this using the 'visible' property node but it only slows the program down...

 

 

Kind regards,

Dries

 

 

0 Kudos
Message 1 of 16
(3,404 Views)

what is your reasoning for putting it into an event structure? would not a simple state machine work for you? your use of controls connected to the stop seems convoluted....

 

case statements:

  • start acquisition
  • stop acquisition
  • save acquisition
  • stop/shutdown loop

note: add an event to your stop3 buttons to exit your structure..

0 Kudos
Message 2 of 16
(3,390 Views)

There is a simple answer to that question:
You can say that I'm pretty new to LabVIEW and in the previous program I made, I also worked with the event structures so I'm used to them...

 

 

0 Kudos
Message 3 of 16
(3,382 Views)

Dear DiresM,

 

From your description all I could understand is that you want a button, which when pressed, saves your latest data in a file. And there is another button which stops your VI.

I have attached a simple VI which can serve you to some extent. Here I'm saving file in a notepad. You can define your directory in file path. 


Message 4 of 16
(3,372 Views)

If only you could put that string block inside the event case! I forgot that. Smiley Tongue

 


0 Kudos
Message 5 of 16
(3,370 Views)

I think you would benefit greatly from an architecture like the Queued Message Handler (QMH).  The idea is that you have one loop handling all of the user iterations (button presses mostly) and another loop to do the DAQ setup, read, stop, and logging.  You send commands from the event loop to the DAQ loop via a queue.  Do a search on it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 16
(3,364 Views)

@DriesM wrote:

I've added the vi in attachment. It seems not to work properly.


  • Your stop3 event frame is actually triggered by the "stop log" button.
  • It is not a good idea to trap interactive loops inside an event structure. You can use the outer loop for everything if done right.
  • You should wire the 2D array across all frames so you can save multiple times (e.g. if you accidentally cancel the file dialog the first time). In your code, the data unrecoverably disappears with each save attempt.
  • You have race conditions. For example you clear the history in parallel of starting to write to the charts, so the clearing might happen after some data is already acquired
  • ...
Message 7 of 16
(3,362 Views)

Hi,

 

Thank you all for your contribution.

 

@Dynamite: I wonder how I have to place the DAQmx subvi's in your example? ( As I was told it is better not to place any while loops inside an event structure)

 

@Cross: You will probably be right, but I'm afraid I don't have the knowledge it requires to use this QHM... 🙂

 

@altenbach: Could you please explain this a bit more in detail?

"It is not a good idea to trap interactive loops inside an event structure. You can use the outer loop for everything if done right."

I guess if I just take away the inner loop my program won't work anymore, so how exactly can I do it right?

 

 

Kind regards,

Dries

 

 

 

Will the program also work if I delete the inner while loop?

 

0 Kudos
Message 8 of 16
(3,354 Views)

 


 

@Cross: You will probably be right, but I'm afraid I don't have the knowledge it requires to use this QHM... 🙂

 

 



It's actually pretty easy to impliment. I've used it many times thanks to corzzrules and others here. Just do some research on it. I know you can do it, cause I did! 🙂

0 Kudos
Message 9 of 16
(3,347 Views)

@DriesM wrote:

@altenbach: Could you please explain this a bit more in detail?

"It is not a good idea to trap interactive loops inside an event structure. You can use the outer loop for everything if done right."

I guess if I just take away the inner loop my program won't work anymore, so how exactly can I do it right?


Here's is a very quick draft manipulating the timeout. (LV 8.5)

 

(Not tested, so there are probably bugs. Modify as needed.)

Message 10 of 16
(3,337 Views)