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.
Functions | Variables
pid.c File Reference

PID algorithm implementation source code. More...

#include "pid.h"
#include "fast_math.h"
#include "system.h"

Go to the source code of this file.

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 = 1
 flag variable for PID parameter availability More...
 
volatile unsigned char pid_control_mode_flag = 0
 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

PID algorithm implementation source code.

Author
Lao·Zhu
Version
V1.0.2
Date
29. October 2021

Definition in file pid.c.

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

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 = 0

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 = 1

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

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().