Shop OBEX P1 Docs P2 Docs Learn Events
Gyroscope or Accellerometer for Tilt Sensor on Flying Platform? — Parallax Forums

Gyroscope or Accellerometer for Tilt Sensor on Flying Platform?

Dakota WriterDakota Writer Posts: 34
edited 2014-04-25 22:49 in Propeller 1
Hello, Parallax! (This is my first post).

Okay, so I'm considering building a quad-prop flying unit, similar to the Elev-8. I want to control it with an XBee connection most of the time, but as a safety feature, and to smooth out the flight, I want the quad-prop to auto-level. I think I can do the programming all right, though I might need some help when I get there. (Anyone have sample C code for the gyroscope?) My question is which option I should select for detecting tilt on a moving platform: the parallax gyroscope, or one of three accellerometers (4 directional, two axis, or three axis)? Or a gyroscope and an accellerometer in conjunction?

Thanks in advance. Any advice is appreciated.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-23 15:31
    You need both a triple axis gyro and a triple axis accelerometer to make a quadcopter auto-level. This is hardly a trivial task.

    In post #10 of my index (see signature) I have a bunch of ELEV-8 links. Among the links is a link to Jason Dorie's QuadX code to control a quadcopter with a Propeller.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-04-23 18:01
    Hello, Parallax! (This is my first post).

    Okay, so I'm considering building a quad-prop flying unit, similar to the Elev-8. I want to control it with an XBee connection most of the time, but as a safety feature, and to smooth out the flight, I want the quad-prop to auto-level. I think I can do the programming all right, though I might need some help when I get there. (Anyone have sample C code for the gyroscope?) My question is which option I should select for detecting tilt on a moving platform: the parallax gyroscope, or one of three accellerometers (4 directional, two axis, or three axis)? Or a gyroscope and an accellerometer in conjunction?

    Thanks in advance. Any advice is appreciated.

    IF you want to test and play and generally futz with the code to learn how the part works, you moght consider playing interactively with FORTH. One of the propforth guy just put up a bunch of gyro and accelerometer code.

    After you you know what the code should look like and how the parts respond, you have a good starting point for the C code.

    http://code.google.com/p/propforth/wiki/MPU6050gyroaccel

    http://code.google.com/p/propforth/wiki/L3GD20gyro

    http://code.google.com/p/propforth/wiki/HMC5883Lcompass

    http://code.google.com/p/propforth/wiki/GY80 <- this stuff isn't finished yet
  • Dakota WriterDakota Writer Posts: 34
    edited 2014-04-23 22:37
    Thanks a lot, both of you.

    So, it looks like I might be going in over my head. I thought that I read somewhere that a gyroscope was basically a spinning "top" that maintains its axis of rotation as long as it spun. I was hoping to set that axis straight up and down, then just measure deviations from that. Unfortunately, as usual, the truth seems a lot more complicated. Please forgive my ignorance, but what exactly does the model on the parallax website do? Would I use it to measure velocity, acceleration, what?

    Also, this is the first time I've heard of FORTH. It that a programming language?

    Again, thank you for your replies. And again, sorry that I don't know this stuff already - that's why I'm asking. I know some Java, C++, and PBASIC, but my real interest in robotics started just last September (and as such, I'm rather new to the whole sensor world). I'd love to learn; just trying to lay the groundwork.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-24 07:41
    I thought that I read somewhere that a gyroscope was basically a spinning "top" that maintains its axis of rotation as long as it spun. I was hoping to set that axis straight up and down, then just measure deviations from that.

    I now I wouldn't explain how an electronic gyro works as well as Parallax has. Between the documents provided on the product page, and Learn.Parallax.com, I think this info is pretty well covered. Sorry for the "Read The Fantastic Manual" answer but Parallax's manuals are fantastic and worth the read.

    A good place to start learning to make use of a gyro and accelerometer is to make a two wheeled balancing robot. Hanno has a good example of this with his DanceBot.

    http://onerobot.org/products/dancebot/

    Hanno has a chapter about the DanceBot in this book:
    http://www.amazon.com/Programming-Customizing-Multicore-Propeller-Parallax/dp/0071664505
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-04-24 11:57
    So, it looks like I might be going in over my head. .

    Good. If you already knew everything, it wouldn't be much fun.
    Please forgive my ignorance, but what exactly does the model on the parallax website do? Would I use it to measure velocity, acceleration, what?
    Ignorance is to be encouraged, and cured. Gyro is for rotational velocity, accelerometer is for acceleration. (I am just repeating from the datasheet, I don;t actually know either).
    Also, this is the first time I've heard of FORTH. It that a programming language?

    Now you've said the secret word. FORTH is the EASY way to do robot stuff. It is an environment and programming language. You can work interactively from the keyboard, very fast development cycles. Also you can run command in litle scripts, really powerful. Lots of little experiments that are easy to do and find errors; (as opposed to a few giant experiements where its impossible to find mistakes). If a silly person like me can write drivers for accellerometer and gyro in FORTH, it MUST be pretty easy. YMMV. After you figure it out in FORTH, it will be MUCH easier to get code working in a traditional programming langague, as you will know what to expect from the parts and that the wires are plugged in correctly.

    Give is a whirl, we'll help you as much as we can. The only confusing part is the I2C protocol, and that secret is well established.
  • Dakota WriterDakota Writer Posts: 34
    edited 2014-04-25 17:40
    Again, thank you.

    It looks like I might be fabricating my own piece, for simplicity's sake (and the budget!). I'm planning a metal ball in a shallow conductive bowl, making resistor connections on the rim when tilted. Using rc_time and an rc circuit, I'll tell which resistor it's contacting. I think that gravity will compensate for acceleration. Big disadvantage, I know, is not knowing how much the craft is tilted; but I don't intend to be trying barrel rolls in this. If it corrects for minor tilts, it should suffice. Use of only a single pin is also an advantage.

    When parts arrive, I might start up a new thread to document the development of my quadcopter. Thanks for all your help.

    Wish me luck! Happy robot-ing!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-25 18:17
    You can get sensors pretty inexpensively off ebay. You'll need to wait a few weeks for the sensor to arrive but it's hard to beat $2.77 for a combined triple axis accelerometer and a triple axis gyro.

    I can tell you right now, your metal ball and metal bowl, might be a fun experiment, but it's not going to be very useful in controlling a quadcopter.

    There are a lot of inexpensive quadcopters. IMO, it's a good idea to start with one of these and then try to make your own board after you've know the quadcopter can really fly. I've had a lot of fun with one like this one. I added a small Propeller board so I could add additional controls to the quadcopter. My attempt to add an ultrasound sensor didn't work because the motors' noise interfered with the sensor. There's some discussion about this small quadcopter here. There are quadcopters which are even smaller and cost less than this one.

    I have additional links to quadcopter threads in post #10 of my index. This includes a link to Jason Dorie's QuadX software he has been working on.

    I'd suggest getting the same kind of sensors Jason is using so you can use his code. Once you find out the type of sensor, you can search ebay and probably find an inexpensive source for the sensors.

    Good luck but don't just rely on luck. Be smart and learn from other people's experience.
  • Dakota WriterDakota Writer Posts: 34
    edited 2014-04-25 19:47
    Thanks for that link to eBay! I had no idea those two parts were that cheap... I was looking at two units from parallax used in conjunction, to the tune of $30 each!

    And I believe you about the custom-made tilt sensor... but, just so that I know, what's the big pitfall?

    I actually thought about adding a ping sensor to detect low altitude; thanks for the warning!

    I'm looking at a pretty small quadcopter - maybe a little over a foot across. Part of why I'm reluctant to spring for an Elev-8 or similar is that the flight unit is pre-programmed. As I'm sure you can understand, the fun for me is as much in the development as the finished product. I can see the logic of getting a unit that already flies, then reprogramming it, though.

    Quick question: for a quadcopter, is there any "generic" rule of thumb for the kv and propeller diameter of the motor vs. the total thrust? I know that there are a lot of variables, just looking for a weight guideline.

    Your giving great help, thank you! Sorry if I seem reluctant to simplify and let someone else do the work... maybe it's a fault, but it's worked well for me so far.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-25 21:24
    Thanks for that link to eBay! I had no idea those two parts were that cheap... I was looking at two units from parallax used in conjunction, to the tune of $30 each!

    Usually the price of a sensor is a small part of the cost of using the sensor. The larger cost is time spent learning to use the sensor. You're not going to get anywhere near the support in learning to use a sensor from an ebay vendor as you will from Parallax. The quality of the ebay part isn't going to be anywhere as good as the quality of a part made by Parallax.

    I buy a lot of stuff from Parallax but I also buy a lot of stuff off ebay.
    And I believe you about the custom-made tilt sensor... but, just so that I know, what's the big pitfall?

    Just call it a gut feeling. That and acceleration from gravity and acceleration from changing velocity is indistinguishable (thank general relativity for this). If you make one, make sure and video your efforts to share with the rest of us.
    I actually thought about adding a ping sensor to detect low altitude; thanks for the warning!

    Ultrasound sensors can work on quadcopters. The small motors on the small quadcopter produced an interfering sound. I doubt larger motors would cause the same issue.
    Quick question: for a quadcopter, is there any "generic" rule of thumb for the kv and propeller diameter of the motor vs. the total thrust?

    There probably are rules of thumb about these things but I don't know them.
    Sorry if I seem reluctant to simplify and let someone else do the work... maybe it's a fault, but it's worked well for me so far.

    I hope you don't mine and smelt your own copper to make your own wire? Unless you like mining and smelting copper that is. Life is short, make sure you're enjoying the process.
  • Dakota WriterDakota Writer Posts: 34
    edited 2014-04-25 22:49
    Duane Degn wrote: »
    I buy a lot of stuff from Parallax but I also buy a lot of stuff off ebay.
    I just found out that my budget isn't as tight as I was worried. This is an extra credit, self-imposed school project, and the school is willing to fund Parallax parts. In that case, the motor question is also solved.
    Duane Degn wrote: »
    Just call it a gut feeling. That and acceleration from gravity and acceleration from changing velocity is indistinguishable (thank general relativity for this). If you make one, make sure and video your efforts to share with the rest of us.
    Will do! I'll probably try for very slow acceleration, and hope that the 9.81 m/s^2 acceleration of gravity overcomes it. Having never touched a quadcopter before, I'll just be ecstatic if it hovers and inches back and forth at command. No acrobatics necessary, at least not on this first draft.
    Duane Degn wrote: »
    Ultrasound sensors can work on quadcopters. The small motors on the small quadcopter produced an interfering sound. I doubt larger motors would cause the same issue.
    So, hopefully, Elev-8 motors will be large enough? It just would be nice for the craft to know if it's about to crash...
    Duane Degn wrote: »
    I hope you don't mine and smelt your own copper to make your own wire? Unless you like mining and smelting copper that is.
    Yeah, I was thinking about that as I posted it. No I'm comfortable buying components, but I'd like to be in a position where, given the parts, I could replicate the craft. Programming in particular I'd rather not copy, even if it is open-source. In this instance, I'd rather have a minimally capable device that I could honestly claim to have programmed 0, than the new 6-prop version of the Elev-8 that I hadn't built. I guess each person needs to decide what his or her level of acceptance for outside code is for a project, and mine is near-0. That, and I don't know that I'll have time to learn both parallax's gyroscope and its accelerometer before school lets out.
    Duane Degn wrote: »
    Life is short, make sure you're enjoying the process.
    Thank you, sound advice. The process I'm describing, whether or not it succeeds ultimately, sounds like one I'll enjoy; enjoy much more than a more developed kit.

    Please, please don't take my response as trying to contradict you - you sound like you've had more experience in this area than me, and I respect that. Still, given the circumstances (which I have not completely communicated on the forum), I think I'll try the homemade part, if only so that I know how it will work without question. If it fails, I can try the parallax parts, plain and simple.
Sign In or Register to comment.