Hopefully this is an easy answer. I have a sinusoidal waveform and I want to take the double integral of it. i.e. I have acceleration and I want position. When I do it in LabVIEW I get weird results. Why isn't my position sinusoidal? What am I doing wrong?
As Sir Ben said, small offsets in data will lead to wild swings when you do the integral. A few solutions:
EDIT: (2 pi f)^2 for d
Yes I have looked up the calculus and saw the C. Its been a while...
A little more background my customer has an accelerometer that we are acquiring data from. They want to know the displacement. Performing a double integral on the accelerometer data should give me the displacement. I am expecting a sinusoidal displacement signal. That is how the UUT is actually moving. The accelerometer data is sinusoidal. I made this quick VI to test my math. I am confused at the results I am getting and what math I need to calculate displacement.
What does remove mean refer to? DC? Shouldn't the High Pass filter get that too?
Yes and Yes, I like to do both even though it may not be necessary. Doing the calculation in frequency space is much easier, no filters or DC removal.
It sounds like you are expecting a harmonic solution, but you are not providing the proper boundary condition. Using the default initial condition for the velocity (1st integral), implies v(0) = 0. For the harmonic solution, v = 0 at the extrema of the acceleration, so if you set the phase of your acceleration waveform to 90 (or 270) degrees you should see what you are expecting.
Also keep in mind there is no such thing as a "zero" in real world measurements.
And even if you found the offset, real-word values drift ever so slightly and they will pile up and you are right back where you started, trying to figure what the correct "C" should be.
Changing that phase is better. However how do I set the initial conditions? I don't have the luxury of manipulating phase to get the desired results. I set the initial conditions in the integration VIs but still don't get expected results when using 0 phase