You can use PID Tuner with a plant represented by a numeric LTI model such as a transfer function (tf) or state-space (ss) model.If you have Simulink ® Control Design™ software, you can use PID Tuner to tune a PID Controller or PID Controller (2DOF) block in a Simulink model. If you have System Identification Toolbox™ software, you can use the app to estimate a plant from measured. PID Tuning by Commercial PID. If you have access to a PID controller unit and a compatible thermal probe that fits down into your hotend, you can use them to tune your PID and calibrate your thermistor. Connection of the output of the PID to your heater varies depending on your electronics.
Getting a good set of roll/pitch tuning parameters for your aircraft isessential for stable, accurate flight. To help with this it is highlyrecommended that you use the AUTOTUNE system described below.
Thus, read the first declaration as 'r is an integer reference initialized to i' and read the second declaration as 's is a double reference initialized to d.' Therefore, you can access the contents of the variable through either the original variable name or the reference. For example, suppose we have the following example −int i = 17;We can declare reference variables for i as follows.int& r = i;Read the & in these declarations as reference.
What AUTOTUNE does¶
- Fixedwing PID Tuning Guide. Where it is possible to reduce electromagnetic interference by mounting the Pixhawk a long way from power supply lines. On small vehicles an external compass is almost always required. Set it to Auto. After setting up the second GPS port: Configure the ECL/EKF2 estimator to blend data from both GPS systems.
- PID tuning on the Pixhawk can be done with autotune. A sweet little feature that does the work for you. This will probably set off a fight over if it works well or not. Unless you are flying an abnormal setup it will work more than well. So if you fly pixhawk that is a big bonus for you.
The AUTOTUNE mode is a flight mode that flies in the same way as FBWA,but uses changes in flight attitude input by the pilot to learn the keyvalues for roll and pitch tuning. So the pilot uses their transmittermode switch to switch to AUTOTUNE mode and then flies the plane for afew minutes. While flying the pilot needs to input as many sharpattitude changes as possible so that the autotune code can learn how theaircraft responds.
Setting up for AUTOTUNE¶
To setup your aircraft for AUTOTUNE you need to select AUTOTUNE mode asone of the flight modes selectable with the flight mode switch on yourtransmitter.
You also should choose a tuning level by setting the AUTOTUNE_LEVELparameter in the advanced parameter screen of your ground station. TheAUTOTUNE_LEVEL parameter controls how aggressive you want the tune tobe. The default is level 6, which produces a medium tune, suitable forbeginner to intermediate pilots. If you are a more experienced pilotthen you could choose level 7, which will result in a bit sharper tune(faster attitude changes). Levels above 7 are not recommended until youhave done an initial tune with a lower level. Levels above 8 should onlybe used by very experienced pilots.
You also need to make sure that all of the basic settings for yourairframe are correct. In particular, ensure that all surface reversalsare correct and that you have a reasonable value set for the minimumairspeed. Autotune won’t do anything until you are above the minimumairspeed you have set in the ARSPD_FBW_MIN parameter. If you don’thave an airspeed sensor then that value is still used, along with anairspeed estimate from other sensors. Also make sure you have done RCcalibration, as AUTOTUNE will only work if you have full controlmovements with your transmitter sticks.
Other things to check:
- if you have an airspeed sensor fitted then make sure it is workingand you have calibrated it. See the section on airspeed calibration.
- check your center of gravity, making sure it is correct according tothe manual for your aircraft. In general it is safer to be a bit morenose heavy than tail heavy.
- check your surface trims. You may wish to use the TRIM_AUTO optionafter reading the documentation for that option.
- make sure your failsafe settings are setup correctly. Try turning offyour transmitter with your plane on the ground (and propeller removedor made safe) and check how the plane reacts
- setup a rally point for a safe place to RTL if needed
Flying in AUTOTUNE¶
Once you are all setup you can start flying in AUTOTUNE mode. You caneither takeoff in AUTOTUNE mode, or takeoff in another mode and switchto AUTOTUNE once you have gained altitude.
When you engage AUTOTUNE mode a few things will happen:
- the autotune system will immediately setup some default values foryour roll and pitch I and D gains, and your roll and pitch maximumrates. These values depend on the AUTOTUNE_LEVEL .
- the autotune system will monitor your demanded roll and pitch rates(as determined by your transmitter stick movements). When thedemanded roll or pitch rate exceeds 80% of the maximum rate theautotune system will use the response of the aircraft to learn rollor pitch tuning values.
- every 10 seconds the autotune system will save the parameters you had10 seconds ago. This means that if autotune causes your aircraft tobecome unstable you have 10 seconds to switch to another mode andrecover. When you switch out of AUTOTUNE mode the last savedparameters are restored.
- If you are starting with the default parameters for roll and pitchyou may find the plane is quite sluggish when you first enterAUTOTUNE. You will find that as the tune progresses this will getbetter. Make sure your flight area has plenty of room for long slowturns.
The key to a successful autotune is to input rapid roll or pitchmovements with the transmitter sticks. You should only do one of eitherroll or pitch at a time, and you should move the stick rapidly to themaximum deflection.
So in the roll direction you should first command a hard right turn withthe aileron stick, then shortly afterwards push the aileron stick hardthe other way to command a hard left turn. Note that you do not need towait for the plane to bank over all the way after each stick movement.After about 2 seconds of stick movement in one direction you can reversethe stick quickly.The plane will steer hard right, then hard left as youmove the aileron stick. With each sudden reversal it will improve thetuning values by about 5%. So you need at least 20 full stick movementsto learn a reasonable tuning value.
For pitch tuning you need to use the pitch transmitter stick to take theaircraft on a roller-coaster ride. Pull back hard on the stick to pitchup, then shortly afterwards push down to pitch down. Continue doing thisfor at least 20 iterations.
If your initial tuning values were too low then you should notice theaircraft becomes progressively more responsive as you fly in AUTOTUNEmode. If the aircraft ever becomes unstable enough that you think it isdangerous to keep flying then you should change out of AUTOTUNE mode.That will restore the parameters you had from 10 seconds ago.
Pixhawk Auto Tune Pid Code
Don’t stop too early¶
It is recommended that you do at least 20 rapid roll movements and atleast 20 rapid pitch movements, preferably far more. Some people stoptoo early end up up with poor values that result in their aircraft notcoping well with wind, or not holding altitude well. Keep flying inAUTOTUNE mode well past the point where you think the plane is flyingwell.
Completing the tune¶
Once you have learned reasonable roll and pitch tuning parameters withautotune you should complete the tune by manually tuning some other keyparameters.
The parameters that are needed for most airframes are:
NAVL1_PERIOD: This defaults to 25, which is a very conservative valuedesigned to cope with badly tuned airframes. It controls how sharply theaircraft will turn in automatic modes (such as AUTO, RTL and LOITER).Most aircraft should use a significantly lower value. Once you havecompleted a successful autotune of roll and pitch values you should dropNAVL1_PERIOD to 18 if you have not tuned it yet. To tune beyond thatlevel you should fly a rectangular mission in AUTO mode and adjustNAVL1_PERIOD down by 1 at a time until the aircraft turns at a rate youare happy with, and does not “wag its tail” in flight.
PTCH2SRV_RLL: This parameter controls how much elevator to add in turnsto keep the nose level. Many aircraft require a small change to thisparameter from the default of 1.0. To see if you need to tune this valueyou should hold a tight circle in FBWA mode by holding the aileron stickhard over while not giving any elevator input. If the plane gainsaltitude then you should lower PTCH2SRV_RLL by a small amount (trylowering to 0.95 initially). If the plane loses altitude while circlingthen try raising PTCH2SRV_RLL by a small amount (try 1.05 initially).If you need to go above 1.3 or below 0.8 then there is probably aproblem with your setup (such as incorrect center of gravity, poorthrust line, poor airspeed calibration, too soft a tune on the pitchloop, or bad compass errors). You should try and fix the setup.
There are many other parameters which can improve the performance ofyour aircraft, but these are the ones that most people need. Please readthe normal manual tuning documentation for more information.
AUTOTUNE Logging¶
The progress of the autotune is recorded in the dataflash log. If youare trying to debug autotune or are posting about autotune on the forumsthen please include the dataflash log.
Here is a typical log file from an autotune session:
The ATRP message has a “Type” field that shows what type of autotune isbeing recorded. A Type value of 0 is for roll tuning, and a value of 1is for pitch tuning. When graphing ATRP results you should choose datawith a Type of either 0 or 1 (not both).
The ATRP.Demanded field is the demanded rate of attitude change (rollrate or pitch rate) in degrees per second. The ATRP.Achieved field iswhat the aircraft actually achieved in attitude change rate. As you cansee in the above graph, at the start of the autotune the demanded valueswere much higher than the achieved, because the tuning gains were toolow. As the tune progressed the demanded and achieved started toconverge. The blue line in the above graph is the ATRP.P value, which isthe P gain for the controller. You can see it rose from 0.8 up to a highof 2.2, then dropped back slightly to around 1.85.
You will also notice that the graph has gaps in it. This is for periodswhere the pilot was not demanding a high rate of attitude change. Theautotune system only works while the pilot is demanding a rapid attitudechange (above 80% of the maximum rate).
Manual tuning versus AUTOTUNE¶
Pixhawk Pid Autotune
For the very best performance with Plane you should perform a manualtune, perhaps starting with the values from autotune. The autotunesystem is designed as a conservative system to get reasonable values formost aircraft, it is not a “perfect tuner”, and manual tuning can resultin better performance if you put the time and effort in. Autotune tunesthe P gain directly, but sets the D and I gain conservatively based onthe AUTOTUNE_LEVEL and value of the P gain.
It is still recommended that everyone start out with AUTOTUNE however.Correctly tuning an aircraft is not easy, and AUTOTUNE does better thanthe vast majority of users can do. So start with an AUTOTUNE and thenexplore the manual tuning guide starting from what AUTOTUNE produces ifyou want to push things further.
Manually increasing the D gain can improve the accuracy of the roll andpitch response and make the plane less affected by gusts and turbulence.The optimum value for D gain for a high performance tune can be found byincreasing the gain in small increments until the aircraft starts tooscillate. The gain should then be halved from the value that caused itto oscillate. The oscillations that are generated using this method canbe large, so do not perform this step unless you are prepared to takemanual control. It is recommended that D gain tuning is performed atlower throttle settings and airspeeds.
If you adjust the I gain manually, then this also changes the value forP that is required to maintain the correct response, so adjusting the Igain is only recommended for advanced users.
Registered User Thread OP |
It's in X configuration - it's just the camera position that's off centre. I have a gimbal but for now was just using a 'stick' mount to hold it to one of the arms |