浏览代码

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

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 年之前
父节点
当前提交
dd1b10aab2
共有 5 个文件被更改,包括 6 次插入3 次删除
  1. 3 1
      Applications/app/nv_storage.c
  2. 3 2
      Applications/foc/motor/encoder.c
  3. 二进制
      Simulink/FOC.slx
  4. 二进制
      Simulink/FOC.slx.autosave
  5. 二进制
      Simulink/FOC.slxc

+ 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);

二进制
Simulink/FOC.slx


二进制
Simulink/FOC.slx.autosave


二进制
Simulink/FOC.slxc