Junjie Wang
/
a_NYP_humanoid_copy
NYP_Humanoid_robot_FYP_2018
Fork of b_NYP_humanoid by
control.h@4:99891561a38b, 2018-05-25 (annotated)
- Committer:
- mr_wang
- Date:
- Fri May 25 09:00:15 2018 +0000
- Revision:
- 4:99891561a38b
NYP_DAD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mr_wang | 4:99891561a38b | 1 | #ifndef __CONTROL_H |
mr_wang | 4:99891561a38b | 2 | #define __CONTROL_H |
mr_wang | 4:99891561a38b | 3 | |
mr_wang | 4:99891561a38b | 4 | #define CONTROL_MODE_NONE 0 |
mr_wang | 4:99891561a38b | 5 | #define CONTROL_MODE_ONOFF 1 |
mr_wang | 4:99891561a38b | 6 | #define CONTROL_MODE_P 2 |
mr_wang | 4:99891561a38b | 7 | #define CONTROL_MODE_PI 3 |
mr_wang | 4:99891561a38b | 8 | #define CONTROL_MODE_PD 4 |
mr_wang | 4:99891561a38b | 9 | #define CONTROL_MODE_PID 5 |
mr_wang | 4:99891561a38b | 10 | |
mr_wang | 4:99891561a38b | 11 | typedef struct{ |
mr_wang | 4:99891561a38b | 12 | unsigned char input; |
mr_wang | 4:99891561a38b | 13 | |
mr_wang | 4:99891561a38b | 14 | double presentvalue; |
mr_wang | 4:99891561a38b | 15 | |
mr_wang | 4:99891561a38b | 16 | double setpoint; |
mr_wang | 4:99891561a38b | 17 | |
mr_wang | 4:99891561a38b | 18 | double upperlimit; |
mr_wang | 4:99891561a38b | 19 | double lowerlimit; |
mr_wang | 4:99891561a38b | 20 | |
mr_wang | 4:99891561a38b | 21 | double upperdeadband; |
mr_wang | 4:99891561a38b | 22 | double lowerdeadband; |
mr_wang | 4:99891561a38b | 23 | |
mr_wang | 4:99891561a38b | 24 | unsigned char mode; |
mr_wang | 4:99891561a38b | 25 | double gain_p; |
mr_wang | 4:99891561a38b | 26 | double gain_i; |
mr_wang | 4:99891561a38b | 27 | double gain_d; |
mr_wang | 4:99891561a38b | 28 | |
mr_wang | 4:99891561a38b | 29 | double error; |
mr_wang | 4:99891561a38b | 30 | double error_p; |
mr_wang | 4:99891561a38b | 31 | double error_i; |
mr_wang | 4:99891561a38b | 32 | double error_d; |
mr_wang | 4:99891561a38b | 33 | |
mr_wang | 4:99891561a38b | 34 | double output; |
mr_wang | 4:99891561a38b | 35 | }CONTROLLER; |
mr_wang | 4:99891561a38b | 36 | |
mr_wang | 4:99891561a38b | 37 | void CONTROL_InputMode_Set(CONTROLLER* control, unsigned char input, double mode); |
mr_wang | 4:99891561a38b | 38 | void CONTROL_Setpoint_Set(CONTROLLER* control, double sp); |
mr_wang | 4:99891561a38b | 39 | void CONTROL_Gain_Set(CONTROLLER* control, double p, double i, double d); |
mr_wang | 4:99891561a38b | 40 | void CONTROL_Limit_Set(CONTROLLER* control, double upper, double lower); |
mr_wang | 4:99891561a38b | 41 | void CONTROL_Deadband_Set(CONTROLLER* control, double upper, double lower); |
mr_wang | 4:99891561a38b | 42 | void CONTROL_PresentValue_Set(CONTROLLER* control, double pv); |
mr_wang | 4:99891561a38b | 43 | double CONTROL_Output_Get(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 44 | |
mr_wang | 4:99891561a38b | 45 | void CONTROL_OnOff(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 46 | void CONTROL_P(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 47 | void CONTROL_PID(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 48 | void CONTROL_PI(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 49 | void CONTROL_PD(CONTROLLER* control); |
mr_wang | 4:99891561a38b | 50 | |
mr_wang | 4:99891561a38b | 51 | void CONTROL_Config(void); |
mr_wang | 4:99891561a38b | 52 | void CONTROL_Task(void); |
mr_wang | 4:99891561a38b | 53 | |
mr_wang | 4:99891561a38b | 54 | #endif |