Просмотр исходного кода

can_report_foc_status 加入挡位上报

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 лет назад
Родитель
Сommit
3a52462034

+ 2 - 3
Applications/foc/core/thro_torque.c

@@ -26,13 +26,12 @@ static __INLINE float gear_rpm_torque(u8 trq, s16 max) {
 	return (float)trq/100.0f * max;
 }
 
-static float thro_torque_gear_map(void) {
+float thro_torque_gear_map(s16 rpm) {
 	mc_gear_t *_current_gear = mc_get_gear_config();
 	if (_current_gear == NULL) {
 		return 0;
 	}
 
-	s16 rpm = (s16)_torque.spd_filted;
 	if (rpm > _current_gear->n_max_speed) {
 		rpm = _current_gear->n_max_speed;
 	}
@@ -75,7 +74,7 @@ float thro_ration_to_voltage(float r) {
 }
 
 static float thro_torque_for_accelerate(void) {
-	float max_torque = thro_torque_gear_map();
+	float max_torque = thro_torque_gear_map((s16)_torque.spd_filted);
 	float acc_r = 1.0f;
 	if (_torque.thro_ration_last < 1.0f) {
 		acc_r = (_torque.thro_ration - _torque.thro_ration_last)/ (1.0f - _torque.thro_ration_last);

+ 2 - 0
Applications/foc/core/thro_torque.h

@@ -17,5 +17,7 @@ void thro_torque_init(void);
 float thro_ration_to_voltage(float r);
 void thro_torque_process(u8 run_mode, float f_throttle);
 float get_user_request_torque(void);
+float thro_torque_gear_map(s16 rpm);
+
 #endif /* _THRO_TORQUE_H__ */
 

+ 1 - 0
Applications/prot/can_foc_msg.c

@@ -87,6 +87,7 @@ void can_report_foc_status(u8 can) {
 	encode_s16(data + 7, get_motor_temp());
 	encode_s16(data + 9, get_mos_temp());
 	encode_u32(data + 11, shark_get_seconds());
+	encode_u8(data + 15, mc_get_gear());
 	can_send_message(get_indicator_can_id(can), data, sizeof(data), 0);
 }