Wednesday, 23 September 2015

Multi Rotor Part 2 - Quadcopter Construction - Step 4

PI Turning and Flight Testing.
"PI Turning is done with propellers fitted, please be careful during this proecess"

KK2.1.5 Flight Controller PI Tuning

  • Tuning is the most important part of getting any quad copter to fly right. Without tuning, the quad copter is very hard to control.
  • I chose to use the KK2.1.5 flight control board for my easy quad copter build because PI tuning is accomplished on this board by setting gain variables used by the firmware loaded on the board with the help of LCD screen, there is no need to connect a computer.
  • The gain variables are set through the lcd menu system on the board. Correctly setting these variables helps the quad fly much better.
  • The creator of the the KK2.0 board and its firmware is Rolf Bakke aka KapteinKUK.
  • The RCGroups forum thread is a great place to download the latest firmware for the board and communicate with others about the board.
  • In KapteinKUK’s forum post he gives very specific directions on setting the gain variables to do PI tuning. 
  • I followed all these directions to tune my quad.
  • I am not a very good pilot and always fly in self-level, however, the tuning process was done with self-leveling off.
  • I went into the first menu item called “PI Editor” and changed all of the variables.
  • I did not change any of the limit values during the tuning process.

Here is what Kaptein KUK has to say about PI tuning :
Roll and Pitch Tuning

  • The right and left roll angle of the quadcopter is controlled by the radio’s aileron stick movement.
  • This is done by moving the right stick on my Mode 2 radio right and left.
  • The forward and back angle of the quadcopter is controlled by the radio’s elevator stick movement.
  • This is done by moving the right stick up and down.
  • By default the KK2.1.5 links the tuning for roll and pitch together and I left it that way for my quad.

Roll/Pitch P Gain Tuning

  • Increase Roll/Pitch P-gain by 10 (5 or less for a small aircraft) at a time, and test your aircraft response by hovering and move the left stick in short and fast movements.
  • I believe when he says “left stick” above, he is using a Mode 1 radio, where the roll and pitch are set up on the left stick. I use a Mode 2 radio where the pitch and roll are on the right side.
  • As I moved the P gain value up by 10 it became more responsive. When I got my P value up to 80 the quad was much more responsive to my stick movements so I left it there.
  • Some folks recommend raising the P value until the quad oscillates and then backing it off a bit, but I just stopped when it felt it stable in after raising it to 80.

Roll/Pitch I Gain Tuning

  • Here, I started with an I gain of 40 which was 50% of the 80 I chose for the P gain. When I got to 60, I noticed it would hold the angle I set by moving the right stick from side to side or forward and back.

Yaw Tuning

  • The rotation of quad copter is controlled by the radio’s rudder stick movement.
  • The rudder is controlled by moving the left stick on my Mode 2 radio right and left.

Yaw P Gain Tuning

  • Here are KapteinKUK’s suggestion on tuning the P gain value for the yaw:
  • Increase Yaw P-gain by 10 (5 or less for a small aircraft) at a time, and test your aircraft response by hovering and move the Yaw control stick until it have yawed about a quarter of a circle, and then center it.
  • I set the P gain to 60. This is where it stayed the most level while yawing.
Yaw I Gain Tuning

  • Finally, here is what KapteinKUK has to say about tuning the P gain value for the yaw:
  • It is generally good to keep the gain values in the low range.
  • Excessive gain may introduce vibration and control issues.
  • I also set the yaw I gain to to 60 to match the P gain.

Self-Level P Gain

  • Under the self-level settings menu there is another P Gain value that is specific to self-level mode.
  • It defaulted to 40 with the version 1.2 firmware that shipped with my board.
  • Version 1.5 and higher versions of the firmware has an improved self-leveling algorithm.
  • Since I prefer to fly in self-level mode, I upgraded my firmware.( I am now using V1.18S1 Pro Firmware by Steveis, so this values and settings have little changes, I will also give the procedure followed by Steveis.)
  • Though it is a little more advanced and may not required, a USBasp AVR can be used to easily load newer versions of the KK2.1 firmware using the LazyZero KKMulticopter Flashtool.
  • The later versions of the firmware have much better self-levelling capability, so I always upgrade my firmware.
  • The self-level P Gain was set to 100 after I changed the firmware to version 1.5.
  • At 100 the quad leveled too quickly and became a little jerky. 
  • When I lowered it to 60 it behaved much better.
  • Example of my final tuned PI gain settings were:

          Roll/Pitch P-gain: 80
          Roll/Pitch I-gain: 60
          Yaw P-gain: 60
          Yaw I-gain: 60
          Self-level P-gain: 60
Note : This is an example, it may not match for your quad copter, you have to obtain the correct gains by trial and error.

Flying - First Flight

  • After doing all of the above stuff, I was ready to take the copter outside to an open space away from people to do an initial flight.
  • Once the copter was in a safe open area with the battery was disconnected, I put the props on the quad .
  • Placed the quad on level ground.
  • Switched on my Tx and confirmed the model selection.
  • Connected the battery to the power harness and immediately stepped away form the quad.
  • Stood at a safe distance from the quad copter and moved my throttle/yaw stick down and right to arm the board in gyro only “rate” mode.
  • Checked to make sure the propellers were rotating correctly by applying a little bit of throttle, but not enough to lift the quad off the ground.
  • I checked that the correct motors were responding to my stick commands by applying a small amount of throttle while testing the aileron, elevator and rudder stick movements. With props on, the quad leaned and turned appropriately.
  • When all props and motors were spinning and responding correctly, I gave the quad enough throttle to lift off and it flew ok with no tuning, but it needed tuning.
  • If I had any problems, I would have immediately lowered the throttle to idle and landed the copter.
  • I also flew it in self-level mode by selecting self level mode with my Tx.
  • It leveled fairly well, but more tuning is required to fly much better.
  • The above steps got the quad copter in the air, but the controls are very loose. Also, the throttle is hard to control and the quad loses altitude when yawing.
  • Tuning will improve these issues greatly.
  • I am not a talented pilot and can’t fly a quad copter that hasn’t been tuned.
  • So beginners should not forget to tune their quads before you demonstrate it in front of people,  which can lead to disaster.
  • General Points - Error messages can only be reset by cycling the power, except for the "sensors not calibrated" message, which is reset after a successful sensor calibration.
  • Error messages include lost RX connection.
  • The KK2.1.5 has an auto-disarm function and will disarm itself after 20 sec if throttle is at idle, for extra safety. it can be turned on/off in "Mode Settings" menu.
  • Lost Model Alarm - The KK2.1 has a lost aircraft alarm and starts to beep (1 sec on and 4 sec off) after 30min of no activity (arm/disarm).

Now we will see the settings for KK2.1.5 , V1.18S1Pro firmware by Steveis.
PI Editor.
  • Enables you to adjust the control loop feedback parameters for Roll, Pitch and Yaw.
  • The proportional term (P) produces an output value that is proportional to the current error value.
  • A high proportional gain results in a large change in the output for a given change in the error.
  • If the proportional gain is too high, the multi copter will overshoot and start to oscillate. 
  • Since the control loop compensates for errors 400 times a second too high a P gain will result in a high frequency oscillation. 
  • If the proportional gain is too low, the control action will be too slow to react on the multicopter and it will be difficult to control.
  • The contribution from the integral term (I) is proportional to both the magnitude of the error and the duration of the error. The integral in a PI controller is the sum of the instantaneous error over time and gives the accumulated offset that should have been corrected previously.
  • If the integral term is too high, the multicopter will start to oscillate.
  • Since the I term is related to the duration of the error over time, too high an I gain will result in a low frequency oscillation.
  • Too low an I gain will result in a less “locked in” feeling.
PI gain adjustment process
  • Go to the "Receiver Test" menu and use the transmitter trims to set the Roll, Pitch and Yaw values to zero.
  • Switch off Self Level.
  • Set the I gain to zero for Roll, Pitch and Yaw.
  • Hover the multicopter and move in one axis (Roll, Pitch or Yaw) and quickly centre the TX control stick.
  • Increase the P gain until the multicopter starts to oscillate when the stick is quickly centred.
  • Decrease the P gain slightly to remove the oscillation.
  • Repeat for all three axis (note, if you have “Link Roll Pitch” set to “Yes” in the Mode Settings menu then adjusting the PI gains and limits for Roll will also adjust the Pitch settings).
  • Increase the Roll and Pitch I gain until it flies straight forward/sideways without pitching up or down. It should feel more “locked in”.
  • Increase the Yaw I gain until Yaw feels “locked in”. You will see most impact on a tricopter. Leave as default for quadcopter.
  • Note, if you have I gains set and you operate your multicopter on the ground, you will find that motors will start to increase in speed while others decrease. 
  • This is the I term working to compensate for long term errors, but on the ground, or in your hand (without props on of course) it doesn’t allow the I term to move the multicopter to compensate for the error.
  • A tuning video can be found here:
PI limits
  • The PI limits are the percentage of motor power that can be used to apply the correction.
  • These should be left at default. For example, a limit of 20 (20% motor power to apply the correction) will allow 80% of motor power to be used for commanding a change in direction from the receiver.
SAFE Screen Information - Pre-flight

  • If the SAFE screen says ERROR, you must fix that error before you can arm it.
  • You will see the actual error on the display.
  • You may have to power cycle the KK2.1.5 to clear an error after fixing it.
  • Top right displays the profile being used (P1 or P2) or tells you which stick scaling and PI profile you are using (PI1 or PI2).
  • It will tell you if Self Level is on or off.
  • The Battery (Batt) voltage will be displayed if you have connected the flight battery +ve to the KK2.1..5 battery monitor pin (pin closest to the edge of the board).
  • Temp is the MPU6050 internal temperature.
  • Roll and Pitch Angle will appear after arming and disarming. They display the angle of the KK2.1.5 after arming and disarming.
  • If you have the Alternative SAFE screen layout selected in Misc Settings 2, it displays the last Motor Layout selected (this is just a guide as you may have changed the settings in the Mixer Editor).
  • Pressing button 4 takes you into the MENU.


  • If the SAFE screen says ERROR, you must pay attention.
  • You will see the actual ERROR on the display. It will most likely be “Error: no yaw input” which means you had a receiver failure during flight.
  • The top left corner will display a number if the KK2.1.5 code took longer than expected to execute during flight, the number of times this happened will be displayed.
  • This shouldn’t happen. If it does, it could indicate a fault with the board.
  • The Roll and Pitch Angle will appear.
  • Pressing button 4 takes you into the MENU.
Problems with Self Level

  • The following will cause accuracy issues with Self Level.
  • Vibrations are the most common cause – balance your propellers, including the hubs.
  • Balance your motor bells.
  • Ensure you don’t have bent motor shafts.
  • Ensure the engineering quality of your prop adapters is acceptable.
  • Finally, dynamically balance your motor with prop and prop adapter.
  • Arming outside the 20deg limit – arm the multicopter when it is level.
  • Exceeding gyro rate while flying – ensure the gyro rate is higher than your expected manoeuvres. 
  • This will cause catastrophic issues if self level is switch on as the KK2.1.5 will have no idea which way is up.
  • Temperature changes – let your multicopter acclimatise to the temperature you are going to fly in before arming.
  • Drifting gyro – gyros drift over a short period of time (minutes). During long flights, you may need to land and rearm to recalibrate the gyros.

Pre-flight checks and setup
Initial Setup of the KK2.1.5 disconnected from Multicopter
  • Remove the KK2.1.5. from the Multicopter.
  • Power up the KK2.1.5 using a 4 cell battery pack or BEC.
  • Select the required Motor Layout.
  • Select the Receiver Type in Mode Settings.
  • If necessary, change Channel Mapping.
  • Power down the KK2.1.5.
  • Set up your transmitter as a simple aircraft with no mixing.
  • If necessary, bind your transmitter to the receiver.
  • Power up your transmitter.
  • Connect the receiver to the KK2.1.5.
  • Power up the KK2.1.5 and receiver.
  • Refer to the Receiver Test section and set up correctly.
  • Power down the KK2.1.5 and receiver.
  • Power down your transmitter.
Setup of the KK2.1.5 mounted in the Multicopter
  • Remove all propellers.
  • Mount the KK2.1.5 on the frame with the LCD facing front and the buttons facing back.
  • Connect the receiver to the pins on the left side. The negative (black or brown) lead towards the edge of the KK2.1.5.
  • Connect the ESCs and servos to the pins on the right side. The negative (black or brown) lead towards the edge of the Kk2.1.5.
  • Connect buzzer and battery voltage monitor if required.
  • Turn on your transmitter.
  • First we must set the throttle limits on the ESCs
  • Set your transmitter throttle stick to maximum
  • Press and hold down buttons 1 & 4 on the KK2.1.5
  • Turn on the power to the Multicopter
  • Wait for the ESC to beep its full throttle calibrated signal. Takes a few seconds, depends on the ESC
  • Lower the throttle to idle
  • Wait for the idle throttle calibrated signal
  • Release buttons 1 & 4.
  • Place the Multicopter on a level surface.
  • Calibrate the accelerometers using the ACC Calibration menu option.
  • There shouldn’t be any errors on the SAFE screen but if there are, they need correcting.
  • All propellers should still be removed.
  • Arm the KK2.1.5 by moving the throttle to minimum and yaw to the right for a few seconds and apply a little throttle.
  • Ensure all motors spin in the direction as indicated by the Motor Layout. 
  • If a motor needs reversing, you need to remove two of the three motor wires from the ESC and swap them over.
  • The KK2.1.5 cannot be used to reverse the direction of a motor.
  • With the motors running, if you push the roll/pitch stick towards a motor, it should slow down and the opposite motor should speed up. If not, check the stick directions in Receiver Test.
  • With the motors running and the sticks central, dip one of the motors and it should speed up. If not, check the stick directions in Receiver Test.
  • Disarm the KK2.1.5 by moving the throttle to minimum and yaw to the left for a few seconds.
  • Turn off the Multicopter.
  • Turn off your transmitter.
First Flight
  • You are now ready to fly.
  • Ensure the propellers are placed on the right motors for the direction that they are turning.
  • Remember to turn your transmitter on first and turn it off last.
  • Turn your transmitter on.
  • Turn on the Multicopter.
  • Step away at least 5 meters.
  • Arm the KK2.1.5 by moving the throttle to minimum and yaw to the right for a few seconds.
  • The buzzer will sound and the KK2.1.5 LED will light.
  • Turn self level off.
  • Gently lift the throttle.
  • If it wants to tip over right away, check your motor connections and your custom made mixer table if you have one.
  • If it’s a tricopter and it starts to pirouette on take off, go to the Mixer Editor and select the channel that the servo is connected to (usually output 4 or 7) and change the Rudder value from +100 to -100.
  • If it shakes and maybe climbs after it’s airborne, adjust the Roll and Pitch P Gain down.
  • If it easily tips over after it's airborne, adjust Roll and Pitch P Gain up.
  • Increase the Roll and Pitch I gain (note the difference from P gain) until it flies straight forward without pitching up or down.
  • Once you have adjusted your PI Gains to your satisfaction, turn self level on and adjust the Self Level P gain.
  • More detailed PI gain setting instructions can be found in the PI Editor section of manual.
  • Adjust Stick Scaling to your liking.
  • After flying, turn off the Multicopter.
  • Then turn off your transmitter.
  • Stick Scaling and overflying the gyro rate:
  • Gimbal setup:
  • Calibrating the ESCs:

Information of firmwares:-
HW Version 2.1.X, SW Version by Steveis
V1.18S1Pro for KK2.1.X
V1.17S1Pro for KK2.1.X
V1.16S1Pro for KK2.1.X
V1.15S1Pro for KK2.1.X
HK V1.6 for KK2.1.X

Happy Flying!!!!!!!!!
Coming up Next :- Basic Trainer Airplane Construction using Coroplast Sheet (Sun board)

No comments:

Post a Comment