MotorWare f2806x Module API Documentation
Functions
float/ctrl.h File Reference

Contains public interface to various functions related to the controller (CTRL) object. More...

#include <math.h>
#include "sw/modules/types/src/types.h"
#include "sw/modules/ctrl/src/float/ctrl_obj.h"
#include "sw/modules/ctrl/src/ctrl_states.h"
#include "sw/modules/motor/src/float/motor.h"
#include "sw/modules/pi/src/float/pi.h"
#include "sw/modules/user/src/float/userParams.h"

Go to the source code of this file.

Functions

void CTRL_checkForErrors (CTRL_Handle handle)
 Checks for any controller errors and, if found, sets the controller state to the error state. More...
 
static void CTRL_computePhasor (const float_t angle_rad, MATH_vec2 *pPhasor)
 Computes a phasor for a given angle. More...
 
static void CTRL_disable (CTRL_Handle handle)
 Disables the controller. More...
 
static void CTRL_enable (CTRL_Handle handle)
 Enables the controller. More...
 
static float_t CTRL_getBWc_rps (CTRL_Handle handle)
 Gets the current controller bandwidth. More...
 
static float_t CTRL_getBWdelta (CTRL_Handle handle)
 Gets the bandwidth scale factor used to maximize phase margin. More...
 
static float_t CTRL_getKctrl_Wb_p_kgm2 (CTRL_Handle handle)
 Gets the speed controller constant. More...
 
static float_t CTRL_getVd_sf (CTRL_Handle handle)
 Gets the direct voltage scale factor. More...
 
static float_t CTRL_getMaxVsMag_V (CTRL_Handle handle)
 Gets the maximum stator voltage magnitude value. More...
 
static void CTRL_computeOutputLimits_Id (CTRL_Handle handle, float_t *outMin, float_t *outMax)
 Computes the Id controller output limits. More...
 
static void CTRL_computeOutputLimits_Iq (CTRL_Handle handle, const float_t Vd_out_V, float_t *outMin, float_t *outMax)
 Computes the Iq controller output limits. More...
 
uint_least16_t CTRL_getCount_current (CTRL_Handle handle)
 Gets the current loop count. More...
 
uint_least16_t CTRL_getCount_isr (CTRL_Handle handle)
 Gets the isr count. More...
 
uint_least16_t CTRL_getCount_speed (CTRL_Handle handle)
 Gets the speed loop count. More...
 
uint_least32_t CTRL_getCount_state (CTRL_Handle handle)
 Gets the state count. More...
 
static float_t CTRL_getCtrlFreq_Hz (CTRL_Handle handle)
 Gets the controller execution frequency. More...
 
static float_t CTRL_getCurrentCtrlPeriod_sec (CTRL_Handle handle)
 Gets the current controller period. More...
 
float_t CTRL_getCtrlPeriod_sec (CTRL_Handle handle)
 Gets the controller execution period. More...
 
CTRL_ErrorCode_e CTRL_getErrorCode (CTRL_Handle handle)
 Gets the error code from the controller (CTRL) object. More...
 
static bool CTRL_getFlag_enable (CTRL_Handle handle)
 Gets the enable controller flag value from the controller. More...
 
bool CTRL_getFlag_enableCurrentCtrl (CTRL_Handle handle)
 Gets the enable current controllers flag value from the controller. More...
 
bool CTRL_getFlag_enableSpeedCtrl (CTRL_Handle handle)
 Gets the enable speed control flag value from the controller. More...
 
static bool CTRL_getFlag_resetInt_Id (CTRL_Handle handle)
 Gets the reset Id integrator flag value from the controller. More...
 
static bool CTRL_getFlag_resetInt_Iq (CTRL_Handle handle)
 Gets the reset Iq integrator flag value from the controller. More...
 
static bool CTRL_getFlag_resetInt_spd (CTRL_Handle handle)
 Gets the reset speed integrator flag value from the controller. More...
 
static bool CTRL_getFlag_useZeroIq_ref (CTRL_Handle handle)
 Gets the use zero Iq reference flag value from the controller. More...
 
static float_t CTRL_getId_A (CTRL_Handle handle)
 Gets the direct current (Id) value from the controller. More...
 
static float_tCTRL_getId_A_addr (CTRL_Handle handle)
 Gets the direct current (Id) memory address from the controller. More...
 
static float_t CTRL_getId_offset_A (CTRL_Handle handle)
 Gets the direct offset current (Id_offset) value from the controller. More...
 
static float_tCTRL_getId_offset_A_addr (CTRL_Handle handle)
 Gets the direct offset current (Id_offset) memory address from the controller. More...
 
static float_t CTRL_getId_ref_A (CTRL_Handle handle)
 Gets the direct reference current (Id_ref) value from the controller. More...
 
static float_tCTRL_getId_ref_A_addr (CTRL_Handle handle)
 Gets the direct reference current (Id_ref) memory address from the controller. More...
 
static void CTRL_getIdq_A (CTRL_Handle handle, MATH_vec2 *pIdq_A)
 Gets the direct/quadrature current vector values from the controller. More...
 
static MATH_vec2CTRL_getIdq_A_addr (CTRL_Handle handle)
 Gets the direct/quadrature current (Idq) vector memory address from the controller. More...
 
static void CTRL_getIdq_offset_A (CTRL_Handle handle, MATH_vec2 *pIdq_offset_A)
 Gets the direct/quadrature offset current (Idq_offset) vector values from the controller. More...
 
static MATH_vec2CTRL_getIdq_offset_A_addr (CTRL_Handle handle)
 Gets the direct/quadrature offset current (Idq_offset) vector memory address from the controller. More...
 
static void CTRL_getIdq_ref_A (CTRL_Handle handle, MATH_vec2 *pIdq_ref_A)
 Gets the direct/quadrature reference current (Idq_ref) vector values from the controller. More...
 
static MATH_vec2CTRL_getIdq_ref_A_addr (CTRL_Handle handle)
 Gets the direct/quadrature reference current (Idq_ref) vector memory address from the controller. More...
 
static float_t CTRL_getIq_A (CTRL_Handle handle)
 Gets the quadrature current (Iq) value from the controller. More...
 
static float_tCTRL_getIq_A_addr (CTRL_Handle handle)
 Gets the quadrature current (Iq) memory address from the controller. More...
 
static float_t CTRL_getIq_offset_A (CTRL_Handle handle)
 Gets the quadrature offset current (Iq_offset) value from the controller. More...
 
static float_tCTRL_getIq_offset_A_addr (CTRL_Handle handle)
 Gets the quadrature offset current (Iq_offset) memory address from the controller. More...
 
static float_t CTRL_getIq_ref_A (CTRL_Handle handle)
 Gets the quadrature reference current (Iq_ref) value from the controller. More...
 
static float_tCTRL_getIq_ref_A_addr (CTRL_Handle handle)
 Gets the quadrature reference current (Iq_ref) memory address from the controller. More...
 
_iq CTRL_getKi (CTRL_Handle handle, const CTRL_Type_e ctrlType)
 Gets the integral gain (Ki) value from the specified controller. More...
 
_iq CTRL_getKp (CTRL_Handle handle, const CTRL_Type_e ctrlType)
 Gets the proportional gain (Kp) value from the specified controller. More...
 
static void CTRL_getGains (CTRL_Handle handle, const CTRL_Type_e ctrlType, float_t *pKp, float_t *pKi)
 Gets the gain values for the specified controller. More...
 
MOTOR_Type_e CTRL_getMotorType (CTRL_Handle handle)
 Gets the motor type from the controller. More...
 
uint_least16_t CTRL_getNumCtrlTicksPerCurrentTick (CTRL_Handle handle)
 Gets the number of controller clock ticks per current controller clock tick. More...
 
uint_least16_t CTRL_getNumCtrlTicksPerSpeedTick (CTRL_Handle handle)
 Gets the number of controller clock ticks per speed controller clock tick. More...
 
uint_least16_t CTRL_getNumIsrTicksPerCtrlTick (CTRL_Handle handle)
 Gets the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick. More...
 
static float_t CTRL_getRefValue (CTRL_Handle handle, const CTRL_Type_e ctrlType)
 Gets the reference value from the specified controller. More...
 
static float_t CTRL_getSpeed_fb_Hz (CTRL_Handle handle)
 Gets the feedback speed value from the controller. More...
 
static float_t CTRL_getSpeed_out_A (CTRL_Handle handle)
 Gets the output value from the speed controller. More...
 
static float_tCTRL_getSpeed_out_A_addr (CTRL_Handle handle)
 Gets the output value memory address from the speed controller. More...
 
static float_t CTRL_getSpeed_outMax_A (CTRL_Handle handle)
 Gets the maximum value for the speed controller. More...
 
static float_t CTRL_getSpeed_outMin_A (CTRL_Handle handle)
 Gets the minimum value for the speed controller. More...
 
static float_t CTRL_getSpeed_ref_Hz (CTRL_Handle handle)
 Gets the output speed reference value from the controller. More...
 
static float_t CTRL_getSpeedCtrlPeriod_sec (CTRL_Handle handle)
 Gets the speed controller period. More...
 
CTRL_State_e CTRL_getState (CTRL_Handle handle)
 Gets the controller state. More...
 
_iq CTRL_getUi (CTRL_Handle handle, const CTRL_Type_e ctrlType)
 Gets the integrator (Ui) value from the specified controller. More...
 
static float_t CTRL_getVd_V (CTRL_Handle handle)
 Gets the direct voltage (Vd) value from the controller. More...
 
static float_tCTRL_getVd_V_addr (CTRL_Handle handle)
 Gets the direct voltage (Vd) value memory address from the controller. More...
 
static float_t CTRL_getVd_offset_V (CTRL_Handle handle)
 Gets the direct offset voltage (Vd_offset) value from the controller. More...
 
static float_tCTRL_getVd_offset_V_addr (CTRL_Handle handle)
 Gets the direct offset voltage (Vd_offset) value memory address from the controller. More...
 
static void CTRL_getVdq_V (CTRL_Handle handle, MATH_vec2 *pVdq_V)
 Gets the direct/quadrature voltage (Vdq) vector values from the controller. More...
 
static MATH_vec2CTRL_getVdq_V_addr (CTRL_Handle handle)
 Gets the direct/quadrature voltage (Vdq) vector memory address from the controller. More...
 
static void CTRL_getVdq_offset_V (CTRL_Handle handle, MATH_vec2 *pVdq_offset_V)
 Gets the direct/quadrature offset voltage (Vdq_offset) vector values from the controller. More...
 
static MATH_vec2CTRL_getVdq_offset_V_addr (CTRL_Handle handle)
 Gets the direct/quadrature offset voltage (Vdq_offset) vector memory address from the controller. More...
 
void CTRL_getVersion (CTRL_Handle handle, CTRL_Version *pVersion)
 Gets the controller version number. More...
 
static float_t CTRL_getVq_V (CTRL_Handle handle)
 Gets the quadrature voltage (Vq) value from the controller. More...
 
static float_tCTRL_getVq_V_addr (CTRL_Handle handle)
 Gets the quadrature voltage (Vq) value memory address from the controller. More...
 
static float_t CTRL_getVq_offset_V (CTRL_Handle handle)
 Gets the quadrature offset voltage (Vq_offset) value from the controller. More...
 
static float_tCTRL_getVq_offset_V_addr (CTRL_Handle handle)
 Gets the quadrature offset voltage (Vq_offset) value memory address from the controller. More...
 
uint_least32_t CTRL_getWaitTime (CTRL_Handle handle, const CTRL_State_e ctrlState)
 Gets the wait time for a given state. More...
 
void CTRL_getWaitTimes (CTRL_Handle handle, int_least32_t *pWaitTimes)
 Gets the wait times from the controller. More...
 
void CTRL_incrCounter_current (CTRL_Handle handle)
 Increments the current counter. More...
 
void CTRL_incrCounter_isr (CTRL_Handle handle)
 Increments the isr counter. More...
 
void CTRL_incrCounter_speed (CTRL_Handle handle)
 Increments the speed counter. More...
 
void CTRL_incrCounter_state (CTRL_Handle handle)
 Increments the state counter. More...
 
CTRL_Handle CTRL_init (void *pMemory, const size_t numBytes)
 Initializes the controller. More...
 
static bool CTRL_isEnabled (CTRL_Handle handle)
 Determines if the controller is enabled. More...
 
bool CTRL_isError (CTRL_Handle handle)
 Determines if there is a controller error. More...
 
static bool CTRL_isIdle (CTRL_Handle handle)
 Determines if the controller is in the idle state. More...
 
static bool CTRL_isNotIdle (CTRL_Handle handle)
 Determines if the controller is not in the idle state. More...
 
void CTRL_reset (CTRL_Handle handle)
 Resets the controller. More...
 
void CTRL_resetCounter_current (CTRL_Handle handle)
 Resets the current counter. More...
 
void CTRL_resetCounter_isr (CTRL_Handle handle)
 Resets the isr counter. More...
 
void CTRL_resetCounter_speed (CTRL_Handle handle)
 Resets the speed counter. More...
 
void CTRL_resetCounter_state (CTRL_Handle handle)
 Resets the state counter. More...
 
static void CTRL_setBWc_rps (CTRL_Handle handle, const float_t BWc_rps)
 Sets the current controller bandwidth. More...
 
static void CTRL_setBWdelta (CTRL_Handle handle, const float_t BWdelta)
 Sets the bandwidth scale factor used to maximize phase margin. More...
 
static void CTRL_setCtrlFreq_Hz (CTRL_Handle handle, const float_t ctrlFreq_Hz)
 Sets the controller frequency. More...
 
void CTRL_setCtrlPeriod_sec (CTRL_Handle handle, const float_t ctrlPeriod_sec)
 Sets the controller execution period. More...
 
static void CTRL_setCurrentCtrlPeriod_sec (CTRL_Handle handle, const float_t currentCtrlPeriod_sec)
 Sets the current controller period value. More...
 
void CTRL_setErrorCode (CTRL_Handle handle, const CTRL_ErrorCode_e errorCode)
 Sets the error code in the controller. More...
 
static void CTRL_setFlag_enable (CTRL_Handle handle, const bool state)
 Sets the enable controller flag value in the controller. More...
 
static void CTRL_setFlag_enableCurrentCtrl (CTRL_Handle handle, const bool state)
 Sets the enable current controllers flag value in the controller. More...
 
void CTRL_setFlag_enableSpeedCtrl (CTRL_Handle handle, const bool state)
 Sets the enable speed control value in the estimator. More...
 
static void CTRL_setFlag_resetInt_Id (CTRL_Handle handle, const bool state)
 Sets the reset Id integrator flag value in the controller. More...
 
static void CTRL_setFlag_resetInt_Iq (CTRL_Handle handle, const bool state)
 Sets the reset Iq integrator flag value in the controller. More...
 
static void CTRL_setFlag_resetInt_spd (CTRL_Handle handle, const bool state)
 Sets the reset speed integrator flag value in the controller. More...
 
static void CTRL_setFlag_useZeroIq_ref (CTRL_Handle handle, const bool state)
 Sets the use zero Iq reference flag value in the controller. More...
 
static void CTRL_setId_A (CTRL_Handle handle, const float_t Id_A)
 Sets the direct current (Id) value in the controller. More...
 
static void CTRL_setId_offset_A (CTRL_Handle handle, const float_t Id_offset_A)
 Sets the direct current (Id) offset value in the controller. More...
 
static void CTRL_setId_ref_A (CTRL_Handle handle, const float_t Id_ref_A)
 Sets the direct current (Id) reference value in the controller. More...
 
static void CTRL_setIdq_A (CTRL_Handle handle, const MATH_vec2 *pIdq_A)
 Sets the direct/quadrature current (Idq) vector values in the controller. More...
 
static void CTRL_setIdq_offset_A (CTRL_Handle handle, const MATH_vec2 *pIdq_offset_A)
 Sets the direct/quadrature current (Idq) offset vector values in the controller. More...
 
static void CTRL_setIdq_ref_A (CTRL_Handle handle, const MATH_vec2 *pIdq_ref_A)
 Sets the direct/quadrature current (Idq) reference vector values in the controller. More...
 
static void CTRL_setIq_A (CTRL_Handle handle, const float_t Iq_A)
 Sets the quadrature current (Iq) value in the controller. More...
 
static void CTRL_setIq_offset_pu (CTRL_Handle handle, const float_t Iq_offset_A)
 Sets the quadrature current (Iq) offset value in the controller. More...
 
static void CTRL_setIq_ref_A (CTRL_Handle handle, const float_t Iq_ref_A)
 Sets the quadrature current (Iq) reference value in the controller. More...
 
static void CTRL_setKctrl_Wb_p_kgm2 (CTRL_Handle handle, const float_t Kctrl_Wb_p_kgm2)
 Sets the speed controller constant. More...
 
static void CTRL_setKi (CTRL_Handle handle, const CTRL_Type_e ctrlType, const float_t Ki)
 Sets the integral gain (Ki) value for the specified controller. More...
 
static void CTRL_setKp (CTRL_Handle handle, const CTRL_Type_e ctrlType, const float_t Kp)
 Sets the proportional gain (Kp) value for the specified controller. More...
 
static void CTRL_setGains (CTRL_Handle handle, const CTRL_Type_e ctrlType, const float_t Kp, const float_t Ki)
 Sets the gain values for the specified controller. More...
 
static void CTRL_setMaxVsMag_V (CTRL_Handle handle, const float_t maxVsMag_V)
 Sets the maximum stator voltage magnitude value. More...
 
static void CTRL_setMotorParams (CTRL_Handle handle, const MOTOR_Type_e motorType, const uint_least16_t numPolePairs, const float_t ratedFlux_Wb, const float_t Ls_d_H, const float_t Ls_q_H, const float_t Rs_d_Ohm, const float_t Rs_q_Ohm, const float_t Rr_d_Ohm, const float_t Rr_q_Ohm)
 Sets the parameters for the motor in the controller. More...
 
static void CTRL_setNumCtrlTicksPerCurrentTick (CTRL_Handle handle, const int_least16_t numCtrlTicksPerCurrentTick)
 Sets the number of controller clock ticks per current controller clock tick. More...
 
static void CTRL_setNumCtrlTicksPerSpeedTick (CTRL_Handle handle, const int_least16_t numCtrlTicksPerSpeedTick)
 Sets the number of controller clock ticks per speed controller clock tick. More...
 
static void CTRL_setNumIsrTicksPerCtrlTick (CTRL_Handle handle, const int_least16_t numIsrTicksPerCtrlTick)
 Sets the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick. More...
 
void CTRL_setParams (CTRL_Handle handle, USER_Params *pUserParams)
 Sets the controller parameters. More...
 
static void CTRL_setSpeed_fb_Hz (CTRL_Handle handle, const float_t speed_fb_Hz)
 Sets the feedback speed value in the controller. More...
 
static void CTRL_setSpeed_out_A (CTRL_Handle handle, const float_t speed_out_A)
 Sets the maximum output value for the speed controller. More...
 
static void CTRL_setSpeed_outMax_A (CTRL_Handle handle, const float_t speed_outMax_A)
 Sets the maximum output value for the speed controller. More...
 
static void CTRL_setSpeed_outMin_A (CTRL_Handle handle, const float_t speed_outMin_A)
 Sets the minimum output value for the speed controller. More...
 
static void CTRL_setSpeed_ref_Hz (CTRL_Handle handle, const float_t speed_ref_Hz)
 Sets the output speed reference value in the controller. More...
 
static void CTRL_setSpeedCtrlPeriod_sec (CTRL_Handle handle, const float_t speedCtrlPeriod_sec)
 Sets the speed controller period value. More...
 
void CTRL_setState (CTRL_Handle handle, const CTRL_State_e state)
 Sets the controller state. More...
 
static void CTRL_setUi (CTRL_Handle handle, const CTRL_Type_e ctrlType, const float_t Ui)
 Sets the integrator (Ui) value in the specified controller. More...
 
static void CTRL_setVd_sf (CTRL_Handle handle, const float_t Vd_sf)
 Sets the direct voltage scale factor. More...
 
static void CTRL_setVdq_V (CTRL_Handle handle, const MATH_vec2 *pVdq_V)
 Sets the direct/quadrature voltage (Vdq) vector values in the controller. More...
 
static void CTRL_setVdq_offset_V (CTRL_Handle handle, const MATH_vec2 *pVdq_offset_V)
 Sets the direct/quadrature offset voltage (Vdq_offset) vector values in the controller. More...
 
void CTRL_setVersion (CTRL_Handle handle, const CTRL_TargetProc_e targetProc, const uint16_t majorReleaseNumber, const uint16_t minorReleaseNumber)
 Sets the controller version. More...
 
void CTRL_setWaitTimes (CTRL_Handle handle, const int_least32_t *pWaitTimes)
 Sets the wait times for the controller states. More...
 
bool CTRL_updateState (CTRL_Handle handle)
 Updates the controller state. More...
 
static void CTRL_setup (CTRL_Handle handle, const float_t speed_ref_Hz, const float_t speed_fb_Hz, const MATH_vec2 *pIdq_A, const MATH_vec2 *pIdq_offset_A, const MATH_vec2 *pVdq_offset_V, const bool flag_enableSpeedCtrl, const bool flag_enableCurrentCtrl, const bool flag_useZeroIq_ref)
 Sets up the user controller (CTRL) object. More...
 
static void CTRL_run (CTRL_Handle handle, MATH_vec2 *pVdq_V)
 Run the controller. More...
 

Detailed Description

Contains public interface to various functions related to the controller (CTRL) object.

(C) Copyright 2014, Texas Instruments, Inc.

Definition in file float/ctrl.h.

Function Documentation

static void CTRL_setFlag_enableCurrentCtrl ( CTRL_Handle  handle,
const bool  state 
)
inlinestatic

Sets the enable current controllers flag value in the controller.

Parameters
[in]handleThe controller (CTRL) handle
[in]stateThe desired state

Definition at line 1328 of file float/ctrl.h.

References _CTRL_Obj_::flag_enableCurrentCtrl.

Referenced by CTRL_setup().