RA Flexible Software Package Documentation  Release v5.2.0

 
Motor return origin (rm_motor_return_origin)

Functions

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Open (motor_return_origin_ctrl_t *const p_ctrl, motor_return_origin_cfg_t const *const p_cfg)
 Opens and configures the motor return origin module. Implements motor_return_origin_api_t::open. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_Close (motor_return_origin_ctrl_t *const p_ctrl)
 Disables specified motor return origin module. Implements motor_return_origin_api_t::close. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_Start (motor_return_origin_ctrl_t *const p_ctrl)
 Start return origin function. Implements motor_return_origin_api_t::start. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_Stop (motor_return_origin_ctrl_t *const p_ctrl)
 Stop (Cancel) return origin function. Implements motor_return_origin_api_t::stop. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_Reset (motor_return_origin_ctrl_t *const p_ctrl)
 Reset variables of return origin module. Implements motor_return_origin_api_t::reset. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_InfoGet (motor_return_origin_ctrl_t *const p_ctrl, motor_return_origin_info_t *const p_info)
 Get information of return origin. Implements motor_return_origin_api_t::infoGet. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_DataSet (motor_return_origin_ctrl_t *const p_ctrl, motor_return_origin_set_data_t *const p_set_data)
 Set necessary data to return origin function. Implements motor_return_origin_api_t::dataSet. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_SpeedCyclic (motor_return_origin_ctrl_t *const p_ctrl)
 Cyclic process of return origin function at speed control period. (Called at timer interrupt.) Implements motor_return_origin_api_t::speedCyclic. More...
 
fsp_err_t RM_MOTOR_RETURN_ORIGIN_ParameterUpdate (motor_return_origin_ctrl_t *const p_ctrl, motor_return_origin_cfg_t const *const p_cfg)
 Update the parameters of return origin function. Implements motor_return_origin_api_t::parameterUpdate. More...
 

Detailed Description

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.

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:

ConfigurationOptionsDefaultDescription
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).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_return_origin0 Module name.
Using modeSearch by pushingSearch 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 stopperMust be set -360 to 360.360.0 When the motor runs over this value, it is judged impossible to search the stopper.
Degree to returnMust be a valid non-negative value.3.0 Degree to return from the stopper (degree)
Mechanical gear ratioMust 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)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_RETURN_ORIGIN_Open(&g_mtr_return_origin0_ctrl, &g_mtr_return_origin0_cfg);
assert(FSP_SUCCESS == err);
/* Start process. */
err = RM_MOTOR_RETURN_ORIGIN_Start(&g_mtr_return_origin0_ctrl);
temp_set_data.f_iq = 1.0F;
temp_set_data.f_position_degree = 180.0F;
/* Set data to the module. */
err = RM_MOTOR_RETURN_ORIGIN_DataSet(&g_mtr_return_origin0_ctrl, &temp_set_data);
/* Get information from the module. */
err = RM_MOTOR_RETURN_ORIGIN_InfoGet(&g_mtr_return_origin0_ctrl, &temp_info);
/* Stop process. */
err = RM_MOTOR_RETURN_ORIGIN_Stop(&g_mtr_return_origin0_ctrl);
/* Close the module. */
err = RM_MOTOR_RETURN_ORIGIN_Close(&g_mtr_return_origin0_ctrl);
}

Data Structures

struct  motor_return_origin_extended_cfg_t
 
struct  motor_return_origin_pushing_t
 
struct  motor_return_origin_instance_ctrl_t
 

Data Structure Documentation

◆ 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.

Function Documentation

◆ RM_MOTOR_RETURN_ORIGIN_Open()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Open ( motor_return_origin_ctrl_t *const  p_ctrl,
motor_return_origin_cfg_t const *const  p_cfg 
)

Opens and configures the motor return origin module. Implements motor_return_origin_api_t::open.

Example:

/* Initializes the module. */
err = RM_MOTOR_RETURN_ORIGIN_Open(&g_mtr_return_origin0_ctrl, &g_mtr_return_origin0_cfg);
Return values
FSP_SUCCESSMotor return origin module 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_ARGUMENTInput parameter error.

◆ RM_MOTOR_RETURN_ORIGIN_Close()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Close ( motor_return_origin_ctrl_t *const  p_ctrl)

Disables specified motor return origin module. Implements motor_return_origin_api_t::close.

Example:

/* Close the module. */
err = RM_MOTOR_RETURN_ORIGIN_Close(&g_mtr_return_origin0_ctrl);
Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_RETURN_ORIGIN_Start()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Start ( motor_return_origin_ctrl_t *const  p_ctrl)

Start return origin function. Implements motor_return_origin_api_t::start.

Example:

/* Start process. */
err = RM_MOTOR_RETURN_ORIGIN_Start(&g_mtr_return_origin0_ctrl);
Return values
FSP_SUCCESSSuccessfully started.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_RETURN_ORIGIN_Stop()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Stop ( motor_return_origin_ctrl_t *const  p_ctrl)

Stop (Cancel) return origin function. Implements motor_return_origin_api_t::stop.

Example:

/* Stop process. */
err = RM_MOTOR_RETURN_ORIGIN_Stop(&g_mtr_return_origin0_ctrl);
Return values
FSP_SUCCESSSuccessfully stopped (canceled).
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_RETURN_ORIGIN_Reset()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_Reset ( motor_return_origin_ctrl_t *const  p_ctrl)

Reset variables of return origin module. Implements motor_return_origin_api_t::reset.

Return values
FSP_SUCCESSSuccessfully reset.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_RETURN_ORIGIN_InfoGet()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_InfoGet ( motor_return_origin_ctrl_t *const  p_ctrl,
motor_return_origin_info_t *const  p_info 
)

Get information of return origin. Implements motor_return_origin_api_t::infoGet.

Example:

/* Get information from the module. */
err = RM_MOTOR_RETURN_ORIGIN_InfoGet(&g_mtr_return_origin0_ctrl, &temp_info);
Return values
FSP_SUCCESSSuccessfully get data.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput parameter error.

◆ RM_MOTOR_RETURN_ORIGIN_DataSet()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_DataSet ( motor_return_origin_ctrl_t *const  p_ctrl,
motor_return_origin_set_data_t *const  p_set_data 
)

Set necessary data to return origin function. Implements motor_return_origin_api_t::dataSet.

Example:

/* Set data to the module. */
err = RM_MOTOR_RETURN_ORIGIN_DataSet(&g_mtr_return_origin0_ctrl, &temp_set_data);
Return values
FSP_SUCCESSSuccessfully set data.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput parameter error.

◆ RM_MOTOR_RETURN_ORIGIN_SpeedCyclic()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_SpeedCyclic ( motor_return_origin_ctrl_t *const  p_ctrl)

Cyclic process of return origin function at speed control period. (Called at timer interrupt.) Implements motor_return_origin_api_t::speedCyclic.

Return values
FSP_SUCCESSSuccessfully perform the process.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_RETURN_ORIGIN_ParameterUpdate()

fsp_err_t RM_MOTOR_RETURN_ORIGIN_ParameterUpdate ( motor_return_origin_ctrl_t *const  p_ctrl,
motor_return_origin_cfg_t const *const  p_cfg 
)

Update the parameters of return origin function. Implements motor_return_origin_api_t::parameterUpdate.

Return values
FSP_SUCCESSSuccessfully data was updated.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput parameter error.