First outdoor trials

Today was mostly spent practising and seeing just what the quad can do. I am absolutely amazed at the rate at which it can climb, even while I still have it limited to 2/3 throttle it is still able to shoot into the air like a rocket, rapidly becoming just a speck in the distance. I seriously wonder if the frame would be able to stand the acceleration of it's full unrestricted throttle šŸ˜€

However, after a very fast decent from around 100m I now see that the lack of gravity during freefall is going to play havoc on the sensor filters. This is because the gyroscopes use the noisy accelerometer readings to zero themselves to cancel out their drift, which normally over a decent period of time supplies a pretty accurate orientation estimate. However, when in freefall, the accelerations across all the axes will drop to nearly zero, causing the atan2 function to output wildy varying angles, offsetting the gyroscopes. The result of this was a very confused quadrocopter only a few meters off the ground, ending with a hard landing. To solve this I need to add some code to disregard the accelerometer values when their magnitude drops much lower than g, which will probably be usable for a few seconds before the gyro drift has chance to build.

The second less technical problem occured when I got rather cocky in a field and managed to lose track of the quadrocopters orientation, resulting in a very painful encounter with a tree. A lot of the frame was broken (again), but I think with more glue and struts I should be able to salvage this frame, or at least keep it going long enough until my new carbon fibre frame arrives.

Comments (9) Trackbacks (0)
  1. Very nice, I’m also building a quadrocopter based on a dsPIC. For now I used the ITG-3200 and BMA180, still waiting for the MPU-9150.
    I also made my ESC’s myself also with a dsPIC.

    What kind of PID controlloop are you using ?

    At the moment I’m using a speedloop as inner loop and angle as outerloop, here is a video of the speed loop:

    • Ha, I’ve seen your videos before, very impressive stuff šŸ™‚
      At the moment I’m using full PID, but only controlling the angle. So far I have just been rushing to get the quad flying to prove the basic concept works, with the hope that for my third year EEE research project I will be able to explore more into the filtering and control loops, possibly integrating other sensors along the way.
      Also, how easy was the brushless controller to build? I tried designing one around a pic16f887 this time last year, but could never get a clean enough back emf reading in order to consistantly sense the zero crossing. This was done using the ADC to measure the BEMF, did you use that or the comparator?

      • Ah I also used first only angle control. The only problem i now hae is drift of the quad itself.
        The esc did took some time I sample the bemf during the pwm on period using dspic33fj16gs504 with alot of interrupts
        Still needs improvement for more bandwith. And better startup of the motor.

  2. hay im currently working on a quad rotor based on a pic32 and would relly love an example of your code so that i can see how your pid is implamented alot of time has been spent on my project just study quartonians in an attempt to get a IMU working and all the attempts have failed so far.

    • I have yet to touch on quaternions, so I have no idea if my PID code is even applicable to yours, but here it is:


      Then applying this to the motors is done by writing a duty cycle to the output compare modules (running in x configuration):
      OC1_output = 0.5*PID_XOUTPUT + -0.5*PID_YOUTPUT - PID_ZOUTPUT + MOTOR_MIN + MOTOR_RANGE*throttle;

      This is pretty much unoptimised, for example now that I’m running with a fixed 400Hz control loop I could remove both floating point dt divisions by appropiately scaling KI and KD. Just shout if you want any aspect of it explaning further.

      Also, how are you finding the pic32? I’ve been debating switching over to one from my dspic33f, but haven’t heard of many people using them yet.

      • I’m a part of the same project as Tim above. Previously we were using an ARM CM3 from STMicro combined with ChibiOS. After have lots of trouble getting things to work, I decided to use the PIC32 instead (after years using PIC18 chips).

        The PIC32 is very much the same as any other PIC I’ve used, so development became very quick and easy. I’m using FreeRTOS in place of ChibiOS, and have written the various drivers with much more knowledge of the platform. Development is much easier than on the ARM CM3.

        I’m not too sure about the control loop. Our CPU is running at 80MHz which should be powerful enough to implement a Kalman filter.

        • Yea, I managed to run an unoptimised floating point kalman filter on my dspic at 400Hz+, so I’m pretty sure your PIC32 should handle it. However from my experience kalman filters aren’t really necessary with modern sensors, as for me a simple complementary filter performed far better. This will be affected by your choice of sensors mind, as I am using the new MPU6050 chip, which has much lower noise levels than the previous ones I had worked with.

          Just another thing I noticed, in the code above where I multiplied each term by 0.5 in order to switch from + to x mode, I think the 0.5 should infact be cos45 = root2/2. For some reason that equation came out as 0.5 in my head and I never noticed the mistake. However it shouldn’t make any real difference, it will just affect the PID coefficients slightly if you want to fix it.

  3. I was more than happy to find this internet-site.I needed to thanks in your time for this glorious read!! I positively enjoying every little bit of it and I have you bookmarked to take a look at new stuff you blog post.

  4. Good afternoon!

    My name is Bruno Robles. . I wonder if you have information about Kalman Algorithm, I need to make a sensorial fusion (accelerometer, gyroscope and magnetometer) for a quadopter stabilization.
    Please, if you can send me information to my e-mail, I will be grateful 100%.
    Thanks. Have a nice day!!!!

    NOTE: I bought the MPU9150 device. Iā€™m working with a dsPIC30F4013 microcontroller.

Leave a comment

No trackbacks yet.