01-10-2012 02:41 PM
I'm writing an application that does data acquisition with a cdaq-9178 with several modules attached. At certain points in the application, I need to change the rate at which I acquire samples. My VB.net code looks like this:
Try myTask.Stop() myTask.Timing.ConfigureSampleClock("", rate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, BUFFER_SIZE) myTask.Start() Catch ex As Exception MessageBox.Show(ex.Message) End Try
Even though I stop the task that is running, it gives me the exception that the operation cannot be performed while the task is running.
01-17-2012 05:54 PM
Hello rodrick.pierce, hope you are doing great!
Seems to me that you are doing it the right way, certainly it is true that youcannot change the sampling rate on the fly unless you stop the task, change the sample rate (from the timming vi), which you are doing, and run the task with different rate. From the code attache I can tell you are doing exactly the same from a LabVIEW point of view, however when it comes to LabVIEW I tend to think that the calls are a little more robust.
Is there any chance you can add a "wait" function or an "is task done" to the code you are running so to verify that the task actually stops after the "acquisition/measurement".
Let us Know how it goes,
Regards,
Luis A.
Applications Engineer.
01-27-2012 07:17 AM
I'm not sure when and how I should be implementing the wait. I tried calling the waituntildone function on my task, but that causes my program to freeze.
01-30-2012 03:37 PM
You might need to call the Wait Until Done function/VI to ensure that the specified operation is completed before you stop the task.
The most common example is a finite acquisition. If you start a task that performs acquisition and then immediately stop the task, the acquisition probably has not completed when you stop the task. As a result, does not complete as expected. To ensure it is completed as expected, call the Wait Until Done function/VI before stopping the task. After the Wait Until Done function/VI executes, the finite acquisition has been completed, and you can stop the task.
In general, use the Wait Until Task Done function/VI with finite measurements and generations.
Regards
Luis A
01-31-2012 10:47 AM
Hi!
Is there a chance I can take a look at the rest of the code, from that piece seems that It should work, hoever we might find something else.
Thanks,
Luis A.
Applications Engineer.
National Instruments.
02-02-2012 12:19 PM
I've given up on changing the data acquisition rate, and now I currently sample at the faster rate and just save data every certain number of samples when it should be going at the slower rate.
02-02-2012 02:48 PM - edited 02-02-2012 02:48 PM
For a variable sample rate with plugin data acq boards, I've usually configured the AI task to get its sample
clock from a dummy AO task or counter pulse train task. You can change an AO task sample rate or a
pulse train frequency on-the-fly without stopping them. Indirectly, this makes the AI sample rate vary too.
I don't know all the cDAQ hardware, but hopefully this will be supported with the chassis/modules you have.
-Kevin P