From 4a5f2cc1c0095760d844c371fc489d9fd4b05a40 Mon Sep 17 00:00:00 2001 From: Capo01 <503426+Capo01@users.noreply.github.com> Date: Sat, 8 Sep 2018 19:22:51 +1000 Subject: [PATCH 1/2] Additional detail for the control method Added additional detail. --- docs/control.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/control.md b/docs/control.md index 0be73866..3775c033 100644 --- a/docs/control.md +++ b/docs/control.md @@ -4,6 +4,17 @@ The motor controller is a cascaded style position, velocity and current control ![Cascaded pos vel I loops](https://static1.squarespace.com/static/58aff26de4fcb53b5efd2f02/t/5b66284a0e2e72aae8818d64/1533421649405/CascadedController.png?format=2500w) -* The position controller is a P loop with a single proportional gain. -* The velocity controller is a PI loop. -* The current controller is a PI loop. +### Position loop: +The position controller is a P loop with a single proportional gain. +* `vel_cmd = (pos_setpoint - pos_feedback) * pos_gain` + +### Velocity loop: +The velocity controller is a PI loop. +* `vel_error_sum += (vel_cmd - vel_feedback) * vel_integrator_gain` +* `current_cmd = (vel_cmd - vel_feedback) * vel_gain + vel_error_sum + vel_feedforward` +### Current loop: +The current controller is a PI loop. +* `current_error_sum += (current_cmd - current_fb) * current_integrator_gain` +* `voltage_cmd = (current_cmd - current_fb) * current_gain + current_error_sum + current_feedforward` + +For more detail refer to [controller.cpp](https://github.com/madcowswe/ODrive/blob/master/Firmware/MotorControl/controller.cpp#L86). From 6eb53f13e0ac8faceebd035769a9db2d4e02e122 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Wed, 12 Sep 2018 18:59:02 -0700 Subject: [PATCH 2/2] Update control.md --- docs/control.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/control.md b/docs/control.md index 3775c033..f0b2da1d 100644 --- a/docs/control.md +++ b/docs/control.md @@ -6,15 +6,25 @@ The motor controller is a cascaded style position, velocity and current control ### Position loop: The position controller is a P loop with a single proportional gain. -* `vel_cmd = (pos_setpoint - pos_feedback) * pos_gain` +```text +pos_error = pos_setpoint - pos_feedback +vel_cmd = pos_error * pos_gain + vel_feedforward +``` ### Velocity loop: The velocity controller is a PI loop. -* `vel_error_sum += (vel_cmd - vel_feedback) * vel_integrator_gain` -* `current_cmd = (vel_cmd - vel_feedback) * vel_gain + vel_error_sum + vel_feedforward` +```text +vel_error = vel_cmd - vel_feedback +current_integral += vel_error * vel_integrator_gain +current_cmd = vel_error * vel_gain + current_integral + current_feedforward +``` + ### Current loop: The current controller is a PI loop. -* `current_error_sum += (current_cmd - current_fb) * current_integrator_gain` -* `voltage_cmd = (current_cmd - current_fb) * current_gain + current_error_sum + current_feedforward` +```text +current_error = current_cmd - current_fb +voltage_integral += current_error * current_integrator_gain +voltage_cmd = current_error * current_gain + voltage_integral (+ voltage_feedforward when we have motor model) +``` For more detail refer to [controller.cpp](https://github.com/madcowswe/ODrive/blob/master/Firmware/MotorControl/controller.cpp#L86).