MikroKopter

Understanding MKTools Parameters

Mikrokopter Tools (MKTools) allows the user to configure settings on the Mikrokopter such as gyro gains, gps holding thresholds, camera motion settings, and many others. The purpose of this page is to present a deeper understanding of the MKTools settings. General information about MKTools can be found here.

The table below can be tracked here. This table summarizes popular setups, MKTools settings, and performance of those settings in the real world. This is a good place to start when learning how to configure your Mikrokopter using MKTools. mkparametertable.jpg

Screen: Stick

Screen: Gyro

Screen: Hohe

Screen: Other

Screen: GPS

Explanation of GPS Parameters

The P-parameter defines the strength of the control for the position hold; therefore, our virtual GPS-helper-pilot steers more strongly towards the target when this factor increases. You can understand this by thinking of a pendulum. The further the pendulum is away from the center (the further the MK is away from the target), the stronger the force is to pull it back to the center. Increasing P would be like increasing gravity or the force to push it back to the center. It so happens that the pendulum accelerates in the direction toward the center. At the moment the center is reached, there is no applied force to move the pendulum in any direction. The pendulum though, would still have some velocity (momentum) at this point and the pendulum would then swing away from the center in the opposite direction (the MK would shoot past the target). Without any friction to dampen the swinging this little game would then continue for ever. The swinging could actually get worse. So, the higher the P-Parameter is the stronger the ‘push’ on the pendulum back towards the center.

This is why we have a D-parameter, it makes sure that it proportionally steers against the over ground speed. This is the ‘friction’ parameter in the control system. It works similarly to friction in a pendulum system. If the friction is too high, then a pendulum that was not at it center would very slowly move back and then just stop when it got close. If the friction is too light, then the pendulum would just swing back and forth for a while.

Now, there is just the right relationship from return-force (P) and friction (D) that would allow a pendulum to quickly swing back to the center and then just stay there. These are the settings that you are trying to find. This is impacted by the reaction of the MK to the virtual GPS-helper-pilot stick movements. This is not impacted by the P and D of the RC-Stick settings but from the Gyro Settings that defines the reaction/behavior of the MK.

On top of this is the fact that the GPS-Position and the over ground speed also changes even for a MK that is stationary. This is because of atmospheric disturbances and start point quality, etc. Putting this is terms of the pendulum example; it would be like the hanging point for the pendulum would also be moving. So for example, trying to hold a pendulum without swinging it at the end of an outreached arm would be very difficult. The pendulum would swing all over the place if the ‘friction’ (D) was not large enough.

Setting GPS Parameters

  1. Set GPS-P (userparam5) to zero
  2. Set GPS-D (userparam6) to a Poti and move the Poti to zero (as seen from the Display-Menu)
  3. Manually hover in one spot
  4. Gradually increase the Poti (GPS-D) until you see some light jittering/wobbling. Then move the Poti back a little
  5. Read the Poti value in MK-Tools (from the Display-Menu) and set GPS-D (userparam6) to that value
  6. Set GPS-P (userparam5) to a Poti and move the Poti to zero (as seen from the Display-Menu)
  7. Again manually hover in one spot
  8. Gradually increase the Poti (GPS-P) until a noticeable position correction is obtained but not too much that the MK strongly over steers.
  9. Read the Poti value in MK-Tools (from the Display-Menu) and set GPS-P (userparam5) to that value

In general, the relationship between GPS D&P has to be correct.

If P is too big and D too little the MK will start to swing. If D is too big then the MK will start to jitter/wobble.

Finally, you have to be certain that the compass actually points to North (about 350° to 10°) when the front of the MK actually is exactly pointing to the North. If this is not correct, then the GPS control will cause the MK to circle around the set point or the MK will just fly away.

Understanding PID Gyros


matrix.gif

These gyros spit out the rate of angular change. What this means is that (in terms of a PID control, see http://www.embedded.com/2000/0010/0010feat3.htm and http://en.wikipedia.org/wiki/PID_controller for starting info on PID controlers) that Gyro-P is the proportional factor of the gyro rate of change or ‘D’ in the PID control of the MK angle.


Now, if you take the integral of the rate of angular change you get the angle, so that Gyro-I is then ‘P’ in the PID control of the MK angle. What does that mean? Well, think of a pendulum as an analogy ‘P’ is the force that tries to move the pendulum back to the center. The further away it is the stronger the force to move it back. When the pendulum gets to the center position the force exerted on it is zero but momentum carries it on and past center only to create a force in the opposite direction again to try and move it back. And a swing in created. If you increase ‘P’ [Gyro-I] you are essentially increasing the force to move the MK back to the correct orientation. If ‘P’ is too big it is like pushing someone on a swing and if you push too much the swinging just gets bigger and bigger [MK would oscillate]. If ‘P’ is too little it would be like turning down gravity and you would swing slowly [MK would correct slowly]. . So ‘P’ is the return force.


Having a MK swing/tilt back and forth like a pendulum would not be a good thing. What you would need is some friction. That’s where ‘D’ [Gyro-P] comes in. ‘D’ is trying to adjust for the rate of change of the angle and provide a force in the opposite direction to try and slow it down if it is approaching the center two fast. ‘D’ is trying to be more predictive. For the pendulum it is like adding friction. That way, as the pendulum swings to the center it is being slowed down and the oscillation die down quickly or don’t happen at all. If ‘D’ is two large its like having the friction to large and the pendulum just stops before it even gets to the center and it resists disturbances or is hard to push [MK tends to hold on to tilts]. If ‘D’ is too small the pendulum just swings back an forth [MK just oscillates for a while] So ‘D’ is like a friction force.


Now what happens if winds blows a pendulum? Well, it would tend (even at rest) to be tilted. For a MK that would also not be good. What is needed is something that accounts for the long term error (average amount away from center) and provides a force to correct. This is the ‘I’ in the PID control. It is the integral of ‘P’. What is ‘I’ in the MK, well I have no clue and I have asked but been ignored many times (now starting to look at the code to figure it out). I would imagine it’s the Hauptregler I-Anteil. So ‘I’ is an adjustment for the average offset error.


If your MK has a lot of vibration noise, what happens? Well for the ‘I’ portion since it is the average, any noise just gets average out. The ‘P’ porting simply just passes the noise on (so this is like having the angle reading jump around from 1, 4, 2, -1, 3, 1, -3,etc). For ‘D’ it’s a different story. ‘D’ is the rate of change of the angel so the jumping around from ‘P’ would mean that to ‘D’ it looks like it is moving one way then the other, slow then fast,etc. For ‘D’ the noise gets amplified. The MK would be jerky.


The goal is to have the pendulum very quickly swing back to center and then just stick. How you achieve that goal on a MK or what that looks like no one will say.


You can imagine that there are trade offs for all of these setting and changing one affects the others. Add to that the fact that the MK properties of YOUR MK affect this as well. How fast the motors can change RPM, the max thrust, the mass of the arm, the center of gravity, the efficiency of the drive system, sensitivity of the sensors, the wind resistance of the frame etc. You change these things and it’s like changing a portion of the PID control. Something as miniscule as changing the stiffness of the propeller would change the efficiency at various RPM and would then require a tweak on probably P (only then to be followed by checking the others).


Now the gyros are not that accurate/stable (if I understand it correctly) so the accelerometers are used to adjust/correct gyro errors thru the ACC/Gyro Comp. parameter. This essentially determines how fast the gyros get brought back in line with the accelerometer readings. How does this affect the MK flying, I don’t have a clue. Played with it but can’t figure it out.


The Stick parameters and how the stick feels in terms of MK control is also related to how the MK PID control is set up. If the PID is very ‘hard’ then you would need a lot of stick amplification to move the MK. If the MK is set up ‘soft’ and you didn’t change the Stick settings the MK would feel very twitchy. All these things are interrelated. Even the GPS parameters.


Example Gyro setup:


  1. First trim the MK so it would not drift one way or the other and set Stick-D to 0.
  2. To set Gyro-I and Gyro-P, start with Gyro-P at zero and Gyro-I at 60 with both on Potis and then took off.

The MK will be sensitive to the controls and wobbly. Give little taps to the sick and observe the behavior.


= Understanding Acc/Gyro-Factor =

Acc/Gyro-Factor (or GyroAccFactor below) is simply a scaling factor that allows the ACC and Gyro integral sensor values to be compared. If the ACC and Gyro Integral lines in MK-Tools do not line up then it can be corrected with this scaling factor.

Once the two sensor values (from Gyro and Acc) are scaled correctly, they can then be compared and used to determine orientation of the MK (pitch/roll). The Acc/Gyro-Com (or GyroAccTrim below) controls the fusion of the two readings (ACC vs Gyro). The larger the number the smaller the impact that the ACC have (it scales the error between the two reading down), the smaller the number the bigger the impact the ACC have. According to the Wiki, larger numbers are better for hovering. The ACC are more suseptable to vibration noise so this is also a factor for MK jitters depending on your setup and vibration levels.

The Drift Compensation limits the amount of correction that can be added to what the MK thinks is its Nuetral position. 0 = no correction. The correction is from a longer term (500ms) comparison of the ACC (using gravity) and the Gyro pitch/roll readings. There might be Gyro drift but gravity should not change and this allows some correction for the long term diff. between the Gyro and ACC for Nutral. When you push your stick to the uper left to cal the Gyro sensors you are essentially calculating Gyro Neutral using the ACC cal values. The Drift Compensation is an attempt to keep the Gyros Neutral in cal during flight.

// MeasurementCounter is incremented in the isr of analog.c
if(MeasurementCounter >= BALANCE_NUMBER) // averaging number has reached
{
static int16_t cnt = 0;
static int8_t last_n_p, last_n_n, last_r_p, last_r_n;
static int32_t MeanIntegralPitch_old, MeanIntegralRoll_old;
// if not lopping in any direction (this should be alwais the case,
// because the Measurement counter is reset to 0 if looping in any direction is active.)
if(!Looping_Pitch && !Looping_Roll)
{
// Calculate mean value of the gyro integrals
MeanIntegralPitch /= BALANCE_NUMBER;
MeanIntegralRoll /= BALANCE_NUMBER;
// Calculate mean of the acceleration values
IntegralAccPitch = (ParamSet.GyroAccFactor * IntegralAccPitch) / BALANCE_NUMBER;
IntegralAccRoll = (ParamSet.GyroAccFactor * IntegralAccRoll ) / BALANCE_NUMBER;
// Pitch ++++++++++++++++++++++++++++++++++++++++++++++++
// Calculate deviation of the averaged gyro integral and the averaged acceleration integral
IntegralErrorPitch = (int32_t)(MeanIntegralPitch - (int32_t)IntegralAccPitch);
CorrectionPitch = IntegralErrorPitch / ParamSet.GyroAccTrim;
AttitudeCorrectionPitch = CorrectionPitch / BALANCE_NUMBER


For the Gyro / ACC Factor: It appears to be a ‘scaling factor’ to allow for the comparison of the Acc (essentially using gravity to measure the angle of the MK) and the Gyro Integral (since the gyros spit out the rate of angular change the Gyro Integral [sum of the angular changes] is just proportional to angle of the MK) This difference allows the Current Reding_Integral_Gyro value to be corrected by the difference between the two. The Acc essentially keeps the Gyro Integral (sum of rate of angular changes) in check. In the code it looks like this.

// determine the deviation of gyro integral from averaged acceleration sensor
tmp_long = (int32_t)(IntegralPitch / ParamSet.GyroAccFactor - (int32_t)Mean_AccPitch);


Later in the code

IntegralAccPitch = (ParamSet.GyroAccFactor * IntegralAccPitch ) / BALANCE_NUMBER; So InegralAccPitch gets scaled up to the IntegralGyro level. (BALANCE_NUMBER is just used to calculate the average value)


If you want to set Gyro / ACC Factor correctly then you should calculate the average ratio of IntegralPitch/Mean_ACCPitch. The resultant average is then the correct scaling factor to be used as Gyro / ACC Factor.

  1. First set Gyro/Acc factor to ‘1’ (note that the debug_out funtion uses the ‘Factor’ to scale the Integral value before outputting it so you need to set it to 1 to get this to work)
  2. Then run the MK-Tool scope and move the MK through about 6 or 7 tilted positions (letting it rest for about 10-20 sec at each) and then export the resulting data (using ‘Export’ button in MK-Tools).
  3. Load the data into Excel, remove the periods where the MK was moving or level, calculate the ratio of IntegralPitch/Mean_AccPitch and average them (for both Roll and Pitch).


The Mean_AccPitch and IntegralPitch (or Roll) traces should match when the MK is tilted and at rest.

= ACC Setup =

If you push the Gas/Yaw stick up and to the right, the zero level of the ACC sensors get stored in EEProm (since V0.68). Every time you turn on the MK, the ACC settings (calibration offsets) are reloaded from the EEProm. For the ACC calibration it is very important that the MK is as horizontal and still as possible. As a rule, the ACC only needs to be calibrated once, after that you can start from an embankment or sloping surface without problems.

Before ever start (take off) the Gyros need to be re-calibrated. To do this,

  1. Move the Gas/Yaw stick up and to the left until you hear the beep/s and the green LED lights up (during this process only the Gyros get calibrated not the ACC).
  2. It is very important that the MK is not moved during this process. The position is not important."
  3. Gravity and the ACC sensors along with the stored offsets in EEProm then take care of of the MK knowing its orientation. The Gyro Integrals (angle) need to have a valid starting point so calibrating them before take off takes care of that.


Managing Vibrations


Content Credits

/!\ ToDo: cleanup, update with new features


MikroKopter: en/MKTools-Setup (zuletzt geändert am 28.04.2010 22:56 durch anonym)