arduino 9 axes motion shield


As far as the hardware that I’m using it’s based on a Arduino microcontroller on top of the Arduino, I have a shield that is connected to a radio, so that can send the data to and from the computer, through this little XD radio. As far as the inertial measurement unit itself, I am using a three axis accelerometer from Adafruit that LLS m30 3d failed HC and I’m. Also that has a three axis acceleration and also a three axis magnetometer and then I’m, also using that l3 g zero, two zero. Three axis gyro from Adafruit. With these two chips, I get the full nine degree of freedom well I’m, showing these actually, if you’re, just getting started with inertial measurement. One player out that it’s cell wrong, or I really recommend the three axis accelerometer from virtue of boat X, it’s, a very simple chip. You can get it up and running with about five to ten lines of code, very simple, digital, read and it’s. The easiest way to start playing around with these these are on the at UC bus there’s, some advantages of that, but it also slows you down a little bit if you’re just getting started. So let me go ahead and show you some of the results right now and I’ll start kind of the simplest thing, which is just the accelerometer and I’m just going to show you the raw signals coming off the x axis y, axis and z, axis acceleration, and What you can see is the pink as the x axis.

The green is the y axis in the blue is the z axis, and these things are really easy to get going, and you can see that you just get data string off this thing very nicely and if you start playing around with it, for instance, if I Go like this, you can see that that is the x axis, which is pink. You can see that I get a nice big acceleration signal. As I move the device now you might see a little bit of noise and the other two axes come to find out. These chips have very good cross access isolation, but it just as I’m playing with it’s hard for me to move it precisely in the x axis. And so, if you see noise on one of the other axis signals that’s more how I’m moving it and not a fundamental limitation of the chip. If I can align it better, I can do better, but you can see we’ve got x axis and then in green. We have y axis and you can see it’s working well and in the z axis and blue up top is like this okay, so you play around with these a little bit. You start getting real excited about how easy it is to get this fairly. Nice acceleration data and the first thing that you start thinking is wow. If I integrate acceleration twice, I can get positioned and I could actually start measuring position of things with these.

Well, you can try doing that, but real quickly. What you find is integration works much better in calculus class than it does when you’re working with microcontrollers and sensors, and what you find is the noise in the signal by the time you integrate this twice. Your system has such an enormous drift. That is pretty much completely useless, and so it is an accelerometer it’s, a great accelerometer, but it’s not good for measuring position, so you play around with a little bit more and what you see is if you watch the z axis. This is just the raw data coming off the accelerometer. If I turn it upside down. I get a very large change in signal and similarly I can tilt the y axis screen is up now green is down or the x axis, the pink is up, and now the is down, and once you start saying is, is that it might not be very Good for measuring position, but you can kind of start seeing that you’re getting something that looks like it might be. Just a really nice tilt, sensor, I’m, going to turn the other accesses off and just look at the z axis. Then. What you can see is is that you can start very nicely looking at tilt, okay and right now, I’m, just looking at the raw signals coming off the accelerometer. What you want to do is kind of calibrate this. This would be if it’s sitting perfectly still with the X, with the z axis I’ve pointed up.

That should correspond to one G and then, if I turn it down, that’s a motion corresponding to negative 1 G. So I can take my two raw readings and I can map those between 1 and minus 1g and I can actually get a calibrated signal out fairly easy. And so let me turn on my calibrated signals x, axis y axis and z, axis accelerometer and now you can see up here. I had 1 G minus 1g on the y axis plus 1 G minus 1g and then finally on the x axis and Luth plus 1 G minus 1g, and so I’ve got this very carefully calibrated and very accurately. Measuring that vertical vector to the force of gravity. Well, actually, if I look at this, let me just look at a couple of accesses. Let me look at the yampz and if I try to spin this very carefully, what you can start seeing is is that I should have done probably X and Z okay. So if I spin it like this very carefully and if the better, the smoother I can spin it the better, you can see it that by spinning it at a constant rate, it looks like that we’re pretty much putting a sign in a cosine wave and that Sort of as a clue, if you go in and actually do the trigonometry, you can see that you can get a fairly accurate angle of tilt. If you just do the arc sine, you know, if you take into account all the three dimensional effects, the tilt angle and if you’re tilting along two accesses is a little bit more complicated than that.

But the simple equation is just take the arc sine of the acceleration signal and that’s a pretty darn good indication of the tilt. And so what you can see in doing that is is that you can get a very nice and accurate measure of tilt using an accelerometer. Now you play around with that a little bit and you get real excited, because you can very accurately measure that tilt just using a three axis accelerometer. But what you end up doing is. Is you start thinking that you have a tilt meter one day while you’re tilting it? You shake it a little bit and you’re reminded that these are not tilt meters. They are, in fact accelerometers and they’re tiltmeters only if you’re very smoothly tilting, but if you have any other type of motion on there, you get large errors and that tilt. Because of the acceleration signal that you have. In addition to take just the 1g vector that you get from gravity okay, so you sort of we’re excited there for a little while, but then you kind of got hung and then you realize is that there’s really something better to measure tilt that it’s so longer? And that’s a gyro and basically the gyro measures and your velocity, the nice thing about that is, if you want to get from velocity to angle, you just have to do one integration and that can be maybe a little bit more tractable and also the ISO.

The gyros have fairly low noise and so let’s just look at this x axis gyro I’ll turn it on and it’s from the other chip. This is auto scaling, and so, when it doesn’t get a signal a little while it just amplifies the noise, and so actually this is a very clean signal and I can show that. But basically, what I’m going to do is I’m going to rotate in the x axis, and you can see that if you look carefully and think about it that this is measuring angular velocity, because when I’m still it goes back to zero. And what you’re looking at is you’re looking at the angular velocity as I’m moving it, but you can see that it actually works pretty well, and if I look at all three axes, its gyro y axis and z axis you can see. If I move along Y, you see a signal in the green. If I move along X, you see a signal in the red and then, if I just move it around Z, you see a nice signal in the blue, so I can measure angular velocity in all three directions or around all three axes. So with that, why don’t we give it a try and see if we can measure our rotational position by integrating these gyro signals in and so I’ll take these raw, data’s and numerically integrate them, and I can show that here and show the integrated signal where I Integrate the angular velocity into an angle and then you can see.

I get three nice signals and if I move like this or move like this, you can see that I’m getting a signal. Let me just put one so you can see it a little bit more. Clearly, let’s see yeah that’s the X and you see now it actually measures the position it’s, not measuring velocity it’s measuring the thoth okay, very nice. I can turn that off and turn the Y on and see. I get a Y signal and look how nice and smooth that data is one of the issues with the accelerometer was the amount of noise in it, and you can see that the jaw doesn’t have noise, it’s kind of very clean signal and almost no noise. Now, that’s the good news, what the bad news is you’re, starting to see here: okay, even though there’s, not noise, there’s drift and what you can see is, if I just set it down and leave it at a very fixed angle. I have this rather significant drift and probably within a few minutes, you could get a couple hundred degrees of drift and then something will happen like right. There. It picked up a little bit of a signal announced a little bit like off to the races on drift notice. That it’s still got a real clean signal on the change, but you just have this overwhelming background drift problem, so you can see. Kind of what you’re up against here is. Is that you love the accelerometer, because there is no drift in the accelerometer at all, but the accelerometer is noisy, which makes it difficult to integrate and, besides being noisy, it also is an accelerometer and therefore, if you’re trying to use it for tilt – and you get Some vibration, that is a mess.

So, if you think about it, what you would like is you would like to sort of get your steady state value from the accelerometer, because there’s no drift so in steady state conditions. You want to kind of trust that reading from the accelerometer, but under a changing signal, you want to trust the changing signal of the gyro, because the gyro is not sensitive to acceleration. When you see a changing signal on the gyro, you know that it’s a real, a real signal, but you can sort of track where you should be that that baseline number, you should get from the acceleration. And so basically, you can do some math, where you’re integrating the values coming off the accelerometers and the gyros and your weighting, the value of the accelerometer, to give you a stable, baseline value and then you’re waiting. The change signal more coming off of the gyro, and so by fusing these two data streams between the it so longer in the gyro, you can actually get a very accurate signal now. The nice thing is is that I have an egg axis, accelerometer and rotation about the x axis. I have a y axis accelerometer and rotation around the y axis. The challenge is, is that with the accelerometer with the gyro? If I look at this other signal, the nice thing is with the gyro. I can see this rotation that is parallel to the earth. The problem is, the accelerometer cannot see this one because the gravity vector is coming straight down, and so I can compensate the other two accesses with the X accelerometer and the X janna row gives me one axis.

The Y celebration and the y Charro give me another axis. Those work well, but I don’t have an accelerometer that I can pair up with this z, axis gyro and so I’ve sort of got a problem because I would still have tripped in the z axis. But what you can do is remember this first chip actually has a three axis axis magnetometer and I have this vector that’s coming of the magnetic field of the earth, and that gives me a signal that I confused with the gyro signal and by doing that, there’s. No drift in the magnetometer, because north is north, that vector is very stable and the sensor is very stable, but I can use that for that other sensor in place of the place of the accelerometer. So basically I end up using the three axis of magnetometer. The three axis of acceleration and the three axes of gyro, and when I do that, what I can end up with is a measurement of roll and pitch and heading, and these are those data that are coming from the fusion. Between these nine nine accesses and let’s. See here it looks like the this one, the roll it looks like the roll is on here. Let’S see let’s, see if I get this right, yeah, okay, and what you can see is is that I can very accurately measure this roll okay and I have one that is a little bit of a cleaner signal where we’ve got the gyros helping out a little Bit more let’s, look at this okay, so that is the pitch.

You can see a very nice signal on the pitch, and what I want you to see is is that now that I have combined the accelerometer and the gyro that you’ve got something that if I just put it there, that is not drifting. The other thing that you see is is that there’s virtually no noise in the data, so by fusing that accelerometer and the gyro I’m able to have the best of both worlds and to not have drift and to not have noise either and so that’s. Just very very nice, and so that is the pitch now let’s turn on the roll. Just look here at the roll, so that would be there and there let’s see just real nice. I can kind of go in small steps. You can see how well it tracks. My motion and how cleanly signal is looking, ok and now let’s look at roll and pitch together. Ok, so you can see if I roll my pitch is staying steady right. This is my pitch. If I change the pitch, my role is staying constant and then, if I change my role, my pitch is well behaved and both of these signals are real clean. Now the yaw is the one like this, and so, if I turn the yaw on again, the yaw is the magnetometer combined with the gyro and that one you’re looking in in the purple, you can see I’m pointing north east south and there’s a place that it Jumps from positive 180 to minus 180, so you have that discontinuity is you’re going around the 360 degrees.

You can see really nice left and right, yeah, really nice pitch it really nice roll and the nice thing is, is that you can do this and the accesses are well behaved, you can tell roll and pitch or you can do the yaw and it all works, Saw it all works very, very well together, and so that is basically how I’ve combined the roll, the pitch in the yaw created from three axis accelerometer, three axis gyro and a 3 axis magnetometer. But what I want to show you is that things getting really fun. Now, if you start taking that and start trying to more accurately or more precisely use it as an indication of your actual position, and we see, I have to upload a different program and so it’ll. Take me just a second here: I’ve got to fill a few of these windows, and then I had to call it my Arduino and we’re going to load different program and let’s see sometimes it’s a little tricky to do this with the radio on it. But if I have my jumpers in the right position, I just do it: Oh cereal, pork, okay, but what I’m doing is you want to actually take this data to a row program and so the program that I’m going to be taking it to is a very Nice program, which is called the Python Indy Python, has some very powerful, very powerful graphics capabilities and it’s fairly easy to get the data and over the sea port over the serial port.

A lot of people really like C C is a hard program to learn to program an and I’m, not very good at C and Python it’s a little bit easier and a little bit more a little bit more. Our Python is a little easier to learn a little bit more intuitive. Those of us who learned on basic Python is a lot more like a lot more like a lot more basic so anyway, let me let me take this and fire up this program and let me see if I can I’m going to need to move these jumpers Back to turn the radio back on no matter what you do, these jumpers are always in the wrong spot. Okay, close that close that and let’s try. This again I’ve got the choppers in the right spot windows. I probably just need to kill it and try again, and these radios really don’t like going from being programmed to communicating. So what you can see here is is that I’ve got a model of my circuit and that model is responding to my hand, motion. Okay, so I’ll tilt it towards you. You can see the X beam, radio. You can see the interface. You can see the Arduino symbol, I can rotate it around, bring it back. This way you can see, we even got the red blinking line, and so let’s look at this would be pitch up and pitch down. You can see that it’s smooth with your roll left.

Alright, you can see underneath it we can look at the young. I got in a little trouble area there, but let’s try it this way. Okay, you can see the gyro chip and neat cell wrong or chip there, and so let’s go up and down down it up, left right quickly, okay, coming down this way that way that way, and so basically this is working really well all the way around and It’S very responsive and it’s very accurate notice. If I hold it still my hand, is twitching a little bit like if I set it down. Okay, you see it stabilizes there’s, just no drift at all in that and there’s really not very much noise at all. Very very stable when it’s sitting up when it’s sitting still and then it just traps tracks. My my motion very well now let’s talk about for my problem area areas are that I am still working on. Remember I’m doing this filter and and fusing of data between for this it’s between the magnetometer and the gyro, and so basically what happens is when I get to this positive 180 degrees, and I move it a little bit further it’s got to jump to negative. A hundred eighty degrees, well, the problem is, is that when you get that large change, the filter thinks it’s noise and wants to filter it out so, rather than just popping over it rotates the other way, and if I turn the filter off, it will make this Transition from here to here without doing that, but then I get more jitter all the way around, and so I need to figure out a way to turn that filter off to go smoothly from the positive 180 to just a degree over or you know, positive, 179 And minus 179 and have it make that transition a little bit more a little bit more smooth, so that’s a problem.

I still have to work on now. Another one – and this is a general problem with Euler angles – is that I come up here when I get absolutely vertical. The yaw doesn’t have any meaning anymore, and so the thing just kind of starts wandering around and it’s kind of, like a singularity, it’s equivalent it’s. The mathematical equivalent of gimbal lock in a physical system, and so it doesn’t it doesn’t, really work at these singularity points. I probably need to go in and see if I can put some special cases in, but the same thing happens here. Sometimes it will flip around at these various 90 degree points, although it seems to kind of be a haven there. Okay, so it doesn’t work at the 90 degree points, and also it doesn’t work upside down, and this is all the kind of ambiguity with the arc. The arc trig functions that, if you look I come up here and if I tilt it past 90 degrees. It starts coming back other way because of that ambiguity and the art trig functions. And so I need to try to see if I can do some special cases for that a little bit better, but you can see here that as far as any position an airplane would be – and this is working very great also if you made it smaller – you You know, use a PC board and some stuff that you could very accurately track your hand position.


arduino 9 axes motion shield Video







arduino 9 axes motion shield news








arduino 9 axes motion shield Social






A modular, Arduino Mega-controlled delta robot for your desktop.
safe image.php?d=AQDI5lGBL JxubWR&w=720&h=720& content%2Fuploads%2F2019%2F08%2F9154041566833130733 - arduino 9 axes motion shield

This interactive floor recalls the precariousness of standing on an icy surface, enhanced with imagery, sounds and physical dynamics.
safe image.php?d=AQDDp  jywcEiEdX&w=720&h=720& v6%252Fshare%252Fplay icon overlay - arduino 9 axes motion shield









(Visited 22 times, 1 visits today)

About The Author

You might be interested in

Comment (28)

  1. Why don’t you just have the filter active between 0 and 179 degrees and 181 and 360 degrees in your program? Switch it off only for that transition.

  2. It is not the filter’s problem for not being able to show 180 degrees. The problem is in the calculation. When you arc sine/cosine, it will only return a value <180 degrees. Your solution to this problem is to find out what is the constant factor after the object is orientated 180 degrees, and just add a case structure during that phase that takes 360 - (current degree) to accurately get the orientation.

  3. very nice and informative vdo sir. i am interfacing this lsm303 device with a pic16 microcontroller. its getting really frustrating trying to get the i2c reading. some documents say that the slave address is 0x18 and others say that its 0x30. im very confused, this is starting to make me feel that im not smart enough and that i might just drop out if this continues. any thoughts on the TWI?  thanks in advance

    1. @Prottoy Nahian I am not an expert on I2C and have struggled like you. I usually try to use a different approach.

  4. Hello sir,

    do you have any tips on using the IMU WYHP GY-85 9DOF? I’ve been struggling to learn how to use this sensor, as well as finding online material for it.

    Thanks in advance!

  5. hey paul,
    im using microchip microprocesor to interface the MPU9250 .
    im reading the sensor Acc 0,0,1 Gyro 0,0,0 Mag 0,0,0 (parallel to earth).
    my problem is when im using MadgwickQuaternionUpdate() or MahonyQuaternionUpdate() im getting bad results :
    1. endless drift
    2. values on pitch and roll toggleing results
    Pitch = -0.72 Roll = 0.86 Yaw = -0.28
    Pitch = 0.68 Roll = -0.90 Yaw = -0.36
    Pitch = -0.70 Roll = 0.87 Yaw = -0.29
    Pitch = 0.68 Roll = -0.91 Yaw = -0.41
    Pitch = -0.76 Roll = 0.80 Yaw = -0.14
    Pitch = 0.73 Roll = -0.89 Yaw = -0.28
    Pitch = -0.76 Roll = 0.80 Yaw = -0.10
    Pitch = 0.67 Roll = -0.92 Yaw = -0.37
    Pitch = -0.74 Roll = 0.82 Yaw = -0.14
    Pitch = 0.75 Roll = -0.88 Yaw = -0.17
    anyone encounter somthing like this?
    what is the problem and what can i do to fix it ?

  6. Thank you for this great and informative video 🙂 I’m especially appreciative that you showed where you had problem points. Did you manage to get over them in the end?

  7. heey sir im from your fans in your method in coding i really like it
    i want to add Kalman filter with your code (IMU 9 DOF)

    1. hey, do you have a code in where you use kalman filter for sensor fusion? I’m planning to implement one in my project too but really having difficulty in finding online resource

  8. at 4:33 so far, realize this is like 3 years old

    I was wondering how you were sending the data to the computer, it looks to be wireless (in your hand and self powered)

    Are you using like a bluetooth dongle? Or maybe there is a usb connection somewhere.

    I see it’s the xbee. Wow this is really cool. The real-time tracking is great.

    1. @Paul McWhorter Thanks for your response and the video. I saw the battery. I actually thought the battery connection to the breadboard was the USB connection to the computer. I’ve heard of xbee before and assumed that’s the wireless part.

      Great video very informative.

  9. Would you be able to assist me with this? I’m using an Arduino UNO with a MPU 9250 and I’m trying to convert my raw values into roll, pitch and yaw.

  10. hello sir
    thank you for the tutorial , how have you done the calibration and the elimination of the bias for both accelero and gyro

  11. Hi nice video! I’m interesting on measure the LINEAR Velocity of the Z (Vertical axis) is this possible without an error or drift when i integrer? What is it necesary for that? Thanks


    IF (X > 175) {
    IF (X = 180) { X=-180;}}
    FILTERENABLE = 0; }}



