Quadratic throttle pedal map

Post Reply
User avatar
johu
Site Admin
Posts: 7182
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 552 times
Been thanked: 1913 times
Contact:

Quadratic throttle pedal map

Post by johu »

I added a contribution to some random project :)
https://github.com/jsphuebner/stm32-sin ... 977ee9066e

I was always bugged by the harsh clonk even when carefully stepping onto the pedal. I tried adding a second, slower ramp from 0-20% but that doesn't help. Then I lowered throtcur to 1 and the clonk was gone. So pedal control just isn't fine grained enough at standstill.

Therefor I added what many have been asking for: added a quadratic pedal map. So first it comes in slowly and then most torque is towards the end of the pedal travel.

I made it x²+x with a factor called "potlinearity". It maxes out and defaults to 99.9% to achieve the former linear throttle map (100% would result in div by 0). By lowering the value you can make it increasingly more quadratic and at 0% it is purely quadratic.

I ended up setting it to 20%.
The regen part is still purely linear.
With potnom normalized 0-1 the formula is

Code: Select all

x = potnom²/(1-potlinearity) + potnom * potlinearity
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 416
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 206 times
Been thanked: 256 times

Re: Quadratic throttle pedal map

Post by davefiddes »

I wondered what this would look like as the linearity changed so I got a computer to draw me a picture:
throttle-linearity.png
User avatar
muehlpower
Posts: 807
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 18 times
Been thanked: 186 times

Re: Quadratic throttle pedal map

Post by muehlpower »

I don't understand that.
johu wrote: Sun Dec 07, 2025 1:14 pm CODE: SELECT ALL

x = potnom²/(1-potlinearity) + potnom * potlinearity

Shouldn't that be
x = potnom²*(1-potlinearity) + potnom * potlinearity

Code: Select all

 
   potnom /= 100;
   float quad = potnom * potnom;
   quad *= (1 - linearity);
   float quadlinear = quad + potnom * linearity;
then there is no division by “0” at 100%
User avatar
johu
Site Admin
Posts: 7182
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 552 times
Been thanked: 1913 times
Contact:

Re: Quadratic throttle pedal map

Post by johu »

ah, sorry potlinearity is divided by 100 before being passed to the throttle module
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
muehlpower
Posts: 807
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 18 times
Been thanked: 186 times

Re: Quadratic throttle pedal map

Post by muehlpower »

I noticed the division by 100, but the question is why the code says

Code: Select all

   quad /= 1 / (1 - linearity);
instead of

Code: Select all

   quad *= (1 - linearity);
User avatar
johu
Site Admin
Posts: 7182
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 552 times
Been thanked: 1913 times
Contact:

Re: Quadratic throttle pedal map

Post by johu »

doh! of course

Won't release again but still fixed it. I mean either version works
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3795
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 166 times
Been thanked: 411 times
Contact:

Re: Quadratic throttle pedal map

Post by arber333 »

May i offer Lebowski polynomal throttle function i was fascinated by it from the start...

There are three coefficients you can set in code that determine the curve. a, b, and c are floats because they can be less then 1.
x is the throttle value and y is the result.
y = a*x + b*x^2 + c*x^3

a, b and c are preset coefficients. Using them you can shape your throttle curve to your liking.
See here the excerpt from the manual...
Upto 2 analog throttles can be connected to the controller IC. Options a and b are for calibration. The IC
will measure the throttle voltage for throttle closed and throttle open. The throttle closed voltage must be
lower than the throttle open voltage.
Either one of the throttle channels can be used for variable strength regen. This can be achieved by
using negative polynomal coefficients (see the next slide)
When analog throttles are used also the 'reverse' switch can be used to select reverse.
Based on the calibration information the throttle voltage will be transformed into variable x (x1 for throttle 1,
x2 for throttle 2) in the range of 0 to 1. Out of range voltages are rounded to 0 or 1.
Variables x1,2 are transformed into variables y1,2 by means of a polynomal function (the purpose of which
is to be able to make different types of throttle response curves):

y1 = a1 x1 + b1 x12 + c1 x13
y2 = a2 x2 + b2 x22 + c2 x23

Options c and d are used to input the coefficients a1,2 , b1,2 and c1,2. Valid values are between -7.999 and
+7.999.
Based on the throttle information the motor's phase current is given by:
phase current = maximum phase current * (y1 + y2)

A negative phase current means current will flow to the battery, this is how variable strength regen can
be obtained. When the conditions are such that the throttle requested phase current means that the
maximum battery current or maximum battery regen current will be violated the phase current is
automatically reduced.
image.png
Attachments
user_manual_v2pA1.pdf
(277.13 KiB) Downloaded 8 times
User avatar
johu
Site Admin
Posts: 7182
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 552 times
Been thanked: 1913 times
Contact:

Re: Quadratic throttle pedal map

Post by johu »

Not bad!
Go, new maintainers ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply