From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Math behind the SubVIs

Hello,

I have a file that has an array of values from a accelerometer. In other words, I sampled at 5000 samples/sec and stored all the values from an trasducer for a period of about 2 mins.

 

So basically the file has 2*60*5000 values of the transducer.

 

I was trying to play with this array to be able to decode it. I randomly applied certain SubVIs given in Lab-View, and finally found the right combination to decode the data. I have the VI ready, but cannot figure out what do the SubVIs mathematically do to my array to get the VI working correctly.

 

  1. I took the array from a file and fed the array of values to the Derivative x(t).vi. What does this SubVI do to my array of values!! And how does the math work for discrete values in the array?
  2. I took the output from the previous SubVi and fed it into Peak Detector.vi. I took the output from it named ‘2nd Derivatives’. This flipped all my +ve values from the previous SubVi to -ve values. How did this happen?
  3. Then I took this data and ran it through the Filter SubVi.

I chose the following options in the SubVI:

·        Smoothing

·        Moving Average

·        Rectangular

·        Half Width of Moving Average= 200

What do these parameters really do to my data?

 

The above combination helped me decode my data

I would appreciate it if you could explain me the math in the above 3 steps.

Thanks.

0 Kudos
Message 1 of 10
(3,549 Views)


DJ101 wrote:

I randomly applied certain SubVIs given in Lab-View, and finally found the right combination to decode the data.


That is an interesting approach and should statstically take forever because you have a nearly infinite number of combinations. There has to be a more targeted way. 😄

So, you have a 3D array (2x60x5000) and none of the tools you mentioned (derivative, peak detector) should even work with it. They all can only handle 1D arrays! I suspect that there is a lot of information you're not telling us. Maybe you could attach your VI?


@DJ101 wrote:

What do these parameters really do to my data?


Every single subVI has a help page. Just right-click on its icon on the diagram and choose "help"

Usually the problem is opposite: You know what you want to do, but don't know how. Here you randomly do something and by some miracle the result looks right. How can you possibly know that you are doing the right operations if you don't understand the operations??? 😉

 

0 Kudos
Message 2 of 10
(3,541 Views)
you have a 3D array (2x60x5000)

That's not what he said.

He has a 1-D array that is 2x60x5000 = 600000 samples.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 10
(3,532 Views)
Maybe you're right....
0 Kudos
Message 4 of 10
(3,527 Views)
"So basically the file has 2*60*5000 values of the transducer."
By the above statement I meant the file has a 1D array that has 2min*60secs*5000samples= 600,000 values.
 
Its the math in the 3 steps that is being applied to that array is what I am not able to understand.
Thanks.
0 Kudos
Message 5 of 10
(3,523 Views)
Do you know what the term "derivative" means?

I'm trying to figure out what you want to know.

The two-cent definition is the rate of change of something. Consult the HELP window for the DERIVATIVE vi.

If you're measuring acceleration, the first derivative is speed, the second derivative is position.

Noise on that signal will eat your lunch, however.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 10
(3,517 Views)

Ya,

its the noise that was killing me.

I filtered the data, and the results improved.

Thanks

0 Kudos
Message 7 of 10
(3,514 Views)
OK, but beware of filtering too much. If you're sampling at 5000 Hz, then presumably you're interested in high-speed events.

You can make the results look prettier by filtering, but that doesn't make them right.

The derivative function is sensitive to noise, and 2nd derivative especially so.

You should start by asking what frequencies you are really interested in, and lower your sample rate to accommodate that.

Then filter accordingly, but carefully.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 10
(3,509 Views)
I am no mathematician, but the acceleration IS the second derivitave of position.  If you want velocity and position calculated from an accel sensor, you will be integrating not deriving... no
 
Chris Co.
0 Kudos
Message 9 of 10
(3,506 Views)
You are correct - my earlier post was wrong.

You integrate the acceleration to get speed.

You integrate speed to get position.

And DC OFFSETS will eat your lunch here.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 10 of 10
(3,481 Views)