![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Implements controller task state machine for robot motor control. More...
#include "motor_driver.h"#include "controller_task.h"#include "stm32f4xx_hal_tim.h"#include "encoder_driver.h"#include <stdio.h>Typedefs | |
| typedef void(* | StateFunc) (ControllerTask *) |
| Function pointer type for controller state functions. | |
Functions | |
| void | controller_task_run (ControllerTask *controller_task) |
| Executes the current state of the controller task. | |
| void | controller_task_state_0_init (ControllerTask *controller_task) |
| Initializes the controller task (State 0). | |
| void | controller_task_state_1_pos (ControllerTask *controller_task) |
| Executes position control logic (State 1). | |
Implements controller task state machine for robot motor control.
Created on: Jun 3, 2025
| void controller_task_run | ( | ControllerTask * | controller_task | ) |
Executes the current state of the controller task.
Validates the current state index and calls the appropriate state function from the task's function list.
| controller_task | Pointer to the ControllerTask structure. |
| void controller_task_state_0_init | ( | ControllerTask * | controller_task | ) |
Initializes the controller task (State 0).
Enables the motor, records the potentiometer's zero point, and sets the task to the next state.
| controller_task | Pointer to the ControllerTask structure. |
| void controller_task_state_1_pos | ( | ControllerTask * | controller_task | ) |
Executes position control logic (State 1).
Executes the position control logic (State 1).
Calculates desired position and error from encoder data and ADC input, then applies control logic using a proportional-integral method. Timing is measured using a hardware timer.
| controller_task | Pointer to the ControllerTask structure. |