Skip to content

Commit

Permalink
Removed more experimental code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Aug 24, 2019
1 parent b18eeac commit 554ac03
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 34 deletions.
7 changes: 0 additions & 7 deletions include/generic/fu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -29,7 +23,6 @@ class MotorVoltage
static u32fp endFrq;
static u32fp minFrq;
static u32fp maxFrq;
static enum minFrqMode minFrqMode;
};

#endif // FU_H_INCLUDED
2 changes: 1 addition & 1 deletion include/project/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 1 addition & 17 deletions src/generic/fu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */)
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
7 changes: 1 addition & 6 deletions src/project/pwmgeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/project/stm32_sine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 554ac03

Please sign in to comment.