Guide to gyro and accelerometer with Arduino including Kalman filtering

Hi Lauszus, I bought the same gyro(Gyro Breakout Board - LY530AL - 300°/s - SEN-09165 - SparkFun Electronics) used by IMU on your project. I just want to read angle from the gyro but having a little confuse about the HP, PD and ST pin. Should I just left them all unconnect or do you have any suggestion?

~Thanks :slight_smile:
~Fino

You can just leave them all unconnected :slight_smile:

  • Lauszus

Hey Lauszus!

First off thanks for posting, this looks great and could be exactly what i need!

basically i am creating a ball full of different sensors which will then act as a synthasizer.this is my final year project and i am stuck here with only a few weeks to go. I have other sensors but what i really want is to be able to read if the ball is being tilted forward or back,left and right and by how much so i can modulate sound accordingly.( i am not trying to measure the acceleration,just the amount it is tilted)

i have been searching all the different possibilities with gyroscopes and accelerometers but can't seem to find clear cut examples of what i want. It looks like your code here is what i need? If i was to buy the 6dof is it as simple as using the code you linked? and then i would be able to get proper tilt values?

I am only a beginner with arduino and just know the basics of reading sensors but i'm finding the task of measuring tilt a bit deep for me.

your help or advice would be greatly appreciated!

(a final year college student freaking out lol) Billy.

Hallo bilbo-bongo

First of all: it sounds like it is exactly what you need :slight_smile:
You really don't need a 6DOF for your project. You only need 3 accelerometers and 2 gyros. But if you don't want to get your hands dirty, you can just buy the same IMU as me and just copy the code.
The only thing you need is some way of picking up the serial commands from the Arduino, exactly as I did with Processing.
Hope that gave you some answers :slight_smile:

  • Lauszus

cool!

Yeah i already have Pd reading the serial and picking up values from my other sensor (pressure) and modulating sound. It's just sensing tilt i couldn't figure out.

you have saved me!

I'm going to order one of those. i'm in ireland,hope it arrives in time!

thanks again!

billy.

Just order it from Watterott.com, it only took 3 days to arrive here in Denmark :wink:

perfect. even better!

Do you know what is the difference between the 70 euro one and the 50 euro one??? specs look the same and the name is the same??

thanks again :slight_smile:

looks like the 70 euro one is sold out anyway

The one that cost 70 euro, is the old one (look at the product number). The one that cost 50 euro is in fact the updated one. The only difference is that it "removes the high-pass filters which were creating some issues with the output." :slight_smile:

  • Lauszus

where's the code?

zip files under the youtube video. have to be logged in to see them i think

Hi chaps. I've been playing around with this board and the code and I must say, thanks for this. Its definitely been a big help.

Im porting this to C++ and Cinder for use in an experiment. I need to get all 3 axes represented though. Is there any particular reason that the Z Axis is not represented?

I notice that altering the Y rotation also alters the Z rotation on the Gyros but not on the Accelerometers. I believe I need to compute the Z somehow but I'm really not too sure on the math.

It is not possible to calculate the z-axis with the accelerometer. Remember that it measures earth gravitational force, and it does not change when you rotate the IMU horizontal. You need something like a magnetometer to calculate the last angle :slight_smile:
If you only need to see if it changes you can just use the gyro and then compensate for drift in the code.

  • Lauszus

Ok that can't be right surely? I get that its not a compass but its billed as 6 Degrees of Freedom which suggests Z. Indeed, its even marked on the board so surely, if can measure the other 2, this 3rd is nothing special. I mean, I own a pair of these vuzix glasses things and they only have a set of gyros and accelerometers. Im not after a direct heading, thats not a problem and I know we cant get that but we most definitely should be able to get the 3rd.

Not as far as I know. You can easily get the z-axis from the gyro, but it will drift. It is not possible to get the z-axis using the accelerometer.

  • Lauszus

Interesting. I need to look over this compensation for drift then. However, Im still not sure why one cant get acceleration on the Z axis (Im British though, so Z axis means depth to me but in this case, I believe we mean yaw). There is a yaw gyro indeed but it is claimed there is a yaw accelerometer as well. Why is it there if it can't be used? It seems confusing. Clearly I must be missing something.

Yes it is yaw (the rotation around the z-axis). The reason why you can not measure yaw with a accelerometer is because the gravitational force from earth does not change when you rotate the IMU horizontal. In theory you will not measure any difference at all, in pratical however you see the acceleration from the movement. I use the z-value from the accelerometer together with pitch and roll to calculate the force vector (this is theoretical 1, but in practice there is a small difference). I also use the z-value from the accelerometer to know when the IMU is tilted more than 90 degrees to both side, so I can get 360 degree resolution instead of only 180 :slight_smile:

  • Lauszus

.."while the accelerometer measures Earth gravitational acceleration (g) in three dimensions"..
not only, it measures the acceleration of the unit as well..P. :slight_smile:

Yes, I understand in the case of the accelerometer now. That does make sense. So, do you use the gyro at all for the Yaw calculation?

Pito: exactly! That is why you can not count on the accelerometer on short terms, because it is to unstable. For example it will jump all over the place if you shake it. That is why you have to combine it with a gyro, that do not change when you for example shake it.

Onidaito: I do not use it right now, but if you look in my code I actualy calculate the yaw. Just write Serial.println(gyroZangle); and you will see the yaw, but remember it will drift!