diff --git a/UAV-ControlSystem/src/Flight/pid.c b/UAV-ControlSystem/src/Flight/pid.c index 471b1db..ad5a3ee 100644 --- a/UAV-ControlSystem/src/Flight/pid.c +++ b/UAV-ControlSystem/src/Flight/pid.c @@ -20,6 +20,7 @@ #include "drivers/failsafe_toggles.h" #include "drivers/motormix.h" #include "utilities.h" +#include "drivers/barometer.h" #define PTERM_SCALE 0.032029f /*P-term used as a scale value to the PID controller*/ @@ -112,7 +113,7 @@ void getCurrentValues(float sensorValues[3], uint8_t ID_profile) break; case PID_ID_BAROMETER: - sensorValues[0] = barometer_GetCurrentAveragedtAltitude(); + sensorValues[0] = barometer_GetCurrentAveragedtAltitude()*20; break; default: @@ -173,7 +174,7 @@ void getPointRate(float *desiredCommand, uint8_t ID_profile) //desiredCommand[THROTTLE] = convertData(RADIO_RANGE, BAROMETER_RANGE, 0, rc_input.Throttle*throttleRate); - desiredCommand[THROTTLE] = 1.9; + desiredCommand[THROTTLE] = 1*20; break; default: @@ -496,7 +497,7 @@ void pidUAVInit(pidProfile_t *pidProfile, uint8_t ID) PidProfile[ID].pidEnabled = false; PidProfile[ID].dterm_lpf = 90; - PidProfile[ID].pid_out_limit = 1000; + PidProfile[ID].pid_out_limit = 2000; break; default: @@ -527,7 +528,7 @@ void pidInit() void pidEproom(void) { - PidProfile[PID_ID_BAROMETER].PIDweight[ROLL] = 200; + PidProfile[PID_ID_BAROMETER].PIDweight[ROLL] = 254; PidProfile[PID_ID_ACCELEROMETER].PIDweight[YAW] = 100; diff --git a/UAV-ControlSystem/src/drivers/barometer.c b/UAV-ControlSystem/src/drivers/barometer.c index 3074445..72ecfd2 100644 --- a/UAV-ControlSystem/src/drivers/barometer.c +++ b/UAV-ControlSystem/src/drivers/barometer.c @@ -512,7 +512,8 @@ float barometer_GetCurrentAveragedtAltitude() } /* Return the average of the stored values */ - return toReturn/averageAltitudeCount; + toReturn = toReturn/averageAltitudeCount; + return toReturn; } diff --git a/UAV-ControlSystem/src/drivers/motormix.c b/UAV-ControlSystem/src/drivers/motormix.c index 0def06d..aff2051 100644 --- a/UAV-ControlSystem/src/drivers/motormix.c +++ b/UAV-ControlSystem/src/drivers/motormix.c @@ -103,7 +103,12 @@ void mix() int16_t RPY_Mix[MOTOR_COUNT]; // Roll Pitch and Yaw variables array int16_t RPY_Mix_Min = 0; // Stores the minimum desired command for any motor int16_t RPY_Mix_Max = 0; // Maximum desired command for any motor - int16_t throttle = PidProfile[PID_ID_BAROMETER].PID_Out[THROTTLE]; // Import throttle value from remote + int16_t throttle = PidProfile[PID_ID_BAROMETER].PID_Out[THROTTLE]; + + if (PidProfile[PID_ID_BAROMETER].pidEnabled && flags_IsSet_ID(systemFlags_flightmode_barometer_id)) + { + throttle += 1482; + } /* Mixer Full Scale enabled */