RA Flexible Software Package Documentation  Release v5.2.0

 
Motor vector control with induction sensor (rm_motor_induction)

Functions

fsp_err_t RM_MOTOR_INDUCTION_Open (motor_ctrl_t *const p_ctrl, motor_cfg_t const *const p_cfg)
 
fsp_err_t RM_MOTOR_INDUCTION_Close (motor_ctrl_t *const p_ctrl)
 Disables specified Motor Induction Control block. Implements motor_api_t::close. More...
 
fsp_err_t RM_MOTOR_INDUCTION_Reset (motor_ctrl_t *const p_ctrl)
 Reset Motor Induction Control block. Implements motor_api_t::reset. More...
 
fsp_err_t RM_MOTOR_INDUCTION_Run (motor_ctrl_t *const p_ctrl)
 Run Motor (Start motor rotation). Implements motor_api_t::run. More...
 
fsp_err_t RM_MOTOR_INDUCTION_Stop (motor_ctrl_t *const p_ctrl)
 Stop Motor (Stop motor rotation). Implements motor_api_t::stop. More...
 
fsp_err_t RM_MOTOR_INDUCTION_ErrorSet (motor_ctrl_t *const p_ctrl, motor_error_t const error)
 Set error information. Implements motor_api_t::errorSet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_SpeedSet (motor_ctrl_t *const p_ctrl, float const speed_rpm)
 Set speed reference[rpm]. Implements motor_api_t::speedSet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_PositionSet (motor_ctrl_t *const p_ctrl, motor_speed_position_data_t const *const p_position)
 Set position reference[degree]. Implements motor_api_t::positionSet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_StatusGet (motor_ctrl_t *const p_ctrl, uint8_t *const p_status)
 Get current control status. Implements motor_api_t::statusGet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_AngleGet (motor_ctrl_t *const p_ctrl, float *const p_angle_rad)
 Get current rotor angle. Implements motor_api_t::angleGet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_SpeedGet (motor_ctrl_t *const p_ctrl, float *const p_speed_rpm)
 Get rotational speed. Implements motor_api_t::speedGet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_ErrorCheck (motor_ctrl_t *const p_ctrl, uint16_t *const p_error)
 Check the occurunce of Error. Implements motor_api_t::errorCheck. More...
 
fsp_err_t RM_MOTOR_INDUCTION_WaitStopFlagGet (motor_ctrl_t *const p_ctrl, motor_wait_stop_flag_t *const p_flag)
 Get wait stop flag. Implements motor_api_t::waitStopFlagGet. More...
 
fsp_err_t RM_MOTOR_INDUCTION_FunctionSelect (motor_ctrl_t *const p_ctrl, motor_function_select_t const function)
 Select using function. Implements motor_api_t::functionSelect. More...
 
fsp_err_t RM_MOTOR_INDUCTION_InertiaEstimateStart (motor_ctrl_t *const p_ctrl)
 Start inertia estimation function. More...
 
fsp_err_t RM_MOTOR_INDUCTION_InertiaEstimateStop (motor_ctrl_t *const p_ctrl)
 Stop(Cancel) inertia estimation function. More...
 
fsp_err_t RM_MOTOR_INDUCTION_ReturnOriginStart (motor_ctrl_t *const p_ctrl)
 Start return origin function. More...
 
fsp_err_t RM_MOTOR_INDUCTION_ReturnOriginStop (motor_ctrl_t *const p_ctrl)
 Stop(Cancel) return origin function. More...
 

Detailed Description

Control a SPM motor on RA MCUs. This module implements the Motor vector control with induction sensor (rm_motor_induction).

Overview

The motor vector control with induction sensor is used to control motor rotation in an application. This module is meant to be used with Surface Permanent Magnet (SPM) motors and allows applications to start or stop motor rotation easily.

Features

The motor induction module has below features.

Target Hardware

The below figure shows an example of target hardware of this Motor Induction Module.

rm_motor_induction_hardware.png
Example of target hardware of motor induction module

Block Diagram

The below figures show block diaram of vector motor control with using induction sensor.

rm_motor_induction_block_diagram.png
Block diagram of vector control with using induction sensor (PI feedback loop)

Modulation

rm_motor_sensorless_moduration.png
Modulation factor
rm_motor_sensorless_svpwm.png
Space vector modulation

State transition

The below figure shows a state transition diagram. Internal state is managed by "SYSTEM MODE".

rm_motor_sensorless_mode_transition.png
State transition diagram

(1) SYSTEM MODE "SYSTEM MODE" indicates the operating states of the system. The state transits on occurrence of each event (EVENT). "SYSTEM MODE" has 3 states that are motor drive stop (INACTIVE), motor drive (ACTIVE), and abnormal condition (ERROR).

(2) EVENT When "EVENT" occurs in each "SYSTEM MODE", "SYSTEM MODE" changes as shown the table in above figure, according to that "EVENT". The occurrence factors of each event are shown below.

EVENT name Occurrence factor
STOP by user operation
RUN by user operation
ERROR when the system detects an error
RESET by user operation

Flowchart

The below figures show flowcharts of motor induction module.

rm_motor_sensorless_main_flowchart.png
Main process
rm_motor_encoder_current_cyclic.png
Current control process
rm_motor_encoder_speed_cyclic.png
Speed control process
rm_motor_sensorless_overcurrent_flowchart.png
Over current detection interrupt process

Configuration

Build Time Configurations for rm_motor_induction

The following build time configurations are defined in fsp_cfg/rm_motor_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 vector control with induction sensor (rm_motor_induction)

This module can be added to the Stacks tab via New Stack > Motor > Motor vector control with induction sensor (rm_motor_induction).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_induction0 Module name.
Limit of over current (A)Must be a valid value2.0F Limit of over current.(Detection threshold)
Limit of over voltage (V)Must be a valid value28.0F Limit of over voltage.(Detection threshold)
Limit of over speed (rpm)Must be a valid value3000.0F Limit of over speed.(Detection threshold)
Limit of low voltage (V)Must be a valid value18.0F Limit of low voltage.(Detection threshold)
Interrupts
CallbackName must be a valid C symbolNULL A user callback function. If this callback function is provided, it is called at speed control cyclic interrupt.

Clock Configuration

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

Pin Configuration

This module does not use I/O pins. Please set used pins on configuration of each hardware modules.

Usage Notes

Limitations

Examples

Basic Example

This is a basic example of minimal use of the motor induction module in an application.

void motor_induction_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_INDUCTION_Open(g_motor_induction0_smpl.p_ctrl, g_motor_induction0_smpl.p_cfg);
handle_error(err);
/* Set speed reference before motor run */
(void) RM_MOTOR_INDUCTION_SpeedSet(g_motor_induction0_smpl.p_ctrl, RM_MOTOR_INDUCTION_TEST_OVER_SPEED_LIMIT);
/* Set position reference before motor run */
(void) RM_MOTOR_INDUCTION_PositionSet(g_motor_induction0_smpl.p_ctrl, &g_posref_sample1);
/* Start motor rotation */
(void) RM_MOTOR_INDUCTION_Run(g_motor_induction0_smpl.p_ctrl);
/* Get current status */
(void) RM_MOTOR_INDUCTION_StatusGet(g_motor_induction0_smpl.p_ctrl, &smpl_status);
/* Get current rotor angle */
(void) RM_MOTOR_INDUCTION_AngleGet(g_motor_induction0_smpl.p_ctrl, &smpl_angle);
/* Get current motor rotational speed */
(void) RM_MOTOR_INDUCTION_SpeedGet(g_motor_induction0_smpl.p_ctrl, &smpl_speed);
/* Check error */
(void) RM_MOTOR_INDUCTION_ErrorCheck(g_motor_induction0_smpl.p_ctrl, &smpl_error);
/* Stop motor rotation */
(void) RM_MOTOR_INDUCTION_Stop(g_motor_induction0_smpl.p_ctrl);
/* If need, set extra error status */
(void) RM_MOTOR_INDUCTION_ErrorSet(g_motor_induction0_smpl.p_ctrl, MOTOR_ERROR_OVER_CURRENT_HW);
/* Reset motor control */
(void) RM_MOTOR_INDUCTION_Reset(g_motor_induction0_smpl.p_ctrl);
/* Close motor control */
(void) RM_MOTOR_INDUCTION_Close(g_motor_induction0_smpl.p_ctrl);
}

Enumerations

enum  motor_induction_ctrl_t
 
enum  motor_induction_ctrl_event_t
 

Enumeration Type Documentation

◆ motor_induction_ctrl_t

Enumerator
MOTOR_INDUCTION_CTRL_STOP 

Stop mode.

MOTOR_INDUCTION_CTRL_RUN 

Run mode.

MOTOR_INDUCTION_CTRL_ERROR 

Error mode.

◆ motor_induction_ctrl_event_t

Enumerator
MOTOR_INDUCTION_CTRL_EVENT_STOP 

Stop event.

MOTOR_INDUCTION_CTRL_EVENT_RUN 

Run event.

MOTOR_INDUCTION_CTRL_EVENT_ERROR 

Error event.

MOTOR_INDUCTION_CTRL_EVENT_RESET 

Reset event.

Function Documentation

◆ RM_MOTOR_INDUCTION_Open()

fsp_err_t RM_MOTOR_INDUCTION_Open ( motor_ctrl_t *const  p_ctrl,
motor_cfg_t const *const  p_cfg 
)

Configure the MOTOR in register start mode. Implements motor_api_t::open.

This function should only be called once as MOTOR configuration registers can only be written to once so subsequent calls will have no effect.

Example:

/* Initializes the module. */
err = RM_MOTOR_INDUCTION_Open(g_motor_induction0_smpl.p_ctrl, g_motor_induction0_smpl.p_cfg);
Return values
FSP_SUCCESSMOTOR 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.
Note

◆ RM_MOTOR_INDUCTION_Close()

fsp_err_t RM_MOTOR_INDUCTION_Close ( motor_ctrl_t *const  p_ctrl)

Disables specified Motor Induction Control block. Implements motor_api_t::close.

Example:

/* Close motor control */
(void) RM_MOTOR_INDUCTION_Close(g_motor_induction0_smpl.p_ctrl);
Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_Reset()

fsp_err_t RM_MOTOR_INDUCTION_Reset ( motor_ctrl_t *const  p_ctrl)

Reset Motor Induction Control block. Implements motor_api_t::reset.

Example:

/* Reset motor control */
(void) RM_MOTOR_INDUCTION_Reset(g_motor_induction0_smpl.p_ctrl);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_Run()

fsp_err_t RM_MOTOR_INDUCTION_Run ( motor_ctrl_t *const  p_ctrl)

Run Motor (Start motor rotation). Implements motor_api_t::run.

Example:

/* Start motor rotation */
(void) RM_MOTOR_INDUCTION_Run(g_motor_induction0_smpl.p_ctrl);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_Stop()

fsp_err_t RM_MOTOR_INDUCTION_Stop ( motor_ctrl_t *const  p_ctrl)

Stop Motor (Stop motor rotation). Implements motor_api_t::stop.

Example:

/* Stop motor rotation */
(void) RM_MOTOR_INDUCTION_Stop(g_motor_induction0_smpl.p_ctrl);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_ErrorSet()

fsp_err_t RM_MOTOR_INDUCTION_ErrorSet ( motor_ctrl_t *const  p_ctrl,
motor_error_t const  error 
)

Set error information. Implements motor_api_t::errorSet.

Example:

/* If need, set extra error status */
(void) RM_MOTOR_INDUCTION_ErrorSet(g_motor_induction0_smpl.p_ctrl, MOTOR_ERROR_OVER_CURRENT_HW);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_SpeedSet()

fsp_err_t RM_MOTOR_INDUCTION_SpeedSet ( motor_ctrl_t *const  p_ctrl,
float const  speed_rpm 
)

Set speed reference[rpm]. Implements motor_api_t::speedSet.

Example:

/* Set speed reference before motor run */
(void) RM_MOTOR_INDUCTION_SpeedSet(g_motor_induction0_smpl.p_ctrl, RM_MOTOR_INDUCTION_TEST_OVER_SPEED_LIMIT);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_INDUCTION_PositionSet()

fsp_err_t RM_MOTOR_INDUCTION_PositionSet ( motor_ctrl_t *const  p_ctrl,
motor_speed_position_data_t const *const  p_position 
)

Set position reference[degree]. Implements motor_api_t::positionSet.

Example:

/* Set position reference before motor run */
(void) RM_MOTOR_INDUCTION_PositionSet(g_motor_induction0_smpl.p_ctrl, &g_posref_sample1);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTData set pointer is invalid..
Note

◆ RM_MOTOR_INDUCTION_StatusGet()

fsp_err_t RM_MOTOR_INDUCTION_StatusGet ( motor_ctrl_t *const  p_ctrl,
uint8_t *const  p_status 
)

Get current control status. Implements motor_api_t::statusGet.

Example:

/* Get current status */
(void) RM_MOTOR_INDUCTION_StatusGet(g_motor_induction0_smpl.p_ctrl, &smpl_status);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTData received pointer is invalid..
Note

◆ RM_MOTOR_INDUCTION_AngleGet()

fsp_err_t RM_MOTOR_INDUCTION_AngleGet ( motor_ctrl_t *const  p_ctrl,
float *const  p_angle_rad 
)

Get current rotor angle. Implements motor_api_t::angleGet.

Example:

/* Get current rotor angle */
(void) RM_MOTOR_INDUCTION_AngleGet(g_motor_induction0_smpl.p_ctrl, &smpl_angle);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTData received pointer is invalid..
Note

◆ RM_MOTOR_INDUCTION_SpeedGet()

fsp_err_t RM_MOTOR_INDUCTION_SpeedGet ( motor_ctrl_t *const  p_ctrl,
float *const  p_speed_rpm 
)

Get rotational speed. Implements motor_api_t::speedGet.

Example:

/* Get current motor rotational speed */
(void) RM_MOTOR_INDUCTION_SpeedGet(g_motor_induction0_smpl.p_ctrl, &smpl_speed);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTData received pointer is invalid..
Note

◆ RM_MOTOR_INDUCTION_ErrorCheck()

fsp_err_t RM_MOTOR_INDUCTION_ErrorCheck ( motor_ctrl_t *const  p_ctrl,
uint16_t *const  p_error 
)

Check the occurunce of Error. Implements motor_api_t::errorCheck.

Example:

/* Check error */
(void) RM_MOTOR_INDUCTION_ErrorCheck(g_motor_induction0_smpl.p_ctrl, &smpl_error);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTData received pointer is invalid..
Note

◆ RM_MOTOR_INDUCTION_WaitStopFlagGet()

fsp_err_t RM_MOTOR_INDUCTION_WaitStopFlagGet ( motor_ctrl_t *const  p_ctrl,
motor_wait_stop_flag_t *const  p_flag 
)

Get wait stop flag. Implements motor_api_t::waitStopFlagGet.

Example:

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note

◆ RM_MOTOR_INDUCTION_FunctionSelect()

fsp_err_t RM_MOTOR_INDUCTION_FunctionSelect ( motor_ctrl_t *const  p_ctrl,
motor_function_select_t const  function 
)

Select using function. Implements motor_api_t::functionSelect.

Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_MODEMode unmatch
Note

◆ RM_MOTOR_INDUCTION_InertiaEstimateStart()

fsp_err_t RM_MOTOR_INDUCTION_InertiaEstimateStart ( motor_ctrl_t *const  p_ctrl)

Start inertia estimation function.

Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_MODEMode unmatch
Note

◆ RM_MOTOR_INDUCTION_InertiaEstimateStop()

fsp_err_t RM_MOTOR_INDUCTION_InertiaEstimateStop ( motor_ctrl_t *const  p_ctrl)

Stop(Cancel) inertia estimation function.

Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_MODEMode unmatch
Note

◆ RM_MOTOR_INDUCTION_ReturnOriginStart()

fsp_err_t RM_MOTOR_INDUCTION_ReturnOriginStart ( motor_ctrl_t *const  p_ctrl)

Start return origin function.

Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_MODEMode unmatch
Note

◆ RM_MOTOR_INDUCTION_ReturnOriginStop()

fsp_err_t RM_MOTOR_INDUCTION_ReturnOriginStop ( motor_ctrl_t *const  p_ctrl)

Stop(Cancel) return origin function.

Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_MODEMode unmatch
Note