position control with gain adjust. Need tweaking
This commit is contained in:
parent
797226616e
commit
c415d29ee0
|
@ -177,8 +177,10 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
|
||||||
//motor->controllers.Pid_Speed.Kd = 0.001f;
|
//motor->controllers.Pid_Speed.Kd = 0.001f;
|
||||||
|
|
||||||
/* VI Control Gains */
|
/* VI Control Gains */
|
||||||
motor->controllers.Pid_Speed.Kp = 0.0002f;
|
//motor->controllers.Pid_Speed.Kp = 0.0002f;
|
||||||
motor->controllers.Pid_Speed.Ki = 0.0000001f;
|
//motor->controllers.Pid_Speed.Ki = 0.0000001f;
|
||||||
|
motor->controllers.Pid_Speed.Kp = motor_param->controller_param.Pid_Speed.Kp;
|
||||||
|
motor->controllers.Pid_Speed.Ki = motor_param->controller_param.Pid_Speed.Ki;
|
||||||
|
|
||||||
//motor->controllers.Pid_Speed.Kp = 0.0005f;
|
//motor->controllers.Pid_Speed.Kp = 0.0005f;
|
||||||
//motor->controllers.Pid_Speed.Ki = 0.0f;
|
//motor->controllers.Pid_Speed.Ki = 0.0f;
|
||||||
|
@ -192,8 +194,10 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
|
||||||
//// Initialize PI Position control
|
//// Initialize PI Position control
|
||||||
//// ------------------------------------------------------------------------------
|
//// ------------------------------------------------------------------------------
|
||||||
PI_objectInit(&motor->controllers.Pi_Pos);
|
PI_objectInit(&motor->controllers.Pi_Pos);
|
||||||
motor->controllers.Pi_Pos.Kp = 40.0f;
|
//motor->controllers.Pi_Pos.Kp = 40.0f;
|
||||||
motor->controllers.Pi_Pos.Ki = 0.0f;
|
//motor->controllers.Pi_Pos.Ki = 0.0f;
|
||||||
|
motor->controllers.Pi_Pos.Kp = motor_param->controller_param.Pi_Pos.Kp;
|
||||||
|
motor->controllers.Pi_Pos.Ki = motor_param->controller_param.Pi_Pos.Ki;
|
||||||
motor->controllers.Pi_Pos.OutMax_pu = (motor_param->motor_Max_Spd_RPM);
|
motor->controllers.Pi_Pos.OutMax_pu = (motor_param->motor_Max_Spd_RPM);
|
||||||
motor->controllers.Pi_Pos.OutMin_pu = -(motor_param->motor_Max_Spd_RPM);
|
motor->controllers.Pi_Pos.OutMin_pu = -(motor_param->motor_Max_Spd_RPM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,6 @@ volatile typedef struct timerflags
|
||||||
volatile bool motor_telemetry_flag;
|
volatile bool motor_telemetry_flag;
|
||||||
} TIMERflags_t;
|
} TIMERflags_t;
|
||||||
|
|
||||||
volatile typedef struct
|
|
||||||
{
|
|
||||||
volatile PI_t Pi_Idc;
|
|
||||||
volatile PID_t Pid_Speed;
|
|
||||||
volatile PI_t Pi_Pos;
|
|
||||||
} MOTOR_Control_Structs;
|
|
||||||
|
|
||||||
volatile typedef struct
|
volatile typedef struct
|
||||||
{
|
{
|
||||||
volatile uint8_t desiredDirection; //! The desired direction of rotation.
|
volatile uint8_t desiredDirection; //! The desired direction of rotation.
|
||||||
|
|
|
@ -71,6 +71,12 @@ typedef volatile struct
|
||||||
//FILTER_FO_Obj derFilter; //!< the derivative filter object
|
//FILTER_FO_Obj derFilter; //!< the derivative filter object
|
||||||
} PID_t;
|
} PID_t;
|
||||||
|
|
||||||
|
volatile typedef struct
|
||||||
|
{
|
||||||
|
volatile PI_t Pi_Idc;
|
||||||
|
volatile PID_t Pid_Speed;
|
||||||
|
volatile PI_t Pi_Pos;
|
||||||
|
} MOTOR_Control_Structs;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// functions
|
// functions
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#ifndef MOTORPARAMETERS_H_
|
#ifndef MOTORPARAMETERS_H_
|
||||||
#define MOTORPARAMETERS_H_
|
#define MOTORPARAMETERS_H_
|
||||||
#include "atmel_start.h"
|
#include "atmel_start.h"
|
||||||
|
#include "control.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// M1 Hall Parameters
|
// M1 Hall Parameters
|
||||||
|
@ -131,6 +132,7 @@ typedef struct
|
||||||
const float32_t motor_MeasureRange_RPM; // give 20% headroom
|
const float32_t motor_MeasureRange_RPM; // give 20% headroom
|
||||||
const float32_t motor_Max_Spd_ELEC;
|
const float32_t motor_Max_Spd_ELEC;
|
||||||
const float32_t motor_Max_Current_IDC_A;
|
const float32_t motor_Max_Current_IDC_A;
|
||||||
|
MOTOR_Control_Structs controller_param;
|
||||||
} BLDCMotor_param_t;
|
} BLDCMotor_param_t;
|
||||||
|
|
||||||
//static BLDCMotor_param_t FH_22mm24BXTR;
|
//static BLDCMotor_param_t FH_22mm24BXTR;
|
||||||
|
@ -151,6 +153,11 @@ const static BLDCMotor_param_t FH_22mm24BXTR = {
|
||||||
.motor_MeasureRange_RPM = 3000 * 1.2, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom
|
.motor_MeasureRange_RPM = 3000 * 1.2, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom
|
||||||
.motor_Max_Spd_ELEC = (3000/60)*7.0, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS
|
.motor_Max_Spd_ELEC = (3000/60)*7.0, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS
|
||||||
.motor_Max_Current_IDC_A = 0.368,
|
.motor_Max_Current_IDC_A = 0.368,
|
||||||
|
.controller_param.Pid_Speed.Kp = 0.00008f,
|
||||||
|
.controller_param.Pid_Speed.Ki = 0.0000001f,
|
||||||
|
//.controller_param.Pid_Speed.Ki = 0.0000001f,
|
||||||
|
.controller_param.Pi_Pos.Kp = 50.0f,
|
||||||
|
.controller_param.Pi_Pos.Ki = 0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Big Motor - 3216W024BXTR */
|
/* Big Motor - 3216W024BXTR */
|
||||||
|
@ -168,6 +175,10 @@ const static BLDCMotor_param_t FH_32mm24BXTR = {
|
||||||
.motor_MeasureRange_RPM = 3200, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom
|
.motor_MeasureRange_RPM = 3200, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom
|
||||||
.motor_Max_Spd_ELEC = 12000, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS
|
.motor_Max_Spd_ELEC = 12000, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS
|
||||||
.motor_Max_Current_IDC_A = 1.0,
|
.motor_Max_Current_IDC_A = 1.0,
|
||||||
|
.controller_param.Pid_Speed.Kp = 0.0002f,
|
||||||
|
.controller_param.Pid_Speed.Ki = 0.0000001f,
|
||||||
|
.controller_param.Pi_Pos.Kp = 40.0f,
|
||||||
|
.controller_param.Pi_Pos.Ki = 0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MOTORPARAMETERS_H_ */
|
#endif /* MOTORPARAMETERS_H_ */
|
Loading…
Reference in New Issue