I will upload parts of my code that involves the handling of PID control which includes transmitters and sensors (angles).

I'll start by writing a brief text in which I explain my variables/algorithms, and to make it simple I will describe only one axis (roll axis):* Throttle, converted using the "map function" to 0-80 (min value = 1060, max value = 1900).

* Setpoint = Reading the value from the transmitter, minimum value = 1060, maximum value = 1900. These values ??are converted by using the "map" function.When the lever is in the neutral position (In the middle) - Setpoint = 0 degreeThe lever is on the bottom - Setpoint = -35 degreesThe lever is at the top - Setpoint = +35 degrees

* After the PID control, and the new motor-output-values ??I convert them back to the values ??of "1060 - 1900" with the "map" function and use the "constrain function" to not let the values ??go under "1060" or over "1900 ".

//Getting readings from receiver and using the map function to make it easier to work with rc_read(); //Read the values from receiver throttle = map(rc_values[THROTTLE], 1060, 1900, 0, 80); PID_ROLL[SETPOINT] = map(rc_values[AILERON], 1060, 1900, 35, -35);

The reason why I'm asking for help is because the tuning of the PID-paramters isn't working that great right now. The best result I've had just by tuning the with KP =0.06 and KD = 0.0055, giving me slow reactions.1. Stays horizontall for like 10 seconds2. Turns to left for a couple of seconds3. Back to step 1.

With high KP values the quadcopter just bumps from one side to another side, uncontrolable.

Please observate that Ive removed other initliaztions in the setup loop because they work. So the sensor degree outputs are correct and also the readins from the receiver are correct.

If there is something wrong, I believe that this part has something to do with it: