Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(motor-control): only add a delay before disengaging motor if ebrake exists #734

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions head/firmware/motor_hardware_rev1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/motor-control/firmware/motor_control_hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions motor-control/firmware/motor_control_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}


1 change: 1 addition & 0 deletions motor-control/firmware/stepper_motor/motor_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void MotorHardware::activate_motor() {
void MotorHardware::deactivate_motor() {
if (pins.ebrake.has_value()) {
gpio::set(pins.ebrake.value());
motor_hardware_delay(10);
}
gpio::reset(pins.enable);
}
Expand Down
Loading