motor_param.c 996 B

123456789101112131415161718192021222324252627282930313233343536373839
  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, 150},
  8. {5050, 110},
  9. {5200, 85},
  10. {5300, 70},
  11. //{5740, 85},//5
  12. //{6050, 90},//10
  13. //{6430, 107},//16
  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. int map_size = ARRAY_SIZE(mot_map);
  22. for (int i = 1; i < map_size; i++) {
  23. if (rpm <= mot_map[i].rpm) { //线性插值
  24. float trq1 = mot_map[i-1].torque;
  25. float min_rpm = mot_map[i-1].rpm;
  26. float trq2 = mot_map[i].torque;
  27. float max_rpm = mot_map[i].rpm;
  28. if (trq1 > trq2) {
  29. return (s16)f_map_inv((float)rpm, min_rpm, max_rpm, trq2, trq1);
  30. }else {
  31. return (s16)f_map((float)rpm, min_rpm, max_rpm, trq1, trq2);
  32. }
  33. }
  34. }
  35. return mot_map[map_size-1].torque;
  36. }