LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help developing something...

Hello Everyone! I really need help developing a 16-sample moving window on an input signal. for each iteration that goes by, the window needs to be able to move one sample to the right. For example, 0 to 15 for the first iteration, 1 to 16 for the second iteration, 2 to 17 for the third iteration, etc. The window needs to be able to sample the signal as well with 16 samples total for the moving window. I am having such a hard time since I was able to make that moving array but being able to make a window out of it and put that window on an input signal is proving to be very hard. Please help me out!

0 Kudos
Message 1 of 13
(730 Views)

Hi Pete,

 

what have you tried and where are you stuck?

Why don't you attach your code?

Best regards,
GerdW


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

Sounds like you could just use the Mean PtByPt VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 13
(662 Views)

It looks like you need a circular buffer, the PtBy Pt does that,you can implement that using a while loop with shift register without initializing it. 

 

The buffer is a subvi, with a while loop with a shift register (don't initialize it). 

Inside the loop, there is a case structure wired to a control coming from a iteration. 

For the iteration =0, the initilize array will create a 15 size array with all the same element from your sample, 

LVNinja_0-1723641856751.png

 

As the iteration increases from 1 .. the case has a replace array subset, 

 

Use a quotient /Reminder to divide the iteration by the number of samples, returning the floor of the division, that number will be wired to the index of replace array. 

At every new sample, the floor of that division will point to the next position of the array (your buffer). You could use it to then calculate an average (called moving average of your 15 samples. 

 

LVNinja_1-1723642040287.png

 

 

0 Kudos
Message 4 of 13
(650 Views)

The buffer.vi is then called as a subvi. 

LVNinja_0-1723642287014.png

 

0 Kudos
Message 5 of 13
(649 Views)

So what do you need to do with the data in the moving window? (average? linear fit? get standard deviation? find min&max? just display it in a graph? something else?) This will determine the best approach.

 

What should happen before you have 16 points? (truncated? Padded?)

Also, what kind of data is this (dynamic, scalar, waveform, etc. etc.) and how does it arrive?

Message 6 of 13
(631 Views)

I am basically trying to use the data in the moving window to Plug into the one-cycle cosine filter I linked below. The value that I am plunging in for is x(k), basically the input single and sample k, but this window needs to be constantly moving to the right 1 sample each iteration meaning the value of k will always be changing and therefore the data at y will also always be changing. I hope this clears stuff up. The input will just be a standard sine waveform that would ideally have noise to isolate the fundamental frequency which is what the one-cycle cosine filter does but for now I am just working with a 1 amplitude 60hz sine wave generator as the signal input to make sure the frequency between the input and output line up. 

 

 

0 Kudos
Message 7 of 13
(606 Views)

Please look at the reply at one of responders on this post, I hope it'll clear stuff up!

0 Kudos
Message 8 of 13
(599 Views)

Hi Pete,

 


@Havordpete wrote:

I am basically trying to use the data in the moving window to Plug into the one-cycle cosine filter I linked below. The value that I am plunging in for is x(k), basically the input single and sample k, …


I don't see the need for a "moving window" in this formula.

You already have a waveform (consisting of several samples) and could easily apply this formula to your array of samples!

 

Suggestion:

 

Best regards,
GerdW


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

Thank you so much for the solution Gerard!! Before I ask any questions about your setup, is it possible to attach the code script for your setup? Or make some kind of VI and attach it in your message? I would greatly appreciate it! 

0 Kudos
Message 10 of 13
(539 Views)