diff --git a/include/project/param_prj.h b/include/project/param_prj.h index 41e37ad..5dc84a0 100644 --- a/include/project/param_prj.h +++ b/include/project/param_prj.h @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#define VER 4.54.R +#define VER 4.55.R /* Entries must be ordered as follows: 1. Saveable parameters (id != 0) @@ -83,7 +83,7 @@ PARAM_ENTRY(CAT_THROTTLE,ampmin, "%", 0, 100, 10, 4 ) \ PARAM_ENTRY(CAT_THROTTLE,slipstart, "%", 10, 100, 50, 90 ) \ PARAM_ENTRY(CAT_REGEN, brknompedal, "%", -100, 0, -50, 38 ) \ - PARAM_ENTRY(CAT_REGEN, brkpedalramp,"%/10ms", 1, 100, 100, 68 ) \ + PARAM_ENTRY(CAT_REGEN, regenramp, "%/10ms", 1, 100, 100, 68 ) \ PARAM_ENTRY(CAT_REGEN, brknom, "%", 0, 100, 30, 19 ) \ PARAM_ENTRY(CAT_REGEN, brkmax, "%", -100, 0, -30, 49 ) \ PARAM_ENTRY(CAT_REGEN, brkrampstr, "Hz", 0, 400, 10, 39 ) \ diff --git a/include/project/throttle.h b/include/project/throttle.h index 0086b41..31e0be7 100644 --- a/include/project/throttle.h +++ b/include/project/throttle.h @@ -48,7 +48,7 @@ class Throttle static s32fp speedkp; static int speedflt; static s32fp idleThrotLim; - static s32fp brkPedalRamp; + static s32fp regenRamp; static s32fp throttleRamp; static int bmslimhigh; static int bmslimlow; diff --git a/src/project/pwmgeneration-sine.cpp b/src/project/pwmgeneration-sine.cpp index 7874067..249bf93 100644 --- a/src/project/pwmgeneration-sine.cpp +++ b/src/project/pwmgeneration-sine.cpp @@ -159,8 +159,8 @@ void PwmGeneration::SetTorquePercent(s32fp torque) ampnomLocal = MIN(ampnomLocal, FP_FROMINT(100)); //anticipate sudden changes by filtering - ampnom = IIRFILTER(ampnom, ampnomLocal, 3); - fslip = IIRFILTER(fslip, fslipspnt, 3); + ampnom = IIRFILTER(ampnom, ampnomLocal, 4); + fslip = IIRFILTER(fslip, fslipspnt, 4); Param::Set(Param::ampnom, ampnom); Param::Set(Param::fslipspnt, fslip); diff --git a/src/project/stm32_sine.cpp b/src/project/stm32_sine.cpp index 2faa127..d831f9a 100644 --- a/src/project/stm32_sine.cpp +++ b/src/project/stm32_sine.cpp @@ -726,7 +726,7 @@ extern void parm_Change(Param::PARAM_NUM paramNum) Throttle::potmax[1] = Param::GetInt(Param::pot2max); Throttle::brknom = Param::Get(Param::brknom); Throttle::brknompedal = Param::Get(Param::brknompedal); - Throttle::brkPedalRamp = Param::Get(Param::brkpedalramp); + Throttle::regenRamp = Param::Get(Param::regenramp); Throttle::brkmax = Param::Get(Param::brkmax); Throttle::throtmax = Param::Get(Param::throtmax); Throttle::idleSpeed = Param::GetInt(Param::idlespeed); diff --git a/src/project/throttle.cpp b/src/project/throttle.cpp index d1b7aa9..bb0612c 100644 --- a/src/project/throttle.cpp +++ b/src/project/throttle.cpp @@ -35,8 +35,7 @@ int Throttle::speedFiltered; s32fp Throttle::idleThrotLim; s32fp Throttle::potnomFiltered; s32fp Throttle::throtmax; -s32fp Throttle::brkPedalRamp; -s32fp Throttle::brkRamped; +s32fp Throttle::regenRamp; s32fp Throttle::throttleRamp; s32fp Throttle::throttleRamped; int Throttle::bmslimhigh; @@ -121,15 +120,20 @@ s32fp Throttle::CalcThrottle(int potval, int pot2val, bool brkpedal) } } - if (potnom > throttleRamped) + if (potnom >= throttleRamped) { throttleRamped = RAMPUP(throttleRamped, potnom, throttleRamp); - potnom = throttleRamped; // FP_MUL(throttleRamped, throtmax) / 100; + potnom = throttleRamped; } - else + else if (potnom < throttleRamped && potnom > 0) + { + throttleRamped = potnom; //No ramping from high throttle to low throttle + } + else //potnom < throttleRamped && potnom <= 0 { - throttleRamped = RAMPDOWN(throttleRamped, potnom, throttleRamp); - potnom = throttleRamped; // FP_MUL(throttleRamped, throtmax) / 100; + throttleRamped = MIN(0, throttleRamped); //start ramping at 0 + throttleRamped = RAMPDOWN(throttleRamped, potnom, regenRamp); + potnom = throttleRamped; } potnom = MIN(potnom, throtmax);