position control with gain adjust. Need tweaking
This commit is contained in:
parent
797226616e
commit
c415d29ee0
|
@ -110,7 +110,7 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
|
|||
//motor->motor_status.nextHallPattern = 3;
|
||||
|
||||
motor->motor_status.speed_average = 0;
|
||||
motor->motor_status.count =1;
|
||||
motor->motor_status.count = 1;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Initialize Phase Current Struct:
|
||||
|
@ -177,8 +177,10 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
|
|||
//motor->controllers.Pid_Speed.Kd = 0.001f;
|
||||
|
||||
/* VI Control Gains */
|
||||
motor->controllers.Pid_Speed.Kp = 0.0002f;
|
||||
motor->controllers.Pid_Speed.Ki = 0.0000001f;
|
||||
//motor->controllers.Pid_Speed.Kp = 0.0002f;
|
||||
//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.Ki = 0.0f;
|
||||
|
@ -192,8 +194,10 @@ void BldcInitStruct(BLDCMotor_t* const motor, BLDCMotor_param_t * const motor_pa
|
|||
//// Initialize PI Position control
|
||||
//// ------------------------------------------------------------------------------
|
||||
PI_objectInit(&motor->controllers.Pi_Pos);
|
||||
motor->controllers.Pi_Pos.Kp = 40.0f;
|
||||
motor->controllers.Pi_Pos.Ki = 0.0f;
|
||||
//motor->controllers.Pi_Pos.Kp = 40.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.OutMin_pu = -(motor_param->motor_Max_Spd_RPM);
|
||||
}
|
||||
|
|
|
@ -45,13 +45,6 @@ volatile typedef struct timerflags
|
|||
volatile bool motor_telemetry_flag;
|
||||
} 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 uint8_t desiredDirection; //! The desired direction of rotation.
|
||||
|
|
|
@ -71,6 +71,12 @@ typedef volatile struct
|
|||
//FILTER_FO_Obj derFilter; //!< the derivative filter object
|
||||
} PID_t;
|
||||
|
||||
volatile typedef struct
|
||||
{
|
||||
volatile PI_t Pi_Idc;
|
||||
volatile PID_t Pid_Speed;
|
||||
volatile PI_t Pi_Pos;
|
||||
} MOTOR_Control_Structs;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// functions
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef MOTORPARAMETERS_H_
|
||||
#define MOTORPARAMETERS_H_
|
||||
#include "atmel_start.h"
|
||||
#include "control.h"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// M1 Hall Parameters
|
||||
|
@ -131,6 +132,7 @@ typedef struct
|
|||
const float32_t motor_MeasureRange_RPM; // give 20% headroom
|
||||
const float32_t motor_Max_Spd_ELEC;
|
||||
const float32_t motor_Max_Current_IDC_A;
|
||||
MOTOR_Control_Structs controller_param;
|
||||
} BLDCMotor_param_t;
|
||||
|
||||
//static BLDCMotor_param_t FH_22mm24BXTR;
|
||||
|
@ -138,36 +140,45 @@ typedef struct
|
|||
|
||||
/* Small Motor - 2214S024BXTR*/
|
||||
const static BLDCMotor_param_t FH_22mm24BXTR = {
|
||||
.pwm_desc = &PWM_0,
|
||||
.speedtimer_hw = TC2,
|
||||
.motor_Poles = 14,
|
||||
.motor_polePairs = 7,
|
||||
.motor_commutationStates = 42, //polePairs * 6
|
||||
.motor_RS_Ohm = 25.9,
|
||||
.motor_LD_H = 0.003150,
|
||||
.motor_LQ_H = 0.003150,
|
||||
.motor_Flux_WB = 0.001575,
|
||||
.motor_Max_Spd_RPM = 3000,
|
||||
.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_Current_IDC_A = 0.368,
|
||||
.pwm_desc = &PWM_0,
|
||||
.speedtimer_hw = TC2,
|
||||
.motor_Poles = 14,
|
||||
.motor_polePairs = 7,
|
||||
.motor_commutationStates = 42, //polePairs * 6
|
||||
.motor_RS_Ohm = 25.9,
|
||||
.motor_LD_H = 0.003150,
|
||||
.motor_LQ_H = 0.003150,
|
||||
.motor_Flux_WB = 0.001575,
|
||||
.motor_Max_Spd_RPM = 3000,
|
||||
.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_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 */
|
||||
const static BLDCMotor_param_t FH_32mm24BXTR = {
|
||||
.pwm_desc = &PWM_1,
|
||||
.speedtimer_hw = TC4,
|
||||
.motor_Poles = 14,
|
||||
.motor_polePairs = 7,
|
||||
.motor_commutationStates = 42, //polePairs * 6
|
||||
.motor_RS_Ohm = 3.37,
|
||||
.motor_LD_H = 0.001290,
|
||||
.motor_LQ_H = 0.001290,
|
||||
.motor_Flux_WB = 0.0063879968,
|
||||
.motor_Max_Spd_RPM = 3000,
|
||||
.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_Current_IDC_A = 1.0,
|
||||
.pwm_desc = &PWM_1,
|
||||
.speedtimer_hw = TC4,
|
||||
.motor_Poles = 14,
|
||||
.motor_polePairs = 7,
|
||||
.motor_commutationStates = 42, //polePairs * 6
|
||||
.motor_RS_Ohm = 3.37,
|
||||
.motor_LD_H = 0.001290,
|
||||
.motor_LQ_H = 0.001290,
|
||||
.motor_Flux_WB = 0.0063879968,
|
||||
.motor_Max_Spd_RPM = 3000,
|
||||
.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_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_ */
|
Loading…
Reference in New Issue