LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sychronize time in the waveform graph based on variable time interval DT in 1D array

Solved!
Go to solution

Hi Guys, 

I have two signals - original and resampled along with time interval for time dT. 

I want to space out the x axis time according to the variable time interval dT from the 1D array. 

1) Can anyone please point me in the direction? For the filtered current waveform, 1D array should replace zero in the blue color. I tried for loop but it does not allow me to connect the waveform graph later. 

Hk637_2-1736958665350.png

 

Hk637_1-1736958372160.png

 

The blue waveform has dT= 0.1 sec and the total time it should show = 3500 sec but it is showing 350000 sec. 

2) How can I correct it?

Thanks in advance. 


 

0 Kudos
Message 1 of 13
(274 Views)

Hi Hk,

 


@Hk637 wrote:

1) Can anyone please point me in the direction? For the filtered current waveform, 1D array should replace zero in the blue color. I tried for loop but it does not allow me to connect the waveform graph later.


A waveform only supports a fixed dt.

It will never accept an array of different dt's…

 


@Hk637 wrote:

Hi Guys, 
The blue waveform has dT= 0.1 sec and the total time it should show = 3500 sec but it is showing 350000 sec. 

2) How can I correct it?


Are there 3.5M elements in the data array? How many samples are there to plot?

 

You know we cannot edit/run/debug images in LabVIEW!? Why don't you attack some sample code???

Best regards,
GerdW


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

Hi  

 

you can get the VI here:

 

https://drive.google.com/file/d/1TncI5GfhGAbxYascmcRzPs6QRvD7sU2-/view?usp=sharing

 

Cumulative addition.png


I tried to use "for loop" and use cumulative addition of array to get the time. But it did not work. This time, I used x-y graph (x-time, y data). But, time seems not coming properly. 

Actual total time = 3200 sec 

From all the element, I resampled and took around 380 current sample. 

Also, plotted the original data set with dT= 0.1 sec spacing given that I need x axis = total 3200 sec as the total time. For this operation, I used the cluster and waveform graph. 

Thanks in advance for point the direction. 

0 Kudos
Message 3 of 13
(233 Views)

Hi Hk,

 


@Hk637 wrote:

you can get the VI here:


Well, you can attach VIs directly with your message, no need for 3rd party hosters with limited lifetime of the attachments!

Another point: you are using the latest LabVIEW version! did you notice the last line in my message signature? Please use File->Save for previous to reach a broader audience! (I prefer LV2019.)

 


@Hk637 wrote:

I tried to use "for loop" and use cumulative addition of array to get the time. But it did not work. This time, I used x-y graph (x-time, y data). But, time seems not coming properly. 


Please define "not properly"!

 

You forgot to answer my questions from previous message…

Best regards,
GerdW


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

You have two "Legacy waveforms", i.e. a cluster of t0, dt, and [y] ([Y] can be a 1D or 2D array).

 

You can easily create an array of those for two different plot spacings in the same graph. However the spacing for each plot must be constant.

 

If at least one of the plots has an uneven X spacing, all you need to do is use an xy graph.

 

(It is silly to show a diagram picture where most values are not even visible.)

 

 

0 Kudos
Message 5 of 13
(220 Views)

@Hk637 wrote:

Hi  

 

you can get the VI here:

 

Cumulative addition.png


I tried to use "for loop" and use cumulative addition of array to get the time. But it did not work. This time, I used x-y graph (x-time, y data). But, time seems not coming properly. 


That code makes absolutely no sense!

Typically resampling is used to turn data with uneven time spacing into data with constant dt. You seems to go the other way. What's the purpose? What are the sizes if the two arrays?

 

As has been mentioned, attach your code after "save for previous (2020 or below)" and make sure all controls contain typical default data.

0 Kudos
Message 6 of 13
(216 Views)

Hi 

I attached the compatible version with 2016 here. 

The total number of sample was 3 Million, I divided it into 4 uneven segments with different sample rate and decimate the 3M signal down to 389 sampled signal. The goal was to give user choice to choose segments and take samples as they want. 

That's why dT is uneven. As those dTs are appended from the 4 segments with uneven sample rate. 

You can see that X-Y curve are giving correct timing but it messes up when I use the code as subVI. 

However, the Original Current Waveform should end at 3200 sec where it is showing 350000. 

Should I take original time frame and the current value then use x-y curve ?

My ultimate goal is to compare two different curve in a same waveform to check how the original and resampled curve look like. The time in the x-axis should be same for both curve. 

Probably, I would be nice if you can point me to an alternative solution for the time array for x-axis or correct the code. 

Thanks.

0 Kudos
Message 7 of 13
(199 Views)

This does not make a lot of sense.

 

A point does not have a dt, that requires two points. So the various input signals (before decimation) all have their t0 and a dt. This means that you can calculate the absolute time for each point. Are the t0's aligned?

0 Kudos
Message 8 of 13
(190 Views)

All the resampled data has same t0. 

 

After making 4 different resampled data segments, I concatenated them in a array. Then I calculated dT between two consecutive points taking the spacing/distance between them. 

0 Kudos
Message 9 of 13
(180 Views)

Hi Hk,

 


@Hk637 wrote:

However, the Original Current Waveform should end at 3200 sec where it is showing 350000.


Your "original current waveform" contains ~3.4M samples, this gives a time of ~341k seconds with a dt of 0.1. Simple math, right?

 

The "filtered current waveform" has 389 samples, they give a total of 1945s with a dt of 5 - as shown in the graph…

 

Your FOR loop to create an array of time values is pure Rube-Goldberg (and uses wrong math). See this suggestion:

Why do you subtract 1 from the loop iterator value?

Why do you need to apply the Abs() function? (Oh, I see: there is a large negative value at the end of the dt array! Where does that value come from? Is the calculation of that array wrong, too?)

 

Best regards,
GerdW


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