>
= 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 [[http://mikrokopter.de/ucwiki/en/MikroKopter-Tool?action=show&redirect=en/MikroKopterTool|here]].
The table below can be tracked [[http://www.rcgroups.com/forums/showthread.php?t=1141571|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. {{attachment:mkparametertable.jpg}}
== Screen: Stick ==
* Stick nick/roll P: Response to degree of stick movement. High value: Needs small stick novements. Low value: Needs large stick movements. Default values: 8-15.
* Stick nick/roll D: Response to speed of stick movement. High value: very twitchy on overcontrol. Low value: sluggish. Default values: 16-30
* Gier P: Yaw response to stick movement. High value: Fast yaw. Low value: Slow yaw. Default values: 6-12.
== Screen: Gyro ==
* Gyro P: Speed of response to gyro angle changes. High value: Fast response, dampending oscillations. Low value: Sluggish response. Default values: 80-100.
* Gyro I: Level of gyro control. High values: Very strong control, wagging if too high. Low values: Oscillations and wind sensitivity. Default values: 120-150
* Gyro D: ??
* Acc/gyro factor: Accurateness of overlay of gyro and acc curves. Check by looking at curves in MKTool. Default value: 30.
* Acc/gyro comp: Frequency of acc/gyro correction. High value: High frequency, more stable. Low value: Less stable. Default values: 16-32. Extended values: Up to 100.
* Dynamic stability: Throttle level for control relative to current throttle position. High value: Can exceed throttle, ballooning in wind gusts. Low value: Remains below throttle, no bouncing in wind. 50-100. Value of 64 should be neutral.
* Haupt I: Level of accurateness between stick and craft attitude. High value: Heading hold. Low value: Less heading hold effect. Default values: 16-32
== Screen: Hohe ==
* Hohe min gas: Minimum throttle if altitude hold active. High value: Less rapid descent on exceeding altitude, even balloon in wind if too high. Low value: More rapid drop on exceeding altitude. Default values: 30-100. Note: test for hover throttle, then set value to just under hover value.
* Hohe P: Rapidity of response to exceeding of altitude. High value: More rapid response. Low value: Slower response, more exceeding of set altitude. Default value: 10
* Baro D: Level of pressure difference leading to response. High value: More sensitive to small differences. Low value: Less sensitive to small gusts . Default value: 30.
* Z acc: Compensation by changes in vertical acc values. High value: More sensitive to vertical acceleration changes. Low value: Less response to rapid descent. Default value: 30
* Verstarkung: Gain, maximum altitude allowed: High value: Larger maximum altitude. Low value: Lower maximum altitude. Default values: 3-4
== Screen: Other ==
* Min gas: Throttle level needed for stationary running of all motors on throttle on. High values: Higher stationary speed, no stopping of motors in flight. Low values: Some motors not starting on motor on, motors stopping in flight. Default values: 10-20. Note: for converted TowerPro's you tend to need values of 15 to 20.
* Max gas: Maximum throttle allowed for user (remainder usable for control?). Higher values: Less stable on low battery, but more throttle for cushening of rapid descent and landing?. Low values: More stable on low battery, bet less ability to prevent hard landing? Default values: 230-250
== 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
1. Set GPS-D (userparam6) to a Poti and move the Poti to zero (as seen from the Display-Menu)
1. Manually hover in one spot
1. Gradually increase the Poti (GPS-D) until you see some light jittering/wobbling. Then move the Poti back a little
1. Read the Poti value in MK-Tools (from the Display-Menu) and set GPS-D (userparam6) to that value
1. Set GPS-P (userparam5) to a Poti and move the Poti to zero (as seen from the Display-Menu)
1. Again manually hover in one spot
1. Gradually increase the Poti (GPS-P) until a noticeable position correction is obtained but not too much that the MK strongly over steers.
1. 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 =
<
>
{{attachment: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.
1. 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.
* If the MK wobbles once or twice and then steadies then crank up Gyro-I until the MK almost continuously oscillated after the stick tap then moved Gyro-I down a notch. Don’t let the oscillations bother you, you can still control the MK (as long as you don’t get Gyro-I too big).
* Then start cranking up Gyro-P. This quickly settles out wobbles.
* Increase Gyro-P and tap the stick to see how it would respond. If Gyro-P gets to big, notice that the MK doesn’t really level itself out after the stick tap. If Gyro-P is too little it will wobble a little after the stick tap but it will level quickly.
* The goal is to not have any wobbles while still having the MK return quickly to level after the stick input.
* The better it is set up the bigger the stick tap you can give and have the MK quickly level and start to slow back down.
* It will also start to feel solid, just don’t let it get to solid or it wont correct quickly enough.
* Hauptregler I-Anteil is the ‘I’ for the PID of the Roll and Nick controller. It will affect the other parameters so if you play with Hauptregler I-Anteil you will have to go back and re-adjust Gyro-P and Gyro-I.
* Acc/Gyro-Comp (or in the code is ‘GyroAccTrim’) controls how fast the difference between ACC and Gyro gets corrected.
* In the code it reads ‘CorrectionPitch = IntegralErrorPitch / ParamSet.GyroAccTrim’ where the IntegralErroPitch is the difference between the MeanIntegralPitch (gyro) and the InegralAccPitch
* It is the difference between the calculated angle (roughly) between the two.
* Big numbers in Acc/Gyro-Comp diminishes the impact of the Acc on the correction.
* Moving on to GPS, set GPS-P and GPS-D on potis and both set to 0. This time start with GPS-D and adjust GPS-D until the MK begins moving around and kind of holding but swinging.
* Then back down some and start to crank up GPS-P until it appeared to have a good hold.
* If you get too much GPS-P you start to swing again, too much GPS-D and you swing…
* Think of the P as the force to push it back and D as the friction
<
>
= 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. <
>
. === Correction Formula: ===
{{{
// 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)
1. 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).
1. 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).
1. It is very important that the MK is not moved during this process. The position is not important."
1. 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 =
* If D is too large (Gyro-P in MK-Tools) then the MK can 'stick' at an angle and not return back to full neutral (this would be like flying a normal heli) and if you dont have the experience then you would probably be touching the controls all the time and overcorrecting the craft. Also, D amplifies noise and vibration could have a bigger impact. [you will aslo need enough P (Gyro-I in MK-Tools) to make sure your craft responds quick enough to return to neutral)
* Assuming you have your PID set up nicely then you could also try minimizing the impact of the ACC sensors by increasing ACC/Gyro-Comp. Again, this will minimize the noise from vibration since the ACC are obviously designed to measure it. The disadvantage is that your craft will then also be more susceptible to wind drifting. If you set ACC/Gyro-Comp to 1 and fly it you will see the thing jittering all over the place. This is the noise from the ACC sensors (vibration). You want ACC/Gyro-Comp as low as you can go without it impacting the stability of the flight and the number is different for each mk and vibration level.
* Don’t set ‘Hauptregler I-Anteil’ too high. If set too high it tends to overcorrect for the difference between stick and actual MK attitude and after you move the stick back to neutral the MK will still be trying to correct for the error cause by the MK not being able to move as fast as your finger.
<
>
= Content Credits =
* Arthur P.
* Brashley
* Old Man Mike
* Rusty (13brv3)
/!\ ToDo: cleanup, update with new features
----
. KategorieEnglish KategorieEnglish