VESC BASED CONTROLLERS - Brakes locking at low speed for larger wheels in FOC - possible Unity Fix

Here’s vedder’s latest firmware recompiled with Jeff’s FOC brake modification.

https://drive.google.com/drive/folders/1hzGp4itbqEqvEZpJ_Gx3BuWK38q1RL0K?usp=sharing

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.

3 Likes

Is there a video of anyone with this working? What are the results?

1 Like

I fixed most of the chatter with the following change:

if (m_control_mode == CONTROL_MODE_CURRENT_BRAKE
    //              && (m_conf->foc_sensor_mode != FOC_SENSOR_MODE_ENCODER) // Don't use this with encoders
    && fabsf(duty_filtered)*GET_INPUT_VOLTAGE() < 0.5
    && (fmax( fabsf(m_iq_set) , 0.5/(m_conf->foc_motor_r*2/3) ) >  (double) fabsf(m_motor_state.iq_filter))) {
  control_duty = true;
  duty_set = 0.0;
}
4 Likes

Is that the one that makes the weird noises?

Yeet, thanks Jeff can’t wait to try this tonight :sunglasses::sunglasses:

3 Likes

Let us know if it works :slight_smile:

2 Likes

big yeet 10char

1 Like

Tested! Works like a charm!

I patched the standard Vedder firmware. I’m using focboxes, MBS 100MM, and 200kv BKB motors.

It never stopped that smooth. I’m happy! Thank you @Deodand!

Here my changes:

https://github.com/vedderb/bldc/compare/master...DAddYE:fix_stop

If you want you can download the stock firmware with @Deaodand patch by downloading from:

https://github.com/DAddYE/bldc/tree/fix_stop

These files under:

build_all/410_o_411_o_412/
build_all/46_o_47/
build_all/48/
build_all/60/

Happy DYIng

7 Likes

Did you try his original fix?

If so, how does the updated code compare to the first iteration?

I missed an absolute value somewhere that was causing majority of chatter.

3 Likes

Nope, I didn’t because here was raining; Ie tried just this one. Brakes are smooth as butter when you come to a dead stop, and there is no chatter.

Wait so this link above

Is this the one that is working great?

1 Like

Patched Ackmaniac 3.102 firmware:

Firmware rebuilt under build_all in that repo.

Loading up for testing now myself.

Edit: Shur enough, works great! No more stuttering, and smooth stopping without locking up in FOC! Thanks again Mr. Jeffery! :stuck_out_tongue:

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.

11 Likes

That’s great! Good news! Maybe @Ackmaniac should release a 3.103 update with the fix applied :innocent::crossed_fingers:

2 Likes

I will give it a try. Sounds interesting.

5 Likes

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.

You tried Jeff’s latest code fix? There was stuttering / rattle for me previously with the first iteration, but it’s gone for me now.

If you are using the latest code, interesting… Do you have a video or audio so we can see what you are experiencing?

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.

4 Likes

Nice 10char

@Ackmaniac and @Deodand I’ve made a PR for Vedder:

and he said:

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.

2 Likes