masenga01 / aeroquad

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

One more Altitude Hold change #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Ted, I think the line "throttleAdjust += PID[ALTITUDE].integratedError;

doesn't need to be there, we've already updated the throttleAdjust with the 
results of updatePID, and then we add the error to it again?

Here's the current working code with what I'd change, just a single delete or 
comment out...

  #ifdef AltitudeHold
    if (altitudeHold == ON) {
      throttleAdjust = updatePID(holdAltitude, altitude.getData(), &PID[ALTITUDE]);
      zDampening = updatePID(0, accel.getZaxis(), &PID[ZDAMPENING]); // This is stil under development - do not use (set PID=0)
      if((abs(flightAngle.getData(ROLL)) > 5) ||  (abs(flightAngle.getData(PITCH)) > 5)) { PID[ZDAMPENING].integratedError = 0; }
        throttleAdjust = constrain((holdAltitude - altitude.getData()) * PID[ALTITUDE].P, minThrottleAdjust, maxThrottleAdjust);
      if (receiver.getData(THROTTLE) > MAXCHECK) //above 1900
        holdAltitude += 0.1;
      if (receiver.getData(THROTTLE) <= MINCHECK) //below 1100
        holdAltitude -= 0.1;
      //throttleAdjust += PID[ALTITUDE].integratedError;
    }
    else {
      // Altitude hold is off, get throttle from receiver
      holdThrottle = receiver.getData(THROTTLE);
      throttleAdjust = autoDescent; // autoDescent is lowered from BatteryMonitor.h during battery alarm
    }
    // holdThrottle set in FlightCommand.pde if altitude hold is on
    throttle = holdThrottle + throttleAdjust; // holdThrottle is also adjust by BatteryMonitor.h during battery alarm
  #else
    // If altitude hold not enabled in AeroQuad.pde, get throttle from receiver
    throttle = receiver.getData(THROTTLE) + autoDescent; //autoDescent is lowered from BatteryMonitor.h while battery critical, otherwise kept 0
  #endif

Original issue reported on code.google.com by akadam...@gmail.com on 31 Jan 2011 at 3:48

GoogleCodeExporter commented 9 years ago
Ack... I read about it in the forum, but didn't actually go and make the 
change.  Thanks for the alert!

Original comment by CaranchoEngineering@gmail.com on 2 Feb 2011 at 8:53