Concept Flow - PID controller in flight stabilization
Read current angle
Calculate error = target - current
Calculate P term = Kp * error
Calculate I term = I term + Ki * error * dt
Calculate D term = Kd * (error - last_error) / dt
Calculate output = P + I + D
Send output to motors
Update last_error = error
↩Loop back to Read current angle
The PID controller reads the current angle, calculates error, computes proportional, integral, and derivative terms, combines them to get output, sends output to motors, then repeats.
