RA Flexible Software Package Documentation
Release v5.2.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 appication. 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 hall 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_hall0 | Module name. |
Conduction type |
| First 60 degree PWM | Select conduction type |
Timeout counts (msec) | Must be a valid non-negative value. | 200 | Counts to judge rotor unrotate |
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) |
Speed PI decimation | Must be a valid non-negative value. | 0 | Speed PI control decimation count |
Freerun timer frequency (MHz) | Must be a valid non-negative value. | 120 | Freerun timer frequency (MHz) |
Speed LPF | Must be a valid non-negative value. | 1.0 | Speed LPF parameter |
Step of speed reference change | Must be a valid non-negative value. | 0.2 | Speed ref change step |
Start reference voltage (V) | Must be a valid non-negative value. | 5.8 | Reference voltage for boot mode (V) |
Hall wait counts | Must be a valid non-negative value. | 12 | Wait counts of hall interrupts to start speed calculation |
Stop judge time | Must be a valid non-negative value. | 1000 | Stop judge time |
Minimum limit speed (rpm) | Must be a valid non-negative value. | 550 | Minimum limit speed (rpm) (mechanical angle) |
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.0005 | PI control gain of integral term |
PI control limit | Must be a valid non-negative value. | 24.0 | PI control limit of integral term |
Hall interrupt mask value | Must be a valid non-negative value. | 15 | For limiting hall interrupt processing. Limited by the number of ADC interrupts |
Motor Parameter | |||
Pole pairs | Must be a valid non-negative value. | 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 |
Hall sensor port U | Manual Entry | BSP_IO_PORT_04_PIN_11 | Hall sensor port U |
Hall sensor port V | Manual Entry | BSP_IO_PORT_04_PIN_10 | Hall sensor port V |
Hall sensor port W | Manual Entry | BSP_IO_PORT_04_PIN_09 | Hall sensor port W |
This module doesn't depend on clock setting, because this module is a simple calculation process.
Depend on included ICU module.
This is a basic example of minimal use of the motor 120 control hall in an application.
Data Structures | |
struct | motor_120_control_hall_extended_cfg_t |
struct | motor_120_control_hall_instance_ctrl_t |
struct motor_120_control_hall_extended_cfg_t |
Extended configurations for motor 120 control hall
Data Fields | ||
---|---|---|
bsp_io_port_pin_t | port_hall_sensor_u | Hall sensor port U. |
bsp_io_port_pin_t | port_hall_sensor_v | Hall sensor port V. |
bsp_io_port_pin_t | port_hall_sensor_w | Hall sensor port W. |
float | f4_start_refv | Reference voltage for boot mode. |
uint32_t | u4_hall_wait_cnt | Wait counts of hall interrupts for speed calculation. |
uint32_t | u4_stop_judge_time | Stop judge time. |
uint32_t | u4_min_speed_rpm | Minimum limit speed (rpm) (mechanical angle) |
uint32_t | u4_hall_interrupt_mask_value | For limiting hall interrupt processing. Limited by the number of ADC interrupts. |
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. |
external_irq_instance_t const * | p_u_hall_irq_instance | U phase hall interrupt. |
external_irq_instance_t const * | p_v_hall_irq_instance | V phase hall interrupt. |
external_irq_instance_t const * | p_w_hall_irq_instance | W phase hall interrupt. |
struct motor_120_control_hall_instance_ctrl_t |
120 control hall 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 | Hall pattern error status. |
motor_120_control_rotation_direction_t | direction | Rotational direction (0:CW ,1:CCW) |
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) |
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. |
uint32_t | u4_cnt_wait_stop | Counter for waiting motor stop. |
motor_120_driver_phase_pattern_t | v_pattern | Voltage pattern. |
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_cnt_timeout | Counter for timeout error. |
uint32_t | u4_hall_timer_cnt | Value of timer counter. |
uint32_t | u4_pre_hall_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_HALL_TIMES] | Counts for 60 degrees. |
uint32_t | u4_timer_cnt_num | Array element number before 360 degrees. |
float | f4_pi_ctrl_err | PI control error. |
float | f4_pi_ctrl_refi | PI control buffer of integral term. |
uint32_t | u4_hall_intr_cnt | For start timing of speed calculation. |
uint32_t | u4_adc_interrupt_cnt | Number of ADC interrupt processing. |
motor_120_control_cfg_t const * | p_cfg | Pointer of configuration structure. |
timer_direction_t | timer_direction | Hold timer direction. |
external_irq_callback_args_t | hall_interrupt_args | For call IRQ callbackSet function. |
timer_callback_args_t | timer_args | For call timer callbackSet function. |
fsp_err_t RM_MOTOR_120_CONTROL_HALL_Open | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_cfg_t const *const | p_cfg | ||
) |
Opens and configures the motor hall 120 detection module. Implements motor_120_control_api_t::open.
Example:
FSP_SUCCESS | Motor 120 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_HALL_Close | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Disables specified motor hall 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_HALL_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_HALL_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_HALL_Reset | ( | motor_120_control_ctrl_t *const | p_ctrl | ) |
Reset variables of motor hall 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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_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_HALL_ParameterUpdate | ( | motor_120_control_ctrl_t *const | p_ctrl, |
motor_120_control_cfg_t const *const | p_cfg | ||
) |
Update the parameters of hall 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. |