flight orientation selection by DIP1 switch

git-svn-id: https://arducopter.googlecode.com/svn/trunk@693 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jphelirc 2010-10-19 16:07:51 +00:00
parent f5cd4e45f9
commit 74674b638b
5 changed files with 31 additions and 23 deletions

View File

@ -83,7 +83,7 @@ TODO:
#define AUX_MID 1500
#define CHANN_CENTER 1500 // Channel center, legacy
#define MIN_THROTTLE 1080 // Throttle pulse width at minimun...
#define MIN_THROTTLE 1040 // Throttle pulse width at minimun...
/*************************************************************/
// General definitions

View File

@ -335,6 +335,7 @@ int leftMotor;
int rightMotor;
byte motorArmed = 0;
int minThrottle = 0;
boolean flightOrientation = 0; // 0 = +, 1 = x this is read from DIP1 switch during system bootup
// Serial communication
char queryType;

View File

@ -84,9 +84,11 @@
// Flight & Electronics orientation
// Frame build condiguration
#define FLIGHT_MODE_+ // Traditional "one arm as nose" frame configuration
//#define FLIGHT_MODE_+ // Traditional "one arm as nose" frame configuration
//#define FLIGHT_MODE_X // Frame orientation 45 deg to CCW, nose between two arms
// 19-10-10 by JP
// This feature has been disabled for now, if you want to change between flight orientations
// just use DIP switch for that. DIP1 down = X, DIP1 up = +
// Magneto orientation and corrections.
// If you don't have magneto actiavted, It is safe to ignore these
@ -202,6 +204,10 @@ void setup() {
// external command/telemetry
// Battery monitor
/* ***************************************************** */
// Main loop
void loop()
{
//int aux;

View File

@ -65,16 +65,17 @@ void read_radio()
if (flightMode==STABLE_MODE) // IN STABLE MODE we convert stick positions to absoulte angles
{
// In Stable mode stick position defines the desired angle in roll, pitch and yaw
#ifdef FLIGHT_MODE_X
// #ifdef FLIGHT_MODE_X
if(!flightOrientation) {
// For X mode we make a mix in the input
float aux_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR;
float aux_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
command_rx_roll = aux_roll - aux_pitch;
command_rx_pitch = aux_roll + aux_pitch;
#else
} else {
command_rx_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR; // Convert stick position to absolute angles
command_rx_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
#endif
}
// YAW
if (abs(ch_yaw-yaw_mid)>6) // Take into account a bit of "dead zone" on yaw

View File

@ -93,7 +93,23 @@ void APM_Init() {
#endif
#endif
readUserConfig(); // Load user configurable items from EEPROM
// Read DIP Switches and other important values. DIP switches needs special functions to
// read due they are not defined as normal pins like other GPIO's are.
SW_DIP1 = APMPinRead(PINE, 7);
SW_DIP2 = APMPinRead(PINE, 6);
SW_DIP3 = APMPinRead(PINL, 6);
SW_DIP4 = APMPinRead(PINL, 7);
/* Works, tested 18-10-10 JP
if(SW_DIP1) {
SerPrln("+ mode");
} else {
SerPrln("x mode");
}
*/
flightOrientation = SW_DIP1; // DIP1 off = we are in + mode, DIP1 on = we are in x mode
readUserConfig(); // Load user configurable items from EEPROM
// Safety measure for Channel mids
if(roll_mid < 1400 || roll_mid > 1600) roll_mid = 1500;
@ -155,22 +171,6 @@ void APM_Init() {
delay(1000);
// Read DIP Switches and other important values. DIP switches needs special functions to
// read due they are not defined as normal pins like other GPIO's are.
SW_DIP1 = APMPinRead(PINE, 7);
SW_DIP2 = APMPinRead(PINE, 6);
SW_DIP3 = APMPinRead(PINL, 6);
SW_DIP4 = APMPinRead(PINL, 7);
/* Works, tested 18-10-10 JP
if(SW_DIP1) {
SerPrln("+ mode");
} else {
SerPrln("x mode");
}
*/
DataFlash.StartWrite(1); // Start a write session on page 1
//timer = millis();
//tlmTimer = millis();