Under /bldc/build_all/ you will find all of the hardware versions for flashing. The rest of the code is there in case anyone feels the need to verify, only changed lines 1680-1685 of mcpwm_foc.c. Didn’t fork because my account already has a fork of bldc from Ack and don’t want to make another github just for this.
Edit: Shur enough, works great! No more stuttering, and smooth stopping without locking up in FOC! Thanks again Mr. Jeffery!
Edit 2: I love the feel of these brakes- I couldn’t even have imagined brakes this refined prior to now. Originally, with wheels locking up, that sucked- always wished for better FOC brakes. The first iteration solved the main issue- no more locking, but it left an aesthetic hiccup- stutter. Now, the aesthetics are just straight plush. If I can try to describe it, coming to a stop feels like a strong braking force (obviously?), with the force curved just right to where it feels like you are landing into a thick down pillow, and the landing is a full stop, no jarring, just comfort. I can’t think of a better way to describe it.
I just gave it a try and my motors have a short rattle in the transition from controlled brake force to shorting the fets. I guess that depends on the motor your using. But i don’t know if that rattle is really healthy.
Just try it with different brake threngths. When you brake hard by the remote it is fine and when you brake gently it sometimes rattles. But I think I solved it already but need more time for testing.
Looks like a sensible fix, thanks! I will give it a try and see how it performs on different setups. The only thing I don’t like about the code is the use of fmax and casting to double in performance-critical code. The FPU in the cortex m4 is 32 bits only, so double precision operations are handled in software, making them up to 50 times (!) slower than single precision operations. In general, when using functions from math.h, you should use the versions ending with an f (e.g. sinf, fabsf, cosf, powf). In this case that would be fmaxf instead of fmax, and omitting the double. This is the reason I switched on the double promotion warning.