Skip to content
Permalink
Browse files

Implement flux braking

This acts as a virtual resistor when the bus voltage is too high.
Instead of a brake chopper, it lets you just dump extra heat into the
motors.
  • Loading branch information...
jpieper committed Oct 28, 2019
1 parent 5007c9b commit cc12eaec91af1145f2fc5261d2d7f9ae3834feb4
Showing with 19 additions and 1 deletion.
  1. +14 −1 moteus/bldc_servo.cc
  2. +5 −0 moteus/bldc_servo.h
@@ -1188,7 +1188,20 @@ class BldcServo::Impl {
limited_q_A :
Limit(limited_q_A, -kMaxUnconfiguredCurrent, kMaxUnconfiguredCurrent);

ISR_DoCurrent(sin_cos, 0.0f, q_A);
const float d_A = [&]() {
if (config_.flux_brake_min_voltage <= 0.0) {
return 0.0f;
}

if (status_.bus_V <= config_.flux_brake_min_voltage) {
return 0.0f;
}

return ((status_.bus_V - config_.flux_brake_min_voltage) /
config_.flux_brake_resistance_ohm);
}();

ISR_DoCurrent(sin_cos, d_A, q_A);
}

float LimitPwm(float in) {
@@ -133,6 +133,9 @@ class BldcServo {
// about 1.6us extra in the ISR.
bool enable_debug = false;

float flux_brake_min_voltage = -1.0f;
float flux_brake_resistance_ohm = 0.1;

Config() {
pid_dq.kp = 0.1f;
pid_dq.ki = 30.0f;
@@ -162,6 +165,8 @@ class BldcServo {
a->Visit(MJ_NVP(default_timeout_s));
a->Visit(MJ_NVP(timeout_max_torque_Nm));
a->Visit(MJ_NVP(enable_debug));
a->Visit(MJ_NVP(flux_brake_min_voltage));
a->Visit(MJ_NVP(flux_brake_resistance_ohm));
}
};

0 comments on commit cc12eae

Please sign in to comment.
You can’t perform that action at this time.