Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
b9868dca5This file is pinned to the selected release. Download the original to open it in your design tool.
HAL_COMP(t2c);
// motor values
HAL_PIN(psi) = 0.01;
HAL_PIN(polecount) = 1.0;
HAL_PIN(ac) = 0.0;
HAL_PIN(pc) = 0.0;
HAL_PIN(nc) = 1.0;
HAL_PIN(ae) = 0.0;
HAL_PIN(pe) = 0.0;
HAL_PIN(ne) = 1.0;
HAL_PIN(pos) = 0.0;
HAL_PIN(t) = 0.0;
HAL_PIN(g) = 0.0;
// torque cmd in
HAL_PIN(torque) = 0.0;
// cur cmd out
HAL_PIN(cur) = 0.0;
RT(
float p = MAX(PIN(polecount), 1.0);
float psi_m = MAX(PIN(psi), 0.01);
float torque = PIN(torque);
float tc = PIN(ac) * sinf(PIN(pc) + PIN(pos) * PIN(nc) * p);
float te = torque * PIN(ae) * sinf(PIN(pe) + PIN(pos) * PIN(ne) * p);
PIN(t) = tc + te;
PIN(cur) = (torque + PIN(g) * (tc + te)) / 3.0 * 2.0 / p / psi_m;
);
ENDCOMP;