(Read 316 times)
Mar 13, 2017, 02:42 pm
I was building a quadcopter but since one of the esc blown up io turn to a twincopter, which seems to be really interesting.
Here i have my first question. To stabilize the servos do i need to implement a pid on the servo axis? or with the mpu6050 angle read is enough?
Mar 13, 2017, 03:55 pm
: Mar 13, 2017, 04:40 pm by MartinL
The PIDs are implemented for rate of rotation (in either degrees/s, centidegrees/s or radians/s) for roll, pitch and yaw, irrespective of what multi-rotor configuration you're using, be it singlecopter, dualcopter, tricopter, quadcopter, hexacopter etc...
It's the subsequent motor mixer settings that divides the throttle and PID values between the motors (and in your case servos), which determines the type of multi-rotor configuration itself.
For a dualcopter you'll have two opposite clockwise and counter clockwise motors/props that control the throttle and roll, while the two opposing servos will control the pitch and yaw.
In the motor mixer with 2 motors and 2 servos you'll require 4 channels:
Channel 1/Motor 1: Throttle 100%, Roll: 100%, Pitch: 0%, Yaw: 0%, Servo Offset 0%
Channel 2/Motor 2: Throttle 100%, Roll: -100%, Pitch 0%, Yaw 0%, Servo Offset 0%
Channel 3/Servo 1: Throttle 0%, Roll 0%, Pitch -100%, Yaw 100%, Servo Offset 50%
Channel 4/Servo 2: Throttle 0%, Roll 0%, Pitch 100%, Yaw 100%, Servo Offset 50%
The percentages show how much of the signal from the throttle and RPY PID control loop outputs are allowed through. So for example, "Throttle 100%" allows through the full throttle stick range from 0 to 100%. The mixer table above also assumes that the servos are opposite to each other and work in opposing directions.
Note that the analogWrite() function will be OK for the motor ESCs, but if you're using analog servos you might need to use a lower PWM frequency at 50Hz.