Monday, 18 March 2013

MultiWii quadcopter - re-flashing the board with new code

So its March and in the UK this means we get glorious sunny skies and 20 degrees C temperatures... oh, wait... that was March 2012. This year we've mostly had snow, wind, fog and rain. All of which are counter-productive to quadcopter testing and flying.

This would be frustrating enough if I hadn't tried to re-flash the flight control board with new MultiWii software that then made the 'copter as unstable as an elephant riding a unicycle on a bouncy castle in an earthquake...

After lots of staring at code and running tests on my ECU, transmitter and motors, I noted that the accelerometer data lines on the multiwii config software were dancing all over the place. Remembering the bit of code in config.h:



      /* MPU6050 Low pass filter setting. In case you cannot eliminate all vibrations to the Gyro, you can try
         to decrease the LPF frequency, only one step per try. As soon as twitching gone, stick with that setting.
         It will not help on feedback wobbles, so change only when copter is randomly twiching and all dampening and
         balancing options ran out. Uncomment only one option!
         IMPORTANT! Change low pass filter setting changes PID behaviour, so retune your PID's after changing LPF.*/
      //#define MPU6050_LPF_256HZ     // This is the default setting, no need to uncomment, just for reference
      //#define MPU6050_LPF_188HZ
      //#define MPU6050_LPF_98HZ
      //#define MPU6050_LPF_42HZ
      //#define MPU6050_LPF_20HZ
      //#define MPU6050_LPF_10HZ
      //#define MPU6050_LPF_5HZ       // Use this only in extreme cases, rather change motors and/or props

 
I tried going through the low-pass filters until the wobbles seemed to be manageable using the 98Hz filter. I also balanced the motors, as these seemed to be creating much noise and vibration. I also added another layer of rubber grommets onto the flight controls mounting board. The results can be seen below on a kitchen table tethered flight:

Roll on Spring! Next step is to get outside and do some hardcore PID tuning :)




Saturday, 26 January 2013

Quadcopter's new brain

A new flight controller for my quadcopter arrived yesterday - a MultiWii 'Standard Edition' board. Now its half the size of the KK Multicopter board that came with my X600 kit, but after a bit of bodging with a carton from Proto-Pic, I came up with an avionics bay...

Unfortunately the FTDI (USB to serial) board didn't arrive with the MultiWii, so out came ol' faithful (without the ATMEGA chip) to let me connect the flight controller to my PC.

MultiWii has a GUI for checking the board is working and setting up the PID and receiver systems. This is incredibly useful as it lets you see what the control inputs are, the sensor values and the motor outputs. I didn't play around with the pre-loaded PID values, but I did set my radio transmitter end-stops so that the flight controller can detect full deflection or min/max throttle. There is a multiwii guide here that covers PIDs. Example guides on Tx/Rx tuning etc are here and here.

First flight with the new board was in a gently gusting south-easterly wind. I'd set an AUX channel on the transmitter to enable ACC/BARO/MAG hold (basically to stabilise pitch, roll, heading and altitude!) and flew with it ON almost exclusively. The quadcopter is much easier to handle and recover when a gust pushes it out of position. I even had a go at a few fast flybys... Not quite up to this standard though:


Monday, 21 January 2013

Quadcopter control system

I had an MPU-6050 6-axis accelerometer/gyro and an Arduino Pro-Mini, so I thought I'd have a go at breadboarding a flight control system based on open-source software/hardware

The open source options I looked at were:






Although FreeIMU isn't technically a flight control system, it provides a sound basis for coding one, as many have done!

After much code gazing, I2C pin swapping and re-flashing of the Arduino mini with known-to-work-code, eventually I gave up trying to get the MPU-6050 to work as it didn't want to talk with the MultiWii code. Instead I bought a multiWii-based board, but its really just an ATMEGA328P (like in the Arduino Uno) with a bunch of sensors on board plus handy pin headers for wiring up the receiver and motors... a snip at under £30 (The MPU-6050 breakout board is £30 on its own...) - I hope it works!

Saturday, 5 January 2013

Quadcopter first flight

With expectations of at least breaking a prop and probably bending an arm, I took to the skies today with my X600 quadcopter...


The first flight was in a steady breeze on a local football pitch (soft muddy grass to cushion landings!) I fitted the props and tightened the bolts on the folding arms, plugged in the battery and took a deep breath as I armed the quadcopter from the transmitter.

From flying IR indoor helicopters I knew that a half-hearted throttle input would tip the machine, so I ran up the motors to idle, checked everything looked OK, then gave it some beans. The quad sprang up and almost hovered. I tried to correct for the wind drift and brought it down again in a controlled flop. Success! Nothing broken!

The next 30 minutes I got to grips with the controls. First impressions are that these machines need you to fly all four axis simultaneously. My experience with fixed wing aircraft wasn't much use as the quad could go in any direction equally fast. The immediate problem I had was I couldn't always tell which way was forward... pulling back on the stick to slow down may result in the quad going faster or sideslipping.

Next step will be to put something (lights? ball-and-string?) to show which way is 'forward' on the quad. Ultimately I'd like to implement and accelerometer based system to stabilise the quad and possibly do some control mixing to make it fly more like an aeroplane.

Monday, 31 December 2012

Quadcopter radio setup



My Spektrum DX6i receiver arrived this morning, which means I can test the quadcopter electronics :)



After some of the usual trial, error and Googling, I found the following process worked for getting my X600 quadcopter kit up and running:


X600-V3-COPTER-COMBO

 [SAFETY NOTE - do not put the propellors on!]

1. 'Bind' the RC transmitter and receiver (For Spektrum this requires a 'bind plug' that shorts the bind signal pin to its ground pin). Follow the bind instructions for your radio kit

2. Connect each ESC in turn directly to the receiver's throttle channel. Then follow section 2 of this guide:
- disconnect all ESCs from the board (only servo cables)
- connect ESCs one after the other directly to RX's throttle channel in order to proceed for calibration
- turn TX on
- move stick to full throttle
- Power the ESC
- wait for initialization beeps + 2 beeps
- after 2 beeps, move throttle stick to minimum
- wait for beeps (generaly 3 + 1 or 1 + 1)
- Unpower ESC and disconnect
- Repeat until all 4 are calibrated and you're done

Here's the ESC manual - there are a lot of poorly Englishised manuals in internet land :(


3.  Re-connect the KK multicopter board to the right ESCs (as in this guide)

4. Power up the quadcopter and 'arm' the KK multicopter board by holding the throttle/rudder stick down and right until the IMU board light comes on again - see chapter on 'Setting up the KKmulticontroller' of this guide

5. Go through the checks in the rest of the KKMulticontroller guide, testing that:
  • The throttle works
  • The pitch/roll/yaw commands are mapped correctly to elevator/aileron/rudder controls
  • The gyros work in the correct way (if you tip the quadcopter then the arm that is being dropped should rev up to stop the tipping motion - detecting yaw correction can be done similarly by twisting the quadcopter and noting if the front/back motors speed up or slow down.
UPDATE

Having wired up my quad in a 'plus' configuration (as advertised) I found that one of the arms didn't react properly. I also noticed that on dropping one arm two motors would speed up. This suggested that the KK multicontroller had an 'X' configuration loaded. To fix I had two options;
  1. Dig out an Arduino and flash it with the AVR ISP so I could compile and re-flash the KK multicopter ATMEGA168 with the quadcopter 'plus' config, or...
  2. Rebuild the 'copter in 'X' configuration.
I went with option 2 as less risky and simpler :) The new 'X' config seems to work in the correct way

Saturday, 29 December 2012

DIY CNC mill first 3-axis run drawing G-code from Inkscape




Quadcopter kit project

Santa pushed the boat out this year and, completely unprompted, gave me a quadcopter kit for Christmas :)

The kit included an airframe, battery, motors, propellors and motor control electronics. The airframe is a CSL X600

In the box were a load of bagged bolts, screws, aluminium section and cut glass-fibre board (?) and absolutely NO instructions.

I found a 'guide' here, a time lapse video here both of which helped to work out how this thing goes together as the design seems to have had some tweaks since the seller website was put up, so looking at the pictures there can be confusing.


The quadcopter is basically assembled in four parts:
1. The central chassis
2. The arms and motor mounts
3. The landing gear
4. Mounting the electronics and motors on the chassis and arms

I started with the central chassis and added the arms, working my way through the bits so I knew what fitted where. The process involved a bit of trial and a lot of error, but below is a pictorial build log...

This plate is the TOP of the quadcopter - here it is upside-down for fitting

Arms mounted

Arms - note that they have a top and bottom side. The tiny hole on the far right shows the bottom of the outer end of the arm - that hole is used by the tension spring in each landing leg


Folded arms

The bottom two plates - make sure that the arms can still fold once this plate is installed!

Motor mount and brushless motor

Motor fixing - use the round-head bolts supplied in the kit and ignore the counter-sunk screws that come with the motor

Landing gear - note this config looks different to the selling website pics

Landing gear spring

Landing gear in action

Out of all the bits supplied with the motor and prop, heres what I think you need...

Assembled prop

Finished build with electronics fitted


 Now to wait for a shiny new Spektrum radio set to arrive in the post...