Motor Driver Evaluation Kit NEVB-MTR1-t01-1.0.0
Firmware for NEVB-MTR1-KIT1 for trapezoidal control of BLDC motors using Hall-effect sensors
Loading...
Searching...
No Matches
pid.h
Go to the documentation of this file.
1/* This file has been prepared for Doxygen automatic documentation generation.*/
21
22#ifndef PID_H
23#define PID_H
24
25// Include standard integer type definitions
26#include "stdint.h"
27
33#define SCALING_FACTOR 256
34
40#define SCALING_FACTOR_ENABLED FALSE
41
46typedef struct pidData
47{
51 int32_t sumError;
53 int16_t P_Factor;
55 int16_t I_Factor;
57 int16_t D_Factor;
59 int16_t maxError;
61 int32_t maxSumError;
62#if (PID_K_D_ENABLE == TRUE)
64 int16_t d_term;
65#endif
67 int16_t p_term;
70 int32_t i_term;
72
74#define MAX_INT 32767
75
77#define MAX_LONG 2147483647L
78
86#define MAX_I_TERM (MAX_LONG - (2 * (int32_t)MAX_INT))
87
88// Boolean values
90#define FALSE 0
91
93#define TRUE (!FALSE)
94
95// Function prototypes
96void PIDInit(int16_t p_factor, int16_t i_factor, int16_t d_factor, pidData_t *pid);
97uint16_t PIDController(int16_t setPoint, int16_t processValue, pidData_t *pid_st);
98void PIDResetIntegrator(pidData_t *pid_st);
99
100#endif /* PID_H */
void PIDInit(int16_t p_factor, int16_t i_factor, int16_t d_factor, pidData_t *pid)
Initialisation of PID controller parameters.
Definition pid.cpp:31
uint16_t PIDController(int16_t setPoint, int16_t processValue, pidData_t *pid_st)
PID control algorithm.
Definition pid.cpp:54
void PIDResetIntegrator(pidData_t *pid_st)
Resets the integrator in the PID regulator.
Definition pid.cpp:130
struct pidData pidData_t
PID Status.
PID Status.
Definition pid.h:47
int32_t maxSumError
Maximum allowed sum error, avoid overflow.
Definition pid.h:61
int16_t P_Factor
The Proportional tuning constant, given in x100.
Definition pid.h:53
int16_t maxError
Maximum allowed error, avoid overflow.
Definition pid.h:59
int16_t D_Factor
The Derivative tuning constant, given in x100.
Definition pid.h:57
int16_t d_term
The D-term represents the rate of change of the error.
Definition pid.h:64
int32_t sumError
Summation of errors, used for integrate calculations.
Definition pid.h:51
int32_t i_term
Definition pid.h:70
int16_t I_Factor
The Integral tuning constant, given in x100.
Definition pid.h:55
int16_t p_term
The P-term represents the immediate response to the current error.
Definition pid.h:67
int16_t lastProcessValue
Last process value, used to find derivative of process value.
Definition pid.h:49