MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

float/ctrl_obj.h
Go to the documentation of this file.
1 #ifndef _CTRL_OBJ_H_
2 #define _CTRL_OBJ_H_
3
8
9 // **************************************************************************
10 // the includes
11
12 // drivers
13
14
15 // modules
16 #include "sw/modules/types/src/types.h"
17 #include "sw/modules/ctrl/src/ctrl_states.h"
18 #include "sw/modules/math/src/float/math.h"
19 #include "sw/modules/motor/src/float/motor.h"
20 #include "sw/modules/pi/src/float/pi.h"
21
22
23 // solutions
24
25
30
31
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37
38 // **************************************************************************
39 // the defines
40
41
44 #define CTRL_MAJOR_RELEASE_NUMBER (2u)
45
46
49 #define CTRL_MINOR_RELEASE_NUMBER (0u)
50
51
54 #define CTRL_NUM_CONTROLLERS (2)
55
56
57 // **************************************************************************
58 // the typedefs
59
62 typedef enum
63 {
64 CTRL_ErrorCode_NoError=0,
65 CTRL_ErrorCode_IdClip,
66 CTRL_ErrorCode_EstError,
67 CTRL_numErrorCodes
68 } CTRL_ErrorCode_e;
69
70
73 typedef enum
74 {
75 CTRL_TargetProc_2806x=0,
76 CTRL_TargetProc_2805x,
77 CTRL_TargetProc_2803x,
78 CTRL_TargetProc_2802x
79 } CTRL_TargetProc_e;
80
81
84 typedef enum
85 {
86 CTRL_Type_PI_spd=0,
87 CTRL_Type_PI_Id,
88 CTRL_Type_PI_Iq
89 } CTRL_Type_e;
90
91
94 typedef struct _CTRL_Version_
95 {
96 uint16_t rsvd;
97 uint16_t targetProc;
98 uint16_t major;
99 uint16_t minor;
100 } CTRL_Version;
101
102
105 typedef struct _CTRL_Obj_
106 {
107 CTRL_Version version;
108
109 CTRL_State_e state;
110
111 CTRL_State_e prevState;
112
113 CTRL_ErrorCode_e errorCode;
114
115 PI_Handle piHandle_Id;
116 PI_Obj pi_Id;
117
118 PI_Handle piHandle_Iq;
119 PI_Obj pi_Iq;
120
121 PI_Handle piHandle_spd;
122 PI_Obj pi_spd;
123
124 MOTOR_Params motorParams;
125
126 int_least32_t waitTimes[CTRL_numStates];
127
128 int_least32_t counter_state;
129
130 int_least16_t numIsrTicksPerCtrlTick;
131
132 int_least16_t numCtrlTicksPerCurrentTick;
133
134 int_least16_t numCtrlTicksPerSpeedTick;
135
136 float_t ctrlFreq_Hz;
137
138 float_t ctrlPeriod_sec;
139 float_t currentCtrlPeriod_sec;
140 float_t speedCtrlPeriod_sec;
141
142 MATH_vec2 Idq_A;
143
144 MATH_vec2 Idq_ref_A;
145
146 MATH_vec2 Idq_offset_A;
147
148 MATH_vec2 Vdq_V;
149
150 MATH_vec2 Vdq_offset_V;
151
152 float_t Vd_sf;
153
154 float_t maxVsMag_V;
155
156 float_t Kp_Id_VpA;
157 float_t Kp_Iq_VpA;
158 float_t Kp_spd_ApHz;
159
160 float_t Ki_Id;
161 float_t Ki_Iq;
162 float_t Ki_spd_ApHz;
163
164 float_t Ui_Id_V;
165 float_t Ui_Iq_V;
166 float_t Ui_spd_A;
167
168 float_t BWc_rps;
169 float_t BWdelta;
170 float_t Kctrl_Wb_p_kgm2;
171
172 float_t speed_ref_Hz;
173
174 float_t speed_fb_Hz;
175
176 float_t speed_out_A;
177 float_t speed_outMax_A;
178 float_t speed_outMin_A;
179
180 int_least16_t counter_isr;
181 int_least16_t counter_current;
182 int_least16_t counter_speed;
183
184 bool flag_enable;
185 bool flag_enableCurrentCtrl;
186 bool flag_enableSpeedCtrl;
187
188 bool flag_resetInt_spd;
189 bool flag_resetInt_Id;
190 bool flag_resetInt_Iq;
191
192 bool flag_useZeroIq_ref;
193 } CTRL_Obj;
194
195
198 typedef struct _CTRL_Obj_ *CTRL_Handle;
199
200
201 // **************************************************************************
202 // the globals
203
204
205 // **************************************************************************
206 // the function prototypes
207
208
209 #ifdef __cplusplus
210 }
211 #endif // extern "C"
212
214
215 #endif // end of _CTRL_OBJ_H_ definition
216
CTRL_Type_PI_spd
PI Speed controller.
Definition: float/ctrl_obj.h:86
_CTRL_Obj_::speed_outMin_A
float_t speed_outMin_A
the minimum output value for the speed controller, A
Definition: float/ctrl_obj.h:178
_CTRL_Version_
Defines the controller (CTRL) version number.
Definition: 32b/ctrl_obj.h:131
_CTRL_Obj_::errorCode
CTRL_ErrorCode_e errorCode
the error code for the controller
Definition: 32b/ctrl_obj.h:152
_CTRL_Obj_::speedCtrlPeriod_sec
float_t speedCtrlPeriod_sec
the period at which the speed controller runs, sec
Definition: float/ctrl_obj.h:140
types.h
Contains the public interface to the types definitions.
_CTRL_Obj_::flag_enable
bool flag_enable
a flag to enable the controller
Definition: float/ctrl_obj.h:184
_CTRL_Obj_::Idq_offset_A
MATH_vec2 Idq_offset_A
the Idq offset values, A
Definition: float/ctrl_obj.h:146
_CTRL_Obj_::counter_isr
int_least16_t counter_isr
the isr counter
Definition: float/ctrl_obj.h:180
ctrl_states.h
_CTRL_Obj_::maxVsMag_V
float_t maxVsMag_V
the maximum stator voltage magnitude value, V
Definition: float/ctrl_obj.h:154
_CTRL_Obj_::counter_speed
int_least16_t counter_speed
the speed counter
Definition: float/ctrl_obj.h:182
_CTRL_Obj_::currentCtrlPeriod_sec
float_t currentCtrlPeriod_sec
the period at which the current controller runs, sec
Definition: float/ctrl_obj.h:139
_CTRL_Obj_::numCtrlTicksPerCurrentTick
int_least16_t numCtrlTicksPerCurrentTick
Defines the number of controller clock ticks per current controller clock tick.
Definition: float/ctrl_obj.h:132
_PI_Obj_
Defines the PI controller object.
Definition: 32b/pi.h:74
_CTRL_Obj_::piHandle_Id
PI_Handle piHandle_Id
the handle for the Id PI controller
Definition: float/ctrl_obj.h:115
_CTRL_Obj_::Ui_spd_A
float_t Ui_spd_A
the start integrator value for the speed controller, A
Definition: float/ctrl_obj.h:166
_CTRL_Obj_::Ki_spd_ApHz
float_t Ki_spd_ApHz
the desired Ki_spd value, A/Hz
Definition: float/ctrl_obj.h:162
math.h
Contains the public interface to the math (MATH) module routines.
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
CTRL_numStates
the number of controller states
Definition: ctrl_states.h:39
_CTRL_Obj_::Vd_sf
float_t Vd_sf
the Vd scale factor
Definition: float/ctrl_obj.h:152
_CTRL_Obj_::Ui_Id_V
float_t Ui_Id_V
the start integrator value for the Id controller, V
Definition: float/ctrl_obj.h:164
_CTRL_Version_::major
uint16_t major
the major release number
Definition: 32b/ctrl_obj.h:135
_CTRL_Obj_::Kctrl_Wb_p_kgm2
float_t Kctrl_Wb_p_kgm2
the controller constant, Wb/(kg*m^2)
Definition: float/ctrl_obj.h:170
_CTRL_Obj_::flag_resetInt_Id
bool flag_resetInt_Id
a flag to reset the Id integrator
Definition: float/ctrl_obj.h:189
CTRL_TargetProc_2803x
2803x processor
Definition: float/ctrl_obj.h:77
CTRL_ErrorCode_e
CTRL_ErrorCode_e
Enumeration for the error codes.
Definition: float/ctrl_obj.h:62
_CTRL_Obj_::ctrlPeriod_sec
float_t ctrlPeriod_sec
Defines the controller period, sec.
Definition: 32b/ctrl_obj.h:209
_CTRL_Obj_
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
_CTRL_Obj_::flag_resetInt_spd
bool flag_resetInt_spd
a flag to reset the speed integrator
Definition: float/ctrl_obj.h:188
_CTRL_Obj_::pi_Id
PI_Obj pi_Id
the Id PI controller object
Definition: float/ctrl_obj.h:116
CTRL_ErrorCode_EstError
estimator error code
Definition: float/ctrl_obj.h:66
_CTRL_Obj_::piHandle_Iq
PI_Handle piHandle_Iq
the handle for the Iq PI controller
Definition: float/ctrl_obj.h:118
CTRL_TargetProc_e
CTRL_TargetProc_e
Enumeration for the target processors.
Definition: float/ctrl_obj.h:73
CTRL_Version
struct _CTRL_Version_ CTRL_Version
Defines the controller (CTRL) version number.
_CTRL_Obj_::flag_resetInt_Iq
bool flag_resetInt_Iq
a flag to reset the Iq integrator
Definition: float/ctrl_obj.h:190
_CTRL_Obj_::flag_enableCurrentCtrl
bool flag_enableCurrentCtrl
a flag to enable the current controllers
Definition: 32b/ctrl_obj.h:277
CTRL_Obj
struct _CTRL_Obj_ CTRL_Obj
Defines the controller (CTRL) object.
_CTRL_Obj_::counter_current
int_least16_t counter_current
the isr counter
Definition: float/ctrl_obj.h:181
_CTRL_Obj_::speed_out_A
float_t speed_out_A
the output value from the speed controller, A
Definition: float/ctrl_obj.h:176
_CTRL_Obj_::ctrlFreq_Hz
float_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: float/ctrl_obj.h:136
CTRL_Type_PI_Iq
PI Iq controller.
Definition: float/ctrl_obj.h:88
_CTRL_Obj_::state
CTRL_State_e state
the current state of the controller
Definition: 32b/ctrl_obj.h:148
_CTRL_Version_::rsvd
uint16_t rsvd
reserved value
Definition: 32b/ctrl_obj.h:133
CTRL_numErrorCodes
the number of controller error codes
Definition: float/ctrl_obj.h:67
_CTRL_Obj_::prevState
CTRL_State_e prevState
the previous state of the controller
Definition: 32b/ctrl_obj.h:150
_CTRL_Obj_::Kp_Id_VpA
float_t Kp_Id_VpA
the desired Kp_Id value, V/A
Definition: float/ctrl_obj.h:156
_CTRL_Obj_::BWdelta
float_t BWdelta
the bandwidth scaling to maximize phase margin
Definition: float/ctrl_obj.h:169
_CTRL_Obj_::numIsrTicksPerCtrlTick
int_least16_t numIsrTicksPerCtrlTick
Defines the number of isr clock ticks per controller clock tick.
Definition: float/ctrl_obj.h:130
_CTRL_Obj_::Vdq_offset_V
MATH_vec2 Vdq_offset_V
the Vdq offset values, V
Definition: float/ctrl_obj.h:150
_CTRL_Obj_::waitTimes
uint_least32_t waitTimes[CTRL_numStates]
an array of wait times for each state, estimator clock counts
Definition: 32b/ctrl_obj.h:191
CTRL_State_e
CTRL_State_e
Enumeration for the controller states.
Definition: ctrl_states.h:34
_CTRL_Obj_::speed_outMax_A
float_t speed_outMax_A
the maximum output value for the speed controller, A
Definition: float/ctrl_obj.h:177
_CTRL_Obj_::motorParams
MOTOR_Params motorParams
the motor parameters
Definition: 32b/ctrl_obj.h:189
_CTRL_Obj_::speed_fb_Hz
float_t speed_fb_Hz
the feedback speed value, Hz
Definition: float/ctrl_obj.h:174
_CTRL_Obj_::version
CTRL_Version version
the controller version
Definition: 32b/ctrl_obj.h:146
CTRL_ErrorCode_IdClip
Id clip error code.
Definition: float/ctrl_obj.h:65
CTRL_ErrorCode_NoError
no error error code
Definition: float/ctrl_obj.h:64
_CTRL_Obj_::Ui_Iq_V
float_t Ui_Iq_V
the start integrator value for the Iq controller, V
Definition: float/ctrl_obj.h:165
CTRL_Type_e
CTRL_Type_e
Enumeration for the controller (CTRL) types.
Definition: float/ctrl_obj.h:84
_CTRL_Obj_::flag_useZeroIq_ref
bool flag_useZeroIq_ref
a flag to force a Iq = 0 reference value
Definition: float/ctrl_obj.h:192
_CTRL_Obj_::pi_spd
PI_Obj pi_spd
the speed PI controller object
Definition: float/ctrl_obj.h:122
_CTRL_Obj_::Kp_spd_ApHz
float_t Kp_spd_ApHz
the desired Kp_spd value, A/Hz
Definition: float/ctrl_obj.h:158
_CTRL_Obj_::speed_ref_Hz
float_t speed_ref_Hz
the reference speed value, Hz
Definition: float/ctrl_obj.h:172
_CTRL_Obj_::Ki_Id
float_t Ki_Id
the desired Ki_Id value, unitless
Definition: float/ctrl_obj.h:160
_CTRL_Obj_::Vdq_V
MATH_vec2 Vdq_V
the Vdq values, V
Definition: float/ctrl_obj.h:148
CTRL_TargetProc_2805x
2805x processor
Definition: float/ctrl_obj.h:76
_CTRL_Obj_::counter_state
int_least32_t counter_state
the state counter
Definition: float/ctrl_obj.h:128
CTRL_TargetProc_2802x
2802x processor
Definition: float/ctrl_obj.h:78
_CTRL_Obj_::Idq_A
MATH_vec2 Idq_A
the Idq values, A
Definition: float/ctrl_obj.h:142
_CTRL_Obj_::BWc_rps
float_t BWc_rps
the bandwidth of the current controllers, rad/sec
Definition: float/ctrl_obj.h:168
_CTRL_Version_::targetProc
uint16_t targetProc
the target processor
Definition: float/ctrl_obj.h:97
_CTRL_Version_::minor
uint16_t minor
the minor release number
Definition: 32b/ctrl_obj.h:136
pi.h
Contains the public interface to the Proportional-Integral (PI) controller module routines...
_MOTOR_Params_
Defines the motor parameters.
Definition: 32b/motor.h:80
_CTRL_Obj_::piHandle_spd
PI_Handle piHandle_spd
the handle for the speed PI controller
Definition: float/ctrl_obj.h:121
motor.h
_CTRL_Obj_::pi_Iq
PI_Obj pi_Iq
the Iq PI controller object
Definition: float/ctrl_obj.h:119
CTRL_TargetProc_2806x
2806x processor
Definition: float/ctrl_obj.h:75
_CTRL_Obj_::Kp_Iq_VpA
float_t Kp_Iq_VpA
the desired Kp_Iq value, V/A
Definition: float/ctrl_obj.h:157
CTRL_Handle
struct _CTRL_Obj_ * CTRL_Handle
Defines the CTRL handle.
Definition: float/ctrl_obj.h:198
_CTRL_Obj_::Ki_Iq
float_t Ki_Iq
the desired Ki_Iq value, unitless
Definition: float/ctrl_obj.h:161
_CTRL_Obj_::flag_enableSpeedCtrl
bool flag_enableSpeedCtrl
a flag to enable the speed controller
Definition: 32b/ctrl_obj.h:267
CTRL_Type_PI_Id
PI Id controller.
Definition: float/ctrl_obj.h:87
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
_CTRL_Obj_::numCtrlTicksPerSpeedTick
int_least16_t numCtrlTicksPerSpeedTick
Defines the number of controller clock ticks per speed controller clock tick.
Definition: float/ctrl_obj.h:134
_CTRL_Obj_::Idq_ref_A
MATH_vec2 Idq_ref_A
the Idq reference values, A
Definition: float/ctrl_obj.h:144