Speed Control

Toolbox for a standard SpeedControl with a PI-Controller in parallel form. It outputs only the reference currents for the FOC. Other control algorithms can be used as well. It can not control a machine on its own.

Setup

typedef struct uz_SpeedControl_t uz_SpeedControl_t

Object definition for uz_SpeedControl_t.

Configuration

struct uz_SpeedControl_config

Configuration struct for SpeedControl. Accessible by the user.

Public Members

bool enable_field_weakening

flag to enable field_weaking

struct uz_PI_Controller_config config_controller

Configuration struct for speed-Controller

In order to configure the SpeedControl check the configuration section of the PI-Controller for further information. If field_weakening is to be used, some values of the uz_PMSM_t struct have to be initialized as well. Otherwise they can be left zero.

Example

Listing 67 Example function call for configuration
 1#include "uz/uz_SpeedControl/uz_speedcontrol.h"
 2int main(void) {
 3   struct uz_SpeedControl_config config = {
 4      .config_controller.Kp = 10.0f,
 5      .config_controller.Ki = 10.0f,
 6      .config_controller.samplingTime_sec = 0.00005f,
 7      .config_controller.upper_limit = 10.0f,
 8      .config_controller.lower_limit = -10.0f,
 9      .enable_field_weakening = false
10   };
11   struct uz_PMSM_t config_PMSM = {
12      .R_ph_Ohm = 0.08f,
13      .Ld_Henry = 0.00027f,
14      .Lq_Henry = 0.00027f,
15      .Psi_PM_Vs = 0.0082f,
16      .polePairs = 4.0f,
17      .I_max_Ampere = 10.0f
18   };
19}

Init function

uz_SpeedControl_t *uz_SpeedControl_init(struct uz_SpeedControl_config config)

Initialization of the SpeedController object.

Parameters
  • config – uz_SpeedControl_config configuration struct

Returns

Pointer to uz_SpeedControl_t object

Example

Listing 68 Example function call to init a PI-Controller for the SpeedControl. config according to configuration section
1#include "uz/uz_SpeedControl/uz_speedcontrol.h"
2int main(void) {
3   uz_SpeedControl_t* instance = uz_SpeedControl_init(config);
4}

Description

Allocates the memory for the SpeedControl instance. Furthermore the input values of the configuration struct are asserted.

Reset

void uz_SpeedControl_reset(uz_SpeedControl_t *self)

Resets the PI-Controller inside the uz_SpeedControl_t.

Parameters
  • self – pointer to uz_SpeedControl_t object

Example

Listing 69 Example function call to reset the SpeedControl. PI-Controller instance via init-function
1int main(void) {
2   uz_SpeedControl_reset(instance);
3}

Description

Resets the PI-Controller of the SpeedControl. The initial condition for the integrator after the reset is 0.0f.

Functions