LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the sample rate while the program is running

I need to change the sample rate between 0.01/sec and 1000/sec in the midst of an experiment.
 
In my program, I need to read data from 3 Analog Input chanels simutaneously and then write data to a Analog Output chanel. I have to read one sample per AI chanel during each loop because I use this data to determine the output value of the AO chanel. I need to change the sample rate while my program is running.
 
I have tried to put the DAQmx Timing.vi inside the while loop (configure the sample rate everytime during the loop), but the buffer size is too small even though I have changed the buffer size to a very large value (in order to achieve the goal of my experiment, I can not change the number of samples per chanel).
 
I am using the internal clock in my program right now.
 
I am using PCI-6259M DAQ card, and SCB 68 connector block.
 
Are there any other ways to solve this problem?
 
Thanks very much
 
Xiaojun
0 Kudos
Message 1 of 7
(3,846 Views)
I have not tried to change the sample rate on the fly but you may need to stop the DAQ task, change the sample rate, then restart the task.  Just an idea but not sure what the root cause of the issue is.
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 7
(3,832 Views)
Two other ways which might work:

One is to always sample at the faster rate and simply discard the unwanted data to get the equivalent of the slower rate. If your computer is not too busy to keep up this approach may be more convenient than reconfiguring the sampling.

Another approach is to put the same data into different input channels and set up separate tasks at different rates. Then call the appropriate task according to the desired rate. This requires that your A/D device has enough channels that the same data can go to more than one. If you adopt this approach make sure the source impedance for your signals is low enough to drive both inputs simultaneously.

Lynn
Message 3 of 7
(3,826 Views)

You very smart Lynn Smiley Happy

Excellent suggestions

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 4 of 7
(3,821 Views)
Thanks, Mat and Lynn
 
If I choose the first method, I think I might try to average the data instead of discarding the unwanted data.
 
If I choose the second method, should I stop the previous task before I start the new one? And how to stream data to the same file continously after the sample rate is changed?
0 Kudos
Message 5 of 7
(3,813 Views)

johnsold

 

''One is to always sample at the faster rate and simply discard the unwanted data to get the equivalent of the slower rate. If your computer is not too busy to keep up this approach may be more convenient than reconfiguring the sampling.''

 

can i ask what you mean by discard the unwanted data, this is for changing number of samples on the fly.
Thanks

0 Kudos
Message 6 of 7
(3,329 Views)

First thing: You are replying to a way old thread, which is not encouraged.

 

To your question: Discard the unwanted data also means take only the required data. So in an acquisition of 1KHz signal if my requirement is just 10 Hz I can take one sample with an interval of 100 samples. This may or may not be averaged based on the requirement.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 7 of 7
(3,323 Views)