Improving the Quadcopter

Since first building the quadcopter with the HobbyKing flight controller board we had a few issues with stability. Robert purchased the MultiWii-Pro board, and was having some issues with the configuration software, so has lent me a second board he purchased. The MultiWii board has many advantages over the KK base HobbyKing controller board. Over the 3 axis giros which are fitted to both boards, the MultiWii has 3 axis accelerometers, magnetometer (compass), barometer and GPS capabilities, although the MultiWii pro normally comes with a GPS unit, they are sensitive to being wired up wrong which is why Robert bought a second unit and this one doesn’t have a GPS. So I purchased a Crius Neo 6 version 3.1 which is based on the U-blox Neo 6M chipset. This is capable of outputting navigation data 5 times per second and an accuracy down to about 2 meters, although the configuration needs updating. This was done by connecting it to a computer through a USB FTDI serial adapter (or similar) and the U-Centre software from U-blox (http://www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html).

The default baud rate of the board is 9600, I connected up, used the View->Configuration view and updated the baud rate to 38400 baud (in the ports section), above this tends to introduce errors, this rate gives a good transfer of data with fewer errors. Once this was updated I updated the baud rate of the connection and reconnected. The Updated the navigation update rate (in the rates section) to 5 times per second (200ms). Updated the SBAS settings to apply SBAS correction data. This improves the accuracy of the GPS unit, but it does require a bit longer to get a full fix. I then went to the NAV5 section and updated the Dynamic model to ‘Pedestrian’. This seems to be the recommended settings for using these on quadcopters and similar. Clicking send updates these settings on the GPS unit, going to Receiver->Action->Save Configuration then also saves the configuration to the non volatile memory on the GPS unit so the settings remain even after the unit is powered down.ucentre

 

The GPS was then connected to the MultiWii board.

Looking round on the web I found this guide to updating the software and settings on the board https://www.youtube.com/watch?v=9TIUif3PE9U

So I downloaded the code from https://code.google.com/p/mw-wingui/downloads/list downloading the files MultiWi2_3-navi-b5-baro_fix.zip and WinGUI_2.3pre8(b5).zip. Then downloaded the IDE for Arduino boards from here: http://arduino.cc/en/Main/Software (http://arduino.cc/download.php?f=/arduino-1.0.6-windows.exe)

After unpacking the MultiWi2_3-navi-b5-baro_fix.zip file and installing the arduino ide software, I opened the multiwii software, (file, open, find the unpacked software and open the MultiWii.ino file) selected config.h file from the down arrow on the right of the screen and updated the config.h file, to my GPS baud rate, I also updated the setting #define MOTOR_STOP which changes the default idle spin up of the motors when the unit is armed, and updated various other settings for this specific board and the X configuration quad copter (my final config.h is available lower down this post). From Tools->Board, selected Arduino Mega 2560 or Mega ADK selected the serial port that the board had been assigned by windows and clicked upload. This compiles and uploads the code to the board.

aduino

I then ran the WinGUI software connected and updated the flight tuning parameters to set the P values to 5.0, 5.0 and 8.0 for roll, pitch and yaw respectively. Click write settings to update these settings to the board.

flighttuning

Then go to RC Control settings, I have a 6 channel receiver, so have 2 extra channels which I can use to change the various flight modes. Each channel can be used in 3 positions, low medium and high. I used the first channel to add the ‘Horizon’ (self leveling) mode to the mid and high position, and ‘Mag’ (heading hold) to the high position this way on the flap switch I can use off as just giro stabalisation, mid position as self leveling and high position as self leveling and heading hold. I then used the second channel mid position (only) for GPS hold, and high position for Return to Home. Again write the setting to the board.

flightcontrol

The MultiWii board also has connections for a camera gimbal, to keep the camera level regardless of the orientation of the quadcopter (within normal flight conditions obviously). I managed to get the gimbal pictured below 3d printed. To activate it this needed more updates to the config.h file enabling the #define SERVO_TILT setting, and also going to the windows gui and enabling the camera stabalisation, since I didn’t have any more channels, I added it to channel 1 on all 3 positions so it was always on.

20141231_074407I did find that the software didn’t seem to work very well, shifting the platform in the wrong direction and not to the appropriate proportion, looking at the software this seemed to be changed by the Servo Rates settings, but I couldn’t get this to work, so I made these changes to the output.cpp file:

Changing:

#if defined(SERVO_TILT)
servo[0] = get_middle(0);
servo[1] = get_middle(1);
if (rcOptions[BOXCAMSTAB]) {
servo[0] += (int32_t)conf.servoConf[0].rate) * att.angle[PITCH]) /50L;
servo[1] += (int32_t)conf.servoConf[1].rate * att.angle[ROLL]) /50L;
}
#endif

to:

#if defined(SERVO_TILT)
servo[0] = get_middle(0);
servo[1] = get_middle(1);
float camTiltPitchProp=1;
float camTiltRollProp=1;
#if defined(TILT_PITCH_PROP)
camTiltPitchProp=TILT_PITCH_PROP;
#endif
#if defined(TILT_ROLL_PROP)
camTiltRollProp=TILT_PITCH_PROP;
#endif
if (rcOptions[BOXCAMSTAB]) {
servo[0] += ((int32_t)(camTiltPitchProp*(float)conf.servoConf[0].rate) * att.angle[PITCH]) /50L;
servo[1] += ((int32_t)(camTiltRollProp*(float)conf.servoConf[1].rate) * att.angle[ROLL]) /50L;
}
#endif

This allowed me to add the settings #define TILT_PITCH_PROP -2.00 and #define TILT_ROLL_PROP -1.00
to the config.h file which I set to be -2.0 and -1.0 for pitch and roll respectively after a bit of testing this seemed to the appropriate setting to make the platform correctly counter the pitch and roll of the quad.

My current output.cpp and config.h can be found here:

http://blog.smfc.co.uk/wp-content/uploads/2015/01/config.h

http://blog.smfc.co.uk/wp-content/uploads/2015/01/output.cpp

 

2 weeks ago in the fog I gave it a quick test:

http://www.youtube.com/watch?v=PMG5xhxUmcQ

As you can see the pitch seems ok, you can see the rotors moving up and down in the frame as the copter’s frame pitches forwards, but the horizon stays quite well level, the roll is far further out, although there is some effect, it is not enough and the camera is rolling with the frame

I was very glad at one point that the return to home worked as I lost it in the fog, fortunately it managed to find its own way back. As you can see the roll was much too low, I think the roll setting was slightly too low, so I updated both pitch and roll to -2.0 although last week the weather was a bit windy to make another test flight, and this week I couldn’t make it.

I would like to test this, and record with the GPS on screen data to get some idea of the speed and fly-ability of the quad, hopefully it is not far from being able to do some air to air recording. I will update this post with details and videos as I get them.

7 thoughts on “Improving the Quadcopter”

    1. It definitely came back in the fog, although we couldn’t see it we could hear it, then eventually it reappeared overhead.
      There is the option ‘land’ in the flight controls. I’m out of channels on my radio, I will have to do some moving around and give that a try. I would guess it would just come down gently (hopefully)

    1. Hello Mr Mel,
      I am fortunate that we have just got a 3d printer at work, and I was able to use that.
      Having the return to home function did make me a bit braver in the fog 🙂