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;
}
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.
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)
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?