Skip to content

Commit

Permalink
Merge pull request #266 from readerror67/pitchroll
Browse files Browse the repository at this point in the history
Separation of pitch-roll rates. Non-arduino way.
  • Loading branch information
trollcop committed Mar 31, 2015
2 parents 5ae178e + bedd2d5 commit ffde4a3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ const clivalue_t valueTable[] = {
{ "rc_expo", VAR_UINT8, &cfg.rcExpo8, 0, 100 },
{ "thr_mid", VAR_UINT8, &cfg.thrMid8, 0, 100 },
{ "thr_expo", VAR_UINT8, &cfg.thrExpo8, 0, 100 },
{ "roll_pitch_rate", VAR_UINT8, &cfg.rollPitchRate, 0, 100 },
{ "roll_rate", VAR_UINT8, &cfg.rollPitchRate[0], 0, 100 },
{ "pitch_rate", VAR_UINT8, &cfg.rollPitchRate[1], 0, 100 },
{ "yaw_rate", VAR_UINT8, &cfg.yawRate, 0, 100 },
{ "tpa_rate", VAR_UINT8, &cfg.dynThrPID, 0, 100},
{ "tpa_breakpoint", VAR_UINT16, &cfg.tpa_breakpoint, 1000, 2000},
Expand Down
3 changes: 1 addition & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ master_t mcfg; // master config struct with data independent from profiles
config_t cfg; // profile config struct
const char rcChannelLetters[] = "AERT1234";

static const uint8_t EEPROM_CONF_VERSION = 73;
static const uint8_t EEPROM_CONF_VERSION = 74;
static uint32_t enabledSensors = 0;
static void resetConf(void);
static const uint32_t FLASH_WRITE_ADDR = 0x08000000 + (FLASH_PAGE_SIZE * (FLASH_PAGE_COUNT - (CONFIG_SIZE / 1024)));
Expand Down Expand Up @@ -285,7 +285,6 @@ static void resetConf(void)
cfg.D8[PIDVEL] = 1;
cfg.rcRate8 = 90;
cfg.rcExpo8 = 65;
cfg.rollPitchRate = 0;
cfg.yawRate = 0;
cfg.dynThrPID = 0;
cfg.tpa_breakpoint = 1500;
Expand Down
5 changes: 3 additions & 2 deletions src/mw.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void annexCode(void)

tmp2 = tmp / 100;
rcCommand[axis] = lookupPitchRollRC[tmp2] + (tmp - tmp2 * 100) * (lookupPitchRollRC[tmp2 + 1] - lookupPitchRollRC[tmp2]) / 100;
prop1 = 100 - (uint16_t)cfg.rollPitchRate * tmp / 500;
prop1 = 100 - (uint16_t)cfg.rollPitchRate[axis] * tmp / 500;
prop1 = (uint16_t)prop1 * prop2 / 100;
} else { // YAW
if (cfg.yawdeadband) {
Expand Down Expand Up @@ -405,7 +405,8 @@ static void pidRewrite(void)
// calculate error and limit the angle to 50 degrees max inclination
errorAngle = (constrain(rcCommand[axis] + GPS_angle[axis], -500, +500) - angle[axis] + cfg.angleTrim[axis]) / 10.0f; // 16 bits is ok here
if (!f.ANGLE_MODE) { //control is GYRO based (ACRO and HORIZON - direct sticks control is applied to rate PID
AngleRateTmp = ((int32_t)(cfg.rollPitchRate + 27) * rcCommand[axis]) >> 4;
AngleRateTmp = ((int32_t)(cfg.rollPitchRate[axis] + 27) * rcCommand[axis]) >> 4;

if (f.HORIZON_MODE) {
// mix up angle error to desired AngleRateTmp to add a little auto-level feel
AngleRateTmp += (errorAngle * cfg.I8[PIDLEVEL]) >> 8;
Expand Down
2 changes: 1 addition & 1 deletion src/mw.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ typedef struct config_t {
uint8_t thrMid8;
uint8_t thrExpo8;

uint8_t rollPitchRate;
uint8_t rollPitchRate[2];
uint8_t yawRate;

uint8_t dynThrPID;
Expand Down
12 changes: 8 additions & 4 deletions src/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "telemetry_common.h"

// Multiwii Serial Protocol 0
#define MSP_VERSION 2
#define MSP_VERSION 3
#define CAP_PLATFORM_32BIT ((uint32_t)1 << 31)
#define CAP_BASEFLIGHT_CONFIG ((uint32_t)1 << 30)
#define CAP_DYNBALANCE ((uint32_t)1 << 2)
Expand Down Expand Up @@ -374,7 +374,7 @@ static void evaluateCommand(void)
case MSP_SET_RC_TUNING:
cfg.rcRate8 = read8();
cfg.rcExpo8 = read8();
cfg.rollPitchRate = read8();
cfg.rollPitchRate[0] = cfg.rollPitchRate[1] = read8();
cfg.yawRate = read8();
cfg.dynThrPID = read8();
cfg.thrMid8 = read8();
Expand Down Expand Up @@ -577,7 +577,7 @@ static void evaluateCommand(void)
headSerialReply(7);
serialize8(cfg.rcRate8);
serialize8(cfg.rcExpo8);
serialize8(cfg.rollPitchRate);
serialize8(cfg.rollPitchRate[0]); // here for legacy support
serialize8(cfg.yawRate);
serialize8(cfg.dynThrPID);
serialize8(cfg.thrMid8);
Expand Down Expand Up @@ -764,10 +764,12 @@ static void evaluateCommand(void)
mcfg.currentscale = read16();
mcfg.currentoffset = read16();
mcfg.motor_pwm_rate = read16();
cfg.rollPitchRate[0] = read8();
cfg.rollPitchRate[1] = read8();
/// ???
break;
case MSP_CONFIG:
headSerialReply(1 + 4 + 1 + 2 + 2 + 2 + 2 + 2 + 2);
headSerialReply(1 + 4 + 1 + 2 + 2 + 2 + 2 + 2 + 2 + 2);
serialize8(mcfg.mixerConfiguration);
serialize32(featureMask());
serialize8(mcfg.serialrx_type);
Expand All @@ -777,6 +779,8 @@ static void evaluateCommand(void)
serialize16(mcfg.currentscale);
serialize16(mcfg.currentoffset);
serialize16(mcfg.motor_pwm_rate);
serialize8(cfg.rollPitchRate[0]);
serialize8(cfg.rollPitchRate[1]);
/// ???
break;

Expand Down

0 comments on commit ffde4a3

Please sign in to comment.