View Single Post
Old 03-20-2009, 06:22 PM   #592 (permalink)
MPaulHolmes
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,362
Thanked 1,202 Times in 765 Posts
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;
__________________
kits and boards
  Reply With Quote