View Single Post
Old 05-10-2009, 10:44 AM   #1177 (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,368
Thanked 1,119 Times in 734 Posts
I've had a number of false "hurray, the perfect throttle" sort of comments. It has never been like this. I think I found the sweet spot! haha! Anyway, I can glide across the pavement at like 1/20th of a mile an hour up a steep hill, or whatever. I feel very sure that the throttle will feel much smoother for Ben. There's a couple tricks that take care of the super low duty and high current conditions.

For computing the PWM duty, I'm now using a PWM range of 0 to 8192. It's sort of like doing fixed point math.

Also, AVERAGE current is computed cycle by cycle, by subtracting the current that was measured 'n' periods ago from currentSum, adding the new current to currentSum, and then dividing by 'n'. It's basically a linked list (a stupid, 1970's version of a linked list), where the front of the list get's deleted, and a new current gets added to the end. This makes it much smoother at low rpm. It maintains memory at all times of the last 'n' currents. Before, I was just measuring current 'n' times, taking the average, measuring current 'n' times, taking the average. There was no memory of the past, which made the average current samples more jumpy, which made driving based on current sort of jerky (but only a bit, and only at VERY low rpm).

It worked really really well only using current proportional to throttle, but if you were going up a hill, accelerating pretty hard, and then came to the top and down the other side rather suddenly, you would accelerate away a bit more than a normal gas car would, since it was trying to keep the same current with less load on the motor, so I added limiting pwm based on if pwm > throttle AND current > throttle. Now, it is good! oh ya!

What I really like is, you have perfect control to go any speed you want. And I mean ANY speed. I was cruising up hills really slow. You can give it just a hair of throttle, and hold perfectly still on a hill, give it a bit more and start moving again. There's no overshoot. You don't accidentally go too fast or too slow, at least with my motor.
__________________
kits and boards
  Reply With Quote