diff --git a/Firmware/MotorControl/low_level.cpp b/Firmware/MotorControl/low_level.cpp index 8aafca4e..0c423346 100644 --- a/Firmware/MotorControl/low_level.cpp +++ b/Firmware/MotorControl/low_level.cpp @@ -636,7 +636,7 @@ void update_brake_current() { // Special handling to avoid the case 0.0/0.0 == NaN. Ibus_sum += brake_duty ? (brake_duty * vbus_voltage / odrv.config_.brake_resistance) : 0.0f; - ibus_ = Ibus_sum; + ibus_ += odrv.ibus_report_filter_k_ * (Ibus_sum - ibus_); if (Ibus_sum > odrv.config_.dc_max_positive_current) { low_level_fault(Motor::ERROR_DC_BUS_OVER_CURRENT); diff --git a/Firmware/MotorControl/odrive_main.h b/Firmware/MotorControl/odrive_main.h index 62bd4f57..b112a19d 100644 --- a/Firmware/MotorControl/odrive_main.h +++ b/Firmware/MotorControl/odrive_main.h @@ -239,6 +239,7 @@ public: float& vbus_voltage_ = ::vbus_voltage; // TODO: make this the actual variable float& ibus_ = ::ibus_; // TODO: make this the actual variable + float ibus_report_filter_k_ = 1.0f; const uint64_t& serial_number_ = ::serial_number; diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index b738e0df..79f0c1e8 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -28,6 +28,12 @@ interfaces: This value is equal to the sum of the motor currents and the brake resistor currents. The motor currents are measured, the brake resistor current is calculated based on `config.brake_resistance`. + ibus_report_filter_k: + type: float32 + doc: | + Filter gain for the reported `ibus`. Set to a value below 1.0 to get a smoother + line when plotting `ibus`. Set to 1.0 to disable. This filter is only applied to + the reported value and not for internal calculations. serial_number: readonly uint64 hw_version_major: readonly uint8 hw_version_minor: readonly uint8