Search origin position proccess for the motor control on RA MCUs. This module implements the Motor Return Origin Function Interface.
Overview
The motor return origin module is used to search origin position in an application. This module should be used with Renesas Motor Workbench (RMW) basically.
Features
The Motor return origin module has below features.
- Search origin position automatically.
Configuration
Build Time Configurations for rm_motor_return_origin
The following build time configurations are defined in fsp_cfg/rm_motor_return_origin_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Motor > Motor return origin function (rm_motor_return_origin)
This module can be added to the Stacks tab via New Stack > Motor > Motor return origin function (rm_motor_return_origin).
Configuration | Options | Default | Description |
General |
Name | Name must be a valid C symbol | g_motor_return_origin0 | Module name. |
Using mode | Search by pushing | Search by pushing | Select using mode |
Search speed (rpm) | Must be a valid non-negative value. | 10.0 | Speed to search origin position (rpm) |
Acceleration of speed (rpm/sec) | Must be set 1 to 10000. | 10000.0 | Acceleration of rotation speed at return moving (rpm/sec) |
Cyclic period of speed control (sec) | Must be a valid non-negative value. | 0.0005 | Cyclic period of speed control (sec) |
Maximum current (A) | Must be a valid non-negative value. | 1.8 | Maximum current (A). Please set to match used motor. |
Percentage of current to judge pushing (%) | Must be a valid non-negative value. | 30.0 | Perentage of current to judge pushing (%) |
Pushing time (sec) | Must be a valid non-negative value. | 1.0 | Time to push the stopper (sec) |
Degree to judge none stopper | Must be set -360 to 360. | 360.0 | When the motor runs over this value, it is judged impossible to search the stopper. |
Degree to return | Must be a valid non-negative value. | 3.0 | Degree to return from the stopper (degree) |
Mechanical gear ratio | Must be a valid non-negative value. | 1.0 | Mechanical gear ratio |
Clock Configuration
This module doesn't depend on clock setting.
Pin Configuration
This module does not use I/O pins.
Usage Notes
Limitations
Examples
Basic Example
This is a basic example of minimal use of the Motor Return origin in an application.
void motor_return_origin_basic_example (void)
{
assert(FSP_SUCCESS == err);
temp_set_data.f_iq = 1.0F;
temp_set_data.f_position_degree = 180.0F;
}
◆ motor_return_origin_extended_cfg_t
struct motor_return_origin_extended_cfg_t |
Extended configurations for return origin function
Data Fields |
float |
f_search_speed_rpm |
Speed to search origin position [rpm]. |
float |
f_return_accel_rpm |
Acceleration speed when return [rpm/s]. |
float |
f_speed_ctrl_period |
Period of speed control [sec]. |
float |
f_maximum_current |
Maximum current [A]. |
float |
f_current_limit_percent_push |
Percentage of current at pushing. |
float |
f_pushing_time |
Keep pushing time [sec]. |
float |
f_over_degree |
Angle to judge search impossible [degree]. |
float |
f_return_degree |
Return angle from pushing position [degree]. |
float |
f_mechanical_gear_ratio |
Mechanical gear ratio. |
◆ motor_return_origin_pushing_t
struct motor_return_origin_pushing_t |
Variables for rerutn origin with pushing
Data Fields |
uint32_t |
u4_time_counter |
Counter of speed cyclic (to judge the time) |
float |
f_sum_position |
Summary of position data. |
uint32_t |
u4_sum_counter |
Counter of summary. |
float |
f_move_amount |
Movement amount [degree]. |
float |
f_judge_iq |
q-axis current to judge pushing |
float |
f_pushing_counts |
Counts to measure pushing time. |
◆ motor_return_origin_instance_ctrl_t
struct motor_return_origin_instance_ctrl_t |
Return origin function instance control block
Data Fields |
uint32_t |
open |
Used to determine if the module is configured. |
motor_return_origin_start_flag_t |
start_flag |
start/stop flag |
motor_return_origin_state_t |
state |
State number of return origin process. |
int8_t |
s1_direction |
Moving direction. |
float |
f_angle_degree_on_edge |
Rotor angle on the edge [degree]. |
float |
f_current_speed |
Current speed. |
float |
f_origin_position_angle_degree |
Searched origin position [degree]. |
float |
f_search_speed |
Speed to search origin position [rad / sampling time]. |
float |
f_accel_speed |
Speed accelaration. |
float |
f_position_reference_degree |
Position reference [degree]. |
motor_return_origin_pushing_t |
st_pushing |
Variables for pushing. |
motor_return_origin_set_data_t |
receive_data |
Received data from speed(position) & current. |
motor_return_origin_cfg_t const * |
p_cfg |
Pointer of configuration structure. |
◆ RM_MOTOR_RETURN_ORIGIN_Open()
Opens and configures the motor return origin module. Implements motor_return_origin_api_t::open.
Example:
- Return values
-
FSP_SUCCESS | Motor return origin module 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 | Input parameter error. |
◆ RM_MOTOR_RETURN_ORIGIN_Close()
Disables specified motor return origin module. Implements motor_return_origin_api_t::close.
Example:
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_RETURN_ORIGIN_Start()
Start return origin function. Implements motor_return_origin_api_t::start.
Example:
- Return values
-
FSP_SUCCESS | Successfully started. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_RETURN_ORIGIN_Stop()
Stop (Cancel) return origin function. Implements motor_return_origin_api_t::stop.
Example:
- Return values
-
FSP_SUCCESS | Successfully stopped (canceled). |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_RETURN_ORIGIN_Reset()
Reset variables of return origin module. Implements motor_return_origin_api_t::reset.
- Return values
-
FSP_SUCCESS | Successfully reset. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_RETURN_ORIGIN_InfoGet()
Get information of return origin. Implements motor_return_origin_api_t::infoGet.
Example:
- Return values
-
FSP_SUCCESS | Successfully get data. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
◆ RM_MOTOR_RETURN_ORIGIN_DataSet()
Set necessary data to return origin function. Implements motor_return_origin_api_t::dataSet.
Example:
- Return values
-
FSP_SUCCESS | Successfully set data. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
◆ RM_MOTOR_RETURN_ORIGIN_SpeedCyclic()
Cyclic process of return origin function at speed control period. (Called at timer interrupt.) Implements motor_return_origin_api_t::speedCyclic.
- Return values
-
FSP_SUCCESS | Successfully perform the process. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_RETURN_ORIGIN_ParameterUpdate()
Update the parameters of return origin function. Implements motor_return_origin_api_t::parameterUpdate.
- Return values
-
FSP_SUCCESS | Successfully data was updated. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |