motor_param.c 866 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "bsp/bsp.h"
  2. #include "foc/motor/motor_param.h"
  3. #include "math/fast_math.h"
  4. #if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_ZD_100
  5. static motor_map_t mot_map[] = {
  6. {4500, 200},
  7. {4740, 170},
  8. {5050, 125},
  9. {5400, 85},
  10. {5740, 85},//5
  11. {6050, 90},//10
  12. {6430, 107},//16
  13. };
  14. #endif
  15. /* 根据电机外特性map,获取当前转速下的最大扭矩,主要给计算当前扭矩需求使用 */
  16. s16 get_max_torque_for_rpm(s16 rpm) {
  17. if (rpm <= mot_map[0].rpm) {
  18. return mot_map[0].torque;
  19. }
  20. for (int i = 1; i < ARRAY_SIZE(mot_map); i++) {
  21. if (rpm <= mot_map[i].rpm) { //线性插值
  22. float trq1 = mot_map[i-1].torque;
  23. float min_rpm = mot_map[i-1].rpm;
  24. float trq2 = mot_map[i].torque;
  25. float max_rpm = mot_map[i].rpm;
  26. return (s16)f_map(rpm, min_rpm, max_rpm, min(trq1, trq2), MAX(trq1, trq2));
  27. }
  28. }
  29. return mot_map[ARRAY_SIZE(mot_map)-1].torque;
  30. }