|
@@ -27,16 +27,16 @@ void torque_get_idq(float torque, float rpm, DQ_t *dq_out) {
|
|
|
if (rpm_idx >= MAX_SPD_POINTS) {
|
|
if (rpm_idx >= MAX_SPD_POINTS) {
|
|
|
rpm_idx = MAX_SPD_POINTS -1;
|
|
rpm_idx = MAX_SPD_POINTS -1;
|
|
|
}
|
|
}
|
|
|
- s16 d = _trq_tbl->d[trq_idx][rpm_idx];
|
|
|
|
|
- s16 q = _trq_tbl->q[trq_idx][rpm_idx];
|
|
|
|
|
|
|
+ s16 d = _trq_tbl->dq[trq_idx][rpm_idx].d;
|
|
|
|
|
+ s16 q = _trq_tbl->dq[trq_idx][rpm_idx].q;
|
|
|
if (trq_idx < MAX_TRQ_POINTS - 1) {
|
|
if (trq_idx < MAX_TRQ_POINTS - 1) {
|
|
|
trq_idx += 1;
|
|
trq_idx += 1;
|
|
|
}
|
|
}
|
|
|
if (rpm_idx < MAX_SPD_POINTS - 1) {
|
|
if (rpm_idx < MAX_SPD_POINTS - 1) {
|
|
|
rpm_idx += 1;
|
|
rpm_idx += 1;
|
|
|
}
|
|
}
|
|
|
- s16 d_delta = _trq_tbl->d[trq_idx][rpm_idx] - d;
|
|
|
|
|
- s16 q_delta = _trq_tbl->q[trq_idx][rpm_idx] - q;
|
|
|
|
|
|
|
+ s16 d_delta = _trq_tbl->dq[trq_idx][rpm_idx].d - d;
|
|
|
|
|
+ s16 q_delta = _trq_tbl->dq[trq_idx][rpm_idx].q - q;
|
|
|
float comp_ceof = 0.5f * ((torque - torque/TBL_TRQ_INTVAL*TBL_TRQ_INTVAL)/(float)TBL_TRQ_INTVAL + (rpm - rpm/TBL_SPD_INTVAL*TBL_SPD_INTVAL)/(float)TBL_SPD_INTVAL);
|
|
float comp_ceof = 0.5f * ((torque - torque/TBL_TRQ_INTVAL*TBL_TRQ_INTVAL)/(float)TBL_TRQ_INTVAL + (rpm - rpm/TBL_SPD_INTVAL*TBL_SPD_INTVAL)/(float)TBL_SPD_INTVAL);
|
|
|
|
|
|
|
|
dq_out->d = d + d_delta * comp_ceof;
|
|
dq_out->d = d + d_delta * comp_ceof;
|