This is the weirdest thing. See the new attachment - I swear it's the same name, but this one has the ATUN logs. You're looking for the ATUN and ATDE entries right? They're there.
The ESCs are Turnigy Multistar either the 30A or 20A (I think 20A on that frame):
Oh, so I start to increase it from default? By a factor of 2? Or 1.5? Will try tomorrow - honestly, I'm so desperate, that I'd try anything at this point :-).
Reduce Rate D untill you don't see oscillation then reduce it a bit further. (about 20%)
Increase Rate P untill you see oscillation.
Reduce Rate P untill you don't see oscillation and then reduce it a bit more. (about 20%)
As I said before though, logs of autotune tell me a lot and I will be able to see why autotune is having trouble. It might be the same reason you are having trouble with manual tune.
The I term eliminates steady state/long term error. Lets say you command the copter to level out by releasing the stick (ie tell it to go to 0 degrees tilt). It might get to 0.5 degrees which is very close but at that point the influence of the proportional term may be too small to actually do anything. P gain times a small number equals a small number so the P controller can never close the gap. The I term adds up this error over time and increases the control signal until the target is met. This isn't 100% accurate to what the APM is doing but I think it is a decent explanation of the principle.
We have a couple of factors that come into play here. We want:
- a large response so any noise or external forces are small in comparison,
- to ensure that we don't saturate the throttle output, especially near the end of the movement,
- a small change in attitude to minimise the brown trouser moments,
- a quick test so we can do it multiple times,
- to ensure it works on all frame sizes.
- to approximate a reasonable error that a copter might experience to ensure the copter can recover from any normal flight condition.
So for the best autotune measurement we want the largest response while not saturating the outputs or pushing them into significantly non-linear region. The maximum output of the roll and pitch loops approximately 4000 after all things are taken into account. So if we say we want to limit ourselves to half this to keep us away from the edges. So with a Rate P of 0.1 we would have a maximum rate request of 20000 centi degrees per second or 200 degrees per second. With a Rate P of 0.25, the maximum autotune allows, we get 8000 centi degrees per second or 80 degrees per second.
The maximum Rate P was chosen based on what I have seen from helping people tune a range of frames and it has turned out to be a pretty good number. The only person I remember seeing reach it, had a pair of camera tubes and the camera out the front of the first props and batteries hanging out the back.
So at the maximum allowed Rate P we get 80 degrees per second gives us exactly half throw on the esc outputs, if Rate D is zero. So 90 degrees per second looks like a nice number.
Now Rate D will also pump the output up and may saturate the outputs at the very beginning. This isn't so bad as it only lasts a fraction of a second and had gone by the time we get to the slow down portion where the test really begins. However, a saturation at the beginning my mess with the results. Soooo...... The initial step input is multiplied by Alpha in the low pass filter before being multiplied by 100, 1/loop time, and then by Rate D. So for 90 degrees we get 9000 x 0.0123 x 100 x Rate_D is the additional output from the Rate_D. Now the maximum Rate D that autotune allows is 0.015. This results in an additional command output of 167. The maximum Rate D was also chosen based on experience and has worked out well so far.
So with a 90 degree per second rate request we get a maximum command response of 9000 * 0.25 + 167 = 2417. This is ok as it only happens if we get to the absolute maximum tune.
Ok what about Stab P. Now this will be able to saturate the outputs. So we chose the smallest angle that we thought was reasonable. The most common step input experienced by a copter is a 45 degree step as the pilot lets go of the sticks from full stick input. This is too much, as any overshoot will then result in the copter swinging past 45 degrees, and it is generally too scary. 20 degrees is what we settled on as a reasonable angel command but not so large as to scare the crap out of people.
So the initial motor output will look something like this. 2000*Stab_P*Rate_P + 2000*Stab_P*Alpha*100*0.01
So with all the maximums we can get to 7870 and that will cause the motors to saturate at the beginning of the test. However, this is a very extreme case and will only happen on copters with large weights on long camera poles. Usual test maximums won't go over approximately 4500 (Rate_P = 0.15; Rate_D = 0.01; Stab_P = 14;). and normal flying pids would stay below 2600 on the same test.
So the numbers are pretty reasonable. Having seen the numbers that Autotune generate I will probably drop the maximum Stab_P to 10 and slightly change the way it does those measurements.
So we have covered the maths. The next question is the pilot response to the numbers that the maths suggest might be ok. Here I flew it (I probably did 50 autotunes) and I found it was ok. I could even do an autotune in my lounge room (it was raining outside). So I figured the average pilot would feel pretty comfortable outside in a park at 10 to 15 meters up.
The final thing I should point out is that the autotuned values result in Rate_P values between 2/3 and 1/2 what we would get using manual tuning methods and Stab P values of approximately 2x the manual values. So the overall motor output is quiet similar to our manual tune numbers. However, the copter is MUCH more stable.
So I hope that was a reasonable explanation. Let me know if you have any questions.
Replies
This is the weirdest thing. See the new attachment - I swear it's the same name, but this one has the ATUN logs. You're looking for the ATUN and ATDE entries right? They're there.
The ESCs are Turnigy Multistar either the 30A or 20A (I think 20A on that frame):
http://www.hobbyking.com/hobbyking/store/__46306__Turnigy_Multistar...
They have been configured for high number of rotors, no brake, NiMh battery.
In fact the entire airframe setup is here:
http://centmesh.csc.ncsu.edu/trac/MeshBed/wiki/HardWare/Drones/Airf...
Thanks,
Mihai
2014-03-11 13-09.log
Try getting Rate_D tuned first. I had some setups that needed 4x the default D to become tame enough for Rate_P adjustment.
Oh, so I start to increase it from default? By a factor of 2? Or 1.5? Will try tomorrow - honestly, I'm so desperate, that I'd try anything at this point :-).
Thanks for the tip,
Mihai
Manual tune procedure is basically:
Increase Rate D until you see some oscillation.
Reduce Rate D untill you don't see oscillation then reduce it a bit further. (about 20%)
Increase Rate P untill you see oscillation.
Reduce Rate P untill you don't see oscillation and then reduce it a bit more. (about 20%)
As I said before though, logs of autotune tell me a lot and I will be able to see why autotune is having trouble. It might be the same reason you are having trouble with manual tune.
So, when does the I term come into play? and how does one look for when adjusting that?
The I term eliminates steady state/long term error. Lets say you command the copter to level out by releasing the stick (ie tell it to go to 0 degrees tilt). It might get to 0.5 degrees which is very close but at that point the influence of the proportional term may be too small to actually do anything. P gain times a small number equals a small number so the P controller can never close the gap. The I term adds up this error over time and increases the control signal until the target is met. This isn't 100% accurate to what the APM is doing but I think it is a decent explanation of the principle.
Hi bblatter and Josh,
We have a couple of factors that come into play here. We want:
- a large response so any noise or external forces are small in comparison,
- to ensure that we don't saturate the throttle output, especially near the end of the movement,
- a small change in attitude to minimise the brown trouser moments,
- a quick test so we can do it multiple times,
- to ensure it works on all frame sizes.
- to approximate a reasonable error that a copter might experience to ensure the copter can recover from any normal flight condition.
So for the best autotune measurement we want the largest response while not saturating the outputs or pushing them into significantly non-linear region. The maximum output of the roll and pitch loops approximately 4000 after all things are taken into account. So if we say we want to limit ourselves to half this to keep us away from the edges. So with a Rate P of 0.1 we would have a maximum rate request of 20000 centi degrees per second or 200 degrees per second. With a Rate P of 0.25, the maximum autotune allows, we get 8000 centi degrees per second or 80 degrees per second.
The maximum Rate P was chosen based on what I have seen from helping people tune a range of frames and it has turned out to be a pretty good number. The only person I remember seeing reach it, had a pair of camera tubes and the camera out the front of the first props and batteries hanging out the back.
So at the maximum allowed Rate P we get 80 degrees per second gives us exactly half throw on the esc outputs, if Rate D is zero. So 90 degrees per second looks like a nice number.
Now Rate D will also pump the output up and may saturate the outputs at the very beginning. This isn't so bad as it only lasts a fraction of a second and had gone by the time we get to the slow down portion where the test really begins. However, a saturation at the beginning my mess with the results. Soooo...... The initial step input is multiplied by Alpha in the low pass filter before being multiplied by 100, 1/loop time, and then by Rate D. So for 90 degrees we get 9000 x 0.0123 x 100 x Rate_D is the additional output from the Rate_D. Now the maximum Rate D that autotune allows is 0.015. This results in an additional command output of 167. The maximum Rate D was also chosen based on experience and has worked out well so far.
So with a 90 degree per second rate request we get a maximum command response of 9000 * 0.25 + 167 = 2417. This is ok as it only happens if we get to the absolute maximum tune.
Ok what about Stab P. Now this will be able to saturate the outputs. So we chose the smallest angle that we thought was reasonable. The most common step input experienced by a copter is a 45 degree step as the pilot lets go of the sticks from full stick input. This is too much, as any overshoot will then result in the copter swinging past 45 degrees, and it is generally too scary. 20 degrees is what we settled on as a reasonable angel command but not so large as to scare the crap out of people.
So the initial motor output will look something like this. 2000*Stab_P*Rate_P + 2000*Stab_P*Alpha*100*0.01
So with all the maximums we can get to 7870 and that will cause the motors to saturate at the beginning of the test. However, this is a very extreme case and will only happen on copters with large weights on long camera poles. Usual test maximums won't go over approximately 4500 (Rate_P = 0.15; Rate_D = 0.01; Stab_P = 14;). and normal flying pids would stay below 2600 on the same test.
So the numbers are pretty reasonable. Having seen the numbers that Autotune generate I will probably drop the maximum Stab_P to 10 and slightly change the way it does those measurements.
So we have covered the maths. The next question is the pilot response to the numbers that the maths suggest might be ok. Here I flew it (I probably did 50 autotunes) and I found it was ok. I could even do an autotune in my lounge room (it was raining outside). So I figured the average pilot would feel pretty comfortable outside in a park at 10 to 15 meters up.
The final thing I should point out is that the autotuned values result in Rate_P values between 2/3 and 1/2 what we would get using manual tuning methods and Stab P values of approximately 2x the manual values. So the overall motor output is quiet similar to our manual tune numbers. However, the copter is MUCH more stable.
So I hope that was a reasonable explanation. Let me know if you have any questions.
I'm going to massage this into the AutoTune wiki under an "Additional Considerations" headline or something to that effect if you're ok with it..