I think I found why it wasn't working... My guess is the voltage is low enough that the following fault is happening:
Code:
if (pi_Id.pwm > MAX_VD_VQ*1024L) {
pi_Id.pwm = MAX_VD_VQ*1024L;
faultBits |= PI_OVERFLOW_FAULT;
}
else if (pi_Id.pwm < -MAX_VD_VQ*1024L) {
pi_Id.pwm = -MAX_VD_VQ*1024L;
faultBits |= PI_OVERFLOW_FAULT;
}
if (pi_Iq.pwm > MAX_VD_VQ*1024L) {
pi_Iq.pwm = MAX_VD_VQ*1024L;
faultBits |= PI_OVERFLOW_FAULT;
}
else if (pi_Iq.pwm < -MAX_VD_VQ*1024L) {
pi_Iq.pwm = -MAX_VD_VQ*1024L;
faultBits |= PI_OVERFLOW_FAULT;
}
You don't have enough voltage, so it is ramping up the pwm beyond what it should go to to vainly attempt to achieve 20amps on a line. Evidently, that 39 or 40v point is right on the edge. I should either reduce it to 10 amps for tuning the loop, or increase voltage. I can email you a 10amp version (that is hard wired into the code) if you want to go that route, but I think higher voltage would be better.