Toolbox for a standard CurrentControl with parallel PI-Controllers, linear decoupling and a space vector limitation. A space vector output limitation and a linear decoupling function are integrated. The decoupling function can be deactivated in the CurrentControl configuration struct.

Figure made with TikZ

Fig. 59 CurrentControl schematic



In order to configure the CurrentControl, multiple configuration structs have to be initialized.

enum uz_CurrentControl_decoupling_select

enum for readable configuring for the decoupling in the CurrentControl sample function


enumerator no_decoupling
enumerator linear_decoupling
struct uz_CurrentControl_config

Configuration struct for CurrentControl. Accessible by the user.

Public Members

enum uz_CurrentControl_decoupling_select decoupling_select

CurrentControl decoupling selector



struct uz_PI_Controller_config config_id

Configuration struct for id-Controller

struct uz_PI_Controller_config config_iq

Configuration struct for iq-Controller

uz_PMSM_t config_PMSM

Configuration struct for PMSM parameters

float max_modulation_index

Max possible modulation index for the chosen modulation method. I.e. 1/sqrt(3) for Space-Vector-Modulation


Listing 41 Example to initialize the configuration struct
 1#include "uz/uz_CurrentControl/uz_CurrentControl.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   };
13   struct uz_PI_Controller_config config_iq = {
14      .Kp = 10.0f,
15      .Ki = 10.0f,
16      .samplingTime_sec = 0.00005f
17   };
18   struct uz_CurrentControl_config CC_config = {
19      .decoupling_select = linear_decoupling,
20      .config_PMSM = config_PMSM,
21      .config_id = config_id,
22      .config_iq = config_iq,
23      .max_modulation_index = 1.0f / sqrtf(3.0f)
24   };


The limitation of the internal PI-Controllers are deactivated, since only the Space vector limitation will be used. The limits can be left at 0 in the config.


With these config structs one can customize the CurrentControl and the included PI-Controller and PMSM config. It is possible to use the CurrentControl with or without the linear decoupling via the CurrentControl_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

typedef struct uz_CurrentControl_t uz_CurrentControl_t

Object definition for CurrentControl.

uz_CurrentControl_t *uz_CurrentControl_init(struct uz_CurrentControl_config config)

Initialization of the uz_CurrentControl object.

  • config – configuration struct for CurrentControl


uz_CurrentControl_t* Pointer to uz_CurrentControl_t instance


Listing 42 Example function call to init a CurrentControl instance. config_CurrentControl according to configuration section
1int main(void) {
2   uz_CurrentControl_t* CC_instance = uz_CurrentControl_init(CC_config);


Allocates the memory for the CurrentControl instance and the included PI-Controller instances. Furthermore the input values of the configuration structs are asserted.


void uz_CurrentControl_reset(uz_CurrentControl_t *self)

Resets the CurrentControl and the integrators of the PI-Controllers.

  • self – uz_CurrentControl_t instance


Listing 43 Example function call to reset the CurrentControl. CurrentControl-Instance via init-function
1int main(void) {
2   uz_CurrentControl_reset(CC_instance);


Resets the CurrentControl and the integrated PI-Controller. The initial condition for the integrator after the reset is 0.0f.