Browse Source

Detent tweaks

Scott Bezek 4 years ago
parent
commit
f362039a95
3 changed files with 13 additions and 2 deletions
  1. 10 0
      firmware/src/interface_task.cpp
  2. 1 0
      firmware/src/knob_data.h
  3. 2 2
      firmware/src/motor_task.cpp

+ 10 - 0
firmware/src/interface_task.cpp

@@ -10,6 +10,7 @@ static KnobConfig configs[] = {
     // int32_t position;
     // float position_width_radians;
     // float detent_strength_unit;
+    // float endstop_strength_unit;
     // float snap_point;
     // char descriptor[50];
 
@@ -18,6 +19,7 @@ static KnobConfig configs[] = {
         0,
         10 * PI / 180,
         0,
+        1,
         1.1,
         "Unbounded\nNo detents",
     },
@@ -26,6 +28,7 @@ static KnobConfig configs[] = {
         0,
         10 * PI / 180,
         0,
+        1,
         1.1,
         "Bounded 0-10\nNo detents",
     },
@@ -34,6 +37,7 @@ static KnobConfig configs[] = {
         0,
         10 * PI / 180,
         0,
+        1,
         1.1,
         "Multi-rev\nNo detents",
     },
@@ -42,6 +46,7 @@ static KnobConfig configs[] = {
         0,
         60 * PI / 180,
         1,
+        1,
         0.55, // Note the snap point is slightly past the midpoint (0.5); compare to normal detents which use a snap point *past* the next value (i.e. > 1)
         "On/off\nStrong detent",
     },
@@ -50,6 +55,7 @@ static KnobConfig configs[] = {
         0,
         60 * PI / 180,
         0.01,
+        0.6,
         1.1,
         "Return-to-center",
     },
@@ -58,6 +64,7 @@ static KnobConfig configs[] = {
         127,
         1 * PI / 180,
         0,
+        1,
         1.1,
         "Fine values\nNo detents",
     },
@@ -66,6 +73,7 @@ static KnobConfig configs[] = {
         127,
         1 * PI / 180,
         1,
+        1,
         1.1,
         "Fine values\nWith detents",
     },
@@ -74,6 +82,7 @@ static KnobConfig configs[] = {
         0,
         8.225806452 * PI / 180,
         1,
+        1,
         1.1,
         "Coarse values\nStrong detents",
     },
@@ -82,6 +91,7 @@ static KnobConfig configs[] = {
         0,
         8.225806452 * PI / 180,
         0.2,
+        1,
         1.1,
         "Coarse values\nWeak detents",
     },

+ 1 - 0
firmware/src/knob_data.h

@@ -7,6 +7,7 @@ struct KnobConfig {
     int32_t position;
     float position_width_radians;
     float detent_strength_unit;
+    float endstop_strength_unit;
     float snap_point;
     char descriptor[50];
 };

+ 2 - 2
firmware/src/motor_task.cpp

@@ -113,7 +113,7 @@ void MotorTask::run() {
             // get runaway due to sensor noise & lag)).
             // TODO: consider eliminating this D factor entirely and just "play" a hardcoded haptic "click" (e.g. a quick burst of torque in each
             // direction) whenever the position changes when the detent width is too small for the P factor to work well.
-            const float derivative_lower_strength = config.detent_strength_unit * 0.06;
+            const float derivative_lower_strength = config.detent_strength_unit * 0.04;
             const float derivative_upper_strength = config.detent_strength_unit * 0;
             const float derivative_position_width_lower = 5 * PI / 180;
             const float derivative_position_width_upper = 10 * PI / 180;
@@ -164,7 +164,7 @@ void MotorTask::run() {
 
         bool out_of_bounds = config.num_positions > 0 && ((angle_to_detent_center > 0 && config.position == 0) || (angle_to_detent_center < 0 && config.position == config.num_positions - 1));
         motor.PID_velocity.limit = 10; //out_of_bounds ? 10 : 3;
-        motor.PID_velocity.P = out_of_bounds ? 4 : config.detent_strength_unit * 4;
+        motor.PID_velocity.P = out_of_bounds ? config.endstop_strength_unit * 4 : config.detent_strength_unit * 4;