-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller_pid_F.h
More file actions
79 lines (49 loc) · 1.3 KB
/
controller_pid_F.h
File metadata and controls
79 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "base.h"
#ifdef __cplusplus
namespace fastdsp {
namespace controller {
#endif
typedef enum{
PID_SAT_P = 0,
PID_SAT_I,
PID_SAT_D,
PID_SAT_OUT,
PID_SAT_MIN = 0,
PID_SAT_MAX
} pid_sat_e;
typedef enum{
PID_KP = 0,
PID_KI,
PID_KD
} pid_k_e;
//! @brief PID controller struct
typedef struct{
float32 p; //!< Proportional value
float32 i; //!< Integration value
float32 d; //!< Differentiation value
float32 control; //!< Output control
float32 k[3]; //!< Time parameters
float32 saturation[4][2]; //!< Saturation ranges
}pid_f_t;
//! PID init function
EXTERN int pid_init_F(
pid_f_t *pid, //!< PID object
float32 kp, //!< Proportional coefficient
float32 ki, //!< Integration coefficient
float32 kd //!< Differentiation coefficient
);
/*!
* @brief PID processing.
* Put target value and to feedback current measured value from model
* @return Control value
*/
EXTERN float32 pid_process_F(
pid_f_t *pid, //!< PID object
float32 target, //!< Target value
float32 feedback //!< Feedback value. Error = target - feedback
);
#ifdef __cplusplus
} //namespace controller
} //namespace fastdsp
#endif