From 554ac031dd75260f3bf3993fe2416ddf5d355e27 Mon Sep 17 00:00:00 2001 From: jsphuebner Date: Sat, 24 Aug 2019 10:15:10 +0200 Subject: [PATCH] Removed more experimental code --- include/generic/fu.h | 7 ------- include/project/param_prj.h | 2 +- src/generic/fu.cpp | 18 +----------------- src/project/pwmgeneration.cpp | 7 +------ src/project/stm32_sine.cpp | 3 --- 5 files changed, 3 insertions(+), 34 deletions(-) diff --git a/include/generic/fu.h b/include/generic/fu.h index 3b2282f..8db4bc0 100644 --- a/include/generic/fu.h +++ b/include/generic/fu.h @@ -7,14 +7,8 @@ class MotorVoltage { public: - enum minFrqMode - { - SETZERO, RAMPDOWN, IGNORE - }; - static void SetBoost(uint32_t boost); static void SetWeakeningFrq(u32fp frq); - static void SetMinFrqMode(enum minFrqMode val); static void SetMaxAmp(uint32_t maxAmp); static void SetMinFrq(u32fp frq); static void SetMaxFrq(u32fp frq); @@ -29,7 +23,6 @@ class MotorVoltage static u32fp endFrq; static u32fp minFrq; static u32fp maxFrq; - static enum minFrqMode minFrqMode; }; #endif // FU_H_INCLUDED diff --git a/include/project/param_prj.h b/include/project/param_prj.h index a7d9f96..a2e4adb 100644 --- a/include/project/param_prj.h +++ b/include/project/param_prj.h @@ -66,7 +66,7 @@ #define POTMODE_DUALCHANNEL 1 #define POTMODE_CAN 2 -#define VER 4.52.R +#define VER 4.53.R #define VERSTR STRINGIFY(4=VER) enum _modes diff --git a/src/generic/fu.cpp b/src/generic/fu.cpp index 6c68fe5..491bb4e 100644 --- a/src/generic/fu.cpp +++ b/src/generic/fu.cpp @@ -8,7 +8,6 @@ uint32_t MotorVoltage::maxAmp; u32fp MotorVoltage::endFrq = 1; //avoid division by 0 when not set u32fp MotorVoltage::minFrq; u32fp MotorVoltage::maxFrq; -enum MotorVoltage::minFrqMode MotorVoltage::minFrqMode = SETZERO; /** Set 0 Hz boost to overcome winding resistance */ void MotorVoltage::SetBoost(uint32_t boost /**< amplitude in digit */) @@ -24,11 +23,6 @@ void MotorVoltage::SetWeakeningFrq(u32fp frq) CalcFac(); } -void MotorVoltage::SetMinFrqMode(enum minFrqMode val) -{ - minFrqMode = val; -} - /** Get amplitude for a given frequency */ uint32_t MotorVoltage::GetAmp(u32fp frq) { @@ -41,17 +35,7 @@ uint32_t MotorVoltage::GetAmpPerc(u32fp frq, u32fp perc) uint32_t amp = FP_MUL(perc, (FP_TOINT(FP_MUL(fac, frq)) + boost)) / 100; if (frq < minFrq) { - switch (minFrqMode) - { - case SETZERO: - amp = 0; - break; - case RAMPDOWN: - amp = FP_MUL(perc, FP_TOINT(FP_MUL(fac, frq))) / 100; - break; - case IGNORE: - break; - } + amp = 0; } if (amp > maxAmp) { diff --git a/src/project/pwmgeneration.cpp b/src/project/pwmgeneration.cpp index 4742327..43fcd7f 100644 --- a/src/project/pwmgeneration.cpp +++ b/src/project/pwmgeneration.cpp @@ -448,18 +448,13 @@ static s32fp ProcessCurrents() if (edge != NoEdge) { Param::SetFlt(Param::il1rms, rms); - - if (((angle + 40000) & 0xFFFF) > SHIFT_180DEG) - sign = edge == PosEdge ? -1 : 1; - else - sign = edge == NegEdge ? -1 : 1; if (opmode != MOD_BOOST || opmode != MOD_BUCK) { //rough approximation as we do not take power factor into account s32fp idc = (SineCore::GetAmp() * rms) / SineCore::MAXAMP; idc = FP_DIV(idc, FP_FROMFLT(1.2247)); //divide by sqrt(3)/sqrt(2) - idc *= sign; //fslip < 0 ? -1 : 1; + idc *= fslip < 0 ? -1 : 1; Param::SetFlt(Param::idc, idc); } } diff --git a/src/project/stm32_sine.cpp b/src/project/stm32_sine.cpp index 52b06a6..444233f 100644 --- a/src/project/stm32_sine.cpp +++ b/src/project/stm32_sine.cpp @@ -221,12 +221,10 @@ static void CalcAmpAndSlip() /* In sync mode throttle only commands amplitude. Above back-EMF is acceleration, below is regen */ if (Encoder::IsSyncMode()) { - MotorVoltage::SetMinFrqMode(MotorVoltage::IGNORE); ampnom = ampmin + FP_DIV(FP_MUL((FP_FROMINT(100) - ampmin), potnom), FP_FROMINT(100)); } else {/* In async mode first X% throttle commands amplitude, X-100% raises slip */ - MotorVoltage::SetMinFrqMode(MotorVoltage::SETZERO); ampnom = ampmin + (100 - FP_TOINT(ampmin)) * FP_DIV(potnom, slipstart); if (potnom >= slipstart) @@ -264,7 +262,6 @@ static void CalcAmpAndSlip() { ampnom = ampmin + FP_MUL(ampmin, potnom) / 100; //ampnom = ampmin + FP_DIV(FP_MUL((FP_FROMINT(100) - ampmin), -potnom), FP_FROMINT(100)); - MotorVoltage::SetMinFrqMode(MotorVoltage::RAMPDOWN); } else {