LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sample Rate - Strain Continuous Input

Solved!
Go to solution

Good morning, 

 

I am just getting started using LabView and decided to use the Example Template Strain - Continuous Input.vi

 

Similar to this question and others, I have run into the problem that the actual sample rate seems to be fixed. I am using a NI 9237 for the strain gauges and the cDAQ-9171 as the chassis. Currently only using the first channel. No matter which value I change samples per loop or sample rate to, the actual sample rate remains at 1612.9 Hz. 

sbrink8_0-1715160434418.png

I am attaching the .vi file as well. 

 

Could someone please explain why changing the two values has absolutely no impact on my sampling rate? I have read through DAQ Device is Not Sampling at Specified Rate in LabVIEW - NI and DAQmx Timing and Sample Rates - NI but it makes no further sense to me. Why are there two control options if they do not do anything. I also tried adding a samples per channel indicator but it had equally no impact. 

 

In short, I would like to be able to adjust the control values so my actual sample rate varies. I would like to sample at 10-100Hz or somewhere in between if possible. Alternatively, could someone advise me on how to change the sample rate in the while loop instead (acquire data in the .vi part). 

 

 

 

0 Kudos
Message 1 of 15
(391 Views)
Solution
Accepted by topic author sbrink8

Hi sbrink,

 


@sbrink8 wrote:

I am using a NI 9237 for the strain gauges and the cDAQ-9171 as the chassis.

No matter which value I change samples per loop or sample rate to, the actual sample rate remains at 1612.9 Hz. 


Simple answer: read the manual for your NI9237 module, especially the paragraph on sample rates!

 


@sbrink8 wrote:

I would like to sample at 10-100Hz or somewhere in between if possible.


Choose a reasonable sample rate (like 2000 Hz) and decimate the resulting data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(387 Views)

Based on the text, I assume you wanted to tell me that 1612.9 Hz is the lowest rate the NI 9237 can sample, correct? 

Edit: I set it to 2000 Hz as suggested. 

sbrink8_0-1715161556688.png

If that is true, could you please advise me on how to decimate in the while loop if possible (to not have to save quite such large files). I thought about using a timer option in the while loop but not sure this is the best way to proceed. Plus also not familiar what an external time base refers to. 

 

0 Kudos
Message 3 of 15
(380 Views)

Hi sbrink,

 


@sbrink8 wrote:

Based on the text, I assume you wanted to tell me that 1612.9 Hz is the lowest rate the NI 9237 can sample, correct? 


Yes.

 


@sbrink8 wrote:

If that is true, could you please advise me on how to decimate in the while loop if possible (to not have to save quite such large files). I thought about using a timer option in the while loop but not sure this is the best way to proceed.


Why do you need a "timer option" when you want to decimate arrays?

You already get good loop timing by reading a known number of samples at a known samplerate! (Simple math: "#sample / samplerate = time" !)

 

See this:

Use Quickdrop and type "decimate" to find the function…

 

I cannot open your VI due to its LabVIEW version. Mind to downconvert (File->Save for previous) and save for LV2021 or older? (I prefer LV2019.)

I also cannot comment on why your NI9237 doesn't seem to support 2000 or 2500 S/s as it should…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(335 Views)

I played around with the decimate function after stumbling upon it on a different thread. I chose to set the factor to a control value, so I can change the rate as desired in my interface. In my test I changed the decimating factor to 2, which should half my data rate, correct? However, while it runs and provides me with less samples, somehow the value is a lot lower than I though (about 10-12Hz vs 1000 Hz). 

 

This is the attached vi V5:

sbrink8_0-1715166230779.png

 

Does this have something to do with the type of sample I am decimating? Currently, I am using the waveform data as it provided me with the time stamp and signal when connecting it to the write to measurement. Now, the first column remains zero which I believe tells me that the decimating does not work fully as intended. Do I need to change the signal input? I believe your example had dbl rather than wave format as input. 

 

I really have no LabView experience prior to this and appreciate any help. I added the .vi file in case there is a simple element that will allow me to convert from waveform to a different type and then successfully into the decimate element plus write to measurement file. 

 

I tried using the get-waveform-comp but then the wire ahead complained about incorrect signal type --> see attached vi V6. 

 

0 Kudos
Message 5 of 15
(322 Views)

Hi sbrink,

 

you didn't read my comment on downconversion…

 


@sbrink8 wrote:

Currently, I am using the waveform data as it provided me with the time stamp and signal when connecting it to the write to measurement. Now, the first column remains zero which I believe tells me that the decimating does not work fully as intended.


The Decimate does work "fully as intended". All those coercion dots don't work as you intended to have your code working!

(After the decimation you don't have a waveform with timing information, but just a simple array of samples…)

Best regards,
GerdW


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

I did not see it initially! Let me add the two files here in the older format. Apologies for this. 

 

 

0 Kudos
Message 7 of 15
(316 Views)

Hi sbrink,

 

please run this and tell us what you get in the "dt" and "Actual sample rate" indicators!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 15
(313 Views)

I changed the DAQmx to have the same signal type and this helped with connecting it in the configuration you have shown. 


Currently getting 0.0005 for dt and 2000 for the actual sample rate. 

Samples per loop is set to 1000. 

sbrink8_0-1715169344170.png

 

0 Kudos
Message 9 of 15
(300 Views)

Hi sbrink,

 


@sbrink8 wrote:

Currently getting 0.0005 for dt and 2000 for the actual sample rate. 

Samples per loop is set to 1000. 


So setting the sample rate works as expected!?

Best regards,
GerdW


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