diff --git a/include/param_prj.h b/include/param_prj.h index 7839f57..631446d 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -17,14 +17,14 @@ * along with this program. If not, see . */ -#define VER 5.10.R +#define VER 5.11.R /* Entries must be ordered as follows: 1. Saveable parameters (id != 0) 2. Temporary parameters (id = 0) 3. Display values */ -//Next param id (increase when adding new parameter!): 135 +//Next param id (increase when adding new parameter!): 138 //Next value Id: 2049 /* category name unit min max default id */ @@ -54,6 +54,7 @@ PARAM_ENTRY(CAT_MOTOR, curki, "", 0, 100000, 20000, 108 ) \ PARAM_ENTRY(CAT_MOTOR, curkifrqgain,"dig/Hz", 0, 1000, 50, 120 ) \ PARAM_ENTRY(CAT_MOTOR, fwkp, "", -10000, 0, -100, 118 ) \ + PARAM_ENTRY(CAT_MOTOR, ffwstart, "Hz", 0, 1000, 200, 136 ) \ PARAM_ENTRY(CAT_MOTOR, syncofs, "dig", 0, 65535, 0, 70 ) \ PARAM_ENTRY(CAT_MOTOR, syncadv, "dig/Hz", 0, 65535, 10, 133 ) diff --git a/libopeninv b/libopeninv index 9dbc313..952921d 160000 --- a/libopeninv +++ b/libopeninv @@ -1 +1 @@ -Subproject commit 9dbc313824b43e3ce262b18dd1f4abd82dad5f86 +Subproject commit 952921dfab9f9bceb73b04f46879c2888b8a3ebf diff --git a/src/pwmgeneration-foc.cpp b/src/pwmgeneration-foc.cpp index 0472286..f1e7e06 100644 --- a/src/pwmgeneration-foc.cpp +++ b/src/pwmgeneration-foc.cpp @@ -50,6 +50,7 @@ void PwmGeneration::Run() { static s32fp frqFiltered = 0, idcFiltered = 0; int dir = Param::GetInt(Param::dir); + int moddedfwkp; int kifrqgain = Param::GetInt(Param::curkifrqgain); s32fp id, iq; @@ -61,15 +62,29 @@ void PwmGeneration::Run() frqFiltered = IIRFILTER(frqFiltered, frq, 8); int moddedKi = curki + kifrqgain * FP_TOINT(frqFiltered); + if (frq < Param::Get(Param::ffwstart)) + { + moddedfwkp = 0; + } + else if (frq > Param::Get(Param::fmax)) + { + moddedfwkp = fwBaseGain; + } + else + { + moddedfwkp = fwBaseGain * (FP_TOINT(frq) - Param::GetInt(Param::ffwstart)); + moddedfwkp/= Param::GetInt(Param::fmax) - Param::GetInt(Param::ffwstart); + } + qController.SetIntegralGain(moddedKi); dController.SetIntegralGain(moddedKi); - fwController.SetProportionalGain(fwBaseGain * dir); + fwController.SetProportionalGain(moddedfwkp * dir); ProcessCurrents(id, iq); if (opmode == MOD_RUN && initwait == 0) { - s32fp fwIdRef = idref <= 0 ? fwController.RunProportionalOnly(iq) : 0; + s32fp fwIdRef = fwController.RunProportionalOnly(iq); dController.SetRef(idref + fwIdRef); Param::SetFixed(Param::ifw, fwIdRef); } diff --git a/src/throttle.cpp b/src/throttle.cpp index 8eabb9e..df5a632 100644 --- a/src/throttle.cpp +++ b/src/throttle.cpp @@ -97,7 +97,7 @@ float Throttle::CalcThrottle(float potnom, float pot2nom, bool brkpedal) else { potnom -= brknom; - potnom = 100.0 * potnom / (100.0 - brknom); + potnom = 100.0f * potnom / (100.0f - brknom); } return potnom; @@ -139,7 +139,7 @@ float Throttle::CalcCruiseSpeed(int speed) int speederr = cruiseSpeed - speedFiltered; float potnom = speedkp * speederr; - potnom = MIN(100.0, potnom); + potnom = MIN(100.0f, potnom); potnom = MAX(brkcruise, potnom); return potnom; @@ -150,16 +150,16 @@ bool Throttle::TemperatureDerate(float temp, float tempMax, float& finalSpnt) float limit = 0; if (temp <= tempMax) - limit = 100.0; - else if (temp < (tempMax + 2.0)) - limit = 50.0; + limit = 100.0f; + else if (temp < (tempMax + 2.0f)) + limit = 50.0f; if (finalSpnt >= 0) finalSpnt = MIN(finalSpnt, limit); else finalSpnt = MAX(finalSpnt, -limit); - return limit < 100.0; + return limit < 100.0f; } void Throttle::BmsLimitCommand(float& finalSpnt, bool dinbms) @@ -195,16 +195,16 @@ void Throttle::IdcLimitCommand(float& finalSpnt, float idc) { if (finalSpnt >= 0) { - s32fp idcerr = idcmax - idc; - s32fp res = idcerr * idckp; + float idcerr = idcmax - idc; + float res = idcerr * idckp; res = MAX(0, res); finalSpnt = MIN(res, finalSpnt); } else { - s32fp idcerr = idcmin - idc; - s32fp res = idcerr * idckp; + float idcerr = idcmin - idc; + float res = idcerr * idckp; res = MIN(0, res); finalSpnt = MAX(res, finalSpnt); @@ -222,7 +222,7 @@ void Throttle::FrequencyLimitCommand(float& finalSpnt, float frequency) float frqerr = fmax - frqFiltered; float res = frqerr * 4; - res = MAX(1, res); + res = MAX(0, res); finalSpnt = MIN(res, finalSpnt); } } diff --git a/src/vehiclecontrol.cpp b/src/vehiclecontrol.cpp index 390828e..34e8f1e 100644 --- a/src/vehiclecontrol.cpp +++ b/src/vehiclecontrol.cpp @@ -467,7 +467,7 @@ void VehicleControl::GetTemps(float& tmphs, float &tmpm) priusTempCoeff *= 2; } - tmphs = 166.66 - tmphsi / priusTempCoeff; + tmphs = 166.66f - tmphsi / priusTempCoeff; } else if (snshs == TempMeas::TEMP_BMWI3HS) {