Paul, you sly devil... you're getting good at this stuff!
Second fail case - Hall stuck at 0. If you are already moving and the hall is stuck at 0, then it will try to push up the current. Then you realize th ings are bad and you drop throttle. Throttle and current will both be 0, so the PWM will NOT CHANGE from where it is! So yes, you ARE going to be rocktting down the road strapped to an electric death machine. I recommend a simple "if throttle = 0, kill it", but that might be harsh on the electronics.
Use excel to choose your values for you. Decide your settling time and overshoot this way. There is, unfortunately, an unknown variable which makes this a little more tricky than it looks. The rate of change of current with respect to PWM duty is NOT constant. At higher rpm, the rate of change of current with respect to pwm duty is lower than it is at low RPM. A properly designed state space version of this controller would alleviate that and you'd get good response across the board.
Be sure to run that calculation on a timer interrupt! You do not want to do this in the main loop.
|