Gyro (Position) sensors (MPU6050) with Arduino - How to access Pitch, Roll and Yaw angles

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in this quickie we're going to look how we can work with this electronic gyro and accelerometer it's the mpu-6050 roller titles is that it so what can a gyro do it can detect the orientation so the gyro chip is right in the middle there and it can detect movement in that direction in that direction and in that direction they have names i mean in the soft you might say label is x y and z in airplane terms and we have at no expense spared as you can tell a small model airplane to explain this so so we have pitch roll and yaw and on this board if you orientate it i think it's this way i think then pitch is rotating on that axis which should be like that for this board roll is like that which is like that on that board and yaw is i was put down is just in that direction like that so the board rotating like that yaw is the most difficult for it to detect and it needs a little calibration for it does that successfully but we'll show you all that so let's move on to the library ender show you a couple of demos although this quickie is going to turn into a wonky so this came just the board and the pin header and i've soldered them on there are quite a few connections to this however you actually only need to use four with your arduino or esp32 i'll bring a higher quality picture on the screen now let's go through them obviously you've got voltage and ground and then this is an i squared c device so we've got sel which is clock and sda which is the data so we just need to hook them up to a4 and a5 which are sda r squared c connections on the arduino and the appropriate ones the sp 32 as well i want to go through the arduino connections today you just need to hook them up as you would with any other r squared c device and bob's your uncle funny shanty away you go so here we go don't worry about the screen this is so i can display the results from this module easier than it being on the serial monitor i will show you the basic software for the serial monitor but i'll also show it on the screen as well so these that screen actually is a squared c device as well so we've got blue io's used for my data and yellow for the clock so we've got an additional connection to that bus going to this screen as well so we've took off the arduino's power and grind up to this rail here jumped over there as well so that screen's got power and ground as well and then on the actual module itself we've got power and ground connected straight onto those connections there and then the actual clock and data connected with the yellow for clock bluetooth data to the arduino's clock and data lines okay this wasn't that easy to find a libra that worked well with this i tried four or five libraries had problems with them all but one and to save you time i will take you straight to that one that works with this oh look at me i'm making people happy it may be all the labs work better with other versions of this board i can't say how they would if you get an mpu 6050 this lobby should work well having said that from the labs i tried just rather awkward very awkward or it just didn't work well maybe it was me not setting them up right but out of the way so let's get to our library let's go to tools and manage libraries so in your search bar if you type in 6050 which is what i'm gonna do you might see a few installed libraries here ignore all of them until i point to the one that you actually are going to install that i know works well and will give you the demo that that i know works well and i've had success with and that is this one mpu 6050 underscore light this worked a treat and i did as i said i tried several this worked really easily works in angles if you want to in degrees fantastic no problems other ones either fiddly faddly hard to set up or i set them up wrong or whatever although i don't know it could be my fault i'm fairly perfect yeah maybe not anyway whatever select this one mpu light and install this this one here whack that in when you've done that there is a demo you can go to on the far menu examples [Music] there we go find it wherever it's gone there it is mpu 6050 light um i think i chose get angle ah that's fine and you can see what it's doing here at the mission it's doing a calibration basically saying do not move your 60 50. it is calibrating this is only important for the your y aw for the your axes for the pitch and roll it doesn't matter if you don't do this and you want to use your you will have problems with that your value just change it just think increments goes upwards slowly over time not even that slowly so that does need to be done if you use an acceleration that may well be done i have not looked at the acceleration of this module just the x and y so i want to be able to just tilt something in two axes that's all i'm interested at the moment so it does that does that set up and then on the serial port make sure you've got it set to 9600 if you want to or change that to whatever serial port speed you're using but on the serials port it will then output the x the y and z with z being the your angle x and y being the picture mode so i'll show you that quickly operating so you can see what comes out of the serial port so we'll upload that to the board so we're uploaded here we go this is the calibration sequence which takes a good few seconds and off we go so if i move in the your axis which is me rotate it on the flat surface you can see the z-axis there is moving that's your and now i'm going to move it what um i think's pitch and you can see the x-axis is increasing and if i go to a full 90 degree angle from the flat surface it one i can see 90 degrees on there and just to show you roll and wires changing if they're all positive in one direction negative in the other again for 90 degrees it'll be minus 90 or plus or plus 90 in the other direction so picture all we can move in all three directions all with nice angles easy to work with so let's have a look at it on screen now this software that i'm going to bring up is one i've written and it's based on the one you've just seen so you'll find this on a project page for this and link is in the description below so i'll upload that okay so i'm going to hold it towards camera and it will calibrate in this orientation just get the camera to focus so it's calibrating and there we go so we've got pitch roll and yar so remove it like this you can see that you're you're not you're yaw the yacht is moving and if i alter the pitch you can see the pitch is moving like that and those pitch and roll are in uh degrees i'm going to give you the roll i'll get to the roll moving like that so if you do the pitch to 90 degrees you won't be able to see but believe me if i go like that to approximately 90 degrees down there then it has 90 degrees on that display so yeah you could think of some sort of little game with a display it could involve moving and tilting and rotating that's what i'm kind of thinking of but you might have a lot of other uses for it at the moment i am a bit stumped as to what i could use this for but it's an interesting module as it is as it stands you may have a really interesting use for it perhaps with the accelerometer maybe you could build an accelerometer to fit into your car so you can tell how fast your car can accelerate for mine it's not to 60 in there i think it's 3.4 days something like that anyway i will just show you what happens if you don't do the calibration and it doesn't affect pitch and roll only affects the r or the z axis let me just upload that chord and we'll come back to this okay i've reprogrammed that well i've just commented that one line that did the calibration so you'll see it'll go straight in just a flash of text maybe to the actual pitch roll and you're now watch the z-axis the wire you're naughty side which slowly just increasing over time now it's not just fluttering like the others are if you look at the pitch and roll they're fluttering they're fluttering out but always around that same so pictures around 5.6 5.7 rolls around 2.1 ish but the yacht is constantly just climbing up 5.6 5.7 5.8 5.96 6.1 and you leave that for a few seconds a few minutes and it's going to be up to 20 30 or so i don't know the ins and outs of the chips so i don't know why that is the case obviously i can understand how y'all would be very hard to do anything against sort of gravity i imagine there's something to do with gravity that can sense for the for the actual roll and the pitch but with your you're not changing the orientation of this chip with gravity at all so i imagine that's where the difficulty comes in and why i need that calibration sequence for me for the project i'm thinking of i don't need the yaw so i could go straight in without any calibration i think as well that actually once you've calibrated one chip to the right settings you can then write call to store them settings in the chord and then it'll work without having to do that calibration sequence every time i think i have seen it certainly seen that hinted at in other libraries i looked at that didn't work uh so i presume maybe in this library it will i'll give you a link to the actual library github page as well you can read about the particular library used but that's it for now if you enjoyed this video you liked it you know that that old big thumbs up it's a big thumbs up and that's about the camera close to the board now or if you'd like to see some more content like this or hopefully even sort of kind of better which wouldn't be hard would it really uh not at all i think we could improve on this then hit that subscribe button thanks very much my patrons who patronize me and thank you for the odd person sometimes in their comments who patronizes me always appreciated and thank you very much for watching until next time bye for now
Info
Channel: XTronical
Views: 47,800
Rating: undefined out of 5
Keywords:
Id: H7fRowInpwM
Channel Id: undefined
Length: 11min 36sec (696 seconds)
Published: Thu Oct 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.