RA Flexible Software Package Documentation
Release v5.6.0
|
|
Usual control of a SPM (Surface Permanent Magnet) motor on RA MCUs. This module implements the Motor 120 degree control (rm_motor_120_degree).
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.
The motor 120 degree module has below features.
The below figure shows examples of target hardware of this Motor 120-degree Module.
The modulation factor "m" is defined as follows.
The below figure shows a state transition diagram. Internal state is managed by "SYSTEM MODE".
(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 |
The below figures show flowcharts of motor 120-degree module.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
General | |||
Name | Name must be a valid C symbol | g_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 | |||
Callback | Name must be a valid C symbol | NULL | A user callback function. |
This module doesn't depend on clock setting, because this module is a simple status transition process.
This module does not use I/O pins. Please set used pins on configuration of each hardware modules.
This is a basic example of minimal use of the motor 120 degree in an application.
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 |
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. |
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) |
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:
FSP_SUCCESS | Successfully configured. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
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:
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_120_DEGREE_Reset | ( | motor_ctrl_t *const | p_ctrl | ) |
Reset motor control block. Implements motor_api_t::reset.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully started. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully stopped. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully set error infomation. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully set speed reference. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully got current control status. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_POINTER | Data received pointer is invalid. |
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:
FSP_SUCCESS | Successfully got rotational speed. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_POINTER | Data received pointer is invalid. |
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:
FSP_SUCCESS | Successfully got wait stop flag. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_POINTER | Data received pointer is invalid. |
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:
FSP_SUCCESS | Successfully error checke process. |
FSP_ERR_ASSERTION | p_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_POINTER | Data received pointer is invalid. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |