RA Flexible Software Package Documentation  Release v5.9.0

 
Motor Angle and Speed Calculation with induction sensor (rm_motor_sense_induction)

Functions

fsp_err_t RM_MOTOR_SENSE_INDUCTION_Open (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg)
 Opens and configures the Angle module. Implements motor_angle_api_t::open. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_Close (motor_angle_ctrl_t *const p_ctrl)
 Disables specified Angle module. Implements motor_angle_api_t::close. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_Reset (motor_angle_ctrl_t *const p_ctrl)
 Reset variables of Angle module. Implements motor_angle_api_t::reset. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_InternalCalculate (motor_angle_ctrl_t *const p_ctrl)
 Calculate internal parameters. Implements motor_angle_api_t::internalCalculate. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_SENSE_INDUCTION_AngleAdjust (motor_angle_ctrl_t *const p_ctrl)
 Angle Adjustment Process. Implements motor_angle_api_t::angleAdjust. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_SENSE_INDUCTION_CyclicProcess (motor_angle_ctrl_t *const p_ctrl)
 Induction sensor Cyclic Process (Call in cyclic timer). Implements motor_angle_api_t::cyclicProcess. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_InfoGet (motor_angle_ctrl_t *const p_ctrl, motor_angle_encoder_info_t *const p_info)
 Gets information of Angle Module. Implements motor_angle_api_t::infoGet. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_CorrectReset (motor_angle_ctrl_t *const p_ctrl)
 Reset to restart calibration Angle module. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_ErrorGet (motor_angle_ctrl_t *const p_ctrl, motor_angle_error_t *const p_error)
 Gets the error information about induction correction. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_ParameterUpdate (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg)
 Update the parameters of angle & speed calculation. Implements motor_angle_api_t::parameterUpdate. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_SensorDataSet (motor_angle_ctrl_t *const p_ctrl, motor_angle_ad_data_t *const p_ad_data)
 Set A/D Converted Data. Implements motor_angle_api_t::sensorDataSet. More...
 
fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_SENSE_INDUCTION_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_SENSE_INDUCTION_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_SENSE_INDUCTION_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...
 

Detailed Description

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

Overview

The motor angle and speed calculation with induction sensor module is used to calculate rotor angle and rotational speed in an application. This module is designed to be used with the motor current module (rm_motor_current).

Features

The motor angle and speed calculation with induction sensor module has the features listed below.

Configuration

Build Time Configurations for rm_motor_sense_induction

The following build time configurations are defined in fsp_cfg/rm_motor_sense_induction_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 Calculation with induction sensor (rm_motor_sense_induction)

This module can be added to the Stacks tab via New Stack > Motor > Motor Angle and Speed Calculation with induction sensor (rm_motor_sense_induction).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_angle0 Module name.
Control type
  • Speed
  • Position
Position Select control Type
Frequency of current control (kHz)Must be a valid non-negative value.20.0 Frequency of current control
Decimation of InterruptMust be a valid integer.1 Decimation of Interrupt
Counts to get signalMust be a valid integer.10 Counts to get analog input signal
Limit of signal errorMust be a valid integer.100 Limit of signal error
Coefficent of speed LPFMust be a valid value0.07 Coefficient of speed LPF
A/D reference voltageMust be a valid non-negative value.3.3 Reference voltage of A/D converter
A/D conversion scaleMust be a valid non-negative value.4095.0 Conversion scale of A/D converter
Openloop speed (rpm)Must be a valid non-negative value.6.0 Rotation speed at calibration openloop (rpm)
D-axis current at openloop (A)Must be a valid non-negative value.1.0 D-axis current at calibration openloop (A)
Angle adjustment timesMust be a valid integer.512 Times to get signal at angle adjustment
Calibration enable
  • Disable
  • Enable
Enable Select enable/disable of signal calibration
Induction sensor pole pairsMust be a valid integer.4 Induction sensor pole pairs
Motor pole pairsMust be a valid integer.4 Motor pole pairs

Clock Configuration

Pin Configuration

Usage Notes

Limitations

Developers should be aware of the following limitations when using the motor angle and speed calculation with induction sensor: all configurations should be set as positive values.

Examples

Basic Example

This is a basic example of minimal use of the motor angle and speed calculation with induction sensor in an application.

void motor_sense_encoder_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_SENSE_INDUCTION_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. */
/* Initialize motor */
(void) RM_MOTOR_SENSE_INDUCTION_AngleAdjust(&g_mtr_angle0_ctrl);
/* Perform cyclic process*/
(void) RM_MOTOR_SENSE_INDUCTION_CyclicProcess(&g_mtr_angle0_ctrl);
/* Calculate information with induction sensor signal input */
(void) RM_MOTOR_SENSE_INDUCTION_InternalCalculate(&g_mtr_angle0_ctrl);
/* Get angle/speed data */
(void) RM_MOTOR_SENSE_INDUCTION_AngleSpeedGet(&g_mtr_angle0_ctrl, &f_get_angle, &f_get_speed, &f_get_phase_err);
}
/* Reset the module */
(void) RM_MOTOR_SENSE_INDUCTION_Reset(&g_mtr_angle0_ctrl);
/* Close the module */
(void) RM_MOTOR_SENSE_INDUCTION_Close(&g_mtr_angle0_ctrl);
}

Enumerations

enum  motor_sense_induction_loop_t
 
enum  motor_sense_induction_calibration_t
 
enum  motor_sense_induction_mode_t
 

Enumeration Type Documentation

◆ motor_sense_induction_loop_t

Enumerator
MOTOR_SENSE_INDUCTION_LOOP_SPEED 

Speed control mode.

MOTOR_SENSE_INDUCTION_LOOP_POSITION 

Position control mode.

◆ motor_sense_induction_calibration_t

Enumerator
MOTOR_SENSE_INDUCTION_CALIBRATION_DISABLE 

Disable calibration.

MOTOR_SENSE_INDUCTION_CALIBRATION_ENABLE 

Enable calibration.

◆ motor_sense_induction_mode_t

Enumerator
MOTOR_SENSE_INDUCTION_MODE_INIT 

Initialize mode (Start status)

MOTOR_SENSE_INDUCTION_MODE_BOOT 

Boot mode (Angle adjustment status)

MOTOR_SENSE_INDUCTION_MODE_DRIVE 

Drive mode (Normal work status)

Function Documentation

◆ RM_MOTOR_SENSE_INDUCTION_Open()

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

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

Return values
FSP_SUCCESSAngle Induction module 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_SENSE_INDUCTION_Close()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_Close ( motor_angle_ctrl_t *const  p_ctrl)

Disables specified Angle 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_SENSE_INDUCTION_Reset()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_Reset ( motor_angle_ctrl_t *const  p_ctrl)

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

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

◆ RM_MOTOR_SENSE_INDUCTION_InternalCalculate()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_InternalCalculate ( motor_angle_ctrl_t *const  p_ctrl)

Calculate internal parameters. Implements motor_angle_api_t::internalCalculate.

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

◆ RM_MOTOR_SENSE_INDUCTION_AngleSpeedGet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_SUCCESSSuccessfully data calculated.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SENSE_INDUCTION_AngleAdjust()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_AngleAdjust ( motor_angle_ctrl_t *const  p_ctrl)

Angle Adjustment Process. Implements motor_angle_api_t::angleAdjust.

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

◆ RM_MOTOR_SENSE_INDUCTION_EncoderCyclic()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_UNSUPPORTEDMotor sense induction software encoderCyclic is not supported.

◆ RM_MOTOR_SENSE_INDUCTION_CyclicProcess()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_CyclicProcess ( motor_angle_ctrl_t *const  p_ctrl)

Induction sensor Cyclic Process (Call in cyclic timer). Implements motor_angle_api_t::cyclicProcess.

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

◆ RM_MOTOR_SENSE_INDUCTION_InfoGet()

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

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

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

◆ RM_MOTOR_SENSE_INDUCTION_CorrectReset()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_CorrectReset ( motor_angle_ctrl_t *const  p_ctrl)

Reset to restart calibration Angle module.

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

◆ RM_MOTOR_SENSE_INDUCTION_ErrorGet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_ErrorGet ( motor_angle_ctrl_t *const  p_ctrl,
motor_angle_error_t *const  p_error 
)

Gets the error information about induction correction.

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

◆ RM_MOTOR_SENSE_INDUCTION_ParameterUpdate()

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

Update the parameters of angle & speed calculation. 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_SENSE_INDUCTION_SensorDataSet()

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

Set A/D Converted Data. Implements motor_angle_api_t::sensorDataSet.

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

◆ RM_MOTOR_SENSE_INDUCTION_CurrentSet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_ERR_UNSUPPORTEDMotor sense induction software currentSet is not supported.

◆ RM_MOTOR_SENSE_INDUCTION_SpeedSet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_ERR_UNSUPPORTEDMotor sense induction software speedSet is not supported.

◆ RM_MOTOR_SENSE_INDUCTION_FlagPiCtrlSet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_ERR_UNSUPPORTEDMotor sense induction software flagPiCtrlSet is not supported.

◆ RM_MOTOR_SENSE_INDUCTION_EstimatedComponentGet()

fsp_err_t RM_MOTOR_SENSE_INDUCTION_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_ERR_UNSUPPORTEDMotor sense induction software estimatedComponentGet is not supported.