Making acceleration limit speed dependent

I was experimenting with my low-mass, high acceleration set up (see https://youtu.be/Vbs8buYSK_s)

and I was trying to figure out the maximum theoretical acceleration and I noticed that the acceleration limit should decrease with speed, since the maximum motor torque falls off with speed.

In particular with my set up, at lower speeds, even as much as 10G (100 000) accelerations are not a problem, but at higher speeds they cause missed steps. It is also lower speeds (e.g. when the printhead is making a lot of small back and forth moves) where I want higher accelerations.

How would one go about implementing an acceleration limit that’s dependent on the stepper’s speed? Probably also dependent on direction, the braking power is probably more than accelerating power.

I understand that it is probably a substantial project, just looking for the best place to start.

That would be a very good feature to have.

Keep in mind, klipper does not enforce an acceleration limit with max_accel in the config or with SET_VELOCITY_LIMIT. See the entry for 20210430 in the Klipper changelog. If you use either to set a max acceleration of 5000, but the slicer emits a “M204 P10000”, it will get an acceleration of 10000 for the subsequent moves.

Hmm yeah I got to keep that in mind, dunno how that should interact with velocity dependent acceleration limits.

I was thinking the velocity dependent limits should represent actual limits of the machine with regards to skipping steps, while other limits set via gcode are a quality / time tradeoff setting. So if you set very high acceleration in gcode it should still obey the “true”, step skipping avoidance limit, with perhaps ability to override that via some other command.