Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
controller_task.h
Go to the documentation of this file.
1
8
9#ifndef INC_CONTROLLER_TASK_H_
10#define INC_CONTROLLER_TASK_H_
11
12#include "motor_driver.h"
13#include <stdlib.h>
14#include <stdio.h>
15#include "stm32f4xx_hal.h"
16#include "encoder_driver.h"
17#include <stdint.h> // Allows use of standard integer types
18
22typedef struct ControllerTask ControllerTask; // forward declaration
23
29typedef void (*controller_fcn_t)(ControllerTask *controller_task);
30
38{
39 int32_t dir;
40 int32_t state;
41 int32_t num_states;
42 uint32_t chan1;
43 uint32_t chan2;
44 int32_t pot_zero;
45 int32_t des_pos;
46 uint32_t prev_time;
47 uint32_t current_time;
48 uint32_t prev_ticks;
49 float k_p;
50 float k_i;
51 uint32_t adc_val;
53 TIM_HandleTypeDef *htim_encoder;
54 TIM_HandleTypeDef *htim_dt;
55 ADC_HandleTypeDef *hadc;
58
59 float prev_error;
60
62};
63
69void controller_task_state_0_init(ControllerTask *controller_task);
70
76void controller_task_run(ControllerTask *controller_task);
77
83void controller_task_state_1_pos(ControllerTask *controller_task);
84
85#endif /* INC_CONTROLLER_TASK_H_ */
void controller_task_state_1_pos(ControllerTask *controller_task)
Executes the position control logic (State 1).
Definition controller_task.c:70
void controller_task_state_0_init(ControllerTask *controller_task)
Initializes the controller task (State 0).
Definition controller_task.c:50
void(* controller_fcn_t)(ControllerTask *controller_task)
Function pointer type for controller task state functions.
Definition controller_task.h:29
void controller_task_run(ControllerTask *controller_task)
Executes the current state of the controller task.
Definition controller_task.c:29
Header file for encoder structure and read/setup functions.
Header file for motor control structure and interface functions.
Structure that defines the controller task.
Definition controller_task.h:38
int32_t num_states
Definition controller_task.h:41
TIM_HandleTypeDef * htim_encoder
Definition controller_task.h:53
uint32_t chan2
Definition controller_task.h:43
uint32_t chan1
Definition controller_task.h:42
TIM_HandleTypeDef * htim_dt
Definition controller_task.h:54
float prev_error
Definition controller_task.h:59
int32_t dir
Definition controller_task.h:39
controller_fcn_t state_list[]
Definition controller_task.h:61
uint32_t prev_time
Definition controller_task.h:46
encoder_t * encoder
Definition controller_task.h:57
float k_p
Definition controller_task.h:49
motor_t * motor
Definition controller_task.h:56
int32_t des_pos
Definition controller_task.h:45
int32_t integral_error
Definition controller_task.h:52
float k_i
Definition controller_task.h:50
uint32_t current_time
Definition controller_task.h:47
uint32_t prev_ticks
Definition controller_task.h:48
int32_t pot_zero
Definition controller_task.h:44
uint32_t adc_val
Definition controller_task.h:51
int32_t state
Definition controller_task.h:40
ADC_HandleTypeDef * hadc
Definition controller_task.h:55
Structure to hold encoder task configuration and state.
Definition encoder_driver.h:22
Motor object data structure.
Definition motor_driver.h:22