miniFOC 1.0.3
This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.
Data Structures | Macros | Functions | Variables
pid.h File Reference

this is the header file of pid.c, which defines the structure of PID algorithm and closed-loop state macro. More...

Go to the source code of this file.

Data Structures

struct  PID_Structure_t
 structure of PID algorithm More...
 

Macros

#define TORQUE_LOOP_CONTROL   1
 torque loop control mode More...
 
#define SPEED_LOOP_CONTROL   2
 speed loop control mode More...
 
#define ANGLE_LOOP_CONTROL   3
 angle loop control mode More...
 

Functions

void pid_config (unsigned char mode)
 configure pid loop parameters More...
 
float pid_calculate_result (PID_Structure_t *pid_handler, float collect)
 calculate result using sampling value More...
 

Variables

unsigned char pid_parameter_available_flag
 flag variable for PID parameter availability More...
 
volatile unsigned char pid_control_mode_flag
 flag variable of PID closed loop mode More...
 
volatile PID_Structure_t speed_pid_handler
 algorithm handler of PID speed loop More...
 
volatile PID_Structure_t angle_pid_handler
 algorithm handler of PID angle loop More...
 

Detailed Description

this is the header file of pid.c, which defines the structure of PID algorithm and closed-loop state macro.

Author
Lao·Zhu
Version
V1.0.1
Date
9. October 2021

Definition in file pid.h.

Macro Definition Documentation

◆ ANGLE_LOOP_CONTROL

#define ANGLE_LOOP_CONTROL   3

angle loop control mode

Definition at line 18 of file pid.h.

◆ SPEED_LOOP_CONTROL

#define SPEED_LOOP_CONTROL   2

speed loop control mode

Definition at line 16 of file pid.h.

◆ TORQUE_LOOP_CONTROL

#define TORQUE_LOOP_CONTROL   1

torque loop control mode

Definition at line 14 of file pid.h.

Function Documentation

◆ pid_calculate_result()

float pid_calculate_result ( PID_Structure_t pid_handler,
float  collect 
)

calculate result using sampling value

Parameters
[in]pid_handlerPID data handler
[in]collectsampled data
Return values
calculatedoutput value of PID controller

Definition at line 61 of file pid.c.

References PID_Structure_t::expect, fast_constrain, PID_Structure_t::kd, PID_Structure_t::ki, PID_Structure_t::kp, PID_Structure_t::last_error, PID_Structure_t::maximum, PID_Structure_t::minimum, PID_Structure_t::sum_maximum, and PID_Structure_t::summary.

Referenced by TIMER13_IRQHandler().

◆ pid_config()

void pid_config ( unsigned char  mode)

Variable Documentation

◆ angle_pid_handler

volatile PID_Structure_t angle_pid_handler
extern

algorithm handler of PID angle loop

Definition at line 28 of file pid.c.

Referenced by flash_read_parameters(), flash_write_parameters(), mdtp_callback_handler(), pid_config(), report_local_variable(), and TIMER13_IRQHandler().

◆ pid_control_mode_flag

volatile unsigned char pid_control_mode_flag
extern

flag variable of PID closed loop mode

Definition at line 20 of file pid.c.

Referenced by main(), mdtp_callback_handler(), pid_config(), report_local_variable(), and TIMER13_IRQHandler().

◆ pid_parameter_available_flag

unsigned char pid_parameter_available_flag
extern

flag variable for PID parameter availability

Definition at line 16 of file pid.c.

Referenced by flash_read_parameters(), flash_write_parameters(), mdtp_callback_handler(), and report_local_variable().

◆ speed_pid_handler

volatile PID_Structure_t speed_pid_handler
extern

algorithm handler of PID speed loop

Definition at line 24 of file pid.c.

Referenced by flash_read_parameters(), flash_write_parameters(), mdtp_callback_handler(), pid_config(), report_local_variable(), and TIMER13_IRQHandler().