|
|
@@ -124,11 +124,11 @@ static void motor_rpm_lookup(s16 rpm, vol_rpm_torque_map *map, rpm_torque_map **
|
|
|
*out_map1 = table;
|
|
|
*out_maph = table + 1;
|
|
|
return;
|
|
|
- }else if (rpm >= table[CONFIG_MAX_VEL_COUNT-1].rpm) {
|
|
|
- *out_map1 = *out_maph = table + CONFIG_MAX_VEL_COUNT - 1;
|
|
|
+ }else if (rpm >= table[map->n - 1].rpm) {
|
|
|
+ *out_map1 = *out_maph = table + map->n - 1;
|
|
|
return;
|
|
|
}
|
|
|
- for (int i = 1; i < CONFIG_MAX_VEL_COUNT; i++) {
|
|
|
+ for (int i = 1; i < map->n; i++) {
|
|
|
if (rpm <= table[i].rpm) {
|
|
|
*out_map1 = table + i - 1;
|
|
|
*out_maph = table + i;
|
|
|
@@ -142,11 +142,11 @@ static void motor_current_lookup(s16 torque, rpm_torque_map *map, torque2dq_t**
|
|
|
if (torque <= table[0].torque) {
|
|
|
*currl = table;
|
|
|
*currh = table + 1;
|
|
|
- }else if (torque >= table[CONFIG_MAX_D_COUNT - 1].torque) {
|
|
|
- *currl = table + CONFIG_MAX_D_COUNT - 2;
|
|
|
- *currh = table + CONFIG_MAX_D_COUNT - 1;
|
|
|
+ }else if (torque >= table[map->n - 1].torque) {
|
|
|
+ *currl = table + map->n - 2;
|
|
|
+ *currh = table + map->n - 1;
|
|
|
}
|
|
|
- for (int i = 1; i < CONFIG_MAX_D_COUNT; i++) {
|
|
|
+ for (int i = 1; i < map->n; i++) {
|
|
|
if (torque <= table[i].torque) {
|
|
|
*currl = table + i - 1;
|
|
|
*currh = table + i;
|
|
|
@@ -219,15 +219,15 @@ s16 motor_torque_ext_char_curve(s16 rpm, s16 vdc) {
|
|
|
/* 获取低电压对应当前转速的最大扭矩 */
|
|
|
motor_rpm_lookup(vel, vmapl, &rmapl, &rmaph);
|
|
|
_DEBUG("vol %d -> rpm %d : %d\n", vmapl->vol, rmapl->rpm, rmaph->rpm);
|
|
|
- s16 max_t1 = rmapl->dqmap[CONFIG_MAX_D_COUNT-1].torque;
|
|
|
- s16 max_t2 = rmaph->dqmap[CONFIG_MAX_D_COUNT-1].torque;
|
|
|
+ s16 max_t1 = rmapl->dqmap[rmapl->n - 1].torque;
|
|
|
+ s16 max_t2 = rmaph->dqmap[rmaph->n-1].torque;
|
|
|
s16 low_vel_max_t = line_intp(vel, rmapl->rpm, rmaph->rpm, max_t1, max_t2);
|
|
|
|
|
|
/* 获取高电压对应当前转速的最大扭矩 */
|
|
|
motor_rpm_lookup(vel, vmaph, &rmapl, &rmaph);
|
|
|
_DEBUG("vol %d -> rpm %d : %d\n", vmaph->vol, rmapl->rpm, rmaph->rpm);
|
|
|
- max_t1 = rmapl->dqmap[CONFIG_MAX_D_COUNT-1].torque;
|
|
|
- max_t2 = rmaph->dqmap[CONFIG_MAX_D_COUNT-1].torque;
|
|
|
+ max_t1 = rmapl->dqmap[rmapl->n-1].torque;
|
|
|
+ max_t2 = rmaph->dqmap[rmaph->n-1].torque;
|
|
|
s16 high_vel_max_t = line_intp(vel, rmaph->rpm, rmaph->rpm, max_t1, max_t2);
|
|
|
|
|
|
/* 对两个电压的扭矩插值,获取最终的最大扭矩 */
|