Kaynağa Gözat

1. 电流环带宽减小到1000
2. 最大相电流限制分硬件(500A)和电机
3. 重新加入电机温度采集

Signed-off-by: huhui <huhui@sharkgulf.com>

huhui 3 yıl önce
ebeveyn
işleme
3a5d066d60

+ 4 - 4
Applications/app/app.c

@@ -106,21 +106,21 @@ static u32 _app_report_task(void *p) {
 		//sys_debug("modulation %f, %f\n", PMSM_FOC_Get()->out.f_vdqRation, PMSM_FOC_Get()->rtLim.rpmLimRamp.interpolation);
 		//sys_debug("Slow: %d - %d\n", g_meas_MCTask.intval_time, g_meas_MCTask.exec_time);
 		//sys_debug("Fast: %d - %d, err: %d-%d-%d\n", g_meas_foc.intval_time, g_meas_foc.exec_time, g_meas_foc.intval_hi_err, g_meas_foc.intval_low_err, g_meas_foc.exec_max_error_time);
-		//sys_debug("FOC time err %d %d\n", g_meas_foc.intval_time_h_error, g_meas_foc.intval_time_l_error);
+		sys_debug("FOC time err %d %d\n", g_meas_foc.intval_time_h_error, g_meas_foc.intval_time_l_error);
 		//sys_debug("acc vol %d, mos2 %d\n", get_acc_vol(), get_mos_temp2());
 		//sys_debug("throttle %f\n", get_throttle_float());
-		//sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
+		sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
 		//sys_debug("target current %f\n", PMSM_FOC_Get()->in.s_targetCurrent);
 		//thro_torque_log();
 		//sys_debug("fan rpm %d, %d\n", mc_params()->fan[0].rpm, mc_params()->fan[1].rpm);
 		encoder_log();
 		///PMSM_FOC_LogDebug();
-		eCtrl_debug_log();
+		//eCtrl_debug_log();
 		//err_code_log();
 	}
 	return 200;
 }
-static int plot_type = 2;
+static int plot_type = 1;
 static void plot_smo_angle(void) {
 	float smo_angle = foc_observer_smo_angle();
 	float delta = smo_angle - PMSM_FOC_Get()->in.s_hallAngle;

+ 4 - 0
Applications/app/nv_storage.c

@@ -433,6 +433,10 @@ void nv_storage_init(void) {
 #endif
 #if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_A1
 	m_params.offset = 0.0f; //编码器做了零位置校准
+	foc_params.n_currentBand = CONFIG_CURRENT_BANDWITH;
+	if (CONFIG_DEFAULT_PHASE_CURR_LIM != foc_params.s_PhaseCurrLim) {
+		foc_params.s_PhaseCurrLim = CONFIG_DEFAULT_PHASE_CURR_LIM;
+	}
 #endif
 	foc_params.s_maxDCVol = CONFIG_MAX_DC_VOL;
 	foc_params.s_minDCVol = CONFIG_MIN_DC_VOL;

+ 2 - 2
Applications/bsp/board_mc100_v1.h

@@ -13,7 +13,7 @@
 
 #define CONFIG_MAX_VBUS_CURRENT 120.0f
 #define CONFIG_MAX_MOT_RPM      9000.0f
-#define CONFIG_MAX_PHASE_CURR   400.0F
+#define CONFIG_MAX_PHASE_CURR   500.0F
 #define CONFIG_MAX_PHASE_VOL    (CONFIG_MOS_MAX_VOL - 20.0F)
 #define CONFIG_MAX_TORQUE       CONFIG_MAX_PHASE_CURR
 
@@ -302,7 +302,7 @@
 #define ENC_PWM_TIMER_INT_FLG TIMER_INT_FLAG_CH0
 #define ENC_PWM_IRQHandler TIMER1_IRQHandler
 
-#define ENC_MAX_interpolation 4.0F
+#define ENC_MAX_interpolation 1.0F
 
 #define ENC_FILTER_NR          15
 #ifdef CONFIG_PWM_UV_SWAP

+ 0 - 1
Applications/foc/foc_config.h

@@ -4,7 +4,6 @@
 #include "bsp/bsp.h"
 
 #define CONFIG_DEFAULT_IDC_LIM 45
-#define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_DEFAULT_RPM_LIM       CONFIG_MAX_MOT_RPM
 #define CONFIG_DEFAULT_LOCK_TORQUE_LIM 20
 

+ 5 - 1
Applications/foc/motor/encoder.c

@@ -336,11 +336,15 @@ static void encoder_sync_pwm_abs(void) {
 }
 
 /*I 信号的中断处理,一圈一个中断*/
+static int abi_I_delta = 0;
 void ENC_ABI_IRQHandler(void) {
 	g_encoder.b_index_cnt = ENC_COUNT;	
 	if (!g_encoder.b_index_found){
 		encoder_sync_pwm_abs();
 	}
+	if (g_encoder.b_index_cnt > 10 && g_encoder.b_index_cnt < (g_encoder.cpr - 10)) {
+		abi_I_delta = g_encoder.b_index_cnt;
+	} 
 }
 
 /* 编码器AB信号读书溢出处理 */
@@ -406,5 +410,5 @@ float encoder_get_abi_angle(void) {
 
 void encoder_log(void) {
 	sys_debug("pwm %f, abi %f\n", encoder_get_pwm_angle(), encoder_get_abi_angle());
-	sys_debug("pwm count %d\n", g_encoder.pwm_count);
+	sys_debug("pwm count %d, I count %d\n", g_encoder.pwm_count, abi_I_delta);
 }

+ 11 - 1
Applications/foc/motor/motor_param.h

@@ -23,6 +23,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define TRQ_PI_KI 0.15F
 
 #define CONFIG_CURRENT_BANDWITH  1000.0f /* 电流环带宽 */
+#define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_MAX_FW_D_CURR     100.0F //d轴最大的退磁电流
 
 #define MOTOR_NR 0x11
@@ -30,6 +31,11 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_R   0.022f
 #define MOTOR_Ld (0.000140F*0.5f)
 #define MOTOR_Lq (0.000340f*0.5f)
+
+//#define MOTOR_R   0.033f
+//#define MOTOR_Ld (0.000168f * 0.5f)//(0.000140F*0.5f)
+//#define MOTOR_Lq (0.000330f * 0.5f)//(0.000340f*0.5f)
+
 #define MOTOR_POLES  4
 #define MOTOR_ENC_OFFSET 0.0F
 #define CONFIG_MAX_MOTOR_TORQUE 200.0F
@@ -39,7 +45,8 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define TRO_PI_KD 0.0F
 #define MOTOR_NR 0x16
 
-#define CONFIG_CURRENT_BANDWITH  2000.0f /* 电流环带宽 */
+#define CONFIG_CURRENT_BANDWITH  1000.0f /* 电流环带宽 */
+#define CONFIG_DEFAULT_PHASE_CURR_LIM 500
 #define CONFIG_MAX_FW_D_CURR     150.0F //d轴最大的退磁电流
 
 #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_NEW2
@@ -56,6 +63,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_NR 0x12
 
 #define CONFIG_CURRENT_BANDWITH  1000.0f /* 电流环带宽 */
+#define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_MAX_FW_D_CURR     100.0F //d轴最大的退磁电流
 
 #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_ZD_100
@@ -72,6 +80,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_NR 0x13
 
 #define CONFIG_CURRENT_BANDWITH  1000.0f /* 电流环带宽 */
+#define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_MAX_FW_D_CURR     100.0F //d轴最大的退磁电流
 
 #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_OLD
@@ -88,6 +97,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_NR 0x14
 
 #define CONFIG_CURRENT_BANDWITH  1000.0f /* 电流环带宽 */
+#define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_MAX_FW_D_CURR     100.0F //d轴最大的退磁电流
 
 #elif CONFIG_MOT_TYPE==MOTOR_3505

+ 0 - 1
Applications/foc/samples.c

@@ -230,7 +230,6 @@ void sample_motor_temp(void) {
 	motor_temp.value = ntc_get_motor_temp(r);
 	LowPass_Filter(motor_temp.filted_value, motor_temp.value, motor_temp.lowpass);
 #endif
-	motor_temp.filted_value = 0;
 }
 
 void sample_mos_temp(void) {