LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i reduce the sample rate of a task

Hi all. very new to Labview so please excuse me if this is a simple question.

 

I have an NI-9237 which has a minimal sample rate much higher than I can use for the test I have designed.

 

I would like to be able to control the sample frequency in the range of 100 samples per second down to 1 sample per 60 seconds. The reason for this is that I need to be able to run the test for several days. I have been using the "Strain - Continuous Input.vi" as the backbone of my program and have had no luck in trying to change the sample rate. 

 

On the forums there have been posts regarding methods of resampling but I can not figure out how to get the task/TDMS file to record a modified signal.

 

Any help would be greatly appreciated.

 

0 Kudos
Message 1 of 10
(5,441 Views)

Downsampling is essentially just combining a whole bunch of points that you have too many of down to a smaller set. So if you want to go from 1Hz to 1/60Hz, you would take 60 data points and average them (or however you want to combine them) down to one point.

 

With respect to your VI, there is a Sample Rate input. Have you played with this? I think your device can probably only go as low as 0.1Hz, so you would have to do some downsampling to get 1 data point per minute.

 

Your task won't record a modified signal, the downsampling is done by your code after you read in the values. This might help.

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 10
(5,436 Views)
You could also simply use the 1Samp option for the DAQmx Read with a Wait (ms) or Time Delay function to control the timing. There will be some jitter but with 1 sample pet minute, I can't imagine that you would be concerned about that.
0 Kudos
Message 3 of 10
(5,418 Views)

Thanks for your response.

 

Unfortunately it seems the NI-9237 is limited to a minimum of 1.613kHz Sample Rate, which I find very frustrating. I have tried forcing it lower with the sample rate input but it will maintain 1.6129kHz. The downsampling example you guided me to works somewhat, which I hope I can make do in a pinch. So far I can't get it to continuously log lower than 10Hz (while a significant improvement I still don't understand why that is the limit), maybe if I put two in sequence?

 

Adding in a wait function does not seem to work. The recorded array data seems to act erratically; the samples either keep the high frequency sampling rate or don't log at all. 

 

Thank you again for your help!

0 Kudos
Message 4 of 10
(5,317 Views)
The wait will certainly work. You are obviously doing something wrong but you have not posted your code so someone can see.
0 Kudos
Message 5 of 10
(5,304 Views)

Hi Sunkistlist,

 

Unfortunately it seems the NI-9237 is limited to a minimum of 1.613kHz Sample Rate, which I find very frustrating.

Well, you could have read the manual before using this module, it's all described in there…

 

To have 100S/s you need to decimate by a factor of 16.

To get from 100S/s to 1/60S/s you need to decimate by a factor of 6000, but I would use two steps (down to 1S/s, then 1S/min) for display reasons…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(5,239 Views)

Thank you for your reply, I need all the help I can get hah! Obviously something is wrong, I just don't understand why or where. To clarify: I did not design this project, the DAQ was purchased without my input, though I can't say I'd have purchased something different. I would have just assumed LabVIEW would have tools easily available for such a problem. Honestly I'm just trying to do a quick patch job for a co-worker. End of line: "sub-optimal conditions Captain".

 

To Dennis_Knutson:

 

I'm including my code which I should have done previously but was too frustrated, I apologize. I have run the program several times with the delay and it turns out to be ~161(+-3) samples/second... Including the DAQmx Read with the delay/while loop will allow me to adjust how many total samples are recorded but the rate remains unchanged regardless of the wait time.

0 Kudos
Message 7 of 10
(5,175 Views)

Hi Sunkist,

 

Including the DAQmx Read with the delay/while loop will allow me to adjust how many total samples are recorded but the rate remains unchanged regardless of the wait time

- The delay has NO influence on sample rate…

- Including the DAQmxRead in the second loop is no good idea, even when you force the execution order by DATAFLOW as you do now…

 

turns out to be ~161(+-3) samples/second...

What6 is the sample rate as shown in your indicator? I don't see any place where you decimate your samples…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(5,163 Views)

I don't have LabVIEW on my phone but if you did not change to 1Samp like I said, then of course your code will not work. with 1Samp, your rate is equal to the wait value.

0 Kudos
Message 9 of 10
(5,148 Views)

Hi GerdW,

 

Thanks for your input. I don't like having the Read in the second loop either, I was trying to isolate the logging loop from whatever buffer the 100 samples per loop Read maintained. If I switch the Read to 1Samp it will only log one sample even within a while loop with append=T which I don't understand why.

 

I mistyped on the sample rate. It is still 1613Hz I was just surprised there was some variance (albiet small).

 

Thanks again!

0 Kudos
Message 10 of 10
(5,138 Views)