RA Flexible Software Package Documentation  Release v5.7.0

 
Motor 120 degree control (rm_motor_120_degree)

Functions

fsp_err_t RM_MOTOR_120_DEGREE_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. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_Close (motor_ctrl_t *const p_ctrl)
 Disables specified motor control block. Implements motor_api_t::close. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_Reset (motor_ctrl_t *const p_ctrl)
 Reset motor control block. Implements motor_api_t::reset. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_Run (motor_ctrl_t *const p_ctrl)
 Run motor (Start motor rotation). Implements motor_api_t::run. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_Stop (motor_ctrl_t *const p_ctrl)
 Stop motor (Stop motor rotation). Implements motor_api_t::stop. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_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_120_DEGREE_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_120_DEGREE_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_120_DEGREE_WaitStopFlagGet (motor_ctrl_t *const p_ctrl, motor_wait_stop_flag_t *const p_flag_wait_stop)
 Get wait stop flag. Implements motor_api_t::waitStopFlagGet. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_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_120_DEGREE_AngleGet (motor_ctrl_t *const p_ctrl, float *const p_angle_rad)
 Set position reference. Implements motor_api_t::angleGet. More...
 
fsp_err_t RM_MOTOR_120_DEGREE_FunctionSelect (motor_ctrl_t *const p_ctrl, motor_function_select_t const function)
 Select using function. Implements motor_api_t::functionSelect. More...
 

Detailed Description

Usual control of a SPM (Surface Permanent Magnet) motor on RA MCUs. This module implements the Motor 120 degree control (rm_motor_120_degree).

Overview

The motor 120 degree control is used to control a motor rotation in an appication. This module is implemented with using a SPM motor. User can start/stop motor rotation simply.

Features

The motor 120 degree module has below features.

Target Hardware

The below figure shows examples of target hardware of this Motor 120-degree Module.

rm_motor_120_sensorless_hardware.png
Example of target hardware of motor 120-degree sensorless
rm_motor_hall_hardware.png
Example of target hardware of motor 120-degree with hall sensor

Modulation

The modulation factor "m" is defined as follows.

rm_motor_sensorless_moduration.png
Modulation factor

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 120-degree module.

rm_motor_sensorless_main_flowchart.png
Main process
rm_motor_120_degree_current_cyclic.png
Current control process of 120-degree sensorless
rm_motor_120_degree_speed_cyclic.png
Speed control process of 120-degree sensorless
rm_motor_120_hall_current_cyclic.png
Current control process of 120-degree with hall sensor
rm_motor_120_hall_speed_cyclic.png
Speed control process of 120-degree with hall sensor
rm_motor_sensorless_overcurrent_flowchart.png
Over current detection interrupt process

Configuration

Build Time Configurations for rm_motor_120_degree

The following build time configurations are defined in fsp_cfg/rm_motor_120_degree_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 120 degree control (rm_motor_120_degree)

This module can be added to the Stacks tab via New Stack > Motor > Motor 120 degree control (rm_motor_120_degree).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_120_degree0 Module name.
Limit of over current (A)Must be a valid non-negative value.4.0 Limit of over current.(Detection threshold)
Limit of over voltage (V)Must be a valid non-negative value.28.0 Limit of over voltage.(Detection threshold)
Limit of over speed (rpm)Must be a valid non-negative value.3000.0 Limit of over speed.(Detection threshold)
Limit of low voltage (V)Must be a valid non-negative value.14.0 Limit of low voltage.(Detection threshold)
Interrupts
CallbackName must be a valid C symbolNULL A user callback function.

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 120 degree in an application.

void motor_120_degree_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_120_DEGREE_Open(g_motor_120_degree0.p_ctrl, g_motor_120_degree0.p_cfg);
assert(FSP_SUCCESS == err);
/* Set speed reference before motor run */
(void) RM_MOTOR_120_DEGREE_SpeedSet(g_motor_120_degree0.p_ctrl, DEF_120_DEGREE_SPEED_REF);
/* Start motor rotation */
(void) RM_MOTOR_120_DEGREE_Run(g_motor_120_degree0.p_ctrl);
/* Get current status */
(void) RM_MOTOR_120_DEGREE_StatusGet(g_motor_120_degree0.p_ctrl, &smpl_status);
/* Get current motor speed */
(void) RM_MOTOR_120_DEGREE_SpeedGet(g_motor_120_degree0.p_ctrl, &smpl_speed);
/* Get wait stop flag */
(void) RM_MOTOR_120_DEGREE_WaitStopFlagGet(g_motor_120_degree0.p_ctrl, &smpl_wait_stop_flag);
/* Check error */
(void) RM_MOTOR_120_DEGREE_ErrorCheck(g_motor_120_degree0.p_ctrl, &smpl_error);
/* Stop motor rotation */
(void) RM_MOTOR_120_DEGREE_Stop(g_motor_120_degree0.p_ctrl);
(void) RM_MOTOR_120_DEGREE_ErrorSet(g_motor_120_degree0.p_ctrl, MOTOR_ERROR_OVER_CURRENT_HW);
/* Reset the process. */
(void) RM_MOTOR_120_DEGREE_Reset(g_motor_120_degree0.p_ctrl);
/* Close the module. */
(void) RM_MOTOR_120_DEGREE_Close(g_motor_120_degree0.p_ctrl);
}

Data Structures

struct  motor_120_degree_statemachine_t
 
struct  motor_120_degree_extended_cfg_t
 

Enumerations

enum  motor_120_degree_ctrl_status_t
 
enum  motor_120_degree_ctrl_event_t
 

Data Structure Documentation

◆ motor_120_degree_statemachine_t

struct motor_120_degree_statemachine_t

Statemachine structure for motor 120 degree

Data Fields
motor_120_degree_ctrl_status_t status The current system status.
motor_120_degree_ctrl_status_t status_next The next system status.
motor_120_degree_ctrl_event_t current_event The current event index.
uint16_t u2_error_status The error information.

◆ motor_120_degree_extended_cfg_t

struct motor_120_degree_extended_cfg_t

Extended configurations for motor 120 degree

Data Fields
motor_120_control_instance_t
const *
p_motor_120_control_instance 120 degree control Instance
float f_overcurrent_limit Over-current limit (A)
float f_overvoltage_limit Over-voltage limit (V)
float f_overspeed_limit Over-speed limit (rpm)
float f_lowvoltage_limit Low-voltage limit (V)

Enumeration Type Documentation

◆ motor_120_degree_ctrl_status_t

Control state

Enumerator
MOTOR_120_DEGREE_CTRL_STATUS_STOP 

Stop mode.

MOTOR_120_DEGREE_CTRL_STATUS_RUN 

Run mode.

MOTOR_120_DEGREE_CTRL_STATUS_ERROR 

Error mode.

◆ motor_120_degree_ctrl_event_t

Control event

Enumerator
MOTOR_120_DEGREE_CTRL_EVENT_STOP 

Stop event.

MOTOR_120_DEGREE_CTRL_EVENT_RUN 

Run event.

MOTOR_120_DEGREE_CTRL_EVENT_ERROR 

Error event.

MOTOR_120_DEGREE_CTRL_EVENT_RESET 

Reset event.

Function Documentation

◆ RM_MOTOR_120_DEGREE_Open()

fsp_err_t RM_MOTOR_120_DEGREE_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.

Example:

/* Initializes the module. */
err = RM_MOTOR_120_DEGREE_Open(g_motor_120_degree0.p_ctrl, g_motor_120_degree0.p_cfg);
Return values
FSP_SUCCESSSuccessfully 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.
Note
This function should only be called once as motor configuration registers can only be written to once so subsequent calls will have no effect.

◆ RM_MOTOR_120_DEGREE_Close()

fsp_err_t RM_MOTOR_120_DEGREE_Close ( motor_ctrl_t *const  p_ctrl)

Disables specified motor control block. Implements motor_api_t::close.

Example:

/* Close the module. */
(void) RM_MOTOR_120_DEGREE_Close(g_motor_120_degree0.p_ctrl);
Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_Reset()

fsp_err_t RM_MOTOR_120_DEGREE_Reset ( motor_ctrl_t *const  p_ctrl)

Reset motor control block. Implements motor_api_t::reset.

Example:

/* Reset the process. */
(void) RM_MOTOR_120_DEGREE_Reset(g_motor_120_degree0.p_ctrl);
Return values
FSP_SUCCESSSuccessfully resetted.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_Run()

fsp_err_t RM_MOTOR_120_DEGREE_Run ( motor_ctrl_t *const  p_ctrl)

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

Example:

/* Start motor rotation */
(void) RM_MOTOR_120_DEGREE_Run(g_motor_120_degree0.p_ctrl);
Return values
FSP_SUCCESSSuccessfully started.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_Stop()

fsp_err_t RM_MOTOR_120_DEGREE_Stop ( motor_ctrl_t *const  p_ctrl)

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

Example:

/* Stop motor rotation */
(void) RM_MOTOR_120_DEGREE_Stop(g_motor_120_degree0.p_ctrl);
Return values
FSP_SUCCESSSuccessfully stopped.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_ErrorSet()

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

Set error information. Implements motor_api_t::errorSet.

Example:

(void) RM_MOTOR_120_DEGREE_ErrorSet(g_motor_120_degree0.p_ctrl, MOTOR_ERROR_OVER_CURRENT_HW);
Return values
FSP_SUCCESSSuccessfully set error infomation.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_SpeedSet()

fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_SpeedSet(g_motor_120_degree0.p_ctrl, DEF_120_DEGREE_SPEED_REF);
Return values
FSP_SUCCESSSuccessfully set speed reference.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
Note

◆ RM_MOTOR_120_DEGREE_StatusGet()

fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_StatusGet(g_motor_120_degree0.p_ctrl, &smpl_status);
Return values
FSP_SUCCESSSuccessfully got current control status.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_POINTERData received pointer is invalid.
Note

◆ RM_MOTOR_120_DEGREE_SpeedGet()

fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_SpeedGet(g_motor_120_degree0.p_ctrl, &smpl_speed);
Return values
FSP_SUCCESSSuccessfully got rotational speed.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_POINTERData received pointer is invalid.
Note

◆ RM_MOTOR_120_DEGREE_WaitStopFlagGet()

fsp_err_t RM_MOTOR_120_DEGREE_WaitStopFlagGet ( motor_ctrl_t *const  p_ctrl,
motor_wait_stop_flag_t *const  p_flag_wait_stop 
)

Get wait stop flag. Implements motor_api_t::waitStopFlagGet.

Example:

/* Get wait stop flag */
(void) RM_MOTOR_120_DEGREE_WaitStopFlagGet(g_motor_120_degree0.p_ctrl, &smpl_wait_stop_flag);
Return values
FSP_SUCCESSSuccessfully got wait stop flag.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_POINTERData received pointer is invalid.
Note

◆ RM_MOTOR_120_DEGREE_ErrorCheck()

fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_ErrorCheck(g_motor_120_degree0.p_ctrl, &smpl_error);
Return values
FSP_SUCCESSSuccessfully error checke process.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_POINTERData received pointer is invalid.
Note

◆ RM_MOTOR_120_DEGREE_PositionSet()

fsp_err_t RM_MOTOR_120_DEGREE_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_120_DEGREE_AngleGet()

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

Set position reference. Implements motor_api_t::angleGet.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note

◆ RM_MOTOR_120_DEGREE_FunctionSelect()

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

Select using function. Implements motor_api_t::functionSelect.

Return values
FSP_ERR_UNSUPPORTEDUnsupported.
Note