LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interpolate multiple timestamps to one single value + downsampling of the aquired data to a fixed frequency?

Solved!
Go to solution

Hello together, I'm using a Keithley 2700 to acquire measurement values sequentially on 6 channels (sampling frequency of the entire array approx. 5 Hz) and in parallel I'm using a NI PIC-6133 to acquire another 2 channels with a sampling rate of several kHz. Due to the sequential sampling of the Keithley each channel has its own time stamp, the simultaneously sampled channels of the 6133 another. I would now like to interpolate these raw data in such a way that there is only one time stamp for each acquisition of the measured values. Additionally I want to reduce the sample rate, e.g. by specifying a different sample rate.

 

Current raw data:
Keithley_Value_A; Timestamp_A
Keithley_Value_B; Timestamp_B
Keithley_Value_C; Timestamp_C
Keithley_Value_D; Timestamp_D
Keithley_Value_E; Timestamp_E
Keithley_Value_F; Timestamp_F
6133_Value_G1; 6133_Value_G2; Timestamp_G

 

Desired interpolation and downsampling:
Keithley_A_new; Keithley_B_new; Keithley_C_new; Keithley_D_new; Keithley_E_new; Keithley_F_new; 6133_Value_G1_new; 6133_Value_G2_new; Timestamp_new

 

Is there a suitable interpolation function in LabVIEW that I can use to do this? Can anyone give me an example?

 

Many thanks for ideas and tips,
Michael.

 

---------------------------------------------

LabVIEW 2016 (PDS)
Windows 10
NI-PCI 6133
Keithley 2700 with GPIB

0 Kudos
Message 1 of 6
(3,648 Views)
Solution
Accepted by MichaGue_01

You can probably do this using a combination of Interpolate 1D Array and Threshold 1D Array. The basic idea would be to find out what fractional index of your original array is needed to get the desired time (using Threshold) then interpolate the values array using Interpolate.

I'd just caution you to be careful given the quite different sample rates about how you interpret your output - it may not really be "true", for example.

 

Below is an example showing this. Note that the last few points (in both cases really, but more noticeable in the slow -> medium case) are not even vaguely valid...

Example_VI.png

If you wanted to do more complicated interpolation (this is just linear) you can find VIs to do that under the Mathematics palette. The VI used here is the similarly named Interpolate 1D.

Example_VI.png

In this case, offset is set to 0 to better display the closeness of matching. "cubic Hermite" looks good for this set (sine, cosine) but the method probably depends on the input and perhaps your available time.


GCentral
Message 2 of 6
(3,595 Views)

Hello cbutcher,

 

I implemented your second example. With an artificial dataset it works very well. If I use a real dataset with an array size greater than 22049 values, no calculation will be performed. Do you have an explanation?

You can find my example in the appendix. The array has 27460 values for X and Y respectively. The calculation works up to 22049 values. If you increase the array length by one to 22050, no interpolated curve will be calculated. Why?

Many thanks for a tip.

 

Greetings Michael

Download All
0 Kudos
Message 3 of 6
(3,496 Views)

How odd! I can't look at this right now but I'll take a look when I get a chance.

 

In the mean time, does the "error" output from the interpolate VI return anything?

You can use Error Cluster from Error Code to get a normal error cluster from the number it returns.


GCentral
0 Kudos
Message 4 of 6
(3,484 Views)
Solution
Accepted by MichaGue_01

There is an error code being returned from the 1D Interpolate, -20145: "Each independent variable must contain the same number of values as the dependent variable."

 

It turns out your Y array has 27460 elements and your X array has 22459 elements. You don't get a graph because the Interpolation block errors out due to a lack of X data.

Message 5 of 6
(3,474 Views)

As MHawk nearly said, your Y array in the cluster (at least as it was attached) has 22049 elements.

 

As a result, the array subset makes them the same length when you have fewer than that number requested, but makes the X array longer than Y when you set a larger value.

 

Wiring Error Code to Error Cluster after the Interpolate describes this issue and allows you to catch it in your application and do something for the user (prompt, throw error, use the shorter length, etc).


GCentral
0 Kudos
Message 6 of 6
(3,451 Views)