Hallöchen zusammen
stehe gerade mächtig auf dem Schlauch (ist eher mal wieder ne mega- Schlauchrolle ). Ich möchte zum ersten Mal einen Sketch für meinen Tricopter anpassen und das Board damit flashen. Nun habe ich Blue Angels Anleitung Punkt für Punkt abackern wollen. Nur, bei mir erscheint der Sketch nie in der Form, wie sie bei BlueAngels Beschreibung erscheint. Ich kann nirgends einstellen, welche Copterbauart ich fliege etc. Bei mir schaut dies so aus:
/*
MultiWiiCopter by Alexandre Dubus
www.multiwii.com
November 2011 V1.9
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version. see <http://www.gnu.org/licenses/>
*/
#include "config.h"
#include "def.h"
#define VERSION 19
/*********** RC alias *****************/
#define ROLL 0
#define PITCH 1
#define YAW 2
#define THROTTLE 3
#define AUX1 4
#define AUX2 5
#define CAMPITCH 6
#define CAMROLL 7
#define PIDALT 3
#define PIDVEL 4
#define PIDLEVEL 5
#define PIDMAG 6
#define BOXACC 0
#define BOXBARO 1
#define BOXMAG 2
#define BOXCAMSTAB 3
#define BOXCAMTRIG 4
#define BOXARM 5
#define BOXGPSHOME 6
#define BOXGPSHOLD 7
static uint32_t currentTime = 0;
static uint16_t previousTime = 0;
static uint16_t cycleTime = 0; // this is the number in micro second to achieve a full loop, it can differ a little and is taken into account in the PID loop
static uint16_t calibratingA = 0; // the calibration is done is the main loop. Calibrating decreases at each cycle down to 0, then we enter in a normal mode.
static uint8_t calibratingM = 0;
static uint16_t calibratingG;
static uint8_t armed = 0;
static uint16_t acc_1G; // this is the 1G measured acceleration
static int16_t acc_25deg;
static uint8_t nunchuk = 0;
static uint8_t accMode = 0; // if level mode is a activated
static uint8_t magMode = 0; // if compass heading hold is a activated
static uint8_t baroMode = 0; // if altitude hold is activated
static uint8_t GPSModeHome = 0; // if GPS RTH is activated
static uint8_t GPSModeHold = 0; // if GPS PH is activated
static int16_t gyroADC[3],accADC[3],magADC[3];
static int16_t accSmooth[3]; // projection of smoothed and normalized gravitation force vector on x/y/z axis, as measured by accelerometer
static int16_t accTrim[2] = {0, 0};
static int16_t heading,magHold;
static uint8_t calibratedACC = 0;
static uint8_t vbat; // battery voltage in 0.1V steps
static uint8_t okToArm = 0;
static uint8_t rcOptions;
static int32_t pressure;
static int32_t BaroAlt;
static int32_t EstVelocity;
static int32_t EstAlt; // in cm
static uint8_t buzzerState = 0;
//for log
static uint16_t cycleTimeMax = 0; // highest ever cycle timen
static uint16_t cycleTimeMin = 65535; // lowest ever cycle timen
static uint16_t powerMax = 0; // highest ever current
static uint16_t powerAvg = 0; // last known current
static int16_t i2c_errors_count = 0;
// **********************
// power meter
// **********************
#define PMOTOR_SUM 8 // index into pMeter[] for sum
static uint32_t pMeter[PMOTOR_SUM + 1]; //we use [0:7] for eight motors,one extra for sum
static uint8_t pMeterV; // dummy to satisfy the paramStruct logic in ConfigurationLoop()
static uint32_t pAlarm; // we scale the eeprom value from [0:255] to this value we can directly compare to the sum in pMeter[6]
static uint8_t powerTrigger1 = 0; // trigger for alarm based on power consumption
// **********************
// telemetry
// **********************
static uint8_t telemetry = 0;
static uint8_t telemetry_auto = 0;
// ******************
// rc functions
// ******************
#define MINCHECK 1100
#define MAXCHECK 1900
volatile int16_t failsafeCnt = 0;
static int16_t failsafeEvents = 0;
static int16_t rcData[8]; // interval [1000;2000]
static int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW
static uint8_t rcRate8;
static uint8_t rcExpo8;
static int16_t lookupRX[7]; // lookup table for expo & RC rate
volatile uint8_t rcFrameComplete; //for serial rc receiver Spektrum
// **************
// gyro+acc IMU
// **************
static int16_t gyroData[3] = {0,0,0};
static int16_t gyroZero[3] = {0,0,0};
static int16_t accZero[3] = {0,0,0};
static int16_t magZero[3] = {0,0,0};
static int16_t angle[2] = {0,0}; // absolute angle inclination in multiple of 0.1 degree 180 deg = 1800
static int8_t smallAngle25 = 1;
// *************************
// motor and servo functions
// *************************
static int16_t axisPID[3];
static int16_t motor[8];
static int16_t servo[4] = {1500,1500,1500,1500};
// **********************
// EEPROM & LCD functions
// **********************
static uint8_t P8[7], I8[7], D8[7]; //8 bits is much faster and the code is much shorter
static uint8_t dynP8[3], dynI8[3], dynD8[3];
static uint8_t rollPitchRate;
static uint8_t yawRate;
static uint8_t dynThrPID;
static uint8_t activate[8];
void blinkLED(uint8_t num, uint8_t wait,uint8_t repeat) {
uint8_t i,r;
for (r=0;r<repeat;r++) {
for(i=0;i<num;i++) {
LEDPIN_TOGGLE; //switch LEDPIN state
BUZZERPIN_ON;
delay(wait);
BUZZERPIN_OFF;
}
delay(60);
}
}
// **********************
// GPS
// **********************
static int32_t GPS_latitude,GPS_longitude;
static int32_t GPS_latitude_home,GPS_longitude_home;
static uint8_t GPS_fix , GPS_fix_home = 0;
static uint8_t GPS_numSat;
static uint16_t GPS_distanceToHome;
static int16_t GPS_directionToHome = 0;
static uint8_t GPS_update = 0;
void annexCode() { //this code is excetuted at each loop and won't interfere with control loop if it lasts less than 650 microseconds
static uint32_t buzzerTime,calibratedAccTime,telemetryTime,telemetryAutoTime,psensorTime;
static uint8_t buzzerFreq; //delay between buzzer ring
uint8_t axis,prop1,prop2;
uint16_t pMeterRaw, powerValue; //used for current reading
der Sketch wäre noch länger, habe ihn aber hier abgewürgt. Einige Begriffe, vor allem "static", erscheinen in oranger Farbe. Ich benütze Arduino 0023 und die 1.9er Software. Ich bin mir sicher, ich bin von der Lösung nicht so weit entfernt, habe aber gestern Abend über eine Stunde geübt, leider ohne Erfolg.
Kann mir jemand sagen, wo ich was falsch mache?
Danke und Gruss,
Rolf
stehe gerade mächtig auf dem Schlauch (ist eher mal wieder ne mega- Schlauchrolle ). Ich möchte zum ersten Mal einen Sketch für meinen Tricopter anpassen und das Board damit flashen. Nun habe ich Blue Angels Anleitung Punkt für Punkt abackern wollen. Nur, bei mir erscheint der Sketch nie in der Form, wie sie bei BlueAngels Beschreibung erscheint. Ich kann nirgends einstellen, welche Copterbauart ich fliege etc. Bei mir schaut dies so aus:
/*
MultiWiiCopter by Alexandre Dubus
www.multiwii.com
November 2011 V1.9
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version. see <http://www.gnu.org/licenses/>
*/
#include "config.h"
#include "def.h"
#define VERSION 19
/*********** RC alias *****************/
#define ROLL 0
#define PITCH 1
#define YAW 2
#define THROTTLE 3
#define AUX1 4
#define AUX2 5
#define CAMPITCH 6
#define CAMROLL 7
#define PIDALT 3
#define PIDVEL 4
#define PIDLEVEL 5
#define PIDMAG 6
#define BOXACC 0
#define BOXBARO 1
#define BOXMAG 2
#define BOXCAMSTAB 3
#define BOXCAMTRIG 4
#define BOXARM 5
#define BOXGPSHOME 6
#define BOXGPSHOLD 7
static uint32_t currentTime = 0;
static uint16_t previousTime = 0;
static uint16_t cycleTime = 0; // this is the number in micro second to achieve a full loop, it can differ a little and is taken into account in the PID loop
static uint16_t calibratingA = 0; // the calibration is done is the main loop. Calibrating decreases at each cycle down to 0, then we enter in a normal mode.
static uint8_t calibratingM = 0;
static uint16_t calibratingG;
static uint8_t armed = 0;
static uint16_t acc_1G; // this is the 1G measured acceleration
static int16_t acc_25deg;
static uint8_t nunchuk = 0;
static uint8_t accMode = 0; // if level mode is a activated
static uint8_t magMode = 0; // if compass heading hold is a activated
static uint8_t baroMode = 0; // if altitude hold is activated
static uint8_t GPSModeHome = 0; // if GPS RTH is activated
static uint8_t GPSModeHold = 0; // if GPS PH is activated
static int16_t gyroADC[3],accADC[3],magADC[3];
static int16_t accSmooth[3]; // projection of smoothed and normalized gravitation force vector on x/y/z axis, as measured by accelerometer
static int16_t accTrim[2] = {0, 0};
static int16_t heading,magHold;
static uint8_t calibratedACC = 0;
static uint8_t vbat; // battery voltage in 0.1V steps
static uint8_t okToArm = 0;
static uint8_t rcOptions;
static int32_t pressure;
static int32_t BaroAlt;
static int32_t EstVelocity;
static int32_t EstAlt; // in cm
static uint8_t buzzerState = 0;
//for log
static uint16_t cycleTimeMax = 0; // highest ever cycle timen
static uint16_t cycleTimeMin = 65535; // lowest ever cycle timen
static uint16_t powerMax = 0; // highest ever current
static uint16_t powerAvg = 0; // last known current
static int16_t i2c_errors_count = 0;
// **********************
// power meter
// **********************
#define PMOTOR_SUM 8 // index into pMeter[] for sum
static uint32_t pMeter[PMOTOR_SUM + 1]; //we use [0:7] for eight motors,one extra for sum
static uint8_t pMeterV; // dummy to satisfy the paramStruct logic in ConfigurationLoop()
static uint32_t pAlarm; // we scale the eeprom value from [0:255] to this value we can directly compare to the sum in pMeter[6]
static uint8_t powerTrigger1 = 0; // trigger for alarm based on power consumption
// **********************
// telemetry
// **********************
static uint8_t telemetry = 0;
static uint8_t telemetry_auto = 0;
// ******************
// rc functions
// ******************
#define MINCHECK 1100
#define MAXCHECK 1900
volatile int16_t failsafeCnt = 0;
static int16_t failsafeEvents = 0;
static int16_t rcData[8]; // interval [1000;2000]
static int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW
static uint8_t rcRate8;
static uint8_t rcExpo8;
static int16_t lookupRX[7]; // lookup table for expo & RC rate
volatile uint8_t rcFrameComplete; //for serial rc receiver Spektrum
// **************
// gyro+acc IMU
// **************
static int16_t gyroData[3] = {0,0,0};
static int16_t gyroZero[3] = {0,0,0};
static int16_t accZero[3] = {0,0,0};
static int16_t magZero[3] = {0,0,0};
static int16_t angle[2] = {0,0}; // absolute angle inclination in multiple of 0.1 degree 180 deg = 1800
static int8_t smallAngle25 = 1;
// *************************
// motor and servo functions
// *************************
static int16_t axisPID[3];
static int16_t motor[8];
static int16_t servo[4] = {1500,1500,1500,1500};
// **********************
// EEPROM & LCD functions
// **********************
static uint8_t P8[7], I8[7], D8[7]; //8 bits is much faster and the code is much shorter
static uint8_t dynP8[3], dynI8[3], dynD8[3];
static uint8_t rollPitchRate;
static uint8_t yawRate;
static uint8_t dynThrPID;
static uint8_t activate[8];
void blinkLED(uint8_t num, uint8_t wait,uint8_t repeat) {
uint8_t i,r;
for (r=0;r<repeat;r++) {
for(i=0;i<num;i++) {
LEDPIN_TOGGLE; //switch LEDPIN state
BUZZERPIN_ON;
delay(wait);
BUZZERPIN_OFF;
}
delay(60);
}
}
// **********************
// GPS
// **********************
static int32_t GPS_latitude,GPS_longitude;
static int32_t GPS_latitude_home,GPS_longitude_home;
static uint8_t GPS_fix , GPS_fix_home = 0;
static uint8_t GPS_numSat;
static uint16_t GPS_distanceToHome;
static int16_t GPS_directionToHome = 0;
static uint8_t GPS_update = 0;
void annexCode() { //this code is excetuted at each loop and won't interfere with control loop if it lasts less than 650 microseconds
static uint32_t buzzerTime,calibratedAccTime,telemetryTime,telemetryAutoTime,psensorTime;
static uint8_t buzzerFreq; //delay between buzzer ring
uint8_t axis,prop1,prop2;
uint16_t pMeterRaw, powerValue; //used for current reading
der Sketch wäre noch länger, habe ihn aber hier abgewürgt. Einige Begriffe, vor allem "static", erscheinen in oranger Farbe. Ich benütze Arduino 0023 und die 1.9er Software. Ich bin mir sicher, ich bin von der Lösung nicht so weit entfernt, habe aber gestern Abend über eine Stunde geübt, leider ohne Erfolg.
Kann mir jemand sagen, wo ich was falsch mache?
Danke und Gruss,
Rolf