This repository contains a study case solution for a linear actuator homing function implemented in C on STM32 using the HAL driver.
The project targets an STM32-based ECU that controls a linear actuator through two digital outputs. Two buttons are used to simulate the actuator end switches, and two LEDs indicate actuator direction.
The implemented solution:
- Runs as a non-blocking step in the main superloop
- Uses a finite state machine for the homing sequence
- Includes debounce handling, timeout checks, and fault protection
- Separates actuator control and homing logic into reusable modules
- Supports midpoint estimation with asymmetric forward and reverse speeds
Src/actuator.c,Inc/actuator.h: actuator direction abstractionSrc/homing.c,Inc/homing.h: non-blocking homing logicSrc/main.c: hardware initialization and superloop integration
- Forward limit input:
PC5 - Reverse limit input:
PC6 - Forward output indicator:
PC8 - Reverse output indicator:
PC9 - Start button:
B1 (PC13)
The project was created with STM32CubeIDE and uses STM32 HAL.
Open the project in STM32CubeIDE and build it with the default Debug configuration.