quadcopter talk (abstractions)
Embed Size (px)
TRANSCRIPT

QUADCOPTER FLIGHT CONTROLLER
building & programming a
from scratch

I’m Ryan Boland
Web Developer@ Tanooki Labs
@bolandrm (github, twitter)


1. Components
2. Quadcopter Physics
3. The Flight Loop

FRAME

Electronic Speed Controllers (ESCs) & Motors

Lithium Polymer (LiPo) Battery

Remote Control Transmitter & Receiver

Flight ControllerMicroprocessor & Inertial measurement Unit (IMU)

My Project - Custom Flight Controller
Arduino Mega 2560 & Prototyping Shield
8-bit AVR 16 MHz clock
256K Flash 8K Ram
Arduino Nano Clone 8-bit AVR
16 MHz clock 32K Flash 2K Ram
Teensy 3.1 32-bit ARM
96 MHz clock 256K Flash 64K Ram
$5$55 $20

Custom PCB

Inertial Measurement Unit
MPU6050 - 3 axis gyroscope, 3 axis accelerometer HMC5883L - 3 axis magnetometer BMP180 - Barometer
GY-87 $8

Flight

Configuration: + vs X

Orientation
x axis <-> roll y axis <-> pitch z axis <-> yaw

Maneuvering

StabilizationRate mode - gyroscopes onlyRemote control determines the rate at which the quadcopter is rotating on any given axis. Also known as Acro or Manual.
Attitude mode - accelerometers & gyros Remote control determines the desired angle of the quadcopter. Also known as self-level or auto-level.

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Gyroscope dataActual rotational rate in °/sec
Remote control dataPilot’s desired rotation rate in °/sec
ErrorDifference between actual and desired rotational rate e = gyro_rate - rc_rate

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

3 errors to correct

PID Controllers (proportional, integral, derivative)
For each axis (yaw, pitch, roll):
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
PilotRCinput
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
Pilot RC input
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
error e(t)
PilotRCinput
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
PilotRCinput
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
PilotRCinput
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
PilotRCinput
3 constants - Kp, Ki, Kd

PID Controllers (proportional, integral, derivative)
PID for dummies:http://www.csimn.com/CSI_pages/PIDforDummies.html
Motor Output
Rotational rate (from gyro)
errore(t)
PilotRCinput
3 constants - Kp, Ki, Kd

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Maneuvering

Flight Controller Code
motor1 = rc_throttle - roll_adjust - pitch_adjust - yaw_adjust;
motor2 = rc_throttle + roll_adjust + pitch_adjust - yaw_adjust;
motor3 = rc_throttle - roll_adjust + pitch_adjust + yaw_adjust;
motor4 = rc_throttle + roll_adjust - pitch_adjust + yaw_adjust;
correcting roll, pitch, yaw

Flight Controller Code
motor1 = rc_throttle - roll_adjust - pitch_adjust - yaw_adjust;
motor2 = rc_throttle + roll_adjust + pitch_adjust - yaw_adjust;
motor3 = rc_throttle - roll_adjust + pitch_adjust + yaw_adjust;
motor4 = rc_throttle + roll_adjust - pitch_adjust + yaw_adjust;
correcting roll, pitch, yaw

Flight Controller Code
motor1 = rc_throttle - roll_adjust - pitch_adjust - yaw_adjust;
motor2 = rc_throttle + roll_adjust + pitch_adjust - yaw_adjust;
motor3 = rc_throttle - roll_adjust + pitch_adjust + yaw_adjust;
motor4 = rc_throttle + roll_adjust - pitch_adjust + yaw_adjust;
correcting roll, pitch, yaw

Flight Controller Code
motor1 = rc_throttle - roll_adjust - pitch_adjust - yaw_adjust;
motor2 = rc_throttle + roll_adjust + pitch_adjust - yaw_adjust;
motor3 = rc_throttle - roll_adjust + pitch_adjust + yaw_adjust;
motor4 = rc_throttle + roll_adjust - pitch_adjust + yaw_adjust;
correcting roll, pitch, yaw

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Safety & Handling Failure
Stale IMU values
Stale remote control values
Angles too high?
Motor outputs too high? (indoor safe mode)
Watchdog

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Wait for data ready interrupt
Read & filter gyroscope data
Read remote control data (user input)
Use PID (proportional, integral, derivative) algorithm to compute required adjustment for each axis
Map adjustment for each axis to motors (Mixer)
Safety checks
Output to motors
Flight Loop (1000 Hz)

Some Takeaways
Be Safe
Start small (mini quad or balancing robot?)
Break things down into subcomponents

Thanks!
@bolandrm