Hello dear members,

I believe that the time has come, where I have to ask you guys for some support over here.

And I also hope that this will help other people with similar projects.

However, I'm up for doing a tricopter. And right now I'm in the phase where I need you guys to confirm if my algorithm for stabilizing is correct.

I'll post a picture to illustrate my thought. As they say, a picture can tell you more a thousand words (If you'd like to see the picture, go to the end of the post).

1. Read values from transmitter (throttle will give from 0 - ~180, the rest of the sticks gives ~90 in middle)

2. Read values from sensor (180 degrees if plan)

3. PID CONTROL

4. Combine PID outputs with throttle value

5. Output the values to the motors

For the PID configs

`PID myPID_Roll_Plus( &Input_Roll_Plus, &Output_Roll_Plus, &Setpoint_Roll_Plus, 1.5, 0.1, 0.5, DIRECT);`

PID myPID_Roll_Minus( &Input_Roll_Minus, &Output_Roll_Minus, &Setpoint_Roll_Minus, 1.5, 0.1, 0.5, REVERSE);

PID myPID_Pitch_Plus( &Input_Pitch_Plus, &Output_Pitch_Plus, &Setpoint_Pitch_Plus, 1.5, 0.1, 0.5, DIRECT);

PID myPID_Pitch_Minus( &Input_Pitch_Minus, &Output_Pitch_Minus, &Setpoint_Pitch_Minus, 1.5, 0.1, 0.5, REVERSE);

Setting the values for the variables (OBS. setpoint is set to 90, because the sticks from the transmitter outputs 90 if not touched)

//////////////////////////////////////////////

///// PID SETTINGS /////

/////////////////////////////////////////////

void PID_SETTINGS(){

myPID_Pitch_Plus.SetMode(AUTOMATIC);

myPID_Pitch_Plus.SetOutputLimits(0,180);

Setpoint_Pitch_Plus = 90;

myPID_Pitch_Minus.SetMode(AUTOMATIC);

myPID_Pitch_Minus.SetOutputLimits(0,180);

Setpoint_Pitch_Minus = 90;

myPID_Roll_Plus.SetMode(AUTOMATIC);

myPID_Roll_Plus.SetOutputLimits(0,180);

Setpoint_Roll_Plus = 90;

myPID_Roll_Minus.SetMode(AUTOMATIC);

myPID_Roll_Minus.SetOutputLimits(0,180);

Setpoint_Roll_Minus = 90;

}

PID calculations (As I said before, the setpoint is set to 90. Thats why Im subtracting with 90. 180 - 90 = 90.

` Input_Pitch_Plus = kalAngleY-90; `

myPID_Pitch_Plus.Compute();

Input_Pitch_Minus = kalAngleY-90;

myPID_Pitch_Minus.Compute();

Input_Roll_Plus = kalAngleX-90;

myPID_Roll_Plus.Compute();

Input_Roll_Minus = kalAngleX-90;

myPID_Roll_Minus.Compute();

The outputs for the motors

` THROTTLE_PID_BACK = RECEIVER_THROTTLE_VAL + Output_Pitch_Plus;`

THROTTLE_PID_FRONT_LEFT = RECEIVER_THROTTLE_VAL + Output_Roll_Plus + Output_Pitch_Minus;

THROTTLE_PID_FRONT_RIGHT = RECEIVER_THROTTLE_VAL + Output_Roll_Minus + Output_Pitch_Minus;

Here is the picture:

This will explain much better than the text above.

Ive also made a page on github, If ud like too see the whole code.

https://github.com/freak174/Tricopter--Build-phase-.gitEdit:

Forgot to mention that I am only trying to stabilize the tricopter by the throttle, which means Ive excluded all other sticks from the transmitter.