CAN baud rate setting fix, spinout detection improvements

This commit is contained in:
PAJohnson
2021-05-13 23:21:48 -04:00
parent 678c1c9c7e
commit b707cd870f
4 changed files with 7 additions and 8 deletions

View File

@@ -367,8 +367,8 @@ bool Controller::update() {
float ideal_electrical_power = 0.0f;
if (axis_->motor_.config_.motor_type != Motor::MOTOR_TYPE_GIMBAL) {
ideal_electrical_power = axis_->motor_.current_control_.power_ - \
axis_->motor_.current_control_.Iq_measured_ * axis_->motor_.current_control_.Iq_measured_ * axis_->motor_.config_.phase_resistance - \
axis_->motor_.current_control_.Id_measured_ * axis_->motor_.current_control_.Id_measured_ * axis_->motor_.config_.phase_resistance;
SQ(axis_->motor_.current_control_.Iq_measured_) * 1.5f * axis_->motor_.config_.phase_resistance - \
SQ(axis_->motor_.current_control_.Id_measured_) * 1.5f * axis_->motor_.config_.phase_resistance;
}
else {
ideal_electrical_power = axis_->motor_.current_control_.power_;

View File

@@ -139,9 +139,6 @@ ODriveIntf::MotorIntf::Error FieldOrientedController::get_alpha_beta_output(
mod_d = V_to_mod * (Vd + v_current_control_integral_d_ + Ierr_d * p_gain);
mod_q = V_to_mod * (Vq + v_current_control_integral_q_ + Ierr_q * p_gain);
// calculate power estimate
power_ = Id * (Vd + v_current_control_integral_d_) + Iq * (Vq + v_current_control_integral_q_);
// Vector modulation saturation, lock integrator if saturated
// TODO make maximum modulation configurable
float mod_scalefactor = 0.80f * sqrt3_by_2 * 1.0f / std::sqrt(mod_d * mod_d + mod_q * mod_q);
@@ -178,6 +175,7 @@ ODriveIntf::MotorIntf::Error FieldOrientedController::get_alpha_beta_output(
if (Idq.has_value()) {
auto [Id, Iq] = *Idq;
*ibus = mod_d * Id + mod_q * Iq;
power_ = vbus_voltage * (*ibus).value();
}
return Motor::ERROR_NONE;

View File

@@ -26,7 +26,7 @@ public:
Protocol protocol = PROTOCOL_SIMPLE;
ODriveCAN* parent = nullptr; // set in apply_config()
void set_baud_rate(uint32_t value) { parent->set_baud_rate(baud_rate); }
void set_baud_rate(uint32_t value) { parent->set_baud_rate(value); }
};
ODriveCAN() {}

View File

@@ -20,13 +20,14 @@ This is the simplest possible way of controlling the ODrive. It is also the most
<axis>.config.enable_step_dir = True
4. Enable circular setpoints
<axis>.controller.config.circular_setpoints = True
Circular setpoints are used to keep floating point error at a manageable error for systems where the motor can rotate large amounts. If the motor is commanded out of the circular range, the position setpoint automatically wraps around to stay in the range. Two parameters are used to control this behavior: `<odrv>.<axis>.controller.config.circular_setpoint_range` and `<odrv>.<axis>.controller.config.steps_per_circular_range`. The circular setpoint range sets the operating range of input_pos, starting at 0.0. The `steps per circular range` setting controls how many steps are needed to traverse the entire range. For example, to use 1024 steps per 1 full motor turn, set
```
<odrv>.<axis>.controller.config.circular_setpoint_range = 1.0
<odrv>.<axis>.controller.config.steps_per_circular_range = 1024
<odrv>.<axis>.controller.config.circular_setpoint_range = 1.0 [turns]
<odrv>.<axis>.controller.config.steps_per_circular_range = 1024 [steps]
```
The circular range is a floating point value and the steps per circular range parameter is an integer. For best results, set both parameters to powers of 2.