Wednesday, February 14, 2018

motor tech - Intro to closed-loop speed control with SimonK.

Shifting gears a bit. Closed-loop control, specifically speed control, has been a wanted and discussed feature in flywheel drives for years now. What I didn't realize was that it has been right in front of my face all this time and I was, in fact, using it. Not optimally yet, mind you - but it was there.

SimonK has a simple "governor" feedback loop to duty cycle, configured with the parameter TIMING_MAX. This is to prevent motors from overspeeding and exceeding the frequency limit of the firmware, which follows from the calculation used to generate the next commutation timing on each cycle. In pre-2015 SimonK, this timing calculation was 24-bit only, and TIMING_MAX was set stock to 0x00e0, giving a commutation period of 56us which equates to 178,571 electrical RPM. With a 14-pole machine (7 pole pairs), this becomes 25,510 mechanical RPM. It turns out my old Hy-Con drives have been governing at this speed all along! The oscillation I mentioned earlier is a minor control instability which occurs under certain conditions because the governor loop is a fairly crude controller, more or less just meant as a safety rev limiter. However, keep the bus voltage*Kv product well away from the governed speed (i.e. not my old 3S hycon!) and it works damn well, giving rock-solid speed regulation. Not like the faint rumble affects flywheelers anyway, I had it all along with T19.

By contrast, 2015+ SimonK has a more agile timing calculation methodology and can safely be governed at up to 312,500eRPM (TIMING_MAX = 0x0080).


Followings from all this:

TIMING_MAX/4 = commutation period.

This is a six-step drive scheme, so 6 commutations = one full AC cycle, and the period of the AC is (6 * TIMING_MAX / 4) microseconds. Divide that period by 10^6, and invert that, and you get frequency in Hz. Divide that by the number of pole pairs in the motor, and multiply by 60 and you get mechanical RPM.

There's your governor setting crib sheet. Back out a TIMING_MAX, punch it in, set all your other parameters how you want them, build and flash.

There is at this time no way to adjust the speed setpoint post-build. You cannot, for instance, have a throttle command interpreted as a speed setpoint, or send the speed setpoint over some protocol from your blaster controller, or anything of the like - you need to recompile and reflash to change governor setting. This ought to be fine, since motor speeds normally pair with physical flywheel and cage parts - and if you are intentionally turning down velocity by slowing your flywheels down, the difficulty of changing the governor settings only makes it more legitimate as a means of safety compliance.

Going closed-loop of course has some very good ramifications for subcritical operation - no longer do startup times and torque curves need to suffer as they do when speed is reduced by commanding less duty a la FDL.

If you need to go faster than 178,571eRPM you need to use 2015+ SimonK and build with your specified TIMING_MAX value. If you want to govern at 178,571eRPM (25,510 mechanical RPM with a 14-pole motor), it is very convenient to simply use stock SimonK version 2014-09-30. For Hy-Con 9.5mm wheels, 25,510 is, or nearly is, critical speed, and a perfect governor setting (I tested while free-spinning my motors on 4S with 2015 SimonK to annoying-sounding 30K+ speeds and didn't get more velocity from that). SimonK 2014-09-30, and indeed every version of SimonK I have ever run, operate perfectly with the Turnigy V-Spec 2205 motors without any sync issues or the like and I have been running 2014-09-30 in combat as of late with zero problems.

Disclaimer


More testing is required with various TIMING_MAX settings and motors before I call this anything other than beta, so if you are using these findings for something different than where I have explored so far, recall the warning in SimonK: "If it breaks, you get to keep both pieces!"

No comments:

Post a Comment