Sorry Matt, it wouldn't let me send the whole thing by PM.
Basically, here's the important part:
if (pwmDuty > throttlePos) {
pwmDuty = throttlePos;
}
else if (current > throttlePos) { // The poor man's PI loop! hahaha!
if (pwmDuty)
pwmDuty--;
}
else if (pwmDuty < throttlePos) {
pwmDuty++;
}
OCR1A = pwmDuty;
|