![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Header file for controller task logic in Zap'Em Blast'Em Robots. More...
#include "motor_driver.h"
#include <stdlib.h>
#include <stdio.h>
#include "stm32f4xx_hal.h"
#include "encoder_driver.h"
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | ControllerTask |
Structure that defines the controller task. More... |
Typedefs | |
typedef void(* | controller_fcn_t) (ControllerTask *controller_task) |
Function pointer type for controller task state functions. |
Functions | |
void | controller_task_state_0_init (ControllerTask *controller_task) |
Initializes the controller task (State 0). | |
void | controller_task_run (ControllerTask *controller_task) |
Executes the current state of the controller task. | |
void | controller_task_state_1_pos (ControllerTask *controller_task) |
Executes the position control logic (State 1). |
Header file for controller task logic in Zap'Em Blast'Em Robots.
Created on: Jun 3, 2025
typedef void(* controller_fcn_t) (ControllerTask *controller_task) |
Function pointer type for controller task state functions.
Each function takes a pointer to a ControllerTask struct.
void controller_task_run | ( | ControllerTask * | controller_task | ) |
Executes the current state of the controller task.
controller_task | Pointer to the ControllerTask instance. |
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).
controller_task | Pointer to the ControllerTask instance. |
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 the position control logic (State 1).
controller_task | Pointer to the ControllerTask instance. |
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. |