Brake/regen hardware and settings

Introduction and miscellaneous that we haven't created categories for, yet
Post Reply
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Brake/regen hardware and settings

Post by mjc506 »

'ning All,

I've been playing with regen settings on my bench, and have either stumbled across a potential concern, or more likely uncovered a(nother) fundamental misunderstanding of the openinverter code :) The below is mainly from my reading of the code - I don't have a good enough setup to test regen very accurately at all.

From throttle.cpp

Code: Select all

s32fp Throttle::CalcThrottle(s32fp potnom, s32fp pot2nom, bool brkpedal)
{
   s32fp scaledBrkMax = brkpedal ? brknompedal : brkmax;

   //Never reach 0, because that can spin up the motor
   scaledBrkMax = -1 + FP_MUL(scaledBrkMax, pot2nom) / 100;

   if (brkpedal)
   {
      potnom = scaledBrkMax;
   }
   else if (potnom < brknom)
   {
      potnom -= brknom;
      potnom = -FP_DIV(FP_MUL(potnom, scaledBrkMax), brknom);
   }
   else
   {
      potnom -= brknom;
      potnom = FP_DIV(100 * potnom, FP_FROMINT(100) - brknom);
   }

   return potnom;
}
So the code sets scaledBrkMax to either brknompedal or brkmax depending whether or not the brake switch is 'on', and then scales it based on pot2

On a setup with a brake switch only, everything seems to act as expected - pressing the brake will result in the throttle being ignored, and brknompedal regen being applied. Fine.

On a setup with a brake switch and pot2, pressing the brake will ignore the throttle and apply brknompedal*pot2 regen. Also fine.

On a setup with no switch, but pot2 tied to the brake pedal, I'm finding that you only get regen if pot1 (throttle) is below brknom. If pot1 is above brknom, you get no braking, even if pot2 is maxed out.

Maybe not an immediate problem, but a failed (or no) brake switch plus a stuck throttle could get exciting! Or, in my case, no brake switch and brknom=0 (so the vehicle just rolls with no inputs) means no braking ever...

Here's the stock firmware pot1/pot2 map: (assuming no brake switch) pot1/throttle across the top, pot2/brake down the left. I've used the default parameters.
Image

Here's a possible alternative - with no brake input, it outputs brkmax at pot1=0, 0 at pot1=brknom and 100 at pot1=100. With pot1=0, output goes from brkmax at pot2=0 to brknompedal at pot2=100. You can also see that braking overrides throttle - if pot2=100, output is always brknompedal no matter what pot1 is doing. (perhaps brkmax and brknompedal should be swapped)
Image
This gives a set amount of 'engine braking' with no input, which increases as pot2 increases. And no effective change with pot2=0.

Any thoughts?
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Brake/regen hardware and settings

Post by arber333 »

That is why you have mechanical brakes still.
I consider throttle priority over regen, but mechanical brakes over throttle allways. That is why you have to move your foot from throttle pedal to the brake pedal.
Granted some 30% of throttle travel could be used for control of regen. With brake switch you could apply greater regen force BEFORE mechanical brakes become effective. Maybe 2mm of travel before brakes grab? But brakes need to have the final word :).
Also you need to be able to remove regen in case of icing in winter.
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: Brake/regen hardware and settings

Post by mjc506 »

Oh yeah, definitely keep mechanical brakes!
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1025 times
Contact:

Re: Brake/regen hardware and settings

Post by johu »

Conclusion: always have a brake pedal switch or modify the software so that a certain threshold of pot2 forms a "virtual" brake pedal switch.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: Brake/regen hardware and settings

Post by mjc506 »

That'd work!
User avatar
muehlpower
Posts: 575
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 103 times

Re: Brake/regen hardware and settings

Post by muehlpower »

the first diagram tells me that I won't connect a brake light switch, how else do you want to make a burn out? brknom to almost 0, pot2 as a poti to the travel of the brake pedal, not the pressure, mainly before the hydraulic brake works.

This should result in little idle travel on the accelerator and hardly any regeneration when the accelerator is released. The vehicle only decelerates when the brake pedal is depressed. Initially electrically, and if that is not enough, also hydraulically.
Post Reply