Then you should get an angle very close to the first one!! It is not as precise as the first one, but that kind of precision is only important if you are building a balancing robot or something like that.
The resolution will also only be 180 degrees.
This shows some pretty decent output which leads me to believe that my unit could be broken as the Yaw value doesn't change at all when I rotate around that axis. I noticed that on the sparkfun page for this item, someone else had a similar problem. I've emailed the chap from the link above in the hopes that I can figure this out. At the moment, the lack of decent/any yaw (no need to use a magnometer just yet) is halting my project Im wondering if there is something else im missing here. I've tried the kalman filter approach as well and that seems worse than just using the raw gyro values :S
Yeah, I've done a little more research and I see what you mean. I guess i just need to integrate over time for yaw off the gyro and then reset when the drift gets too much... until maybe I get a magnetometer as well!
Is it possible to also use the kalman filter for only an accelerometer? It will only use one axis (of the three available). I just need a smooth movement of the servo I'm using
You can not use the kalman filter with only one input. Sorry but you need a gyro too, that is why it called "sensor fusion"
You could perhaps use some other kind of smoothing algorithm.
Hey Lauszus, I finished my final year project in college. I thought I would show it on here so people can see what can be done with the code and sensor. Thanks again for you help!
Lauszus:
You can not use the kalman filter with only one input. Sorry but you need a gyro too, that is why it called "sensor fusion"
You could perhaps use some other kind of smoothing algorithm.
The accelerometer can measure the roll and the pitch, but not the yaw. The gyro can measure both the roll, pitch, and the yaw, but all these will drift. In total that gives only the roll and the pitch. You need a magnetometer to measure the yaw too.
Ok thanks for the clarification...
one last thing: in my project there is actually one movement which I won't need to do: which is the "pitch" on the image I've posted earlier.
I'm guessing that all I need to do is position the sensor perpendicular to ground
hence transforming the yaw (which I wouldn't need) into the pitch
and your code would still work...is that right?
would it work if I shift the frame of reference in such a way or the code measures pitch and roll in reference to the force of gravity?
No that is not correct. The thing is that the accelerometers can not "see" when rotate the IMU along yaw. So it will not make a difference if you just rotate the sensor. Remember that it measures acceleration, which I use to measure Earth gravitational force to calculate the angle. You can also use a accelerometer in for example a rocket to measure the acceleration of the rocket.
I am not sure that I understand your second question?
ok let's check with an image
I really don't understand why one parameter can't be measured if it's said to be a 6DOF and not a 5DOF!?!?!
moreover gyroscopes measure angular velocity around themselves...not influenced by the force of gravity :~
I made it very simple
can you please answer the questions at the bottom simply with a Y or N?
in your setup (I'm deducing) can the following be measured???
1.1 Yaw = N?!?! right?
1.2 Roll = Y
1.3 Pitch = Y
1.4 - 1.5 - 1.6 = x y z = Y Y Y
In my setup - can the following being measured??
2.1 - old Yaw - new Pitch = Y? N?
2.2 - Roll = Y
2.3 - old Pitch - new Yaw = Y? N?
2.4 - 2.5 - 2.6 - x y z = Y Y Y
What I really need for my project is (considering the my sensor positioning pictured right)
to be able to measure
x, y, z, ROLL, and PITCH (old yaw, blue line)
It is right gyros are not affected by the gravity only accelerometers!
Okay you have to understand that just because you rotate the sensor does not mean that you can measure yaw. So your answer is:
1.1: N
2.1: Y
2.3: N
No matter what you can NOT measure yaw with a accelerometer, unfortunately If you only need a estimated angle you could just use the gyro, and then keep calibrating the zeroValue.
If you need to know the exact angle of the yaw, you have to use a 9DOF!!
Hopes that was what you needed to know or just post another comment, and I will gladly help
Nice hand drawing btw
ok thanks for your reply
my fault I should have made it clearer: when I asked if it could be measured, I meant the ANGLE...not the acceleration
It's clear (sort of ): you can't measure yaw with the accelerometer...but I was thinking with the gyro...and as you said you can.
in Fact at the end of your code you are only calculating x and y angles and not Z angle...is there are reason why?
Moreover...when you say "keep calibrating the zeroValue"
you mean that after the previous calculation I set the
gyroZeroZ = zAngle? so I keep calculating incremental angle variation?ΓΉ
or do you mean to take out the comments to the line
gyroZangle=gyroZangle+gyroZrate*dtime/1000;//Without any filter
why did you leave that commented? it wasn't working?
Anyhow, thanks a lot for the help
if you ever need a quick hand drawn sketch (dirty and quick) just ask
You can not measure the yaw like that. The problem is that accZangle is not correct. Because accZangle is not affected when rotation the sensor, as I described earlier.
When I wrote calibrating I mean that you should keep doing this:
gyroZeroZ = calibrateGyroZ();
The reason why I outcommented it, is because it drifts, and I do not use it anywhere.
Although it uses one more sensor (the magnetometer) I found this guy's work pretty amazing - the FreeIMU (library and hardware)
an Arduino library for reading the 3 sensors (the accelerometer and gyroscopes are the same as yours)
and performs all the sensor fusion needed for a simple interface