motor_param.c 981 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 rpm_trq_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. int map_size = ARRAY_SIZE(mot_map);
  21. for (int i = 1; i < map_size; i++) {
  22. if (rpm <= mot_map[i].rpm) { //线性插值
  23. float trq1 = mot_map[i-1].torque;
  24. float min_rpm = mot_map[i-1].rpm;
  25. float trq2 = mot_map[i].torque;
  26. float max_rpm = mot_map[i].rpm;
  27. if (trq1 > trq2) {
  28. return (s16)f_map_inv((float)rpm, min_rpm, max_rpm, trq2, trq1);
  29. }else {
  30. return (s16)f_map((float)rpm, min_rpm, max_rpm, trq1, trq2);
  31. }
  32. }
  33. }
  34. return mot_map[map_size-1].torque;
  35. }