-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathcontroller.h
84 lines (62 loc) · 1.74 KB
/
controller.h
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
77
78
79
80
81
82
83
84
#ifndef CONTROLLER_H
#define CONTROLLER_H
struct PID_Reg{
double Kp; // Proportional gain
double Ti; // Integral time constant
double Ki; // Ki = Kp/Ti*TS (note TS is included here for ease of discrete implementaion)
double i_state; // Integral internal state
double i_limit; // Output limit
double e_state; // last error internal state
double o_state; // last output internal state
};
double PID(struct PID_Reg *r, double err);
struct ControllerForExperiment{
double timebase;
double ual;
double ube;
double R;
double KE;
double Ld;
double Lq;
// double Tload;
// double rpm_cmd;
double npp;
double Js;
double Js_inv;
double omg__fb;
double ial__fb;
double ibe__fb;
double psi_mu_al__fb;
double psi_mu_be__fb;
double rotor_flux_cmd;
double omg_ctrl_err;
double speed_ctrl_err;
double cosT;
double sinT;
double omega_syn;
double theta_d__fb;
double id__fb;
double iq__fb;
double ud_cmd;
double uq_cmd;
double id_cmd;
double iq_cmd;
double Tem;
double Tem_cmd;
// double theta_M;
// double iMs;
// double iTs;
// double uMs_cmd;
// double uTs_cmd;
// double iMs_cmd;
// double iTs_cmd;
struct PID_Reg PID_speed;
struct PID_Reg PID_id;
struct PID_Reg PID_iq;
};
extern struct ControllerForExperiment CTRL;
void CTRL_init();
void control(double speed_cmd, double speed_cmd_dot);
void cmd_fast_speed_reversal(double timebase, double instant, double interval, double rpm_cmd);
void cmd_slow_speed_reversal(double timebase, double instant, double interval, double rpm_cmd);
#endif