View Single Post
Old 07-21-2009, 06:03 PM   #5 (permalink)
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,368
Thanked 1,202 Times in 765 Posts
The one you have right now is a current ramping code I believe. Increment current . It's not a PI loop. It sounds like at low RPM, the current was swinging back and forth. A properly tuned PI loop should be much better, but it might take a few tries to find the right P and I for your motor. I'm certain it would be different from mine. Probably smaller P and I values, but I don't know how much smaller.

The third option looks a little like this:

if (pwmDuty > throttlePos) {
else if (current > throttlePos) {
else if (pwmDuty < throttlePos) {

So, you don't get the jerky starts from throttle only being proportional to pwmDuty, since current can't be bigger than throttle either.
kits and boards
  Reply With Quote