I have got an interesting idea and wanted to get some input from the experts here.
I have a copter which I was not able to tune well after a long saga of tests and trial and errors, mainly due to different behaviour in different flight stages, and to fly safely I had to set the PIDs values in such a way that it would be generating small amplitude oscillations (overtuned what I call it).
The idea is to use LUA script to change PIDs based on the flight stage.
For instance, one problem is when descending vertically, the PIDs necessary to keep my copter stable are generally higher. So:
If I do something like: if Vz is larger than 2 m/s and roll and pitch are less than 5 degrees average for the last 1 second, increase PI by 15 %.
However, if I descend vertically and fly horizontally, the PIDs necessary required are generally lower than the stadanrd ones,SO:
if Vz is larger than 2 m/s and roll or pitch is more than 15 degrees on average for the last 2 or 3 seconds (equivalent to about 15 m/s horizontal speed), then decrease PI by about 15 %. I do not want to use GPS speed, because in high wind situations that would result in incorrect evaluation of the air speed.
The other interesting ideas I can see for instance is to automatically adjust PIDs for weight. I would tune manually the copter for two weights with two sets of PIDs and P Angle, etc. Then, when flying off, the LUA would do something like:
if Vz close to zero and roll and pitch close to zero for 3 seconds during first 30 seconds after take off, do power evaluation, obtain power needed for hover (I x V). Based on power, estimate copter weight, interpolate PIDs obtained manually, and load the interpolated values. If the pilot does not do this short hover, then ignore, and just keep the preset PIDs.
Similar adjustments could be easily made for altitude.
Also, I am not sure if it is possible to implement an oscillation detector. A very crude method I found to cut off the oscillations is to set SMAX rates for limiting the PD gain. But it works as ON/OFF method. Oscillations appear, are killed, and then may reappear.
But, one can detect higer frequency oscillations (3…8 Hz) quite easily using LUA:
something like if Roll or Pitch varies from average Roll or Pitch by more than 0.5º and the max variance has a period which is within 20 % of the previous 3 max variance events, then there are oscillations in that axis, then decrease PD for that axis, wait for 2 seconds, then reevaluate. Obviously, this decrease of PD should be limited to no more than a certain amount from the base PD, may be 20 %.
Any input on these ideas?
1 post - 1 participant