Field Oriented Control (FOC)
Toolbox for a standard FOC with parallel PI-Controllers, linear decoupling and a space vector limitation.
Setup
Configuration
In order to configure the FOC, multiple configuration structs have to be initialized.
-
enum uz_FOC_decoupling_select
enum for readable configuring for the decoupling in the FOC sample function
Values:
-
enumerator no_decoupling
-
enumerator linear_decoupling
-
enumerator no_decoupling
-
struct uz_FOC_config
Configuration struct for FOC. Accessible by the user.
Public Members
-
enum uz_FOC_decoupling_select decoupling_select
FOC decoupling selector
0 = no_decoupling
1 = linear_decoupling
-
struct uz_PI_Controller_config config_id
Configuration struct for id-Controller
-
struct uz_PI_Controller_config config_iq
Configuration struct for iq-Controller
-
enum uz_FOC_decoupling_select decoupling_select
Example
1#include "uz/uz_FOC/uz_FOC.h"
2int main(void) {
3 struct uz_PMSM_t config_PMSM = {
4 .Ld_Henry = 0.0001f,
5 .Lq_Henry = 0.0002f,
6 .Psi_PM_Vs = 0.008f
7 };//these parameters are only needed if linear decoupling is selected
8 struct uz_PI_Controller_config config_id = {
9 .Kp = 10.0f,
10 .Ki = 10.0f,
11 .samplingTime_sec = 0.00005f,
12 .upper_limit = 10.0f,
13 .lower_limit = -10.0f
14 };
15 struct uz_PI_Controller_config config_iq = {
16 .Kp = 10.0f,
17 .Ki = 10.0f,
18 .samplingTime_sec = 0.00005f,
19 .upper_limit = 10.0f,
20 .lower_limit = -10.0f
21 };
22 struct uz_FOC_config config_FOC = {
23 .decoupling_select = linear_decoupling,
24 .config_PMSM = config_PMSM,
25 .config_id = config_id,
26 .config_iq = config_iq
27 };
28}
Description
With these config structs one can customize the FOC and the included PI-Controller and PMSM config.
It is possible to use the FOC with or without the linear decoupling via the FOC_config member decoupling_select
.
If no decoupling is selected, no variables for the struct uz_PMSM_t
have to be configured and can be left 0.
Each of the two PI-Controller need their own config struct.
One for the id-Controller and the other one for the iq-Controller.
Init function
-
uz_FOC *uz_FOC_init(struct uz_FOC_config config)
Initialization of the uz_FOC object.
- Parameters
config – configuration struct for FOC
- Returns
uz_FOC* Pointer to uz_FOC instance
Example
config_FOC
according to configuration section1int main(void) {
2 uz_FOC* FOC_instance = uz_FOC_init(config_FOC);
3}
Description
Allocates the memory for the FOC instance and the included PI-Controller instances. Furthermore the input values of the configuration structs are asserted.
Reset
-
void uz_FOC_reset(uz_FOC *self)
Resets the FOC and the integrators of the PI-Controllers.
- Parameters
self – uz_FOC instance
Example
1int main(void) {
2 uz_FOC_reset(FOC_instance);
3}
Description
Resets the FOC and the integrated PI-Controller. The initial condition for the integrator after the reset is 0.0f.