![]() |
RA Flexible Software Package Documentation
Release v6.0.0
|
|
Calculation process for the motor control on RA MCUs. This module implements the Motor 120-Degree Control Interface.
The motor current is used to control the electric current of motor rotation in an application. This module should be called cyclically after the A/D conversion of electric current of each phase in an application. This module calculates each phase voltage with input current reference, electric current and rotor angle.
The motor 120 control sensorless module has below features.
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_control_sensorless0 | Module name. |
Conduction type |
| First 60 degree PWM | Select conduction type |
Stop BEMF | Must be a valid non-negative value. | 0.5 | Value of stop motor BEMF (U+V+W) |
Timeout counts (msec) | Must be a valid integer. | 2000 | Undetected time |
Maximum voltage for BOOT (V) | Must be a valid non-negative value. | 8.0 | Maximum output voltage for boot mode (V) |
Maximum voltage (V) | Must be a valid non-negative value. | 20.0 | Maximum output voltage (V) |
Minimum voltage (V) | Must be a valid non-negative value. | 3.0 | Minimum output voltage (V) |
Carrier frequency (kHz) | Must be a valid non-negative value. | 20.0 | PWM carrier frequency (kHz) |
Adjusting angle | Must be a valid non-negative value. | 0 | Adjusting angle |
Speed PI decimation | Must be a valid integer. | 1 | Speed PI control decimation count |
Free run timer frequency (MHz) | Must be a valid integer. | 120 | Freerun timer frequency (MHz) |
Speed LPF K | Must be a valid non-negative value. | 1.0 | Speed LPF parameter |
Step of speed change | Must be a valid non-negative value. | 0.2 | Speed reference change step |
Boot reference voltage (V) | Must be a valid non-negative value. | 3.0 | Voltage reference for boot mode |
Voltage lamping time | Must be a valid integer. | 128 | Voltage lamping time |
Voltage constant adjust time | Must be a valid integer. | 64 | Voltage constant adjust time value (msec) |
Open loop start speed (rpm) | Must be a valid integer value. | 150 | Open loop start speed (rpm) |
Open loop mode2 speed (rpm) | Must be a valid integer value. | 185 | to mode2 change speed (rpm) |
Open loop mode3 speed (rpm) | Must be a valid integer value. | 1000 | to mode3 change speed (rpm) |
Open loop start voltage (V) | Must be a valid non-negative value. | 3.0 | start reference voltage (V) |
Open loop mode1 speed rate | Must be a valid non-negative value. | 0.25 | increase rate of reference speed (rpm/control period) |
Open loop mode2 voltage rate | Must be a valid non-negative value. | 0.00285 | increase rate of reference voltage (v/control period) |
Open loop mode2 speed rate | Must be a valid non-negative value. | 0.71 | increase rate of reference speed (rpm/control period) |
Open loop mode3 voltage rate | Must be a valid non-negative value. | 0.002 | increase rate of reference voltage (v/control period) |
Open loop maximum voltage (V) | Must be a valid non-negative value. | 6.5 | openloop maximum voltage (V) |
PI control KP | Must be a valid non-negative value. | 0.02 | PI control gain of proportional term |
PI control KI | Must be a valid non-negative value. | 0.004 | PI control gain of integral term |
PI control limit | Must be a valid non-negative value. | 24.0 | PI control limit of integral term |
Motor Parameter | |||
Pole pairs | Must be a valid integer. | 2 | Pole pairs |
Resistance (ohm) | Must be a valid non-negative value. | 6.447 | Resistance |
Inductance of d-axis (H) | Must be a valid non-negative value. | 0.0045 | Inductance of d-axis |
Inductance of q-axis (H) | Must be a valid non-negative value. | 0.0045 | Inductance of q-axis |
Permanent magnetic flux (Wb) | Must be a valid non-negative value. | 0.02159 | Permanent magnetic flux |
Motor Parameter > Rotor inertia (kgm^2) | Must be a valid non-negative value. | 1.8 | Rotor inertia |
Interrupts | |||
Callback | Name must be a valid C symbol | NULL | callback function |
This module doesn't depend on clock setting, because this module is a simple calculation process.
This module does not use I/O pins.
This is a basic example of minimal use of the motor 120 control sensorless in an application.
Data Structures | |
struct | motor_120_control_sensorless_extended_cfg_t |
struct | motor_120_control_sensorless_instance_ctrl_t |
Enumerations | |
enum | motor_120_control_sensorless_draw_in_position_t |
enum | motor_120_control_sensorless_pattern_change_flag_t |
struct motor_120_control_sensorless_extended_cfg_t |
Extended configurations for motor 120 control sensorless
Data Fields | ||
---|---|---|
float | f4_stop_bemf | Value of stop motor BEMF (U+V+W) |
float | f4_max_boot_v | Max output voltage for boot mode (V) |
float | f4_carrier_freq | Carrier wave frequency (kHz) |
int32_t | s4_angle_shift_adjust | Adjusting angle. |
float | f4_boot_ref_v | Voltage reference when zero speed (V) |
uint32_t | u4_v_up_time | Voltage lamping time. |
uint32_t | u4_v_const_time | Voltage constant adjust time value (ms) |
int32_t | s4_ol_start_rpm | Start speed (rpm) |
int32_t | s4_ol_mode1_change_rpm | To mode2 change speed (rpm) |
int32_t | s4_ol_mode2_change_rpm | To mode3 change speed (rpm) |
float | f4_ol_start_refv | Start reference voltage (V) |
float | f4_ol_mode1_rate_rpm | Increase rate of reference speed (rpm/control period) |
float | f4_ol_mode2_rate_refv | Increase rate of reference voltage (v/control period) |
float | f4_ol_mode2_rate_rpm | Increase rate of reference speed (rpm/control period) |
float | f4_ol_mode3_rate_refv | Increase rate of reference voltage (v/control period) |
float | f4_ol_mode3_max_refv | Openloop max voltage (V) |
motor_120_driver_instance_t const * |
p_motor_120_driver_instance | Motor 120 driver access module. |
timer_instance_t const * | p_speed_cyclic_timer_instance | Cyclic process of speed control timer module. |
timer_instance_t const * | p_speed_calc_timer_instance | Speed calculate timer module. |
struct motor_120_control_sensorless_instance_ctrl_t |
120 control sensorless instance control block
Data Fields | ||
---|---|---|
uint32_t | open | Used to determine if the channel is configured. |
motor_120_control_status_t | active | Flag to set active/inactive the motor 120 control. |
motor_120_control_run_mode_t | run_mode | Drive mode. |
motor_120_control_timeout_error_flag_t | timeout_error_flag | Timeout error status. |
motor_120_control_pattern_error_flag_t | pattern_error_flag | Bemf pattern error status. |
motor_120_control_rotation_direction_t | direction | Rotational direction (0:CW ,1:CCW) |
float | f4_ol_pattern_set_calc | Counts to change timing of open loop pattern. |
float | f4_speed_calc_base | Base counts to calculate rotation speed. |
float | f_rpm2rad | Translate value to radian/second to rpm. |
float | f4_v_ref | Voltage reference (output of speed PI control) |
uint32_t | u4_pwm_duty | PWM duty. |
float | f4_ref_speed_rad | Motor speed reference. |
float | f4_ref_speed_rad_ctrl | Motor speed reference for speed PI control. |
float | f4_speed_rad | Motor speed. |
uint32_t | u4_cnt_speed_pi | Counter for period of speed PI control. |
motor_120_control_wait_stop_flag_t | flag_wait_stop | Flag for waiting for motor stop. |
float | f4_vn_ad | Neutral voltage. |
uint32_t | u4_cnt_adj_v | Voltage lamping count adjustment. |
motor_120_control_sensorless_draw_in_position_t | flag_draw_in | Status of draw in a initial position. |
motor_120_driver_phase_pattern_t | v_pattern | Voltage pattern. |
uint32_t | u4_v_pattern_num | Selecting pattern number for openloop drive. |
uint32_t | u4_bemf_signal | Pattern of BEMF. |
uint32_t | u4_pre_bemf_signal | Previous pattern of BEMF. |
motor_120_control_sensorless_pattern_change_flag_t | flag_pattern_change | Pattern change flag. |
motor_120_control_speed_ref_t | flag_speed_ref | Speed reference flag. |
motor_120_control_voltage_ref_t | flag_voltage_ref | Voltage reference flag. |
uint32_t | u4_ol_signal | Pattern of BEMF. |
uint32_t | u4_ol_pattern_set | Openloop frequency. |
uint32_t | u4_cnt_ol_pattern_set | Counter for openloop pattern change. |
uint32_t | u4_cnt_timeout | Counter for timeout error. |
uint32_t | u4_bemf_timer_cnt | Value of timer counter. |
uint32_t | u4_pre_bemf_timer_cnt | Previous value of timer counter. |
int32_t | s4_timer_cnt_ave | Counts for 360 degrees. |
uint32_t | u4_timer_cnt_buf[MOTOR_120_CONTROL_SENSORLESS_TIMES] | Counts for 60 degrees. |
uint32_t | u4_timer_cnt_num | Array element number before 360 degrees. |
uint32_t | u4_cnt_carrier | Counter for carrier interrupt. |
uint32_t | u4_pre_cnt_carrier | Previous carrier interrupt count. |
uint32_t | u4_angle_shift_cnt | Shift degrees count. |
float | f4_pi_ctrl_err | PI control error. |
float | f4_pi_ctrl_refi | PI control buffer of integral term. |
motor_120_control_cfg_t const * | p_cfg | Pointer of configuration structure. |
timer_direction_t | timer_direction | Hold timer direction. |
timer_callback_args_t | timer_args | For call timer callbackSet function. |
Draw in a initial position
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_Open | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_cfg_t const *const | p_cfg | ||
) |
Opens and configures the motor sensorless 120 detection module. Implements motor_120_control_api_t::open.
Example:
FSP_SUCCESS | Motor driver 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. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_Close | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Disables specified motor sensorless 120 detection module. Implements motor_120_control_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_120_CONTROL_SENSORLESS_Run | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Run motor (Start motor rotation). Implements motor_120_control_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_120_CONTROL_SENSORLESS_Stop | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Stop motor (Stop motor rotation). Implements motor_120_control_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_120_CONTROL_SENSORLESS_Reset | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Reset variables of motor sensorless 120 detection module. Implements motor_120_control_api_t::reset.
Example:
FSP_SUCCESS | Successfully reset. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_SpeedSet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
float const | speed_rpm | ||
) |
Set speed[rpm]. Implements motor_120_control_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_120_CONTROL_SENSORLESS_SpeedGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
float *const | p_speed_rpm | ||
) |
Get speed. Implements motor_120_control_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 | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_CurrentGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_driver_current_status_t *const | p_current_status | ||
) |
Get current. Implements motor_120_control_api_t::currentGet.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_WaitStopFlagGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_wait_stop_flag_t *const | p_flag | ||
) |
Get wait stop flag. Implements motor_120_control_api_t::waitStopFlagGet.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_TimeoutErrorFlagGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_timeout_error_flag_t *const | p_timeout_error_flag | ||
) |
Get timeout error flag. Implements motor_120_control_api_t::timeoutErrorFlagGet.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_PatternErrorFlagGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_pattern_error_flag_t *const | p_pattern_error_flag | ||
) |
Get pattern error flag. Implements motor_120_control_api_t::patternErrorFlagGet.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_VoltageRefGet | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_voltage_ref_t *const | p_voltage_ref | ||
) |
Get voltage ref. Implements motor_120_control_api_t::voltageRefGet.
Example:
FSP_SUCCESS | Successfully resetted. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Input parameter error. |
fsp_err_t RM_MOTOR_120_CONTROL_SENSORLESS_ParameterUpdate | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_cfg_t const *const | p_cfg | ||
) |
Update the parameters of sensorless 120 detection module. Implements motor_120_control_api_t::parameterUpdate.
Example:
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. |