BMCL_Config.h 10.2 KB
#ifndef __BMCL_CONFIG_H_
#define __BMCL_CONFIG_H_

#include "stdint.h"
#include "BMCL_DevSpecific.h"
#include "MGE_Hal.h"
//=================BMCL Config HW (Using LL Lib) =================

#define BMCL_CONFIG_SELECT_1_GPIO_PORT BMCL_DEVSPECIFIC_SELECT_1_GPIO_PORT
#define BMCL_CONFIG_SELECT_2_GPIO_PORT BMCL_DEVSPECIFIC_SELECT_2_GPIO_PORT

#define BMCL_CONFIG_SELECT_1_GPIO_PIN BMCL_DEVSPECIFIC_SELECT_1_GPIO_PIN
#define BMCL_CONFIG_SELECT_2_GPIO_PIN BMCL_DEVSPECIFIC_SELECT_2_GPIO_PIN


//=================BMCL Config Para=================

extern float pitchCenAngle;
extern float yawCenAngle ;
extern float rollCenAngle ;

//=================BMCL Config Live Setting=================

// PreSetting
#define BMCL_CONFIG_MOT_SELECT_UNKNOW -1
#define BMCL_CONFIG_MOT_SELECT_PITCH 0
#define BMCL_CONFIG_MOT_SELECT_ROLL 1
#define BMCL_CONFIG_MOT_SELECT_YAW 2

#define BMCL_CONFIG_IS_PITCH   (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_PITCH)
#define BMCL_CONFIG_IS_ROLL   (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_ROLL)
#define BMCL_CONFIG_IS_YAW   (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_YAW)


//========Setting=======
#define BMCL_CONFIG_MOT_SELECT_SCANTIMES 50 // The scan times of Motor axis selection GPIO

//=================BMCL Config Setting & Define=================

#define BMCL_CONFIG_VERSION (uint32_t)1

#define BMCL_CONFIG_EEPROM_ADDR  0x0800F800 //62k
#define BMCL_CONFIG_EEPROM_ADDR2  0x0800FC00 //63k

#define BMCL_CONFIG_EEPROM_CRC_INIVAULE 0x1c81

// typedef enum
// {
//     BMCL_CONFIG_MGE_CAL_STA_EMPTY = 0x00,
//     BMCL_CONFIG_MGE_CAL_STA_CALED = 0x01,
// } BMCL_CONFIG_MGE_CAL_STA;

// typedef enum
// {
//     BMCL_CONFIG_MOT_CAL_STA_EMPTY = 0x00,
//     BMCL_CONFIG_MOT_CAL_STA_CALS1 = 0x01,
//     BMCL_CONFIG_MOT_CAL_STA_CALS2 = 0x02,
// } BMCL_CONFIG_MOT_CAL_STA;

// typedef enum
// {
//     BMCL_CONFIG_MOT_CAL_STA_EMPTY = 0x00,
// } BMCL_CONFIG_EEPROM_STA;

// _______________Default parameters_______________

// NOTE: BMCL_CD_Y -> BMCL_CONFIG_DEFPARA_YAW
// NOTE: Change it depend on Platform standard situation



//======================= F1 Motor Board Default Para Pitch

// !  BMCL_CD_P_MOT_FOC_PP is uint8_t
// !  BMCL_CD_P_MGE_DIRECTION is int8_t
// !  BMCL_CD_P_INTER_RANGE is uint32_t

#define BMCL_CD_P_MOT_FOC_Udc 12.0f
#define BMCL_CD_P_MOT_FOC_ULIMIT 5.0f

#define BMCL_CD_P_MOT_FOC_PP 7

#define BMCL_CD_P_MGE_DIRECTION MGE_DIRECTION_CW
#define BMCL_CD_P_MGE_ABSOFFSET 3.22241449f
#define BMCL_CD_P_MGE_ELEANGLE  2.77957392f

#define BMCL_CD_P_MOT_CENTER_ANG 0.0f


#define BMCL_CD_P_INTER_RANGE 2
#define BMCL_CD_P_INTER1_RANGE 3

#define BMCL_CD_P_ANG_GENPID_KP 700.0f
#define BMCL_CD_P_ANG_GENPID_KI 0.1f
#define BMCL_CD_P_ANG_GENPID_KD 15.0f
#define BMCL_CD_P_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_P_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_P_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_P_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_P_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_P_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDc 0.0f

#define BMCL_CD_P_VEL_GENPID_KP 0.3f
#define BMCL_CD_P_VEL_GENPID_KI 10.0f
#define BMCL_CD_P_VEL_GENPID_KD 0.0f
#define BMCL_CD_P_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_P_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_P_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_P_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_P_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_P_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDc 0.0f

#define BMCL_CD_P_KPF_VELP_Q 0.005f
#define BMCL_CD_P_KPF_VELP_R 20.0f

#define BMCL_CD_P_KPF_ANGP_Q 0.0001f
#define BMCL_CD_P_KPF_ANGP_R 0.01f

#define BMCL_CD_P_KPF_SSMQ_Q 0.01f
#define BMCL_CD_P_KPF_SSMQ_R 0.1f

#define BMCL_CD_P_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_P_KPF_MOTANGP_R 0.1f


//======================= F1 Motor Board Default Para Roll

// !  BMCL_CD_R_MOT_FOC_PP is uint8_t
// !  BMCL_CD_R_MGE_DIRECTION is int8_t
// !  BMCL_CD_R_INTER_RANGE is uint32_t

#define BMCL_CD_R_MOT_FOC_Udc 24.0f
#define BMCL_CD_R_MOT_FOC_ULIMIT 5.0f

#define BMCL_CD_R_MOT_FOC_PP 7

#define BMCL_CD_R_MGE_DIRECTION MGE_DIRECTION_CCW
// #define BMCL_CD_R_MGE_ABSOFFSET 0.787124157f
#define BMCL_CD_R_MGE_ABSOFFSET -5.89930677f
// #define BMCL_CD_R_MGE_ELEANGLE 4.4036727f
#define BMCL_CD_R_MGE_ELEANGLE 6.10601282f

#define BMCL_CD_R_MOT_UP_ANG  120.0f      //上限(角度制)
#define BMCL_CD_R_MOT_DOWN_ANG  -90.0f   //下限位
#define BMCL_CD_R_MOT_CENTER_ANG  4.6144133f*_RtoD 


#define BMCL_CD_R_INTER_RANGE 2
#define BMCL_CD_R_INTER1_RANGE 3

#define BMCL_CD_R_ANG_GENPID_KP 200.0f
#define BMCL_CD_R_ANG_GENPID_KI 0.5f
#define BMCL_CD_R_ANG_GENPID_KD 1.0f
#define BMCL_CD_R_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_R_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_R_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_R_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_R_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_R_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDc 0.0f

#define BMCL_CD_R_VEL_GENPID_KP 0.1f
#define BMCL_CD_R_VEL_GENPID_KI 1.0f
#define BMCL_CD_R_VEL_GENPID_KD 0.0f
#define BMCL_CD_R_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_R_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_R_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_R_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_R_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_R_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDc 0.0f

#define BMCL_CD_R_KPF_VELP_Q 0.005f
#define BMCL_CD_R_KPF_VELP_R 20.0f

#define BMCL_CD_R_KPF_ANGP_Q 0.0001f
#define BMCL_CD_R_KPF_ANGP_R 0.01f

#define BMCL_CD_R_KPF_SSMQ_Q 0.01f
#define BMCL_CD_R_KPF_SSMQ_R 0.1f

#define BMCL_CD_R_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_R_KPF_MOTANGP_R 0.1f

//======================= F1 Motor Board Default Para Yaw

// !  BMCL_CD_Y_MOT_FOC_PP is uint8_t
// !  BMCL_CD_Y_MGE_DIRECTION is int8_t
// !  BMCL_CD_Y_INTER_RANGE is uint32_t

#define BMCL_CD_Y_MOT_FOC_Udc 12.0f
#define BMCL_CD_Y_MOT_FOC_ULIMIT 5.0f

#define BMCL_CD_Y_MOT_FOC_PP 7


#define BMCL_CD_Y_MGE_DIRECTION MGE_DIRECTION_CCW
#define BMCL_CD_Y_MGE_ABSOFFSET 3.6f
#define BMCL_CD_Y_MGE_ELEANGLE 4.87077045
// #define BMCL_CD_Y_MGE_ELEANGLE 4.68861246f

#define BMCL_CD_Y_MOT_CENTER_ANG -3.6f*_RtoD

#define BMCL_CD_Y_INTER_RANGE 2
#define BMCL_CD_Y_INTER1_RANGE 3

#define BMCL_CD_Y_ANG_GENPID_KP 700.0f
#define BMCL_CD_Y_ANG_GENPID_KI 0.1f
#define BMCL_CD_Y_ANG_GENPID_KD 15.0f
#define BMCL_CD_Y_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_Y_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_Y_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_Y_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_Y_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_Y_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDc 0.0f

#define BMCL_CD_Y_VEL_GENPID_KP 0.2f
#define BMCL_CD_Y_VEL_GENPID_KI 5.0f
#define BMCL_CD_Y_VEL_GENPID_KD 0.0f
#define BMCL_CD_Y_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_Y_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_Y_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_Y_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_Y_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_Y_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDc 0.0f

#define BMCL_CD_Y_KPF_VELP_Q 0.005f
#define BMCL_CD_Y_KPF_VELP_R 20.0f

#define BMCL_CD_Y_KPF_ANGP_Q 0.0001f
#define BMCL_CD_Y_KPF_ANGP_R 0.01f

#define BMCL_CD_Y_KPF_SSMQ_Q 0.01f
#define BMCL_CD_Y_KPF_SSMQ_R 0.1f

#define BMCL_CD_Y_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_Y_KPF_MOTANGP_R 0.1f



// _______________Default parameters_______________


//=======InitALL Fun
int bmcl_Config_Init();/// @brief 电机驱动参数初始化,固定值,只能通过宏定义修改
/// @param
void BMCL_motorSetting_PreLoad(void);

/// @brief 电机GenPID参数预初始化,使用.h文件中的值
/// @param
void BMCL_motorPID_PreLoad(void);

/// @brief 电机滤波器参数预初始化,使用.h文件中的值
/// @param
void BMCL_filter_PreLoad(void);

// //=======InitALL ForTest Fun
// void motor_PreLoadALL_CailJump(void);


#endif