Ver Fonte

Z信号timer的滤波系数加大到0xF最大,尽量减少干扰,可以漏采,但是不能采错

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin há 2 anos atrás
pai
commit
b592151f79

+ 2 - 0
Applications/bsp/gd32/board_mc100_v1.h

@@ -337,6 +337,8 @@
 
 #define CONFIG_ENC_FILTER_NR          12 //1100: fSAMP=fDTS/16, N=8,采样率 120M/16 = 7.5M
 #define CONFIG_PWM_FILTER_NR          12
+/* Z 信号宽度设计为4LSB,200hz机械转速,200K,Z脉冲宽度5us*4=20us, 按照timer滤波系数15算,1/3.75*8=2.1us采集到信号没有变才认为是有效值*/
+#define CONFIG_Z_IDX_FILTER_NR        15 //1111:  fSAMP=fDTS/32, N=8,采样率 120M/32 = 3.75M
 
 #ifdef CONFIG_PWM_UV_SWAP
 #define ENCODER_CC_INVERT 1

+ 3 - 1
Applications/bsp/gd32/board_mc105_v3.h

@@ -378,9 +378,11 @@
 
 #define ENC_MAX_interpolation 1.0F
 
+/* 200hz机械转速,200K(12000RPM),AB信号高低电平宽度5us/2=2.5us, 按照timer滤波系数12算,1/7.5*8=1.06us采集到信号没有变才认为是有效值*/
 #define CONFIG_ENC_FILTER_NR          12 //1100: fSAMP=fDTS/16, N=8,采样率 120M/16 = 7.5M
 #define CONFIG_PWM_FILTER_NR          12
-
+/* Z 信号宽度设计为4LSB,200hz机械转速,200K(12000RPM),Z脉冲宽度5us*4=20us, 按照timer滤波系数15算,1/3.75*8=2.1us采集到信号没有变才认为是有效值*/
+#define CONFIG_Z_IDX_FILTER_NR        15///1111:  fSAMP=fDTS/32, N=8,采样率 120M/32 = 3.75M
 #ifdef CONFIG_PWM_UV_SWAP
 #define ENCODER_CC_INVERT 1
 #endif

+ 1 - 1
Applications/bsp/gd32/enc_intf.c

@@ -164,7 +164,7 @@ void enc_intf_z_counter(void) {
 	timer_icinitpara.icpolarity  = TIMER_IC_POLARITY_RISING;
 	timer_icinitpara.icselection = TIMER_IC_SELECTION_DIRECTTI;
 	timer_icinitpara.icprescaler = TIMER_IC_PSC_DIV1;
-	timer_icinitpara.icfilter	 = CONFIG_PWM_FILTER_NR;
+	timer_icinitpara.icfilter	 = CONFIG_Z_IDX_FILTER_NR;
 	timer_input_capture_config(timer, ENC_I_TIMER_CHAN, &timer_icinitpara);
 
 	/* select the master slave mode */