Control.h File Reference
Useful routines for AC machines control.
More...
#include "Utils.h"
#include "QDOperations.h"
#include "FilterAndRotations.h"
#include "DataStorage.h"
Go to the source code of this file.
Data Structures |
struct | VHzConfiguration |
| storing of V/Hz control More...
|
struct | CommandsData |
| command configuration More...
|
struct | CommandGeneratorCfg |
| command generator configuration More...
|
struct | CubicCommandsData |
| For implementing Y=a*X^3+b*X^2+c*X+d;. More...
|
Defines |
#define | MAX_COMMANDS 10 |
#define | RealizableReference(ref, meass, error, controlAction, maxControlAction, kp, ki) |
#define | RealizableReferenceQD(ref, meass, error, controlAction, maxControlAction, kp, ki) |
Typedefs |
typedef struct CommandsData | commandsData |
typedef struct CommandGeneratorCfg | _commandGeneratorCfg |
typedef struct CubicCommandsData | _cubiccommandsData |
Functions |
void | InitVHz (_iq vbus, _iq fmax, _iq ts) |
static void | VHz (_iq F, volatile _iq *vas, volatile _iq *vbs, volatile _iq *vcs) |
static void | HomopolarInjection (volatile _iq *vas, volatile _iq *vbs, volatile _iq *vcs) |
static int | RegisterCommand (_iq vbegin, _iq vend, _iq tUS, volatile _iq *command, commandsData **commandData, void(*CommandFcn)(struct CommandsData *command), void *extra) |
static void | StartCommands (void) |
| Start all the commands. It sets the start bit and the initial value of the variable to vbegin.
|
static void | StartCommand (struct CommandsData *command) |
static void | SetCommand (struct CommandsData *command, _iq vbegin, _iq vend) |
static void | ConfigureCommandGenerator (_iq schedPeriodUS, _iq error) |
static void | StartCommandGenerator (void) |
static void | UpdateCommands (void) |
| Update commands by calling the CommandFcn set during the configuration process.
|
static void | UpdateCommand (struct CommandsData *command) |
static int | IsValue (struct CommandsData *command, _iq value, _iq error) |
static int | IsFinalValue (struct CommandsData *command, _iq error) |
static void | RampCommandFcn (struct CommandsData *command) |
static void | SCommandFcn (struct CommandsData *command) |
static void | SConfigFcn (struct CommandsData *command, void *extra) |
static void | CubicCommandFcn (struct CommandsData *command) |
static void | CubicConfigFcn (struct CommandsData *command, void *extra, _iq derBegin, _iq derEnd) |
Variables |
struct VHzConfiguration | vhzConf |
_commandGeneratorCfg | commandGeneratorCfg |
commandsData | commands [MAX_COMMANDS] |
Detailed Description
Useful routines for AC machines control.
File Name : Control.h Project : TIMotorLIB TI Doc: na
- Author:
- Pablo Garcia (pgarcia@isa.uniovi.es) Islam ElSayed (islam@isa.uniovi.es)
This module includes routines related to control of AC machines, although is intended to be extended by any general control algorithms useful for control or power converters. Implemented algorithms are:
- 3ph V/Hz generation.
- generic command shaping.
- realizable references.
- Date:
- 2007
Definition in file Control.h.
Define Documentation
#define RealizableReference |
( |
ref, |
|
|
meass, |
|
|
error, |
|
|
controlAction, |
|
|
maxControlAction, |
|
|
kp, |
|
|
ki |
|
) |
|
Value:{\
if(_IQabs(controlAction[N])>= maxControlAction ){\
controlAction[N] = _IQmpy(maxControlAction,_IQ(SIGN(controlAction[N])));\
INV_PI_REG(error,controlAction,kp,ki);\
}\
}
Realizable references for data variables. Control action is saturated to maxControlAction
- Parameters:
-
| ref | pointer to actual controller reference |
| meass | meassured variable |
| error | pointer to actual controller input error |
| controlAction | pointer to actual control action |
| maxControlAction | maximum allowed control action |
| kp | proportional gain of the controller |
| ki | integral gain of the controller Realizable references for data variables. Control action is saturated to maxControlAction |
| ref | pointer to actual controller reference |
| meass | meassured variable |
| error | pointer to actual controller input error |
| controlAction | pointer to actual control action |
| maxControlAction | maximum allowed control action |
| kp | proportional gain of the controller |
| ki | integral gain of the controller |
- Note:
- This macro can not be implemted as a static inline function because compiler is not inlining it.
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 565 of file Control.h.
#define RealizableReferenceQD |
( |
ref, |
|
|
meass, |
|
|
error, |
|
|
controlAction, |
|
|
maxControlAction, |
|
|
kp, |
|
|
ki |
|
) |
|
Value:Realizable references for dq variables. Control action vector is saturated to maxControlAction by saturating the magnitude and keeping the same phase.
- Parameters:
-
| ref | pointer to actual controller reference |
| meass | meassured variable |
| error | pointer to actual controller input error |
| controlAction | pointer to actual control action |
| maxControlAction | maximum allowed control action |
| kp | proportional gain of the controller |
| ki | integral gain of the controller Realizable references for dq variables. Control action vector is saturated to maxControlAction by saturating the magnitude and keeping the same phase (minimum phase distortion LIM). |
| ref | pointer to actual controller reference |
| meass | meassured variable |
| error | pointer to actual controller input error |
| controlAction | pointer to actual control action |
| maxControlAction | maximum allowed control action |
| kp | proportional gain of the controller |
| ki | integral gain of the controller |
- Note:
- This macro can not be implemted as a static inline function because compiler is not inlining it.
Definition at line 619 of file Control.h.
Typedef Documentation
Function Documentation
static void ConfigureCommandGenerator |
( |
_iq |
schedPeriodUS, |
|
|
_iq |
error | |
|
) |
| | [inline, static] |
Configure command generator by reseting the ncommand variable and seting the period for the command evaluation
- Parameters:
-
| schedPeriodUS | Period for command calculation in us. |
| error | Maximum allowed command error |
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 319 of file Control.h.
static void CubicCommandFcn |
( |
struct CommandsData * |
command |
) |
[inline, static] |
Implement cubic function Y=a*X^3+b*X^2+c*X+d; with given derivatives at begin and end.
- Parameters:
-
| command | pointer to structure of type commandsData |
Definition at line 470 of file Control.h.
static void CubicConfigFcn |
( |
struct CommandsData * |
command, |
|
|
void * |
extra, |
|
|
_iq |
derBegin, |
|
|
_iq |
derEnd | |
|
) |
| | [inline, static] |
calculate cubic function constants. d=y1; c=d1; a=(y2-y1-d1*x2-(d2*x2)/2+(d1*x2)/2)/(-0.5*x2^3); b=(d2-d1-3*a*x2^2)/(2*x2);
- Parameters:
-
| command | pointer to structure of type commandsData |
| extra | pointer to structure of type CubicCommandsData |
| derBegin | at begin] |
| derEnd | at end] |
Definition at line 499 of file Control.h.
static void HomopolarInjection |
( |
volatile _iq * |
vas, |
|
|
volatile _iq * |
vbs, |
|
|
volatile _iq * |
vcs | |
|
) |
| | [inline, static] |
Hompolar harmonic injection: "Current and Flux Regulation in Field-Weakening Operation", Fernando Briz, Alberto Diez, Michael W. Degner, Robert D. Lorenz IEEE Trans.Ind. App., Vo, 37, N 1, Jan/Feb 2001
- Parameters:
-
| *vas,: | pointer to phase a voltage |
| *vbs,: | pointer to phase b voltage |
| *vcs,: | pointer to phase c voltage |
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 207 of file Control.h.
void InitVHz |
( |
_iq |
vbus, |
|
|
_iq |
fmax, |
|
|
_iq |
ts | |
|
) |
| | |
Configure V/Hz control.
- Parameters:
-
| vbus,: | bus voltage (V) |
| fmax,: | max frequency (Hz) |
| ts,: | sample time (s) |
Definition at line 28 of file Control.c.
static int IsFinalValue |
( |
struct CommandsData * |
command, |
|
|
_iq |
error | |
|
) |
| | [inline, static] |
Indicate where a command has reached the final value within an error
- Parameters:
-
| command | pointer to the registered command in the configuration structure |
| error | distance to the final value |
- Returns:
- 1 if final value is reached, 0 otherwise
Definition at line 390 of file Control.h.
static int IsValue |
( |
struct CommandsData * |
command, |
|
|
_iq |
value, |
|
|
_iq |
error | |
|
) |
| | [inline, static] |
Indicate where a command has reached a value within an error
- Parameters:
-
| command | pointer to the registered command in the configuration structure |
| value | |
| error | distance to the final value |
- Returns:
- 1 if final value is reached, 0 otherwise
Definition at line 377 of file Control.h.
static void RampCommandFcn |
( |
struct CommandsData * |
command |
) |
[inline, static] |
Generate ramp command
- Parameters:
-
| command | pointer to command variable |
command->command += _IQdiv(_IQmpy((command->vend-command->vbegin), commandGeneratorCfg.schedPeriodUS), command->tUS);
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 401 of file Control.h.
static int RegisterCommand |
( |
_iq |
vbegin, |
|
|
_iq |
vend, |
|
|
_iq |
tUS, |
|
|
volatile _iq * |
command, |
|
|
commandsData ** |
commandData, |
|
|
void(*)(struct CommandsData *command) |
CommandFcn, |
|
|
void * |
extra | |
|
) |
| | [inline, static] |
Register a new command.
- Parameters:
-
| vbegin | Initial value for the command |
| vend | Final value for the command |
| tUS | Time constant for the trajectory |
| command | Variable to be modified by the command trajectory |
| commandData | pointer to the registered command in the configuration structure |
| CommandFcn | Function pointer to the desired trajectory generator |
| extra | (optional) parameters required for command execution |
RETURNS:
- Returns:
- -1 if MAX_COMMANDS have been previously registered, 0 otherwise
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 242 of file Control.h.
static void SCommandFcn |
( |
struct CommandsData * |
command |
) |
[inline, static] |
Implement spline function Y=a*X^3+b*X^2+c*X+d; in case of the derivative at begin and end are equal to zero.
- Parameters:
-
| command | pointer to structure of type commandsData |
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 417 of file Control.h.
static void SConfigFcn |
( |
struct CommandsData * |
command, |
|
|
void * |
extra | |
|
) |
| | [inline, static] |
calculate spline function constants in the case of derivatives at begin and end are equal to zero. d=y1; c=d1=0; a=(y2-y1)/(-0.5*x2^3); b=(-3*a*x2)/2;
- Parameters:
-
| command | pointer to structure of type commandsData |
| extra | pointer to structure of type CubicCommandsData |
Definition at line 446 of file Control.h.
static void SetCommand |
( |
struct CommandsData * |
command, |
|
|
_iq |
vbegin, |
|
|
_iq |
vend | |
|
) |
| | [inline, static] |
Restarts a command. It sets the start bit and the initial value of the variable to vbegin
- Parameters:
-
| command | pointer to the registered command in the configuration structure |
| vbegin | initial value |
| vend | final value |
Definition at line 300 of file Control.h.
static void StartCommand |
( |
struct CommandsData * |
command |
) |
[inline, static] |
Start a command. It sets the start bit and the initial value of the variable to vbegin
- Parameters:
-
| command | pointer to the registered command in the configuration structure |
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 286 of file Control.h.
static void StartCommandGenerator |
( |
void |
|
) |
[inline, static] |
Start command generator by modifying the ISR of the selected timer
- Deprecated:
Definition at line 332 of file Control.h.
static void StartCommands |
( |
void |
|
) |
[inline, static] |
Start all the commands. It sets the start bit and the initial value of the variable to vbegin.
Definition at line 271 of file Control.h.
static void UpdateCommand |
( |
struct CommandsData * |
command |
) |
[inline, static] |
Update command by calling the CommandFcn set during the configuration process
- Parameters:
-
| command | pointer to the registered command in the configuration structure |
- Examples:
- TIMotorLIBExampleSw/main.c.
Definition at line 355 of file Control.h.
static void UpdateCommands |
( |
void |
|
) |
[inline, static] |
Update commands by calling the CommandFcn set during the configuration process.
Definition at line 341 of file Control.h.
static void VHz |
( |
_iq |
F, |
|
|
volatile _iq * |
vas, |
|
|
volatile _iq * |
vbs, |
|
|
volatile _iq * |
vcs | |
|
) |
| | [inline, static] |
Variable Documentation