RA Flexible Software Package Documentation
Release v5.6.0
|
|
Usual control of a SPM motor on RA MCUs. This module implements the Motor Vector Control with hall sensors (rm_motor_hall).
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.
The motor vector control with hall sensors has below features.
The below figure shows an example of target hardware of this Motor Hall Module.
The below figure shows block diaram of vector motor control with hall sensors.
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 hall 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_hall0 | Module name. |
Limit of over current (A) | Must be a valid value | 0.42F | Limit of over current.(Detection threshold) |
Limit of over voltage (V) | Must be a valid value | 28.0F | Limit of over voltage.(Detection threshold) |
Limit of over speed (rpm) | Must be a valid value | 3000.0F | Limit of over speed.(Detection threshold) |
Limit of low voltage (V) | Must be a valid value | 14.0F | Limit of low voltage.(Detection threshold) |
Interrupts | |||
Callback | Name must be a valid C symbol | NULL | A user callback function. If this callback function is provided, it is called at speed control cyclic interrupt. |
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 vector control with hall sensors in an application.
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:
FSP_SUCCESS | MOTOR HALL 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_INVALID_ARGUMENT | Configuration parameter error. |
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:
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_HALL_Reset | ( | motor_ctrl_t *const | p_ctrl | ) |
Reset Motor Hall Control block. Implements motor_api_t::reset.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_HALL_Run | ( | motor_ctrl_t *const | p_ctrl | ) |
Run Motor (Start motor rotation). Implements motor_api_t::run.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_HALL_Stop | ( | motor_ctrl_t *const | p_ctrl | ) |
Stop Motor (Stop motor rotation). Implements motor_api_t::stop.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Data received pointer is invalid.. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Data received pointer is invalid.. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Data received pointer is invalid.. |
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:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Data received pointer is invalid.. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |
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.
FSP_ERR_UNSUPPORTED | Unsupported. |