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 is_field_weakening_active

flag to enable field_weaking

uz_PMSM_t config_PMSM

PMSM struct which carries necessary motor related parameters for field weakening

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 76 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      .config_PMSM.R_ph_Ohm = 0.08f,
10      .config_PMSM.Ld_Henry = 0.00027f,
11      .config_PMSM.Lq_Henry = 0.00027f,
12      .config_PMSM.Psi_PM_Vs = 0.0082f,
13      .config_PMSM.polePairs = 4.0f,
14      .config_PMSM.I_max_Ampere = 10.0f,
15      .is_field_weakening_active = false
16   };
17}

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 77 Example function call to init the SpeedController for the SpeedControl. config according to configuration section
1int main(void) {
2   uz_SpeedControl_t* instance = uz_SpeedControl_init(config);
3}

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 78 Example function call to reset the SpeedControl. SpeedControl 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