Forráskód Böngészése

解决零位置校准除数少1的问题

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 éve
szülő
commit
dd1b10aab2

+ 3 - 1
Applications/app/nv_storage.c

@@ -436,7 +436,9 @@ void nv_storage_init(void) {
 #if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_ZD_100
 	m_params.offset = 0.0f; //编码器做了零位置校准
 #endif
-
+#if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_A1
+	m_params.offset = 0.0f; //编码器做了零位置校准
+#endif
 	sys_debug("current band %f -- %d\n", foc_params.n_currentBand, sizeof(foc_params_t));
 }
 

+ 3 - 2
Applications/foc/motor/encoder.c

@@ -302,9 +302,10 @@ float encoder_zero_phase_detect(float *enc_off) {
 		total_ph += phase;
 		total_enc_off += g_encoder.pwm_count;
 	}
-	float offset_now = total_ph/(float)count;
+	sys_debug("count = %d\n", count);
+	float offset_now = total_ph/(float)(count + 1);
 	g_encoder.enc_offset = offset_now;
-	g_encoder.enc_count_off = (u32)(total_enc_off/(float)count);
+	g_encoder.enc_count_off = (u32)(total_enc_off/(float)(count + 1));
 	if (enc_off) {
 		*enc_off = (float)g_encoder.enc_count_off;
 		sys_debug("encoder off %f\n", *enc_off);

BIN
Simulink/FOC.slx


BIN
Simulink/FOC.slx.autosave


BIN
Simulink/FOC.slxc