Interface for DX6i RC Quadcopter controller

Committer:
randrews33
Date:
Mon Mar 30 19:26:24 2015 +0000
Revision:
0:6374902c761b
Initial commit - basic, but untested functionality

Who changed what in which revision?

UserRevisionLine numberNew contents of line
randrews33 0:6374902c761b 1 /**
randrews33 0:6374902c761b 2 * Institution: Georgia Institute of Technology - ECE Department - Senior Design II
randrews33 0:6374902c761b 3 * Team: AH3
randrews33 0:6374902c761b 4 * Created: 3/24/2015
randrews33 0:6374902c761b 5 * Last Edit: 3/26/2015
randrews33 0:6374902c761b 6 * By: Taylor Andrews, Luke Panayioto
randrews33 0:6374902c761b 7 **/
randrews33 0:6374902c761b 8
randrews33 0:6374902c761b 9 #ifndef _DX6I_CONTROLLER_H_
randrews33 0:6374902c761b 10 #define _DX6I_CONTROLLER_H_
randrews33 0:6374902c761b 11
randrews33 0:6374902c761b 12 #include "mbed.h"
randrews33 0:6374902c761b 13
randrews33 0:6374902c761b 14 class DX6iController {
randrews33 0:6374902c761b 15 private:
randrews33 0:6374902c761b 16 DigitalOut _pwmPin;
randrews33 0:6374902c761b 17
randrews33 0:6374902c761b 18 /**
randrews33 0:6374902c761b 19 * The signal received by the quadcopter is an array of nine PWM signals (called a PPM signal), and is
randrews33 0:6374902c761b 20 * exactly 22 ms long. Each segment in the array has a specific purpose. The first four correspond to
randrews33 0:6374902c761b 21 * the throttle, roll, pitch, and yaw, respectively.
randrews33 0:6374902c761b 22 *
randrews33 0:6374902c761b 23 * The fifth and sixth correspond to the stability and enable modes. The stability mode configures the
randrews33 0:6374902c761b 24 * quadcopter's internal stabilization systems through a combination of onboard accelerometers and
randrews33 0:6374902c761b 25 * gyroscopes. The stability mode has two presets, what I just label as "full" and "partial", in
randrews33 0:6374902c761b 26 * addition to an "off" setting (below it is initialized with full stability enabled, and it is highly
randrews33 0:6374902c761b 27 * encouraged to keep it there). The Enable mode simply allows the quadcopter to throttle, and only
randrews33 0:6374902c761b 28 * has two settings "on" and "off". Obviously, this must be configured for "on", unless it is utilized
randrews33 0:6374902c761b 29 * in some fashion as to prevent some sort of catastrophic collision.
randrews33 0:6374902c761b 30 *
randrews33 0:6374902c761b 31 */
randrews33 0:6374902c761b 32
randrews33 0:6374902c761b 33 // Channels: [Remainder] [Throttle] [Roll] [Pitch] [Yaw] [Stability] [Enable] ([Extra_1] [Extra_2]
randrews33 0:6374902c761b 34
randrews33 0:6374902c761b 35 // delay between signals in microseconds (µSec)
randrews33 0:6374902c761b 36 int pulseInterval; // 400 µSec
randrews33 0:6374902c761b 37 int nChannels; //channels must be at least 7
randrews33 0:6374902c761b 38
randrews33 0:6374902c761b 39 // uptime of each signal in microseconds low / mid / high // Corrections to PPM signal order
randrews33 0:6374902c761b 40 int Throttle_Uptime; //1 700 / 1100 / 1500 // Throttle
randrews33 0:6374902c761b 41 int Roll_Uptime; //2 700 / 1100 / 1500 (R/L) // Roll
randrews33 0:6374902c761b 42 int Pitch_Uptime; //3 770 / 1170 / 1550 (B/F) // Pitch
randrews33 0:6374902c761b 43 int Yaw_Uptime; //4 700 / 1090 / 1500 (R/L) // Yaw
randrews33 0:6374902c761b 44 int Stabilize_Uptime; //5 LLLL / MMMM / 1500 (3,2,1)
randrews33 0:6374902c761b 45 int Enable_Uptime; //6 700 / ---- / 1500 (Off/On) Note: Bind I Button
randrews33 0:6374902c761b 46 int Extra_Uptime; //7 LLLL / 1100 / HHHH // IDK
randrews33 0:6374902c761b 47 int Extra2_Uptime; //8 LLLL / 1100 / HHHH // IDK
randrews33 0:6374902c761b 48 int Remainder_Uptime;
randrews33 0:6374902c761b 49
randrews33 0:6374902c761b 50 // Trim values
randrews33 0:6374902c761b 51 int mThrottleTrim;
randrews33 0:6374902c761b 52 int mRollTrim;
randrews33 0:6374902c761b 53 int mPitchTrim;
randrews33 0:6374902c761b 54 int mYawTrim;
randrews33 0:6374902c761b 55
randrews33 0:6374902c761b 56 void updateRemainder();
randrews33 0:6374902c761b 57
randrews33 0:6374902c761b 58 public:
randrews33 0:6374902c761b 59 DX6iController(PinName pwmPin);
randrews33 0:6374902c761b 60 ~DX6iController();
randrews33 0:6374902c761b 61
randrews33 0:6374902c761b 62 void generateSignal(int externalDelay);
randrews33 0:6374902c761b 63
randrews33 0:6374902c761b 64 void updateThrottle(int newThrottle);
randrews33 0:6374902c761b 65 void updatePitch(int newPitch);
randrews33 0:6374902c761b 66 void updateRoll(int newRoll);
randrews33 0:6374902c761b 67 void updateYaw(int newYaw);
randrews33 0:6374902c761b 68
randrews33 0:6374902c761b 69 void updateThrottleTrim(int newThrottleTrim);
randrews33 0:6374902c761b 70 void updatePitchTrim(int newPitchTrim);
randrews33 0:6374902c761b 71 void updateRollTrim(int newRollTrim);
randrews33 0:6374902c761b 72 void updateYawTrim(int newYawTrim);
randrews33 0:6374902c761b 73 };
randrews33 0:6374902c761b 74
randrews33 0:6374902c761b 75 #endif // _DX6I_CONTROLLER_H_