From 1ffb311a62e549ae8d793defc78c3323b6e4c162 Mon Sep 17 00:00:00 2001 From: Alise Au <20424172+ahiuchingau@users.noreply.github.com> Date: Wed, 8 Nov 2023 14:16:19 -0500 Subject: [PATCH 1/3] fix(head): engage head ebrake at boot (#732) --- head/firmware/motor_hardware_rev1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/head/firmware/motor_hardware_rev1.c b/head/firmware/motor_hardware_rev1.c index 1b3f49d43..478decc79 100644 --- a/head/firmware/motor_hardware_rev1.c +++ b/head/firmware/motor_hardware_rev1.c @@ -20,9 +20,7 @@ void initialize_rev_specific_pins() { HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - // TODO: Handle brakes better, this just disengages - // them at boot - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5 | GPIO_PIN_0, GPIO_PIN_SET); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5 | GPIO_PIN_0, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET); From f9f88854eefb467ed22850839425109881c256c3 Mon Sep 17 00:00:00 2001 From: Alise Au <20424172+ahiuchingau@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:00:07 -0500 Subject: [PATCH 2/3] fix(motor-control): z stage falls after being disengaged (#733) Adding a delay before disengaging the motor --- include/motor-control/firmware/motor_control_hardware.h | 1 + motor-control/firmware/motor_control_hardware.c | 6 ++++++ motor-control/firmware/stepper_motor/motor_hardware.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/include/motor-control/firmware/motor_control_hardware.h b/include/motor-control/firmware/motor_control_hardware.h index a9b0ca4f1..2cdcc123d 100644 --- a/include/motor-control/firmware/motor_control_hardware.h +++ b/include/motor-control/firmware/motor_control_hardware.h @@ -24,6 +24,7 @@ uint16_t motor_hardware_encoder_pulse_count(void* encoder_handle); uint16_t motor_hardware_encoder_pulse_count_with_overflow(void* encoder_handle, int8_t *overflows); void motor_hardware_reset_encoder_count(void* encoder_handle, uint16_t reset_value); uint16_t motor_hardware_get_stopwatch_pulses(void* stopwatch_handle, uint8_t clear); +void motor_hardware_delay(uint32_t delay); #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/motor-control/firmware/motor_control_hardware.c b/motor-control/firmware/motor_control_hardware.c index bf13b9043..d4cdb534a 100644 --- a/motor-control/firmware/motor_control_hardware.c +++ b/motor-control/firmware/motor_control_hardware.c @@ -7,6 +7,7 @@ #include "FreeRTOS.h" #include "platform_specific_hal_conf.h" #include "stm32g4xx_hal_tim.h" +#include "stm32g4xx_hal.h" #include "task.h" HAL_StatusTypeDef custom_stop_pwm_it(TIM_HandleTypeDef* htim, @@ -131,3 +132,8 @@ uint16_t motor_hardware_get_stopwatch_pulses(void* stopwatch_handle, uint8_t cle return count; } +void motor_hardware_delay(uint32_t delay) { + HAL_Delay(delay); +} + + diff --git a/motor-control/firmware/stepper_motor/motor_hardware.cpp b/motor-control/firmware/stepper_motor/motor_hardware.cpp index 9b4d38151..ec422b22b 100644 --- a/motor-control/firmware/stepper_motor/motor_hardware.cpp +++ b/motor-control/firmware/stepper_motor/motor_hardware.cpp @@ -24,6 +24,7 @@ void MotorHardware::deactivate_motor() { if (pins.ebrake.has_value()) { gpio::set(pins.ebrake.value()); } + motor_hardware_delay(10); gpio::reset(pins.enable); } void MotorHardware::start_timer_interrupt() { From bf6121f9d48e26e4963458cbee5ac397e0361475 Mon Sep 17 00:00:00 2001 From: ahiuchingau <20424172+ahiuchingau@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:34:44 -0500 Subject: [PATCH 3/3] only adds delay if there is an ebrake --- motor-control/firmware/stepper_motor/motor_hardware.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motor-control/firmware/stepper_motor/motor_hardware.cpp b/motor-control/firmware/stepper_motor/motor_hardware.cpp index ec422b22b..a28dcef33 100644 --- a/motor-control/firmware/stepper_motor/motor_hardware.cpp +++ b/motor-control/firmware/stepper_motor/motor_hardware.cpp @@ -23,8 +23,8 @@ void MotorHardware::activate_motor() { void MotorHardware::deactivate_motor() { if (pins.ebrake.has_value()) { gpio::set(pins.ebrake.value()); + motor_hardware_delay(10); } - motor_hardware_delay(10); gpio::reset(pins.enable); } void MotorHardware::start_timer_interrupt() {