One change I've done is to limit the size of pwmDutyFine instead of pwmDuty, to keep the pi loop under control. That's a good idea about ReadThrottle, ReadCurrent, changing to Convert... I had been trying to think of a better name. That's much better.
If I do a ConvertThrottle() every time in main, I'm computing the throttle much more often than I would need to (since it's only read every 16 pwm cycles). Is it better to do it more often outside the ISR than to have a longer ISR? I wasn't sure what the best thing to do was there.
By the way, I'm pretty sure the code is working. I'm fairly certain that the control board now has some bad capacitors. I believe that they were damaged awhile back, perhaps when the controller blew up, and now they are really bad. The oscilloscope made it pretty clear that they were no longer doing their jobs.
I'm not going to be able to test the software until I fix that naughty control board, or I get the new fancy ones back.
|