RA Flexible Software Package Documentation  Release v5.2.0

 
Motor Angle (rm_motor_estimate)

Functions

fsp_err_t RM_MOTOR_ESTIMATE_Open (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg)
 Opens and configures the Angle Estimation module. Implements motor_angle_api_t::open. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_Close (motor_angle_ctrl_t *const p_ctrl)
 Disables specified Angle Estimation module. Implements motor_angle_api_t::close. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_Reset (motor_angle_ctrl_t *const p_ctrl)
 Reset variables of Angle Estimation module. Implements motor_angle_api_t::reset. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_CurrentSet (motor_angle_ctrl_t *const p_ctrl, motor_angle_current_t *const p_st_current, motor_angle_voltage_reference_t *const p_st_voltage)
 Set d/q-axis Current Data & Voltage Reference. Implements motor_angle_api_t::currentSet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_SpeedSet (motor_angle_ctrl_t *const p_ctrl, float const speed_ctrl, float const damp_speed)
 Set Speed Information. Implements motor_angle_api_t::speedSet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_FlagPiCtrlSet (motor_angle_ctrl_t *const p_ctrl, uint32_t const flag_pi)
 Set the flag of PI Control runs. Implements motor_angle_api_t::flagPiCtrlSet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_AngleSpeedGet (motor_angle_ctrl_t *const p_ctrl, float *const p_angle, float *const p_speed, float *const p_phase_err)
 Gets the current rotor's angle and rotation speed. Implements motor_angle_api_t::angleSpeedGet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_EstimatedComponentGet (motor_angle_ctrl_t *const p_ctrl, float *const p_ed, float *const p_eq)
 Gets estimated d/q-axis component. Implements motor_angle_api_t::estimatedComponentGet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_ParameterUpdate (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg)
 Update the parameters of Angle&Speed Estimation. Implements motor_angle_api_t::parameterUpdate. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_InternalCalculate (motor_angle_ctrl_t *const p_ctrl)
 Calculate internal parameters. Implements motor_angle_api_t::internalCalculate. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_AngleAdjust (motor_angle_ctrl_t *const p_ctrl)
 Angle Adjustment Process. Implements motor_angle_api_t::angleAdjust. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_EncoderCyclic (motor_angle_ctrl_t *const p_ctrl)
 Encoder Cyclic Process (Call in cyclic timer). Implements motor_angle_api_t::encoderCyclic. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_InfoGet (motor_angle_ctrl_t *const p_ctrl, motor_angle_encoder_info_t *const p_info)
 Gets information of Encoder Angle Module. Implements motor_angle_api_t::infoGet. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_CyclicProcess (motor_angle_ctrl_t *const p_ctrl)
 Perform induction cyclic process. Implements motor_angle_api_t::cyclicProcess. More...
 
fsp_err_t RM_MOTOR_ESTIMATE_SensorDataSet (motor_angle_ctrl_t *const p_ctrl, motor_angle_ad_data_t *const p_ad_data)
 Set sensor data. Implements motor_angle_api_t::sensorDataSet. More...
 

Detailed Description

Calculation proccess for the motor control on RA MCUs. This module implements the Motor angle Interface.

Overview

The motor angle and speed estimation module is used to calculate rotor angle and rotational speed in an application. This module should be called cyclically after the A/D conversion of electric current of each phase in an application.

Features

The Motor Angle and Speed Estimation Module has below features.

Configuration

Build Time Configurations for rm_motor_estimate

The following build time configurations are defined in fsp_cfg/rm_motor_estimate_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Motor > Motor Angle and Speed Estimation (rm_motor_estimate)

This module can be added to the Stacks tab via New Stack > Motor > Motor Angle and Speed Estimation (rm_motor_estimate).

ConfigurationOptionsDefaultDescription
Motor Parameter
Pole pairsMust be a valid non-negative value.2 Pole pairs
Motor Parameter > Resistance[ohm]Must be a valid value8.5F Resistance
Motor Parameter > Inductance of d-axis[H]Must be a valid value0.0045F Inductance of d-axis
Motor Parameter > Inductance of q-axis[H]Must be a valid value0.0045F Inductance of q-axis
Motor Parameter > Permanent magnetic flux[Wb]Must be a valid value0.02159F Permanent magnetic flux
Motor Parameter > Rotor inertia[kgm^2]Must be a valid value0.0000028F Rotor inertia
Motor Parameter > Nominal current[Arms]Must be a valid value1.67 Nominal current
NameName must be a valid C symbolg_motor_angle0 Module name.
Openloop damping
  • Disable
  • Enable
Enable Openloop damping functionally enable or disable
Natural frequency of BEMF observerMust be a valid value1000.0F Natural frequency of BEMF observer
Damping ratio of BEMF observerMust be a valid value1.0F Damping ratio of BEMF observer
Natural frequency of PLL Speed estimate loopMust be a valid value20.0F Natural frequency of PLL Speed estimate loop
Damping ratio of PLL Speed estimate loopMust be a valid value1.0F Damping ratio of PLL Speed estimate loop
Control periodMust be a valid value0.00005F Control period

Clock Configuration

This module doesn't depend on clock setting, because this module is a simple calculation process.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Limitations

Developers should be aware of the following limitations when using the Motor Angle and Speed Estimation:

Examples

Basic Example

This is a basic example of minimal use of the Motor Angle and Speed Estimation in an application.

void motor_estimate_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
motor_angle_current_t smpl_current:
/* Initializes the module. */
err = RM_MOTOR_ESTIMATE_Open(&g_mtr_angle0_ctrl, &g_mtr_angle_set0_cfg);
assert(FSP_SUCCESS == err);
/* Basically run this module at A/D conversion finish interrupt.
* This implementation is an example. */
while (true)
{
/* Application work here. */
/* Set PI Control Flag before get Angle/Speed and Estimated Component */
(void) RM_MOTOR_ESTIMATE_FlagPiCtrlSet(&g_mtr_angle0_ctrl, 1U);
smpl_current.id = 1.0F;
smpl_current.iq = 1.0F;
smpl_voltage.vd = 10.0F;
smpl_voltage.vq = 10.0F;
/* Set Current and Speed data before get Angle/Speed and Estimated Component */
(void) RM_MOTOR_ESTIMATE_CurrentSet(&g_mtr_angle0_ctrl, smpl_current, smpl_voltage);
/* Set Internal Speed Reference & damping speed data before get Angle/Speed and Estimated Component */
(void) RM_MOTOR_ESTIMATE_SpeedSet(&g_mtr_angle0_ctrl, 104.27F, 10.0F);
/* Get Angle/Speed data */
(void) RM_MOTOR_ESTIMATE_AngleSpeedGet(&g_mtr_angle0_ctrl, &f_get_angle, &f_get_speed, &f_get_phase_err);
/* Get Estimated Component */
(void) RM_MOTOR_ESTIMATE_EstimatedComponentGet(&g_mtr_angle0_ctrl, &f_get_ed, &f_get_eq);
}
}

Function Documentation

◆ RM_MOTOR_ESTIMATE_Open()

fsp_err_t RM_MOTOR_ESTIMATE_Open ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_cfg_t const *const  p_cfg 
)

Opens and configures the Angle Estimation module. Implements motor_angle_api_t::open.

Return values
FSP_SUCCESSMTR_ANGL_EST successfully configured.
FSP_ERR_ASSERTIONNull pointer, or one or more configuration options is invalid.
FSP_ERR_ALREADY_OPENModule is already open. This module can only be opened once.
FSP_ERR_INVALID_ARGUMENTConfiguration parameter error.

◆ RM_MOTOR_ESTIMATE_Close()

fsp_err_t RM_MOTOR_ESTIMATE_Close ( motor_angle_ctrl_t *const  p_ctrl)

Disables specified Angle Estimation module. Implements motor_angle_api_t::close.

Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_Reset()

fsp_err_t RM_MOTOR_ESTIMATE_Reset ( motor_angle_ctrl_t *const  p_ctrl)

Reset variables of Angle Estimation module. Implements motor_angle_api_t::reset.

Return values
FSP_SUCCESSSuccessfully reset.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_CurrentSet()

fsp_err_t RM_MOTOR_ESTIMATE_CurrentSet ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_current_t *const  p_st_current,
motor_angle_voltage_reference_t *const  p_st_voltage 
)

Set d/q-axis Current Data & Voltage Reference. Implements motor_angle_api_t::currentSet.

Return values
FSP_SUCCESSSuccessfully set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_SpeedSet()

fsp_err_t RM_MOTOR_ESTIMATE_SpeedSet ( motor_angle_ctrl_t *const  p_ctrl,
float const  speed_ctrl,
float const  damp_speed 
)

Set Speed Information. Implements motor_angle_api_t::speedSet.

Return values
FSP_SUCCESSSuccessfully set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_FlagPiCtrlSet()

fsp_err_t RM_MOTOR_ESTIMATE_FlagPiCtrlSet ( motor_angle_ctrl_t *const  p_ctrl,
uint32_t const  flag_pi 
)

Set the flag of PI Control runs. Implements motor_angle_api_t::flagPiCtrlSet.

Return values
FSP_SUCCESSSuccessfully set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_AngleSpeedGet()

fsp_err_t RM_MOTOR_ESTIMATE_AngleSpeedGet ( motor_angle_ctrl_t *const  p_ctrl,
float *const  p_angle,
float *const  p_speed,
float *const  p_phase_err 
)

Gets the current rotor's angle and rotation speed. Implements motor_angle_api_t::angleSpeedGet.

Return values
FSP_SUCCESSSuccessful data get.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_EstimatedComponentGet()

fsp_err_t RM_MOTOR_ESTIMATE_EstimatedComponentGet ( motor_angle_ctrl_t *const  p_ctrl,
float *const  p_ed,
float *const  p_eq 
)

Gets estimated d/q-axis component. Implements motor_angle_api_t::estimatedComponentGet.

Return values
FSP_SUCCESSSuccessfully data gotten.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_ParameterUpdate()

fsp_err_t RM_MOTOR_ESTIMATE_ParameterUpdate ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_cfg_t const *const  p_cfg 
)

Update the parameters of Angle&Speed Estimation. Implements motor_angle_api_t::parameterUpdate.

Return values
FSP_SUCCESSSuccessfully data is update.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_InternalCalculate()

fsp_err_t RM_MOTOR_ESTIMATE_InternalCalculate ( motor_angle_ctrl_t *const  p_ctrl)

Calculate internal parameters. Implements motor_angle_api_t::internalCalculate.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_AngleAdjust()

fsp_err_t RM_MOTOR_ESTIMATE_AngleAdjust ( motor_angle_ctrl_t *const  p_ctrl)

Angle Adjustment Process. Implements motor_angle_api_t::angleAdjust.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_EncoderCyclic()

fsp_err_t RM_MOTOR_ESTIMATE_EncoderCyclic ( motor_angle_ctrl_t *const  p_ctrl)

Encoder Cyclic Process (Call in cyclic timer). Implements motor_angle_api_t::encoderCyclic.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_InfoGet()

fsp_err_t RM_MOTOR_ESTIMATE_InfoGet ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_encoder_info_t *const  p_info 
)

Gets information of Encoder Angle Module. Implements motor_angle_api_t::infoGet.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_ESTIMATE_CyclicProcess()

fsp_err_t RM_MOTOR_ESTIMATE_CyclicProcess ( motor_angle_ctrl_t *const  p_ctrl)

Perform induction cyclic process. Implements motor_angle_api_t::cyclicProcess.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.

◆ RM_MOTOR_ESTIMATE_SensorDataSet()

fsp_err_t RM_MOTOR_ESTIMATE_SensorDataSet ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_ad_data_t *const  p_ad_data 
)

Set sensor data. Implements motor_angle_api_t::sensorDataSet.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.