1

gyroscopes which measure rate of rotation of angles when integrated produce angles right? my question is how do i do this? what im doing so far is just adding all the angles ive detected and that seems to be very wrong

AngleIntegrated = GyroDegPersec * (1/GyroBandWidth);

suggestions are very welcome. thanks

user571099
  • 1,491
  • 6
  • 24
  • 42

3 Answers3

2

You need to integrate with respect to time. So ideally you should sample the gyroscope at regular (fixed) time intervals, T, and then incorporate that sampling interval, T, into your integral calculation.

Note that T needs to be small enough to satisfy the Nyquist criterion.

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • thank you for replying. im sampling my gyroscope as soon as it has new data to offer, going by its bandwidth of 50 hz. im sampling at (1/50) seconds. what should my code be to actually perform this integral calculation? – user571099 Jan 11 '11 at 11:53
  • 1
    @user571099: OK, if `1/GyroBandWidth` is your sample interval (`T` in my answer above) then yes, your calculation is essentially correct. However note that for accurate results you should probably implement a proper integrator, rather than just summing. – Paul R Jan 11 '11 at 12:00
  • sorry for being noobish, how do i do a proper integrator? im only using c. i cant think of any other way to do integration other than summing – user571099 Jan 11 '11 at 12:03
  • @user571099: normally digital integrators are designed to have a frequency response which eliminates the problem of accumulating any small constant error in the input signal (a small DC offset will obviously get accumulated into a large error value over time if you just keep summing). – Paul R Jan 11 '11 at 12:13
  • suppose ,in C code sir, how do i perform a digital integration? – user571099 Jan 11 '11 at 12:32
  • A frequency response filter only helps to reduce or eliminate error terms ε(t) at frequencies where they dominate the real ω(t). And obviously a constant ε only has frequency 0. So, if your measured data has a DC component, this will inevitably be lost by a filter that eliminates the constant ε (has a pole at f=0) – MSalters Jan 11 '11 at 12:36
1

You can integrate in discrete domain. Suppose the angular rate is da, it's time integral is a. k is the discrete step number.

a(k) = a(k-1) + T*0.5*(da(k) + da(k-1))

For example, da(k) is current angular rate reading. da(k-1) is previoud angular rate reading. a(k-1) is the previous step's integration value(rotation angle). T is sampling rate. If the sensor outputs in every 1 millisecond, T becomes 0.001.

You can use this formula when k>0. The initial value, a(0), must be given.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
Husnu
  • 11
  • 1
0

Knowing that of course you can't count on having a correct value in the long run (by integration your error window will always increase over time) what I would do is reading the gyroscope, interpolating the current read and previous few ones to get a smooth curve (e.g. a parabola using current read and previous two) and then computing the integral of that parabola from last read time and current time.

6502
  • 112,025
  • 15
  • 165
  • 265
  • thanks for the reply! is that something like RungeKutta 2nd order sir? – user571099 Jan 11 '11 at 11:52
  • Runga Kutta uses 4 points, so the current and previous 3. As a result, it does give a good estimate of the value 1.5 periods ago. This delay is the price paid for a better estimator. You can decrease the delay by altering the weights, but this also decreases the quality of the smoothing. – MSalters Jan 11 '11 at 13:01
  • @MSalters and 6502 Do you have any example of such implementations? – sam Sep 03 '12 at 17:27
  • @sam: It's so trivial I don't bother, just `(1*x[-3]+3*x[-2]+3*x[-1]+x[0])/8` – MSalters Sep 04 '12 at 06:39