ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
|
Quadrature encoder interface for STM32 timers. More...
Go to the source code of this file.
Classes | |
struct | encoder_t |
Structure for tracking encoder state and motion data. More... |
Functions | |
void | encoder_init (encoder_t *encoder, TIM_HandleTypeDef *htim) |
Initializes an encoder structure with a given timer. | |
void | encoder_update (encoder_t *encoder) |
Updates the encoder's internal position, delta, and speed. | |
int32_t | encoder_getposition (encoder_t *encoder) |
Returns the current position (accumulated counts) of the encoder. | |
int32_t | encoder_getdelta (encoder_t *encoder) |
Returns the most recent change in encoder count. | |
float | encoder_getspeed (encoder_t *encoder) |
Returns the current speed in counts per second. | |
void | encoder_reset (encoder_t *encoder) |
Resets encoder position and delta tracking. |
Quadrature encoder interface for STM32 timers.
Provides data structures and functions for tracking position, velocity, and delta counts using hardware timers configured in encoder mode.
int32_t encoder_getdelta | ( | encoder_t * | encoder | ) |
Returns the most recent change in encoder count.
encoder | Pointer to encoder structure. |
Returns the most recent change in encoder count.
encoder | Pointer to encoder structure. |
int32_t encoder_getposition | ( | encoder_t * | encoder | ) |
Returns the current position (accumulated counts) of the encoder.
encoder | Pointer to encoder structure. |
Returns the current position (accumulated counts) of the encoder.
encoder | Pointer to encoder structure. |
float encoder_getspeed | ( | encoder_t * | encoder | ) |
Returns the current speed in counts per second.
encoder | Pointer to encoder structure. |
Returns the current speed in counts per second.
encoder | Pointer to encoder structure. |
void encoder_init | ( | encoder_t * | encoder, |
TIM_HandleTypeDef * | htim ) |
Initializes an encoder structure with a given timer.
encoder | Pointer to encoder structure. |
htim | Pointer to initialized TIM_HandleTypeDef configured for encoder mode. |
Initializes an encoder structure with a given timer.
encoder | Pointer to encoder structure to initialize. |
htim | Pointer to a TIM_HandleTypeDef configured in encoder mode. |
void encoder_reset | ( | encoder_t * | encoder | ) |
Resets encoder position and delta tracking.
encoder | Pointer to encoder structure. |
Resets encoder position and delta tracking.
encoder | Pointer to encoder structure. |
void encoder_update | ( | encoder_t * | encoder | ) |
Updates the encoder's internal position, delta, and speed.
encoder | Pointer to encoder structure. |
Updates the encoder's internal position, delta, and speed.
Computes the count delta between updates and handles overflow. Speed is calculated in counts per second (CPS).
encoder | Pointer to encoder structure to update. |