RA Flexible Software Package Documentation  Release v5.6.0

 
Motor Vector Control with hall sensors (rm_motor_hall)

Functions

fsp_err_t RM_MOTOR_HALL_Open (motor_ctrl_t *const p_ctrl, motor_cfg_t const *const p_cfg)
 
fsp_err_t RM_MOTOR_HALL_Close (motor_ctrl_t *const p_ctrl)
 Disables specified Motor Hall Control block. Implements motor_api_t::close. More...
 
fsp_err_t RM_MOTOR_HALL_Reset (motor_ctrl_t *const p_ctrl)
 Reset Motor Hall Control block. Implements motor_api_t::reset. More...
 
fsp_err_t RM_MOTOR_HALL_Run (motor_ctrl_t *const p_ctrl)
 Run Motor (Start motor rotation). Implements motor_api_t::run. More...
 
fsp_err_t RM_MOTOR_HALL_Stop (motor_ctrl_t *const p_ctrl)
 Stop Motor (Stop motor rotation). Implements motor_api_t::stop. More...
 
fsp_err_t RM_MOTOR_HALL_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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_PositionSet (motor_ctrl_t *const p_ctrl, motor_speed_position_data_t const *const p_position)
 Set position reference. Implements motor_api_t::positionSet. More...
 
fsp_err_t RM_MOTOR_HALL_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_HALL_FunctionSelect (motor_ctrl_t *const p_ctrl, motor_function_select_t const function)
 Select function. Implements motor_api_t::functionSelect. More...
 

Detailed Description

Usual control of a SPM motor on RA MCUs. This module implements the Motor Vector Control with hall sensors (rm_motor_hall).

Overview

The motor vector control with hall sensors is used to control a motor rotation in an appication. 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 vector control with hall sensors has below features.

Target Hardware

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

rm_motor_hall_hardware.png
Example of target hardware of motor hall module

Block Diagram

The below figure shows block diaram of vector motor control with hall sensors.

rm_motor_hall_block_diagram.png
Block diagram of vector control with hall sensors

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 hall module.

rm_motor_sensorless_main_flowchart.png
Main process
rm_motor_hall_current_cyclic.png
Current control process
rm_motor_hall_speed_cyclic.png
Speed control process
rm_motor_sensorless_overcurrent_flowchart.png
Over current detection interrupt process

Configuration

Build Time Configurations for rm_motor_hall

The following build time configurations are defined in fsp_cfg/rm_motor_hall_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 hall sensors(rm_motor_hall)

This module can be added to the Stacks tab via New Stack > Motor > Motor Vector Control with hall sensors(rm_motor_hall).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_hall0 Module name.
Limit of over current (A)Must be a valid value0.42F 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 value14.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 vector control with hall sensors in an application.

void motor_hall_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_HALL_Open(g_motor_hall0_smpl.p_ctrl, g_motor_hall0_smpl.p_cfg);
assert(FSP_SUCCESS == err);
/* Set speed reference before motor run */
(void) RM_MOTOR_HALL_SpeedSet(g_motor_hall0_smpl.p_ctrl, DEF_HALL_TEST_OVSPD_LIM);
/* Start motor rotation */
(void) RM_MOTOR_HALL_Run(g_motor_hall0_smpl.p_ctrl);
/* Get current status */
(void) RM_MOTOR_HALL_StatusGet(g_motor_hall0_smpl.p_ctrl, &smpl_status);
/* Get current rotor angle */
(void) RM_MOTOR_HALL_AngleGet(g_motor_hall0_smpl.p_ctrl, &smpl_angle);
/* Get current motor speed */
(void) RM_MOTOR_HALL_SpeedGet(g_motor_hall0_smpl.p_ctrl, &smpl_speed);
/* Check error */
(void) RM_MOTOR_HALL_ErrorCheck(g_motor_hall0_smpl.p_ctrl, &smpl_error);
/* Stop motor rotation */
(void) RM_MOTOR_HALL_Stop(g_motor_hall0_smpl.p_ctrl);
/* When error is detected with extra Hardware */
(void) RM_MOTOR_HALL_ErrorSet(g_motor_hall0_smpl.p_ctrl, MOTOR_ERROR_OVER_CURRENT_HW);
/* Reset motor control (Clear error status) */
(void) RM_MOTOR_HALL_Reset(g_motor_hall0_smpl.p_ctrl);
/* Close motor control */
(void) RM_MOTOR_HALL_Close(g_motor_hall0_smpl.p_ctrl);
}

Function Documentation

◆ RM_MOTOR_HALL_Open()

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

Configure the MOTOR HALL 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_HALL_Open(g_motor_hall0_smpl.p_ctrl, g_motor_hall0_smpl.p_cfg);
Return values
FSP_SUCCESSMOTOR HALL 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_HALL_Close()

fsp_err_t RM_MOTOR_HALL_Close ( motor_ctrl_t *const  p_ctrl)

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

Example:

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

◆ RM_MOTOR_HALL_Reset()

fsp_err_t RM_MOTOR_HALL_Reset ( motor_ctrl_t *const  p_ctrl)

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

Example:

/* Reset motor control (Clear error status) */
(void) RM_MOTOR_HALL_Reset(g_motor_hall0_smpl.p_ctrl);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_HALL_Run()

fsp_err_t RM_MOTOR_HALL_Run ( motor_ctrl_t *const  p_ctrl)

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

Example:

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

◆ RM_MOTOR_HALL_Stop()

fsp_err_t RM_MOTOR_HALL_Stop ( motor_ctrl_t *const  p_ctrl)

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

Example:

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

◆ RM_MOTOR_HALL_ErrorSet()

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

Set error information. Implements motor_api_t::errorSet.

Example:

/* When error is detected with extra Hardware */
(void) RM_MOTOR_HALL_ErrorSet(g_motor_hall0_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_HALL_SpeedSet()

fsp_err_t RM_MOTOR_HALL_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_HALL_SpeedSet(g_motor_hall0_smpl.p_ctrl, DEF_HALL_TEST_OVSPD_LIM);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_HALL_StatusGet()

fsp_err_t RM_MOTOR_HALL_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_HALL_StatusGet(g_motor_hall0_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_HALL_AngleGet()

fsp_err_t RM_MOTOR_HALL_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_HALL_AngleGet(g_motor_hall0_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_HALL_SpeedGet()

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

Get rotational speed. Implements motor_api_t::speedGet.

Example:

/* Get current motor speed */
(void) RM_MOTOR_HALL_SpeedGet(g_motor_hall0_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_HALL_ErrorCheck()

fsp_err_t RM_MOTOR_HALL_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_HALL_ErrorCheck(g_motor_hall0_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_HALL_PositionSet()

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

Set position reference. Implements motor_api_t::positionSet.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note

◆ RM_MOTOR_HALL_WaitStopFlagGet()

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

Get wait stop flag. Implements motor_api_t::waitStopFlagGet.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note

◆ RM_MOTOR_HALL_FunctionSelect()

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

Select function. Implements motor_api_t::functionSelect.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note