From 40deb276525b557ab8c6b9a1670f71e32eff4ee3 Mon Sep 17 00:00:00 2001 From: fiona Date: Sun, 2 Aug 2026 10:00:07 +0000 Subject: [PATCH] FA-FO hardware changes --- firmware/MotionControllerRP/src/hw_config.h | 35 ++++++++++--------- .../src/robot_joint/robot_joint.cpp | 2 +- .../servo_control/actuator_calibration.cpp | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/firmware/MotionControllerRP/src/hw_config.h b/firmware/MotionControllerRP/src/hw_config.h index f65d333..4345f6d 100644 --- a/firmware/MotionControllerRP/src/hw_config.h +++ b/firmware/MotionControllerRP/src/hw_config.h @@ -27,7 +27,7 @@ constexpr float ENCODER_ANGLE_TO_ROTOR_ANGLE = (ENCODER_MAGNET_PITCH*2.0f) / // enables error checking for encoders (slow) - useful for debugging // Note: some chips seem to return always a crc of 0 producing massiv false errors -constexpr bool ENABLE_ENCODER_CRC = false; +constexpr bool ENABLE_ENCODER_CRC = true; //--- HOMING ------------------------------------------------------------------ @@ -38,7 +38,7 @@ constexpr float HOMING_CURRENT = 0.15f; // range 0..1 //--- CALIBRATION ------------------------------------------------------------- // degrees from home position -constexpr float CALIBRATION_RANGE = 83; +constexpr float CALIBRATION_RANGE = 83; // velocity of the magnetic field during calibration (lower is more accurate) constexpr float CALIBRATION_FIELD_VELOCITY = 20.0f; @@ -70,7 +70,7 @@ constexpr float VEL_KI = 90.0f; #define JOINT_READY_OVERRIDE -// #define SINGLE_AXIS_BOARD +#define SINGLE_AXIS_BOARD #ifndef SINGLE_AXIS_BOARD // Pins for 3Axis Board // #define PIN_BUILTIN_LED 23 // RP2040 pico clone @@ -87,18 +87,18 @@ constexpr float VEL_KI = 90.0f; #define PIN_M2_PWM_B_POS 10 #define PIN_M2_PWM_B_NEG 11 - #define PIN_M3_PWM_A_POS 5 - #define PIN_M3_PWM_A_NEG 4 - #define PIN_M3_PWM_B_POS 6 + #define PIN_M3_PWM_A_POS 20 + #define PIN_M3_PWM_A_NEG 21 + #define PIN_M3_PWM_B_POS 22 #define PIN_M3_PWM_B_NEG 7 #define PIN_MOTOR_EN 18 #define PIN_MOTOR_PWMAB 19 - #define PIN_ENCODER1_CS 20 - #define PIN_ENCODER2_CS 21 - #define PIN_ENCODER3_CS 22 + #define PIN_ENCODER1_CS 4 + #define PIN_ENCODER2_CS 5 + #define PIN_ENCODER3_CS 6 #define PIN_ENCODER_SCK 2 #define PIN_ENCODER_MISO 0 #define PIN_ENCODER_MOSI 3 @@ -121,19 +121,22 @@ constexpr float VEL_KI = 90.0f; #define PIN_M2_PWM_B_POS 10 #define PIN_M2_PWM_B_NEG 11 - #define PIN_M3_PWM_A_POS 5 - #define PIN_M3_PWM_A_NEG 4 - #define PIN_M3_PWM_B_POS 6 + #define PIN_M3_PWM_A_POS 20 + #define PIN_M3_PWM_A_NEG 21 + #define PIN_M3_PWM_B_POS 22 #define PIN_M3_PWM_B_NEG 7 #define PIN_MOTOR_EN 18 #define PIN_MOTOR_PWMAB 19 - #define PIN_ENCODER1_CS 20 - #define PIN_ENCODER2_CS 21 - #define PIN_ENCODER3_CS 22 + #define PIN_ENCODER1_CS 4 + #define PIN_ENCODER2_CS 5 + #define PIN_ENCODER3_CS 6 #define PIN_ENCODER_SCK 2 #define PIN_ENCODER_MISO 0 #define PIN_ENCODER_MOSI 3 -#endif \ No newline at end of file + + #define PIN_TOOL1 16 + #define PIN_TOOL2 17 +#endif diff --git a/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp b/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp index b343a1f..d4263e9 100644 --- a/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp +++ b/firmware/MotionControllerRP/src/robot_joint/robot_joint.cpp @@ -57,7 +57,7 @@ bool RobotJoint::calibrate(bool print_measurements) { bool homing_ok = homing_controller.run_blocking(servo_controller, -HOMING_VELOCITY, 360.0f*DEG_TO_RAD, HOMING_CURRENT, ENCODER_ANGLE_TO_ROTOR_ANGLE, - 0.0f); + 17.5f*DEG_TO_RAD); if(homing_ok == false) { LOG_ERROR("Joint-%i: Calibration failed due to unsuccessful homing sequence", joint_idx); return false; diff --git a/firmware/MotionControllerRP/src/servo_control/actuator_calibration.cpp b/firmware/MotionControllerRP/src/servo_control/actuator_calibration.cpp index 1bc86f0..92a0d27 100644 --- a/firmware/MotionControllerRP/src/servo_control/actuator_calibration.cpp +++ b/firmware/MotionControllerRP/src/servo_control/actuator_calibration.cpp @@ -58,7 +58,7 @@ bool measure_calibration_data( if(encoder.get_status() & MT6835_STATUS_WEAKFIELD) weak_field_measurements++; - if(print_measurements) + if(true) LOG_RAW("%15.10f, %15.10f, %f", motor_pos, field_angle, encoder_angle_raw); encoder_angle_and_motor_pos.push_back({encoder_angle_raw, motor_pos});