Purely for fun, I'm trying to build an autopilot that uses an Arduino Due and a Adafruit 10-DOF IMU and I am having trouble getting the PID to control my servos like I expect it should. Some background information is that I am completely new to the world of drones so I'm currently still learning about the intricacies of autonomous flight control, I am currently using the Arduino PID library and am currently testing the system on a fixed-wing mock-up that uses elevon mixing for controlling the attitude (like a Skyfun).

My problem might be more fundamental than the actual implementation of PID control but basically I'm not sure if my inputs and outputs for the PID function are what they should be. Currently, my input is the pitch of the sensor, the setpoint is the desired pitch of the plane, and the output is an angle written to each servo. The tuning parameters I am using I pulled from some ArduPilot documentation and are most definitely not correct. Kp = 0.45, Ki = 0.05, Kd = 17.

Ignoring the very wrong tuning parameters for a moment, are these the correct input and outputs for a PID loop that stabilizes flight control? The issue I'm having so far is that even when the sensor is reading a pitch of 90 degrees (mapped to be horizontal) the servos continue to adjust themselves despite the fact that the plane is at the setpoint. In my mind at this point the servos would not keep adjusting right? When I print the output to serial I regularly see angles being written that are much greater than I'd imagine for a plane whose pitch isn't changing (which I can also see in serial).

Could it be the case that I am simply trying to update the servo to much? Are my tuning parameters the only thing wrong here?

Here is how my PID loop is implemented

void loop() {pitchPID.Compute();Serial.print("Output:");Serial.println(output);if(output < 180 && output > 10){leftElevonServo.write(output);rightElevonServo.write(output);}}

If anyone can shed any light that might point me in the right direction, I would very be appreciative!

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity