From 39f1ce0a0685b45ab482280bc13e8c2beade0f18 Mon Sep 17 00:00:00 2001 From: Charlie Smurthwaite Date: Tue, 10 Jan 2023 16:56:18 +0000 Subject: [PATCH] make sine output filter "filterConst" a configurable value "sinefilter" --- include/param_prj.h | 3 ++- src/pwmgeneration-sine.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/param_prj.h b/include/param_prj.h index e3a9899..ea2df3d 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -24,7 +24,7 @@ 2. Temporary parameters (id = 0) 3. Display values */ -//Next param id (increase when adding new parameter!): 146 +//Next param id (increase when adding new parameter!): 148 //Next value Id: 2049 /* category name unit min max default id */ @@ -47,6 +47,7 @@ PARAM_ENTRY(CAT_MOTOR, udcnom, "V", 0, 1000, 0, 78 ) \ PARAM_ENTRY(CAT_MOTOR, fslipmin, "Hz", 0.3, 10, 1, 37 ) \ PARAM_ENTRY(CAT_MOTOR, fslipmax, "Hz", 0.3, 10, 3, 33 ) \ + PARAM_ENTRY(CAT_MOTOR, sinefilter, "dig", 0, 10, 4, 147 ) \ PARAM_ENTRY(CAT_MOTOR, fslipconstmax,"Hz", 0, 10, 5, 100 ) #define MOTOR_PARAMETERS_FOC \ diff --git a/src/pwmgeneration-sine.cpp b/src/pwmgeneration-sine.cpp index ac55833..169b08c 100644 --- a/src/pwmgeneration-sine.cpp +++ b/src/pwmgeneration-sine.cpp @@ -83,8 +83,8 @@ void PwmGeneration::Run() void PwmGeneration::SetTorquePercent(float torque) { - const int filterConst = 4; - const float roundingError = FP_TOFLOAT((float)((1 << filterConst) - 1)); + int filterConst = Param::GetInt(Param::sinefilter); + float roundingError = FP_TOFLOAT((float)((1 << filterConst) - 1)); float fslipmin = Param::GetFloat(Param::fslipmin); float ampmin = Param::GetFloat(Param::ampmin); float slipstart = Param::GetFloat(Param::slipstart);