Kaynağa Gözat

二段加减速的第一段step和大小通过宏来控制

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 yıl önce
ebeveyn
işleme
4e17ebfa28

+ 6 - 6
Applications/foc/core/e_ctrl.h

@@ -191,10 +191,10 @@ static void eRamp_set_X2_target(e_Ramp *ramp, float c) {
 	float step_ms = CONFIG_eCTRL_STEP_TS;	
 	if (delta > 0) {
 		step_val = (delta)/(ramp->acct/step_ms);
-		if (step_val > 0.1f) {
-			float first_delta = min(delta, 5.0f);
+		if (step_val > CONFIG_RAMP_SECOND_STEP) {
+			float first_delta = min(delta, CONFIG_RAMP_SECOND_TARGET);
 			ramp->first_target = c_now + first_delta;
-			ramp->first_step = 0.1f;
+			ramp->first_step = CONFIG_RAMP_SECOND_STEP;
 			delta -= first_delta;
 			step_val = (delta)/(ramp->acct/step_ms);
 		}else {
@@ -202,10 +202,10 @@ static void eRamp_set_X2_target(e_Ramp *ramp, float c) {
 		}
 	}else if (delta < 0){
 		step_val = (delta)/(ramp->dect/step_ms);
-		if (ABS(step_val) > 0.1f) {
-			float first_delta = MAX(delta, -5.0f);
+		if (ABS(step_val) > CONFIG_RAMP_SECOND_STEP) {
+			float first_delta = MAX(delta, -CONFIG_RAMP_SECOND_TARGET);
 			ramp->first_target = c_now + first_delta;
-			ramp->first_step = -0.1f;
+			ramp->first_step = -CONFIG_RAMP_SECOND_STEP;
 			delta -= first_delta;
 			step_val = (delta)/(ramp->dect/step_ms);
 		}else {

+ 4 - 0
Applications/foc/foc_config.h

@@ -44,6 +44,10 @@
 
 #define CONFIG_MTPA_CALI_RAMP_TIME (10 * 1000)
 
+#define CONFIG_RAMP_SECOND_STEP (0.1F)
+#define CONFIG_RAMP_SECOND_TARGET (5.0F)
+
+
 #define CURRENT_LOOP_RAMP_COUNT 300
 
 #endif /* _FOC_CONFIG_H__ */