Sorry, I wrote another encyclopedia...
The turret is driven by a motor via an ESC
Is this a direct drive brushless motor, like used with a camera gimbal, or something like a bi-directional motor/ESC on a gearbox or screw-drive? Really either one should work. Direct drive brushless setups have their own controllers which also have PIDs.
I can't find the right settings for Axis Lock mode. In fact it turns but much too slow and not with the right angle. If I turn the tank let's say 90 deg the turret turns only 70 deg.
First of all, I see that you are talking about "Cam-Stab" to stabilize your turret but you said your CC3D is mounted on the turret. Some description is in order.
CC3D code is designed to stabilize an aircraft, and from this knows the bank angle of the aircraft. Based on the known bank angle, it sends servo commands to the gimbal. The gimbal may be designed and configured to work up to say +- 40 degrees. When CC3D knows the aircraft is level, it sends "neutral" signal to the gimbal servo(s). When it is banked 40 degrees, it sends a min or max signal to the servo. When banked 20 degrees it sends half of min/max signal. This gets distorted by the servo's rotary output. When using the cam stab module the CC3D is mounted on the aircraft, not the gimbal. CC3D does not actually know the angle of the gimbal. Gimbal will be fairly level, but it cannot be exact unless you use servos with linear outputs, and even then the servos are not exactly linear. Rotary servo output is badly non-linear at endpoints.
The other way to stabilize a gimbal is to mount the CC3D on the gimbal. CC3D is dedicated to the gimbal in this case and cannot also stabilize an aircraft. Gimbal will be exactly level because CC3D sees that the servo has not moved the gimbal enough and tells it to move farther and farther till it is perfect.
You mention Cam-Stab and also say your CC3D is mounted on the turret. You do NOT use the CameraStabilization module when the CC3D is mounted on the turret (gimbal).
I assume that you are not stabilizing anything in the tank but the turret.
Either the CC3D must be mounted to the tank (not turret) and you must use and tune the Camera Stabilization module and you should leave the Stabilization PIDs at default. Turret angle will not be exact because of non-linearities. This assumes that your actuator is something that acts like a servo. An ESC/motor/gearbox is not like a servo in that the input signal controls rate, not position (like a servo).
<OR>
The CC3D is mounted to the turret and you must NOT use cam stab module and you must tune the PIDs. Turret angle will be exact because CC3D can measure it directly and will tell the "servos" (motor/ESC/gearbox for you) to keep moving till it is perfect.
Axis Lock mode is more complex than for instance Attitude mode. Axis Lock will try hard to stay at the desired angle, but if it gets "too far off" it will give up and lock to the new angle. How far is "too far off" is one of the Axis Lock configurations. If your PIDs are slow then it is easy to get "too far off". I suggest that you use Attitude mode for tuning your PIDs. That way you know you are fighting the PID, not fighting the Axis Lock configuration.
As I recall, the simple complementary filter in the CC3D code has a singularity at some 90 degree banks (pitch I recall). Be aware of that. I don't think that is affecting you though. I assume that CC3D is mounted level, not on edge, and that your normal usage would not include +-90 degree pitch.
(Given that CC3D is mounted on turret and using Axis Lock) Some possible reasons for turret moving only 70 degrees when body moves 90 degrees:
- Axis Lock lost lock and relocked at new angle (use Attitude mode for tuning to remove this possibility)
- PID does not have nearly enough "I" term
- mechanically the turret can only move 70 degrees (does it always move 70 degrees when body moves only 70 degrees)
You should be able to find a set of PIDs that work for any mode.
First of all, save / copy your current PID settings in case you want to go back to them. I would try to tune PIDs two different ways and see what works:
1 - Reset all PIDs to default values, then when adjusting PIDs, adjust them all by multiplying each P,I,D by the same factor. Example: It is oscillating, so multiply each PID term individually by 0.5 to cut them all in half.
2 - Set "I" and "D" to zero and adjust "P" till it just starts to oscillate. Cut P in half. Adjust I upward from zero till it oscillates, then reduce I till it stops oscillating.
Is it possible for you to tune PIDs in Rate mode? It is really best to first tune "inner loop" in Rate mode, then tune "outer loop" in Attitude mode. I'm not sure you will need to tune the outer loop.
Mixing in the CC3D ? please explain
LibrePilot has gimbal functions
I was assuming that you were using CC3D gimbal functions but you are not. When using gimbal functions CC3D does not know the actual angle of the gimbal (turret) because CC3D is not mounted on the gimbal. You can mix additional servo control into the gimbal servo to modify it's angle however you like. With CC3D mounted on gimbal though, if you do this, the CC3D will think it is not level and will remove every little bit of change you do from the second input.
How big is your tank?