PID changes

Added ID profile to PID init and new init func
This commit is contained in:
johan9107 2016-10-17 11:58:36 +02:00
parent 0e61e0ebf2
commit 2227ab997f
2 changed files with 15 additions and 11 deletions

View File

@ -111,7 +111,7 @@ void pidInit();
* BRIEF: Initializes the pid profile PID controller * * BRIEF: Initializes the pid profile PID controller *
* INFORMATION: Recommended to use if unexpected values occur of profile * * INFORMATION: Recommended to use if unexpected values occur of profile *
**************************************************************************/ **************************************************************************/
void pidUAVInit(pidProfile_t *pidProfile); void pidUAVInit(pidProfile_t *pidProfile, uint8_t ID);
/************************************************************************** /**************************************************************************
* BRIEF: Dynamic PID controller, able to handle several PID controller * * BRIEF: Dynamic PID controller, able to handle several PID controller *

View File

@ -133,11 +133,12 @@ void getPointRate(float *desiredCommand, uint8_t ID_profile)
* BRIEF: Initializes the pid profile PID controller * * BRIEF: Initializes the pid profile PID controller *
* INFORMATION: Recommended to use if unexpected values occur of profile * * INFORMATION: Recommended to use if unexpected values occur of profile *
**************************************************************************/ **************************************************************************/
void pidUAVInit(pidProfile_t *pidProfile) void pidUAVInit(pidProfile_t *pidProfile, uint8_t ID)
{ {
/*This is recommended init settings*/ /*This is recommended init settings*/
pidProfile->ID_profile = 0; pidProfile->ID_profile = ID;
pidProfile->pidEnabled = true;
pidProfile-> pidStabilisationEnabled = true; pidProfile-> pidStabilisationEnabled = true;
pidProfile->DOF = 0; pidProfile->DOF = 0;
@ -203,10 +204,13 @@ void pidUAVInit(pidProfile_t *pidProfile)
**************************************************************************/ **************************************************************************/
void pidInit() void pidInit()
{ {
pidUAVInit(&PidGyroProfile);
pidUAVInit(&PidAccelerometerProfile); mpu6000_init(&gyroProfile,&accelProfile);
pidUAVInit(&PidCompassProfile);
pidUAVInit(&PidBarometerProfile); pidUAVInit(&PidGyroProfile, PID_ID_GYRO);
pidUAVInit(&PidAccelerometerProfile, PID_ID_ACCELEROMETER);
pidUAVInit(&PidCompassProfile, PID_ID_COMPASS);
pidUAVInit(&PidBarometerProfile, PID_ID_BAROMETER);
} }
/************************************************************************** /**************************************************************************
@ -318,15 +322,15 @@ void pidRun(uint8_t ID)
case PID_ID_GYRO: case PID_ID_GYRO:
if (!PidGyroProfile.pidEnabled) if (!PidGyroProfile.pidEnabled)
{
pidUAV(&PidGyroProfile);
}
else
{ {
PidGyroProfile.PID_Out[ROLL] = RawRcCommand.Roll; PidGyroProfile.PID_Out[ROLL] = RawRcCommand.Roll;
PidGyroProfile.PID_Out[PITCH] = RawRcCommand.Pitch; PidGyroProfile.PID_Out[PITCH] = RawRcCommand.Pitch;
PidGyroProfile.PID_Out[YAW] = RawRcCommand.Yaw; PidGyroProfile.PID_Out[YAW] = RawRcCommand.Yaw;
} }
else
{
pidUAV(&PidGyroProfile);
}
break; break;
case PID_ID_ACCELEROMETER: case PID_ID_ACCELEROMETER: