Buy FOCBOX Unity

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


#83

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.


#84

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


#85

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;
}

#86

Is that the one that makes the weird noises?


#87

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


#88

Let us know if it works :slight_smile:


#89

big yeet
10char


#90

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:

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

These files under:

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

Happy DYIng


#91

Did you try his original fix?

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


#92

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


#93

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.


#94

Wait so this link above

Is this the one that is working great?


#95

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.


#96

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


#97

I will give it a try. Sounds interesting.


#98

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.


#99

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?


#100

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.


#101

Nice
10char


#102

@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.