Here's my schematic (sorry for that - made in hurry) of current PID implementation for ACRO mode. Red - variables names.
1. comment says, that it takes into account the cycle time, but in fact, there's no such thing.
2. why there is 32-bit division?
- Code: Select all
else error = ((int32_t)rcCommand[axis]<<6)/conf.P8[axis]
3. Why P8 is added to I component? also, see 4.
4. P8 for I component and P8dyn for P are in the feedback part of the loop, not the forward part. This means, that changing these variables would not only change the open loop gain, but would also alter the total system amplification (in this case - gyro scaling). I can't bear the fact, that when I increase P in GUI, the rate to stick position scaling is decreased. Is that done intentionally? I don't feel like it's a good thing.
5. When dynamic P adjustment takes place (P8dyn is decreased) the scaling for P and I component becomes different - they start to try maintaining the different rate values. I don't think that it helps. Initial idea was to change not the open loop gain (as well as I and D), but just change the scaling corresponding to the throttle, right?
- Code: Select all
if (abs(gyroData[axis])>640) errorGyroI[axis] = 0;
7. D component doesn't take into account stick position at all. That's why it doesn't make the control sharper - it just tries to dampen fast angle changes of the body, and that's it.
I'm currently testing the rewritten version, where classic PID controller is implemented - P I and D are in the forward part of the loop, so no scaling problem present and other, supposedly, problems are fixed. But first I would like to hear the opinion, do I get it all right, or some/all of listed facts serve the useful purpose?
P.S. Forgot to say - "deltasum" includes difference calculation, moving average of 3 elements that code does and multiplication by dynD8