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

I do not agree that this will solve the issue. Assymetric values will cause your brakes at high speed to be weaker than your brakes at low speed but the transition will be a linear ramp, not a sudden jerk just before coming to a stop that throws you from your board as is being described here.

5 Likes

Use bindings and you don’t get thrown🤣

belt slips when it locks

1 Like

good for u

1 Like

I haven’t followed all the linked threads before this one, but for me it sounds like what you describe as “lockup” is the phase where the VESC switches from regen braking to shorting the motor phases. At least that is what I notice on my bike using a 11.9 kV motor. I searched for a log from the past to show that behavior, because right now can’t test it. I found that: There you can see that the braking after 16:53:34 switches at around 6 km/h. (don’t get distracted from the high current pull before, were I was testing steep hill climb capabilities :slight_smile: ) You can clearly feel that the braking changes and I wouldn’t be surprised that this is what you describe as “locking issue” because it is abrupt and changes the braking force drastically.

2 Likes

this is BLDC or FOC?

FOC 10 char

Ok great this is super helpful! Looking at the mcpwm_foc.c code at line 1676 looks like it might be one possible source of the issue:

	// When the filtered duty cycle in sensorless mode becomes low in brake mode, the
	// observer has lost tracking. Use duty cycle control with the lowest duty cycle
	// to get as smooth braking as possible.
	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) < 0.03) {
		control_duty = true;
		duty_set = 0.0;
	}

interestingly this bit of code is enabled with or without hall sensors enabled. The only bit that doesn’t make sense is this should be triggered when the duty cycle is less than 3% but in hexakopter’s plot we see the duty cycle plummet is starting at 19% duty cycle which is strange.

Are you running a sensored motor?

5 Likes

Great that it is helpful. Maybe someone else with a Metr Pro module can share a record were he is braking and noticed that locking problem. The problem with my record is that I can’t remember if and how much I was using the mechanical brake of my bike, which would distort the data. In general I am just using the mechanical brake at slow speeds because I don’t like that switching phase, so its hard to find another log where I am using the VESC to brake at very slow speeds.

Yes, I am using the hall sensors from my motor. So sensored FOC. The brake settings are -100A motor current and -12A battery current. I also would like to use motor current = battery current to get a linear feeling, but thats just not possible with my battery without destroying it. So for me @trampa’s suggestion to just put in -30A battery current on a dual ESC setup sounds quite dangerous or at least not healthy for the battery, because just very few batteries can handle that.

1 Like

Re- examining the data and re-reading your post now I actually think this is a very good candidate for the bit that causes the phenomenon described. I’m not certain why if you have hall sensors it would be preferable to keep this enabled. Maybe I should hop over to Vedder’s forum and see if he can explain the reasoning.

1 Like

Just tried out some FW with this subsection commented out, definitely not an improvement :smile: though I trust vedder enough to know it wasn’t there for nothing. Even with hall sensors the motors vibrate like crazy when approaching low rpms.

I had an idea for a solution. People that are experiencing issues with this problem in FOC, go into vesc tool and try turning down the following two variables by like, a factor of 10 (just to effect dramatic change)

Motor Settings -> FOC -> Advanced -> Duty Downramp Kp Motor Settings -> FOC -> Advanced -> Duty Downramp Ki

I think the defaults are 10 and 200 so try instead 1 and 20. Then go out and use your breaks and report back please!

EDIT:

			if (fabsf(duty_set) < (duty_abs - 0.05) ||
				(SIGN(m_motor_state.vq) * m_motor_state.iq) < m_conf->lo_current_min) {

Because of this if statement on line 1696 (our duty cycle is at most 3% off and this sets a threshold of 5%) the duty downramp controller is never used for that final 3% margin that causes unsmooth motion. I’m getting closer to a solution here but need to sleep. Don’t bother changing those gains it won’t effect anything.

8 Likes

Bookmarked, will try it and report back

1 Like

First of all: On a skateboard no one pulls a 100% brake at full speed. It would throw you off. You wouldn’t pull your front brake on your bike 100% at speed, same thing. You have a build in Amp limiter in you hand. Second: once the speed gets lower you will not be able to push the full current injection. Battery currents drop fast with decreasing speed. If your motor is maxed at -30A regen, your battery will see a max of 15A at half the speed. In reality values are even lower. Third: When do you need strong brakes you are happy to have them and a linear behaviour is always more controllable and predictable. Fourth: If your battery will ever see a 20A injection, it will be for a very very short time only. A MTB 12S 4-7P battery pack can handle that with ease. Big Lipos will swallow such a short current injection even better.

1 Like

Current raptor 2’s have a battery min of -10 out of the box. You can change this to -12 but anything lower won’t work.

So with my current settings it’s battery -12A and Motor -55A. And the lockup is real. At high speeds I can fully brake while doing the Karate kid final kick. And below a certain speed the wheels suddenly start skidding.

Here’s a video of me going from full speed to full brake.

Setting up braking linear on the Raptor 2 can’t be done. I’m really tempted to void warranty by flashing non-Raptor 2 firmware. -20A/-24A motor min would change how I ride this board.

Will the Unity change this for Raptor 2.1?

I think we are okay to flash?

https://enertionboards.zendesk.com/hc/en-us/articles/360000406455-How-to-configure-R2-with-BLACK-motors-OR-stuttering-problems

@barajabali

Technically, Flashing with anything other then 2.18 or 2.8 can void your warranty.

But we haven’t had to enforce that recently

3 Likes

I think this asymmetric braking issue is something different from the problems described in this thread where at the final little bit before stopping wheels lock. It is good to bring up to differentiate between the two behaviours though.

I am determined to get the topic issue of this thread solved. I think I have identified the FW bits that are the culprit which is awesome! Now it’s just a matter of figuring out how best to implement a fix. I tried about 10 different things last night, its a tricky problem let me see if I can explain the issue here:

The braking mode in FOC works by always applying a current relative to the throttle pull in the opposite direction of the current velocity. As the velocity gets very small it becomes exceedingly difficult to determine what the direction of travel is. Even if you have hall sensors, as one hall sensor ticks up it indicates you are going 1 direction if you apply brake current and it then sends you in the opposite direction, the hall sensor will kick back and you end up with vibrational behaviour as the motor bounces back and forth between the two halls. Additionally each time there is a zero crossing the vesc applies full braking current in the opposite direction, the results are noisey and not ideal if you try to use this method close to zero speed.

Simply releasing the brake at extremely low speed probably isn’t acceptable either as it would be quite annoying to always roll smooth until small speed picked up then jerk to a stop when full brake held in.

My understanding of what happens instead is at a certain low speed the software simply shorts all the motor leads together, and this causes active field collapse which induces a viscous damping effect within the motor. Please someone correct me if this understanding is incorrect! Take a motor on your bench, electrically connect all three of its leads and feel the result. The problem is, the braking force of this phenomenon may not match well with the braking force of normal braking, and the hard switch (an if statement that duty cycle < 0.03 AKA 3% of max speed) causes behaviour that feels non-smooth and is one of the last parts of the vesc FW that doesn’t behave intuitively.

I think this braking behavior is also responsible for that Gummy/hysteresis feel in your brakes at lower speed and high braking force down steep hills if anyone has felt that phenomenon before. I’m talking down a steep hill when you are braking hard and you let on and off the brakes and feel kind of a soft latching/unlatching feeling in the brakes.

11 Likes

Well you have definitely hit the nail on the head about what the problem is, this exactly describes everything that is annoying haha.

Now just to figure out if there is a way to fix it

Incredible, great analysis. And your description of the phenomena is 100% on point.

Again, amazed at the time you’re putting into this, I am deeply humbled.

2 Likes

I have more than a few ideas to try out, If I can get my hands on a test board to use in the hotel in Shenzen next week I’ll try to crack this over some beers in the hotel with @Blasto.

3 Likes