motor_param.c 858 B

1234567891011121314151617181920212223242526272829303132333435
  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. {1500, 200},
  7. {2500, 130},
  8. {3000, 110},
  9. {3500, 100},
  10. {4000, 90},
  11. {4500, 80},
  12. {5000, 70},
  13. {5500, 60},
  14. };
  15. #endif
  16. /* 根据电机外特性map,获取当前转速下的最大扭矩,主要给计算当前扭矩需求使用 */
  17. s16 get_max_torque_for_rpm(s16 rpm) {
  18. if (rpm <= mot_map[0].rpm) {
  19. return mot_map[0].torque;
  20. }
  21. for (int i = 1; i < ARRAY_SIZE(mot_map); i++) {
  22. if (rpm <= mot_map[i].rpm) { //线性插值
  23. float max_trq = mot_map[i-1].torque;
  24. float min_rpm = mot_map[i-1].rpm;
  25. float min_trq = mot_map[i].torque;
  26. float max_rpm = mot_map[i].rpm;
  27. return (s16)f_map(rpm, min_rpm, max_rpm, min_trq, max_trq);
  28. }
  29. }
  30. return mot_map[ARRAY_SIZE(mot_map)-1].torque;
  31. }