fixed a scaling bug in imax

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1553 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jasonshort 2011-01-24 02:07:25 +00:00
parent d905bbc551
commit c9227dbcaf
2 changed files with 6 additions and 11 deletions

View File

@ -58,11 +58,6 @@ PID::get_pid(int32_t error, uint16_t dt, float scaler)
return output;
}
void
PID::imax(float v)
{
_imax = fabs(v);
}
void
PID::load_gains()
@ -76,7 +71,7 @@ PID::load_gains()
_kp = (float)(eeprom_read_word((uint16_t *) _address)) / 1000.0;
_ki = (float)(eeprom_read_word((uint16_t *) (_address + 2))) / 1000.0;
_kd = (float)(eeprom_read_word((uint16_t *) (_address + 4))) / 1000.0;
_imax = eeprom_read_word((uint16_t *) (_address + 6)) * 100;
_imax = (float)(eeprom_read_word((uint16_t *) (_address + 6)));
//_kp = (float)_ee.read_int(_address) / 1000.0;
//_ki = (float)_ee.read_int(_address + 2) / 1000.0;
@ -103,10 +98,10 @@ PID::save_gains()
// save is a NOP if the gain array is managed externally
break;
case STORE_EEPROM_UINT16:
eeprom_write_word((uint16_t *) _address, (int)(_kp * 1000));
eeprom_write_word((uint16_t *) (_address + 2), (int)(_ki * 1000));
eeprom_write_word((uint16_t *) (_address + 4), (int)(_kd * 1000));
eeprom_write_word((uint16_t *) (_address + 6), (int)_imax/100);
eeprom_write_word((uint16_t *) _address, (int)(_kp * 1000.0));
eeprom_write_word((uint16_t *) (_address + 2), (int)(_ki * 1000.0));
eeprom_write_word((uint16_t *) (_address + 4), (int)(_kd * 1000.0));
eeprom_write_word((uint16_t *) (_address + 6), (int)(_imax));
/*_ee.write_int(_address, (int)(_kp * 1000));
_ee.write_int(_address + 2, (int)(_ki * 1000));

View File

@ -105,7 +105,7 @@ public:
void kP(const float v) { _gain_array[0] = v; }
void kI(const float v) { _gain_array[1] = v; }
void kD(const float v) { _gain_array[2] = v; }
void imax(const float v);
void imax(const float v) { _gain_array[3] = fabs(v); }
void address(const uint16_t v) { _address = v; }