Tuning Guide

From STorM32-BGC Wiki V1
Revision as of 16:35, 3 March 2014 by OlliW (talk | contribs) (Created page with "One of the most important steps is of course the proper tuning of the gimbal. However, it is also, unfortunately, the least straight-forward and most debatable step. This is f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

One of the most important steps is of course the proper tuning of the gimbal. However, it is also, unfortunately, the least straight-forward and most debatable step. This is for several reasons:

  • the process of tunning involves several functional parts of the gimbal controller firmware, in particular the PID controllers for each axis and the IMU/AHRS/MARG part (there appears to be no unique definition of each of these ackronyms, so choose yourself which you like to use)
  • each functional part involves typically many parameters
  • although the parts are functional-wise independent from each other, they are not independent performance-wise

In short, tuning is an experimental process of try-and-error, and no unique or universal answer appears to be available - at least so far. The following can hence only attempt to give some ideas.


The following is thus also necessarily very subjective, i.e. based on indivudal experiences for particular gimbals. If your experience led to different tuning "rules" please feel free to share.

Tuning the PID controller of one axis

Preliminaries

The PID controller is the part of the firmware which controls the orientation (attitude) of the camera, i.e., takes the measured attitude and drives the motors such that the camera stays put. It is assumed that the reader understands the basics of PID controllers; many introductions are available on the web. At this point the first, and maybe most important comment is at place:

The PID tuning rules given in (essentially) all texts on PID controllers do NOT apply to brushless direct-drive gimbals!

So, the situation for the brushless gimbals is somwehat different than for the "usual" systems, and this obviously affects the tuning practice. Furthermore, although maybe termed PID in all cases it seems that the implemented PID controllers differ in their working, one probably should distinguish as follows:

  • AlexMos 2.3 and below, EvvGC: these firmwares implement basically PD controllers, with a "weak" I term
  • BruGi, BGC32, AlexMos 2.4, o323bgc/STorM32bgc: these firmwares implement "full" PID controllers

Comment: The AlexMos codes are of course not available, one can hence only speculate, however the various available descriptions/tutorials are telling.

The good message at this point is that the "full" PID controllers in the second category of firmwares seem to work by the same basic principle, which means that the tuning recipes given for them may also be used to tune STorM32-BGC gimbals. The "bad" message is that there seem to be two different general strategies in the tuning, which may be called "low-PWM" tunning and "high-PWM" tuning. The "low-PWM" tunning has emerged as a result of experience for Gopro and larger gimbals; the "high-PWM" tuning has been described for small or micro gimbals. It is not clear though if the "high-PWM" tunning would not work also for larger gimbals.

As a general tuning rule, consider:

Don't overdue it. Better be a bit conservative.

The first sentence is supposed to mean that while it is true that a proper tuning can lead to enormous performance gains and is mandatory for optimal operation it is also true that it's meaningless to adjust the parameters to its last digit. The second sentence reflects the fact that a PID controller which is aggresively tuned for a certain condition (e.g. battery voltage) is also very sensitive to changes in these conditions, i.e., is less robust.

Finally, although it may be obvious and as it's repeated often may be a bit smart ass, it cannot be over emphasized:

The key to a good performance of the gimbal is a perfect mechanics and balance.

Inspection of the various threads immediately confirms this point.

Basic PID parameters

The basic PID controller parameters are [P], [I], [D], and [Vmax]. 

The paramter [Vmax] is known in other firmwares as e.g. the motor PWM or motor power.

The o323bgc firmware provides also the parameters [Pan], [Voltage Correction], and somewhat hidden [Hold To Pan Transition Time]. The later are however not relevant for the basic tuning, and should in fact be inactivated for the basic tuning.

Coarse tunning settings

For the basic tuning, the advance tunning options should be inactivated.

  • [Pan] MUST be set to zero (or the hold mode ensured by other means, such as via the [AUX Kex Modes])
  • [Voltage Correction] should be set to 0%
  • the battery should neither be fully charged nor nearly discharged (i.e. have a voltage of around 3.7 V per cell)

The first step is to obtain a basic, working tuning (coarse tuning) of all axes. One should tune first the pitch axis, then roll, and only then yaw. Ideally one would block the roll and yaw axes while tuning the pitch axes, and the yaw axis while tuning the roll axis. In any case make use of the [Roll Usage], and [Yaw Usage] parameters to avoid uncontrolled motion or even damage to the gimbal.

Once the gimbal is coarsely tuned, one may proceed to the fine tunning. Here the Data Display is most useful.

"Low-PWM" tuning

The "low-PWM" tuning strategy starts from the recommendation to set [Vmax], or motor power or PWM, as small as possible.

The motor power should of course be also as large as needed, which sets the lower bound. It is typically given by the motors (cogging torque, friction) or the quality of balance. Typical tuning guides are

As said before, this recipe emerged from the experience by several authors on Gopro and larger gimbals, and in this sense maybe considered as "prooven". However, the Vmax value must not be too small.

The value of [Vmax], or motor power or PWM, should not be below 65 or 25%.

Lowering the Vmax value also diminishes the available angle resolution, and if it's too small the gimbal can't correct smoothly anymore.

"High-PWM" tuning

The "high-PWM" tuning strategy starts from the recommendation to set [Vmax], or motor power or PWM, as large as possible.

Here, the upper limit is essentially determined by the heat produced in the motors. Obviously, the motors should not get too hot. In practical terms, one should be able to touch the motors for several seconds (10 sec or more). The rational in this tunning is that a larger motor power makes the system to react faster (allowing in principle a faster correction and hence smaller error angles) and to be more robust against disturbancs such as cogging torque, frictions, wind gusts and so on.

The motor heat is however not the only factor which determines the proper Vmax value. As with the other parameters, one needs to experiment. It may e.g. happen that with a too large Vmax one never obtains a vibration free, good tuning, and a somewhat lower Vmax is much better.

As regards P, I, D, these two procedures seem to work:

  • Procedure A: Set I to a small value (might be worth to try even zero). Increase D and P by turn, and step by step. The gimbal should not start to oscillate. Since it are only two paramters one will quickly find the "best" balance of large D and large P. Now turn up the I value until the gimbal starts to oscillate (watch the accelerometer data in the Data Display), and back off by some 10 %. Finally, experiment with all three values. The general goal should be to get a large I value.
  • Procedure B: Set P to zero, and first adjust I and D. That is, increase I until the gimbal oscillates, then increase D to damp the oscillation. Repeat until neither increasing I nor D stops gimbal oscillations. Now also use P, and experiment with all three values until the result is satisfying. The general goal should be to get a large I value.

Voltage correction

The voltage correction mechanism in 0323bgc attempts to compensate the effects by a varying battery voltage on the PID controller tuning. It does it by modifying the actual motor power. i.e. [Vmax] values proportionally to the voltage change.

For instance, with a voltage correction of 100%, a drop in the battery voltage by 25% leads to an increase of the actually used Vmax value by 25%. With a voltage correction of 50%, a voltage drop by 25% leads to a 12.5% increase in Vmax, and so on.

The mechanism can significantly reduce the dependence of the gimbal performance on the battery voltage. It can however not accomplish what could be achieved with a truely constant (regulated) voltage.

Tuning the pan mode

In o323bgc the pan mode, also known as follow mode, is in some ways independent on the PID controller tuning. Thus, the PID controller tuning must be done with the pan mode deactivated. However, on the other hand, once the PID controller is tuned, the pan mode can be adjusted easily without having to touch the PID controller in any ways. (this is probably one of the apealing features of 0323bgc)

The pan mode is controlled by the parameters [Pitch Pan], [Roll Pan], and [Yaw Pan].

These paramters determine the pan speeds for each of the three axes. A zero means that the pan mode is deactivated, i.e., that the axis is in hold mode (also known as locked mode). There is little more to say here.

The transitions from hold to pan and pan to hold modes, which are possible via e.g. the external keys, present a challenge, since the abrupt accelerations on the camera which may occur in these situations cannot be handled well by the brushless gimbal technique. The acceleration after having switched from hold to pan can be limited or smoothened using the [Hold To Pan Transition Time] parameter.

Tuning the IMU/AHRS/MARG

PLEASE ADD

Understanding the parameters

Usefull references maybe (from the German FPVC forum):