Hi, in order to complete a self-balancing project, i would like at first to get the most accurate angle.
From what i understood, i need and accelerometer and gyroscope. I bought an ITG3200 and a MMA7660FC.
Actually, i'm using a library from seeedstudio for the gyroscope but i have a question :
I integrated the angular acceleration but the problem is that even when the plateform the gyroscop is on isn't moving and i initialise it, it won't give a stable measure: it fluctuates from -9.7 to -10.0 degrees per second at some initialisation and -10.00 to -10.5 at some others.
This is kinda problematic because in my code i have something like : angle = angle + (dt)*(az+9.9505);
(the value is the average i calculated ) But sometime, when the "zeros" are from -10.00 to -10.5, it kinda fucks up my angle
First question: is this normal or should i get something totally stable ?
A lot people mention the fact that gyro drifts but i'm unsure if we are talking about the same problem.
I've seen a lot about complementary/kalman filter and i'm planning to use these to get a better angle but i would first like to know if my gyroscop is fine.
Other point : will only an accelerometer be enough to get something good or is a magnetometer needed as well?
Not sure if I can help any but I've been watching these Youtube videos lately...check out this one:
Pretty amazing self-balancing robot. The author has a dozen+ videos up on this robot balancing in different situations.
Also notice the Calculus on the whiteboard at the beginning...ugh it's been 14 years since I took Calculus & Diff.Eq.
You can try looking at (and I could be mistaken) something like (dθ/dt) or the change in the angle over the change in time.
*Edit: Looking back at your post I see you're using Calculus (and probably a lot better than I am with it right now...)
Hopefully the videos will help you.
Indeed it is mentioned in the datasheet : zero settings : to +-1 deg/s on final, so this is approximatly what i'm having, but i've seen people using it though.
What i need is someone who has this gyro to help me in the code or whatever to get it more stable accurate and reliable
And thomas, yea indeed this one is quite incredible but too bad it's in japan and i can't get to know what he is using (which gyro, accel, is he even programming with an arduino ?) so this isn't really helpfull but never min thanks anyway
If you're looking for some help, check this out, http://forum.arduino.cc/index.php/topic,8871.0.html this helped me a lot for the understanding and for what i need in term of filter but too bad i don't have same gyro !
Usually the first step is to measure the zero point and subtract that from all of your measurements.
You might also want to measure the sensitivity and correct for sensitivity offset. That's harder to do since you need to rotate through a precisely known angle.
Yep but my problem is in mesuring the zero :since the zero is different from one measure to one other and is never stable, it makes it all harder to simply substract it in code...
Maybe it's just a problem in the library i'm using but i've downloaded others and i can't get them to work...
I'm going to buy one other and try it... maybe mine is not working as it should..
The gyro will only give you rate of change of angle, and since it will always have an offset error, you can't measure angle accurately by integrating the gyro output. Use the accelerometer to measure the angle. However, the gyro (in the correct orientation) will provide you with a more sensitive measurement of rate of change of angle than the accelerometer can. So I suggest you use the accelerometer to provide the signal for the P and I terms in your PID controller, and the gyro to provide the signal for the D term.
Actually, you do not need to calculate the angle. You can use the gyro output itself as the input to a digital filter to calculate the motor input directly. You also do not need an accelerometer. You also do not need a Kalman filter. But you do need to model the motor and robot body in order to calculate the filter parameters using software such as Mathematica or Matlab to solve the system of differential equations. Or, you can use potentiometers or some means of adjustment to set the parameters of the filter on the robot without solving the system of equations.
You can see the controller that does no require an accelerometer on my website... http://nxtotherway.webs.com
dc42:
The gyro will only give you rate of change of angle, and since it will always have an offset error, you can't measure angle accurately by integrating the gyro output. Use the accelerometer to measure the angle. However, the gyro (in the correct orientation) will provide you with a more sensitive measurement of rate of change of angle than the accelerometer can. So I suggest you use the accelerometer to provide the signal for the P and I terms in your PID controller, and the gyro to provide the signal for the D term.
Gyro's aren't that bad! When I was playing with one I got reasonable stability with drift on the order of say 45 degrees in 20+ seconds
(stationary, worse if moving). Accelerometers will not give you anything like a good measure of angle when the thing is moving,
you certainly can't use them as the primary source of angle - that's what the gyro is for.
You need to combine the higher frequency information from the gyro (timescale of seconds) with the long term orientation
from the accelerometer (averaging out any actual acceleration and thus mainly representing the gravity vector).
You can think of this as a drift-correction signal from the accelerometer to the gyro.
You may want to be more sophisticated and gate-out the accelerometer entirely during periods of rapid motion / vibration.
You either do this in one 'dimension' (if rotation is about a single axis) or in three (all other cases). Of course one dimension
of rotation means one axis gyro and two axis accelerometer!
Three dimensions involves both gyro and accelerometer being 3-axis, and the maths involves DCM's or quaternions,
find a library! In one dimension its pretty intuitive: integrate the gyro to get raw angle, drift correct that using a low-pass
filtered angle from the accelerometer.
Try a time constant for filtering of several seconds.