RA Flexible Software Package Documentation  Release v5.2.0

 
Motor Current Controller (rm_motor_current)

Functions

fsp_err_t RM_MOTOR_CURRENT_Open (motor_current_ctrl_t *const p_ctrl, motor_current_cfg_t const *const p_cfg)
 Opens and configures the Motor Current Module. Implements motor_current_api_t::open. More...
 
fsp_err_t RM_MOTOR_CURRENT_Close (motor_current_ctrl_t *const p_ctrl)
 Disables specified Motor Current Module. Implements motor_current_api_t::close. More...
 
fsp_err_t RM_MOTOR_CURRENT_Reset (motor_current_ctrl_t *const p_ctrl)
 Reset variables of Motor Current Module. Implements motor_current_api_t::reset. More...
 
fsp_err_t RM_MOTOR_CURRENT_Run (motor_current_ctrl_t *const p_ctrl)
 Run(Start) the Current Control. Implements motor_current_api_t::run. More...
 
fsp_err_t RM_MOTOR_CURRENT_ParameterSet (motor_current_ctrl_t *const p_ctrl, motor_current_input_t const *const p_st_input)
 Set (Input) Parameter Data. Implements motor_current_api_t::parameterSet. More...
 
fsp_err_t RM_MOTOR_CURRENT_CurrentReferenceSet (motor_current_ctrl_t *const p_ctrl, float const id_reference, float const iq_reference)
 Set Current Reference Data. Implements motor_current_api_t::currentReferenceSet. More...
 
fsp_err_t RM_MOTOR_CURRENT_SpeedPhaseSet (motor_current_ctrl_t *const p_ctrl, float const speed, float const phase)
 Set Current Speed & rotor phase Data. Implements motor_current_api_t::speedPhaseSet. More...
 
fsp_err_t RM_MOTOR_CURRENT_CurrentSet (motor_current_ctrl_t *const p_ctrl, motor_current_input_current_t const *const p_st_current, motor_current_input_voltage_t const *const p_st_voltage)
 Set d/q-axis Current & Voltage Data. Implements motor_current_api_t::currentSet. More...
 
fsp_err_t RM_MOTOR_CURRENT_ParameterGet (motor_current_ctrl_t *const p_ctrl, motor_current_output_t *const p_st_output)
 Get Output Parameters. Implements motor_current_api_t::parameterGet. More...
 
fsp_err_t RM_MOTOR_CURRENT_CurrentGet (motor_current_ctrl_t *const p_ctrl, float *const p_id, float *const p_iq)
 Get d/q-axis Current. Implements motor_current_api_t::currentGet. More...
 
fsp_err_t RM_MOTOR_CURRENT_PhaseVoltageGet (motor_current_ctrl_t *const p_ctrl, motor_current_get_voltage_t *const p_voltage)
 Gets the set phase voltage. Implements motor_current_api_t::phaseVoltageGet. More...
 
fsp_err_t RM_MOTOR_CURRENT_ParameterUpdate (motor_current_ctrl_t *const p_ctrl, motor_current_cfg_t const *const p_cfg)
 Update the parameters of Current Control. Implements motor_current_api_t::parameterUpdate. More...
 
void rm_motor_current_encoder_cyclic (motor_current_instance_t const *p_ctrl)
 

Detailed Description

Calculation process for the motor control on RA MCUs. This module implements the Motor current Interface.

Overview

The motor current is used to control the electric current of motor rotation in an appication. This module should be called cyclically after the A/D conversion of electric current of each phase in an application. This module calculates each phase voltage with input current reference, electric current and rotor angle.

Features

The Motor Current Module has below features.

Configuration

Build Time Configurations for rm_motor_current

The following build time configurations are defined in fsp_cfg/rm_motor_current_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 Current Controller (rm_motor_current)

This module can be added to the Stacks tab via New Stack > Motor > Motor Current Controller (rm_motor_current).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_current0 Module name.
Sensor type
  • Sensorless
  • Encoder
  • Induction
  • Hall
Sensorless Select sensor type
Shunt type
  • 1 shunt
  • 2 shunt
  • 3 shunt
2 shunt Select shunt type
Current control decimationMust be a valid non-negative value.0 Decimation of current control.
PWM carrier frequency (kHz)Must be a valid value20.0F PWM carrier frequency.
Input voltage (V)Must be a valid value24.0F Input voltage for limitation of current PI control.
Sample delay compensation
  • Disable
  • Enable
Enable Select enable/disable sample delay compensation.
Period magnification valueMust be a valid non-negative value.1.5 Period magnification value for sampling delay compensation.
Voltage error compensation
  • Disable
  • Enable
Enable Select enable/disable voltage error compensation.
Voltage error compensation table of voltage 1Must be a valid value0.672F Voltage error compensation table of voltage.
Voltage error compensation table of voltage 2Must be a valid value0.945F Voltage error compensation table of voltage.
Voltage error compensation table of voltage 3Must be a valid value1.054F Voltage error compensation table of voltage.
Voltage error compensation table of voltage 4Must be a valid value1.109F Voltage error compensation table of voltage.
Voltage error compensation table of voltage 5Must be a valid value1.192F Voltage error compensation table of voltage.
Voltage error compensation table of current 1Must be a valid value0.013F Voltage error compensation table of current.
Voltage error compensation table of current 2Must be a valid value0.049F Voltage error compensation table of current.
Voltage error compensation table of current 3Must be a valid value0.080F Voltage error compensation table of current.
Voltage error compensation table of current 4Must be a valid value0.184F Voltage error compensation table of current.
Voltage error compensation table of current 5Must be a valid value0.751F Voltage error compensation table of current.
Interrupts
CallbackName must be a valid C symbolNULL A user callback function. If this callback function is provided, it is called at A/D conversion finish interrupt.
Design Parameter
Current PI loop omega (Hz)Must be a valid value300.0F Current PI loop omega
Current PI loop zetaMust be a valid value1.0F Current PI loop zeta
Motor Parameter
Pole pairsMust be a valid non-negative value.2 Pole pairs
Resistance (ohm)Must be a valid value8.5F Resistance
Inductance of d-axis (H)Must be a valid value0.0045F Inductance of d-axis
Inductance of q-axis (H)Must be a valid value0.0045F Inductance of q-axis
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

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

Examples

Basic Example

This is a basic example of minimal use of the Motor Current in an application.

void motor_current_basic_example (void)
{
motor_current_input_current_t temp_input_current;
motor_current_input_voltage_t temp_input_voltage;
motor_current_get_voltage_t temp_get_voltage;
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_CURRENT_Open(g_test_motor_current.p_ctrl, g_test_motor_current.p_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 current reference before get phase voltage */
(void) RM_MOTOR_CURRENT_CurrentReferenceSet(g_test_motor_current.p_ctrl, 1.0F, 1.0F);
/* Set speed and phase data before get phase voltage */
(void) RM_MOTOR_CURRENT_SpeedPhaseSet(g_test_motor_current.p_ctrl, 104.72F, 1.0F);
temp_input_current.iu = 1.0F;
temp_input_current.iv = 1.0F;
temp_input_current.iw = 1.0F;
temp_input_voltage.vdc = 24.0F;
temp_input_voltage.va_max = 24.0F;
/* Set electric current and voltage before get phase voltage */
(void) RM_MOTOR_CURRENT_CurrentSet(g_test_motor_current.p_ctrl, temp_input_current, temp_input_voltage);
/* Activate the process. */
(void) RM_MOTOR_CURRENT_Run(g_test_motor_current.p_ctrl);
/* Get d/q-axis current*/
(void) RM_MOTOR_CURRENT_CurrentGet(g_test_motor_current.p_ctrl, &f_get_id, &f_get_iq);
/* Get the flag of PI control */
(void) RM_MOTOR_CURRENT_PhaseVolageGet(g_test_motor_current.p_ctrl, &temp_get_voltage);
/* Get Output Parameter */
(void) RM_MOTOR_CURRENT_ParameterGet(g_test_motor_current.p_ctrl, &test_output);
(void) RM_MOTOR_CURRENT_ParameterUpdate(g_test_motor_current.p_ctrl, g_test_motor_current.p_cfg);
}
/* Reset the process. */
(void) RM_MOTOR_CURRENT_Reset(g_test_motor_current.p_ctrl);
/* Close the module. */
(void) RM_MOTOR_CURRENT_Close(g_test_motor_current.p_ctrl);
}

Enumerations

enum  motor_current_shunt_type_t
 

Enumeration Type Documentation

◆ motor_current_shunt_type_t

Selection of shunt type

Enumerator
MOTOR_CURRENT_SHUNT_TYPE_1_SHUNT 

Only use U phase current.

MOTOR_CURRENT_SHUNT_TYPE_2_SHUNT 

Use U and W phase current.

MOTOR_CURRENT_SHUNT_TYPE_3_SHUNT 

Use all phase current.

Function Documentation

◆ RM_MOTOR_CURRENT_Open()

fsp_err_t RM_MOTOR_CURRENT_Open ( motor_current_ctrl_t *const  p_ctrl,
motor_current_cfg_t const *const  p_cfg 
)

Opens and configures the Motor Current Module. Implements motor_current_api_t::open.

Return values
FSP_SUCCESSMotor Current 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_CURRENT_Close()

fsp_err_t RM_MOTOR_CURRENT_Close ( motor_current_ctrl_t *const  p_ctrl)

Disables specified Motor Current Module. Implements motor_current_api_t::close.

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

◆ RM_MOTOR_CURRENT_Reset()

fsp_err_t RM_MOTOR_CURRENT_Reset ( motor_current_ctrl_t *const  p_ctrl)

Reset variables of Motor Current Module. Implements motor_current_api_t::reset.

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

◆ RM_MOTOR_CURRENT_Run()

fsp_err_t RM_MOTOR_CURRENT_Run ( motor_current_ctrl_t *const  p_ctrl)

Run(Start) the Current Control. Implements motor_current_api_t::run.

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

◆ RM_MOTOR_CURRENT_ParameterSet()

fsp_err_t RM_MOTOR_CURRENT_ParameterSet ( motor_current_ctrl_t *const  p_ctrl,
motor_current_input_t const *const  p_st_input 
)

Set (Input) Parameter Data. Implements motor_current_api_t::parameterSet.

Return values
FSP_SUCCESSSuccessfully data is set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput argument error.

◆ RM_MOTOR_CURRENT_CurrentReferenceSet()

fsp_err_t RM_MOTOR_CURRENT_CurrentReferenceSet ( motor_current_ctrl_t *const  p_ctrl,
float const  id_reference,
float const  iq_reference 
)

Set Current Reference Data. Implements motor_current_api_t::currentReferenceSet.

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

◆ RM_MOTOR_CURRENT_SpeedPhaseSet()

fsp_err_t RM_MOTOR_CURRENT_SpeedPhaseSet ( motor_current_ctrl_t *const  p_ctrl,
float const  speed,
float const  phase 
)

Set Current Speed & rotor phase Data. Implements motor_current_api_t::speedPhaseSet.

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

◆ RM_MOTOR_CURRENT_CurrentSet()

fsp_err_t RM_MOTOR_CURRENT_CurrentSet ( motor_current_ctrl_t *const  p_ctrl,
motor_current_input_current_t const *const  p_st_current,
motor_current_input_voltage_t const *const  p_st_voltage 
)

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

Return values
FSP_SUCCESSSuccessfully data is set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput parameter error.

◆ RM_MOTOR_CURRENT_ParameterGet()

fsp_err_t RM_MOTOR_CURRENT_ParameterGet ( motor_current_ctrl_t *const  p_ctrl,
motor_current_output_t *const  p_st_output 
)

Get Output Parameters. Implements motor_current_api_t::parameterGet.

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

◆ RM_MOTOR_CURRENT_CurrentGet()

fsp_err_t RM_MOTOR_CURRENT_CurrentGet ( motor_current_ctrl_t *const  p_ctrl,
float *const  p_id,
float *const  p_iq 
)

Get d/q-axis Current. Implements motor_current_api_t::currentGet.

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

◆ RM_MOTOR_CURRENT_PhaseVoltageGet()

fsp_err_t RM_MOTOR_CURRENT_PhaseVoltageGet ( motor_current_ctrl_t *const  p_ctrl,
motor_current_get_voltage_t *const  p_voltage 
)

Gets the set phase voltage. Implements motor_current_api_t::phaseVoltageGet.

Return values
FSP_SUCCESSSuccessful data calculation.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput parameter error.

◆ RM_MOTOR_CURRENT_ParameterUpdate()

fsp_err_t RM_MOTOR_CURRENT_ParameterUpdate ( motor_current_ctrl_t *const  p_ctrl,
motor_current_cfg_t const *const  p_cfg 
)

Update the parameters of Current Control. Implements motor_current_api_t::parameterUpdate.

Return values
FSP_SUCCESSSuccessfully data was updated.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ rm_motor_current_encoder_cyclic()

void rm_motor_current_encoder_cyclic ( motor_current_instance_t const *  p_ctrl)

(end addtogroup MOTOR_CURRENT)