05-29-2007 08:08 PM
05-30-2007 03:52 AM - edited 05-30-2007 03:52 AM
Message Edited by devchander on 05-30-2007 03:53 AM
06-03-2007 03:02 PM
06-04-2007
09:29 PM
- last edited on
09-17-2026
03:06 PM
by
Content Cleaner
Hello arkejellon,
I've read your post and have been trying to see what you are trying to do with your application. I can see that you are thinking of using our USB-6009 or USB-6221 devices to acquire data at 100-200Hz range. There are some subtle issues with your application I don't see, but here are some suggestions:
1) consider using a producer/consumer structure, where you are collecting data in the produced loop and placing the data on a queue structure. The consumer loop will then be used process the data that you collected. It will run while there is something on the queue. The queue operates similarly to a FIFO. Refer to the following resource to find out more about Producer/Consumer design structures.
Application Design Patterns: Producer/Consumer
This is type of design structure is used in all kinds of applications, for example, high-speed data streaming applications where they are sampling at 400MB/s.
2) use event structure to deal with execptions. For instance if a stop button press has been detected then you can have an event that would complete the read task and release the resources. Here is a tutorial on the issue.
Changing the Face of Design Patterns with LabVIEW 7 Express Event Structure [link removed; article no longer available]
Take a look at these resources and see if you can leverage them in you application.
Regards,
Sandra T.
Applications Engineer | National Instruments
06-11-2007 03:35 PM
Just adding to the good suggestions from Sandra T.
The two options you outlined are NOT your only alternatives. For example, let's consider what you called "Method 2" where you stated, "However, the downside to this approach is that when the test is started, we must wait until the total number of samples has been acquired before the code will continue to execute...". That statement is only true if you call DAQmx Read while leaving the '# samples to read' input at its default value of -1, which is what happens when it's left unwired. You could instead wire any smaller # N that you choose, and it will then give you the earliest N values. (There are actually methods available to ask for the most recent N or some intermediate subset as well, but those don't seem necessary here.) Something I've typically done is to call a DAQmx Read property node to query the '# of available samples'. If I then request that # of samples (or less) in my call to DAQmx Read, I'll get them back immediately with no waiting.
So... you can start your task using a buffer sized for 10 minutes. Then if the operator determines that the test should be terminated after 30 seconds, they press the "Stop" button. Your code can then call the DAQmx Read property node to query '# available samples' which you then wire into the call to DAQmx Read. You'll immediately get back all the data taken up to that moment. Then you can call DAQmx Stop or DAQmx Clear and the rest of your code will continue right away.
Sandra T's suggestions about producer-consumer and event-driven architectures would give you a framework for handling even more complex scenarios. Good luck!
-Kevin P.
11-14-2008 01:52 PM
Just adding to the good suggestions from Sandra T.
The two options you outlined are NOT your only alternatives. For example, let's consider what you called "Method 2" where you stated, "However, the downside to this approach is that when the test is started, we must wait until the total number of samples has been acquired before the code will continue to execute...". That statement is only true if you call DAQmx Read while leaving the '# samples to read' input at its default value of -1, which is what happens when it's left unwired. You could instead wire any smaller # N that you choose, and it will then give you the earliest N values. (There are actually methods available to ask for the most recent N or some intermediate subset as well, but those don't seem necessary here.) Something I've typically done is to call a DAQmx Read property node to query the '# of available samples'. If I then request that # of samples (or less) in my call to DAQmx Read, I'll get them back immediately with no waiting.
So... you can start your task using a buffer sized for 10 minutes. Then if the operator determines that the test should be terminated after 30 seconds, they press the "Stop" button. Your code can then call the DAQmx Read property node to query '# available samples' which you then wire into the call to DAQmx Read. You'll immediately get back all the data taken up to that moment. Then you can call DAQmx Stop or DAQmx Clear and the rest of your code will continue right away.
Sandra T's suggestions about producer-consumer and event-driven architectures would give you a framework for handling even more complex scenarios. Good luck!
-Kevin P.
How to you exactly "stop" and how to you call the DAQmx Rear property node to query # available samples? I'm not sure how to path things correctly.
11-17-2008 09:34 AM - edited 11-17-2008 09:36 AM
Yin,
I think Kevin was refering to this property node that you can see in this picture:
A "Stop" button can be placed on the front panel and in the case Kevin described he would perform a DAQmx read based on when this button was pressed. If you would like to do this also you would need to have that button connected to a case structure that will perform the desired operations in the true case.
If this does not answer your questions could you please be a little more specific about what you want to code and what you have tried.
11-30-2008 05:17 AM - edited 11-30-2008 05:20 AM
jason;
what if i wanted to make an interruption for the Data acquisition and start it once i receive a rising edge at one of the device PFIs, for example i will continually acquire 6 channels , and once a rising edge occur i will restart the acquisition at this event and collect the data for example for 20 seconds. how can i interrupt the Data acquisiton process and restart it even if it wasn't finsihed yet (i usually need the number of samples 10 times the sampling rate which means 10 seconds for single acquisition.
note: i'm not interested in the data acquired before the rising edge
i found this thread very close to what i wanna ask about that's why i posted here
can you help in this
Thanks in Advance
12-01-2008 10:49 AM
MAshraf,
I am not sure why we are using a continouous read if we are trying to read for 20 seconds. We would simply perform a finite read triggered by the PFI line. Why do we need to interrupt the acquisition? I am still unsure as to your application so I cannot give you my recommendation, but it seems like a triggered finite read is what you need.
There is a DAQmx Reset Device if your question is solely how do I abort mid acquisition, but I would not recommend using this.
12-01-2008 12:15 PM
Jason, Kevin,
I have programmed a one shot event that collects X number of data at Y frequency. So you hit go and then data is collected for X/Y seconds. Sometimes the data collection process will be 30 minutes long but the test can be finished in as little as 5 minutes. I have tried using the property node but I am not sure where to insert it to get it to work.
I'm also not sure how to create an interrupt or even to get labview to read events before the data collection stops.