# Integration of a Gyro signal ## Recommended Posts Hi,

I'm using the Labjack U12 and the DAQFactory Express software to acquire the signal of a gyro, which is measuring the angular velocity. Now I'm interested to get the angle. Therefore I need to integrate the gyro signal. Is there an easy way to do this online with the DAQFactory Express software, so I can display the integrated value?

TIA

Peter Knieling

University of Wuppertal

Germany

##### Share on other sites There are three normal ways to do integration with a signals at discrete times:

1) You curve fit to the data and integrate the curve

2) You do a boxcar integral

3) You do a trapazoidal

#1 is a bit tough and requires some finessing and is usually reserved for post-data analysis and is difficult to do in a real-time display application. #2 and 3 are rather easy:

#2: here we are just adding up each point in the y axis and multiplying it by the deltaT between consequtive points. When deltaT is constant, its really easy, but in DAQFactory its just as easy when deltaT is not constant. Lets assume you have MyChannel and want to integrate the last 100 points. The expression is:

Sum(MyChannel[0,99] * (MyChannel.Time[0,99] - MyChannel.Time[1,100]))

MyChannel[0,99] is an array with each data point value. MyChannel.Time[0,99] - MyChannel.Time[1,100] is an array with the deltaT for each point. Multiplying two arrays of the same size yields an array of that size. Then we take the sum and we're there.

#3: here, instead of assuming each area between consequtive points has a flat top, we assume a trapazoid running from the top of one point to the next. The expression is not that much more complex, and the result it certainly more accurate:

Sum((MyChannel[0,99] + MyChannel[1,100]) / 2 * (MyChannel.Time[0,99] - MyChannel.Time[1,100]))

The deltaT part stays the same, however, the first part becomes the average of each consequtive pairs of data points. Remember, the area of a flat bottomed trapazoid is simply the width * average of the long and short lengths or width * (long length + short length) / 2

In DAQFactory you can put these expressions anywhere, such as a display value component to view the result. If you want to graph the integral over time, you'll need to store this scaler result in some sort of array. I recommend just using a test D to A channel and doing: MyIntegralChannel = Sum(...) in a sequence like this (for 1 second updates):

while (1)

MyIntegralChannel = Sum(...)

delay(1)

endwhile

Then you can graph MyIntegralChannel vs time.

#### Archived

This topic is now archived and is closed to further replies.