Feed on
Posts
Comments

I recently got into the quadcopter hobby and purchased a UDI U818A mini quadcopter from Ebay which is fun to fly and have been experimenting changing the battery packs and adding FPV. I’ve been thinking about going to a larger quadcopter but before I do, I’d like to plan around with making my own micro quadcopter and experimenting with the software.

quad_3

After purchasing 4 micro motors (Hubsan X4 H107), a set of propellers to suit, a MPU6050 3 axis accelerometer and gyro, I was ready to start building.

quad_1

The first part was to build a frame, using my CNC I built one from acrylic just big enough to fit all 4 motors with propellers without touching each other, a bit of blu-tac later and they are semi-secured in place, good enough for testing. One big downside is that acrylic is heavy compared to most other materials.

Testing the 4 motors all at once at different voltages gave me the following current draw results – 1.7v @ 780ma, 2.5v @ 1.2A, 3v @ 1.5A, 3.5v @ 1.9A, 4v @ 2.2A but I expect that it could be double or triple that due to the wires I was using so each one might draw 1-1.5 amps each.

quad_2

After testing different mosfets to use, I went with the IRLML6344 a 29 mOhm, 30Vds, 5A continuous mofset with a sckotty diode rated at 1 amp, a quick PCB design later and we’ve got our motor controller board. I did have some trouble testing the board, it seemed that I kept frying the mosfets in such a way that made them stay on even when the gate was low, it turns out that I forgot to connect ground to the PWM I was generating, oops. After ground was connected, it all work nicely and the mosfets didn’t really get hot.

IMG_4088

I hacked up one of my PCBs that had an ATmega footprint to act as the controller and started work on converting the MPU-6050 Arduino code to C code which took a while, I had to add some capacitors for power filtering otherwise when the motors started the MCU would reset. The MPU-6050 has a special DMP motion functionality which offloads the processing on the chip directly and gives you the results directly, if you don’t use the DMP motion you need to do some sort of filtering otherwise the results can be all over the place. Here’s some links to learn more about using the MPU-6050 and the library I used the DMP from.

http://youtu.be/yhXcDba7zFc

Once the conversion of the MPU-6050 code was done I started playing around with controlling the motors based on the position of the MPU-6050 but it turns out that it’s much harder than it seems, but it was great to see it lift up and fly for a bit. I was doing basic things like if it was tilting to one side, it would increase the PWM cycle for the side falling and decrease for the side rising, trying to take into account a decent amount of angle before it would take place. It would slowly rev up all the motors and then it would take off, here’s where my code ended if you want to take a look: Quad_Test. As you can see in the video, I did get it to fly briefly but there was lots of oscillation and later when playing with my code it would move in one direction and slowly spin in circles.

So it was time to go back to the drawing board and I happened to find the MultiWii software which runs on Arduino and I had an Arduino Pro Mini laying around so popped everything on that board and gave it a try, I also added nRF capability so I can control it from a Gamecube controller. I was running the Arduino Pro Mini at 3.3V which means that the 16MHz clock it had by default needed to be divided by 2 which I did in the software and also lower the baud rate to 38400. It took a little while to get the controls working well as I had to interface to the MultiWii software and in the end it was flying but only for a few seconds, no where near good enough to control. Download Quad_TX-RX_v1.0

quad_4

I didn’t know it back then (about a month ago when I did this build) but by default MultiWii runs in acrobatic mode meaning that it’s up to you to control the quadcopter, any adjustment you make the quadcopter will continue that action until you move it to another direction. You can set it to angle/horizontal mode which will auto level the quadcopter for you and you should calibrate the accelerometer by pressing the CALIB_ACCR button before doing so. Also the PIDs should be tuned or at the very least, you need to put the I and D gains to 0 so you can firstly focus on P (reduce it to say 1.5 to 2.5 to start with) to have it start flying.

http://youtu.be/Yw8oPb22GHQ

So now it hovers (better than shown in the video but requires more tweaking), all in all it was a good experience to learn the amount of processing that goes into making a quadcopter fly and I’m happy with the MultiWii software enough that I can build a bigger quadcopter, I’m starting to receive my parts for a ZMR250 build as shown on the RCModelReviews channel.

20 Responses to “Building a Micro Quadcopter using MultiWii”

  1. Rob says:

    What mosfet did you used ?

  2. Robert says:

    I build something very similar to your copter. I used IRLML2502 mosfet.
    The current issue is with stability, and my copter usualy flips. Probably something is wrong with configuration. Any tip what should I check ?

    • Alex says:

      Hi Robert,

      Is there anything in particular that you do to make it flip or is it just random?

      A few things to check:
      – Have you calibrated the accelerometer when it’s flat on a table by pressing CALIB_ACC?
      – If you move the quad when connecting the power, it could by the gyro needs calibration too when it isn’t being moved, when not armed, move the throttle to the bottom left and move the pitch to the bottom, the status LED should light for 1-2 seconds.
      – How is the accelerometer mounted? Maybe try putting some foam under it. Also when the motors are on and near full throttle, do you see any big spikes? If so, the accelerometer may need to be mounted differently or possible the motors are causing too much vibration, may need to be secured better to the frame.
      – Try lowering the Level P from 9 (default) little bits at a time, you can go right down to 1 if need be, also try this for I, go in 0.05 increments.
      – You can lower PID for Pitch and Roll too
      – Lastly it could be you have a faulty accelerometer/gyro

      • Robert says:

        Hi Alex,
        Thank you for your response.
        I calibrated accelerometer when quad was not armed and on flat. Should I calibrate it every time when connecting power ?
        As far as I checked yesterday – spikes was even when throttle was just above min.
        I’m using EZ-GUI to control my quad. I don’t have any other remote currently.

  3. Kirby says:

    hey. i’m going to make this. i’ve learned alot of c-programming. what are all the parts? and how did you hack the pcb into a flight controller?

    • Kirby says:

      thats a power distribution board right. you made that yourself.

      • Alex says:

        Hi Kirby,

        Yes I just made a PDB/ESC you could call it, for the motors. Really all it is, is mosfets on a PCB with a diode and resistor. If you wanted to, you could use a TO220 style mosfet (but it might weight a bit). There isn’t too much programming needed, more just understanding where to connect everything.

        Parts are 4 micro motors (Hubsan X4 H107), a set of propellers to suit, a MPU6050 3 axis accelerometer and gyro, an ATmega (I had re-used a PCB that had it from an old project), 4 mosfets diodes resistors, nRF24 modules and Gameboy controller but it’s all a bit complex.

        You could simplify it all and just grab a Multiwii board off Ebay for about $20 (or try non-genuine Naze32 from Banggood for $20 too but be careful as I’ve heard people blowing theirs up when connecting the USB), then all you need is the mosfets/PDB and a receiver/transmitter.

        • kirby says:

          Questions: are you a programmer by chance what do you do for a living?
          Another question I was thinking about making a mini quadcopter for an entry into college project. Tell me a way I could make an HC06 module controlled quadcopter with arduino uno, program the firmware from srcatch along with 7mm brushed motors, and MPU 6050. or (( I’ve also bought a CJMCU flight nano STM32 quadcopter with 9DOF sensors. I was thinking about programming this from scratch along with an ST Vlink programmer/debugger. Is this all possible. I dont want to use a controller. I like smart-phone controlled stuff. Is there any way? Also I dont use ESC’s, there seems to be FEts integrated on the board I’m trying to use. Also whats that part in the top left corner that says INSide gadgets. Is that the reciever? thanks. gonna start making this.

          • Alex says:

            Hi Kirby,

            Not really a programmer, I’ve been writing code just as part of my hobby, I do IT support as my day job.

            I think that would all be possible but the the difficult part would be writing the firmware from scratch as you would need to understand and implement your own PID controller with leveling and then write your Andriod app to connect to it but if you research and look at others code it might help to learn it and see if improvements can be made.

            HC06 bluetooth module works but won’t give much range but if it’s going to be controllable by the phone that may be something you don’t really need.

            The top left board is my old project PCB which has the ATmega with Multiwii.

  4. kirby says:

    Okay, PID control right, that makes sense. can you code the multwii or naze32 from scratch?

    I’m going to program this like I said before http://www.ebay.com/itm/261901265159. I’m going to solder the HEC06 bluetooth module to it. How should i approach programming it from scratch and making my own firmware? I have a ST Vlink2 or usb ttl serial converter, can I program it that way? Didnt wan’t to build a full size quad but definetely gonna get a naze 32. i don’t have a receiever so i can’t use that. I’m only going to use the HC06 will bluetooth control even though the range is limited. how do i start per say? I don’t have experience. i havent gotten the parts yet but just theorizing everything for now until i start the build. people have done this before to some extent, the eachine h8 for example. http://hackaday.com/2016/01/07/open-source-firmware-for-a-mini-quadrotor/
    thank you for taking the time. last question. thanks for your help alex.

    • Alex says:

      If it was to program everything of Multiwii or Naze, I don’t think I could do it all. If I researched the PID loop for some time and looked at some example code, I think it should be possible for just the basic control.

      I haven’t really worked with ARM before (but I did recently buy an eval board I need to play around with), yes looks like a USB serial TTL should do the job.

      Since you are going for that Ebay frame, I would take a look at the work others have done (looks like the processor is one of the ones that runs the Naze32) and slowly changes parts of it out, like change the receiver to the HC06 controlled by the PC, then change it to the phone, then modify the source to try taking everything out so it’s just the minimum needed, play around with that until you understand how it all works and then write your own.

  5. kirby says:

    gonna be a programmer.

  6. kirby says:

    play around with the cleanflight software then right? that’s what works on it? Is that even possible, to mess around with the software? have you made any progress with the eval board all IT work aside? just wondering? also, do i just need the st vlink 2 dongle or should i get a debugger adapter as well(keil uvision/eclipse+Open OCD+GCC compiler)? i’ve made some progress i guess.

    • Alex says:

      Hi Kirby,

      Yes, the source is all their for cleanflight or betaflight should you wish to check it out. I haven’t made any progress with the eval board myself, mostly just spending time researching/playing around with settings with betaflight, trying to get a good tune. I would just start of with the STvlink first and see if you really need the debug adapter later on.

  7. Kevin says:

    Hi you have an awesome site. I really like your quadcopter work and your attempt at the FC. its something I’ve been thinking about for a while!

    just wanted to say you have awesome work and if you have an instagram check out kkuwata.ee I would like to follow you if you have an account. your projects are really cool!

  8. ARUNABHA says:

    I am a student of electronic and telecommunication engineering ……….. I want to make a mini drone …..help me

    Thank you sir …..

Leave a Reply