LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling without interpolation?

Solved!
Go to solution

I would like to sample an incoming signal at a frequency determined by user input (and this frequency must be able to change throughout the program). However, all of the sampling VIs I have found interpolate values between the sampled points. However, I would like to simply delete them.

 

The initial signal enters through the DAQmx at a rate of 1500Hz with a sample count of 1000Hz.

 

Is there a VI that will let me do this, or is there another method that anyone can recommend? I am relatively new to Labview, so I might be missing something obvious, but I haven't been able to find what I need through my searches.

0 Kudos
Message 1 of 6
(4,603 Views)

It is not quite clear to me what you are trying to do, I think you are mixing your terminology a little bit.

 

Are you trying to change the hardware sample rate (so that your DAQ task samples faster or slower)? 

OR

Are you trying to take data sampled at a constant rate and re-sample it to a different frequency (by removing or adding samples)? -in this case, there are VI's that will do what you are asking, including removing samples, but it would have to do interpolation to find estimated values at the new x-axis location of your new samples unless the target sample rate is an even fraction of the original sample rate.

 

e.g. If your hardware samples at 10Hz (10 samples per second) and you want to resample the data to 5Hz, it would keep every other sample from your incoming data since the x coordinate of every other 10Hz sample would line up with your 5Hz target. On the other hand, if you trie to resample to 3Hz, it will have to do interpolation to estimate the y-value at the x locations that do not exist in your original sample stream.

 

QFang
-------------
CLD LabVIEW 7.1 to 2016
0 Kudos
Message 2 of 6
(4,590 Views)

I will give an example to make it clearer.

 

For example, I have a 1Hz signal, and I would like to extract 10 points at equally spaced intervals from the signal. So, I would have to extract a point every tenth of a second. For my result, I would like to have 10 points that I can put in a table. Only the y value is important; the timing does not matter for the table.

0 Kudos
Message 3 of 6
(4,587 Views)

Do you know the frequency of the signal you want to sample? Synchronized sampling without a reference frequency can be quite tricky, depending on whether the signal frequency is stable and how much noise is on the signal.

 

Lynn

0 Kudos
Message 4 of 6
(4,579 Views)
Solution
Accepted by topic author Laura121

In that case, can you keep your sample rate constant, then just read out every x'th sample from the returned array?

 

For example, your hardware samples at 1500Hz, you want data at 500Hz (user changeable) so you take every 1500/500 = 3rd sample from the data that is returned.

 

While not necessarily hugely efficient, for the rates we have talked about here, you could easily do this by using a for-loop and rebuilding a downsampled array similar to the snippet below.

Note that if you don't allow interpolation and you don't care about the time(s), this may work for you, or it may not. The for-loop method allows you to tweak it to do what you need, including if you want to change the numbers to string etc.

The built in function is possibly much more efficient, but I don't know if you need a special toolkit or not for it.

Both are shown in the snippet.

 

sampling snippet.png

QFang
-------------
CLD LabVIEW 7.1 to 2016
0 Kudos
Message 5 of 6
(4,572 Views)

What about using reshape array as follows?

 

reshape2.png

 

It's basically decimating the array, but by a dynamic number rather than by changing the Decimate primitive.

 

Edit - I'd bet it's quicker, but I could be wrong.


Edit 2 - Missed the alternative code which uses the Decimate Waveform, which is far better again 🙂

---
CLA
Message 6 of 6
(4,565 Views)