From b92b805e138eac4dff39f9aa61c67c5a5562b929 Mon Sep 17 00:00:00 2001 From: Scott Bezek Date: Sat, 15 Jan 2022 21:21:23 -0800 Subject: [PATCH] cleanup --- firmware/src/interface_task.cpp | 9 +++++++-- firmware/src/motor_task.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/firmware/src/interface_task.cpp b/firmware/src/interface_task.cpp index 88b6cb2..4c1f188 100644 --- a/firmware/src/interface_task.cpp +++ b/firmware/src/interface_task.cpp @@ -6,6 +6,13 @@ using namespace ace_button; #define COUNT_OF(A) (sizeof(A) / sizeof(A[0])) static KnobConfig configs[] = { + // int32_t num_positions; + // int32_t position; + // float position_width_radians; + // float detent_strength_unit; + // float snap_point; + // char descriptor[50]; + { 0, 0, @@ -99,13 +106,11 @@ void InterfaceTask::run() { nextConfig(); } } - // Serial.println(digitalRead(36)); delay(10); } } void InterfaceTask::handleEvent(AceButton* button, uint8_t event_type, uint8_t button_state) { - Serial.println("EVENT!"); switch (event_type) { case AceButton::kEventPressed: nextConfig(); diff --git a/firmware/src/motor_task.cpp b/firmware/src/motor_task.cpp index 80cc217..7b55f8b 100644 --- a/firmware/src/motor_task.cpp +++ b/firmware/src/motor_task.cpp @@ -69,7 +69,13 @@ void MotorTask::run() { tlv.update(); delay(10); - motor.initFOC(-0.6, Direction::CCW); + // Tune zero offset to the specific hardware (motor + mounted magnetic sensor). + // SimpleFOC is supposed to be able to determine this automatically (if you omit params to initFOC), but + // it seems to have a bug (or I've misconfigured it) that gets both the offset and direction very wrong! + // So this value is based on experimentation. + // TODO: dig into SimpleFOC calibration and find/fix the issue + float zero_electric_offset = -0.6; + motor.initFOC(zero_electric_offset, Direction::CCW); Serial.println(motor.zero_electric_angle); command.add('M', &doMotor, "foo");