Saruulmongolia / aeroquad

Automatically exported from code.google.com/p/aeroquad
0 stars 0 forks source link

Some obsolete code in readEEPROM #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. in DataStorage.h the new readPID function already sets
  pid->lastPosition = 0;
  pid->integratedError = 0;
So in readEEPROM these two assignments after the readPID call are obsolete now. 
Here is the fixed code, also added readPDI for the altitude code:

void readEEPROM(void) {
  readPID(ROLL, ROLL_PID_GAIN_ADR);
  readPID(PITCH, PITCH_PID_GAIN_ADR);
  readPID(YAW, YAW_PID_GAIN_ADR);

  readPID(LEVELROLL, LEVELROLL_PID_GAIN_ADR);
  readPID(LEVELPITCH, LEVELPITCH_PID_GAIN_ADR);

  readPID(HEADING, HEADING_PID_GAIN_ADR);

  readPID(LEVELGYROROLL, LEVEL_GYRO_ROLL_PID_GAIN_ADR);
  readPID(LEVELGYROPITCH, LEVEL_GYRO_PITCH_PID_GAIN_ADR);

  #ifdef AltitudeHold
    readPID(ALTITUDE, ALTITUDE_PGAIN_ADR);
    PID[ALTITUDE].windupGuard = readFloat(ALTITUDE_WINDUP_ADR);
    readPID(ZDAMPENING, ZDAMP_PGAIN_ADR);
    minThrottleAdjust = readFloat(ALTITUDE_MIN_THROTTLE_ADR);
    maxThrottleAdjust = readFloat(ALTITUDE_MAX_THROTTLE_ADR);
    altitude.setSmoothFactor(readFloat(ALTITUDE_SMOOTH_ADR));
  #endif

  #ifdef HeadingMagHold
    compass.setMagCal(XAXIS, readFloat(MAGXMAX_ADR), readFloat(MAGXMIN_ADR));
    compass.setMagCal(YAXIS, readFloat(MAGYMAX_ADR), readFloat(MAGYMIN_ADR));
    compass.setMagCal(ZAXIS, readFloat(MAGZMAX_ADR), readFloat(MAGZMIN_ADR));
  #endif

  windupGuard = readFloat(WINDUPGUARD_ADR);
  levelLimit = readFloat(LEVELLIMIT_ADR);
  levelOff = readFloat(LEVELOFF_ADR);
  timeConstant = readFloat(FILTERTERM_ADR);
  smoothHeading = readFloat(HEADINGSMOOTH_ADR);
  aref = readFloat(AREF_ADR);
  flightMode = readFloat(FLIGHTMODE_ADR);
  headingHoldConfig = readFloat(HEADINGHOLD_ADR);
  minAcro = readFloat(MINACRO_ADR);
  accel.setOneG(readFloat(ACCEL1G_ADR));
}

Original issue reported on code.google.com by al...@arcor.de on 4 Dec 2010 at 1:36

GoogleCodeExporter commented 8 years ago
Thanks missed that it was already set inside readPID().  For some unexplained 
reason I can't get readPI working for altitude or zdampening.  When I try to 
recall them after reboot, they read some other random value.  It's very 
puzzling because that would mean readPID shouldn't work anywhere else?

I'll close this as fixed, but will comment out the readPIDs for AltitudeHold 
for now.  Maybe you can see something going on?

Thank you for this overall fix, it has saved a lot of space.  I'm thinking of a 
similar strategy with the Serial Comm stuff.  Will post about it in forums.

Original comment by CaranchoEngineering@gmail.com on 4 Dec 2010 at 9:49

GoogleCodeExporter commented 8 years ago
Change the declaration of if IDEeprom from byte to int to fit the used range.
Old: void readPID(unsigned char IDPid, unsigned char IDEeprom) {
New: void readPID(unsigned char IDPid, unsigned int IDEeprom) {

Original comment by al...@arcor.de on 4 Dec 2010 at 12:57