05-17-2013 07:41 AM
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
05-17-2013 08:45 AM - edited 05-17-2013 09:05 AM
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:
note: add an event to your stop3 buttons to exit your structure..
05-17-2013 08:50 AM
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...
05-17-2013 09:14 AM
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.
05-17-2013 09:20 AM
If only you could put that string block inside the event case! I forgot that.
05-17-2013 09:30 AM
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.
05-17-2013 09:39 AM
@DriesM wrote:
I've added the vi in attachment. It seems not to work properly.
05-17-2013 10:02 AM
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?
05-17-2013 10:23 AM
@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! 🙂
05-17-2013 10:47 AM
@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.)