|
fsp_err_t | RM_MOTOR_SENSE_HALL_Open (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg) |
| Opens and configures the angle hall sensor module. Implements motor_angle_api_t::open. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_Close (motor_angle_ctrl_t *const p_ctrl) |
| Disables specified Angle Estimation module. Implements motor_angle_api_t::close. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_Reset (motor_angle_ctrl_t *const p_ctrl) |
| Reset variables of Angle Estimation module. Implements motor_angle_api_t::reset. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_CurrentSet (motor_angle_ctrl_t *const p_ctrl, motor_angle_current_t *const p_st_current, motor_angle_voltage_reference_t *const p_st_voltage) |
| Set d/q-axis Current Data & Voltage Reference. Implements motor_angle_api_t::currentSet. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_SpeedSet (motor_angle_ctrl_t *const p_ctrl, float const speed_ctrl, float const damp_speed) |
| Set Speed Information. Implements motor_angle_api_t::speedSet. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_FlagPiCtrlSet (motor_angle_ctrl_t *const p_ctrl, uint32_t const flag_pi) |
| Set the flag of PI Control runs. Implements motor_angle_api_t::flagPiCtrlSet. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_AngleSpeedGet (motor_angle_ctrl_t *const p_ctrl, float *const p_angle, float *const p_speed, float *const p_phase_err) |
| Gets the current rotor's angle and rotation speed. Implements motor_angle_api_t::angleSpeedGet. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_EstimatedComponentGet (motor_angle_ctrl_t *const p_ctrl, float *const p_ed, float *const p_eq) |
| Gets estimated d/q-axis component. Implements motor_angle_api_t::estimatedComponentGet. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_ParameterUpdate (motor_angle_ctrl_t *const p_ctrl, motor_angle_cfg_t const *const p_cfg) |
| Update the parameters of Angle&Speed Estimation. Implements motor_angle_api_t::parameterUpdate. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_InternalCalculate (motor_angle_ctrl_t *const p_ctrl) |
| Calculate internal parameters. Implements motor_angle_api_t::internalCalculate. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_AngleAdjust (motor_angle_ctrl_t *const p_ctrl) |
| Angle Adjustment Process. Implements motor_angle_api_t::angleAdjust. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_EncoderCyclic (motor_angle_ctrl_t *const p_ctrl) |
| Encoder Cyclic Process (Call in cyclic timer). Implements motor_angle_api_t::encoderCyclic. More...
|
|
fsp_err_t | RM_MOTOR_SENSE_HALL_InfoGet (motor_angle_ctrl_t *const p_ctrl, motor_angle_encoder_info_t *const p_info) |
| Gets information of Encoder Angle Module. Implements motor_angle_api_t::infoGet. More...
|
|
Calculation proccess for the motor control on RA MCUs. This module implements the Motor angle Interface.
Overview
The motor angle and speed calculation with hall sensors module is used to calculate rotor angle and rotational speed in an application. This module is designed to be used with the motor current module (rm_motor_current).
Features
The motor angle and speed calculation with hall sensors module has the features listed below.
- Calculate rotor angle [radian].
- Calculate rotational speed [radian/second].
Configuration
Build Time Configurations for rm_motor_sense_hall
The following build time configurations are defined in fsp_cfg/rm_motor_sense_hall_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 Angle and Speed Calculation with Hall sensors (rm_motor_sense_hall)
This module can be added to the Stacks tab via New Stack > Motor > Motor Angle and Speed Calculation with Hall sensors (rm_motor_sense_hall).
Configuration | Options | Default | Description |
General |
Name | Name must be a valid C symbol | g_motor_angle0 | Module name. |
Hall sensor |
U phase input port | Manual Entry | BSP_IO_PORT_12_PIN_04 | Hall sensor port U |
V phase input port | Manual Entry | BSP_IO_PORT_12_PIN_05 | Hall sensor port V |
W phase input port | Manual Entry | BSP_IO_PORT_11_PIN_01 | Hall sensor port W |
sensor pattern #1 | Manual Entry | 1 | Hall sensor pattern #1 |
sensor pattern #2 | Manual Entry | 5 | Hall sensor pattern #2 |
sensor pattern #3 | Manual Entry | 4 | Hall sensor pattern #3 |
sensor pattern #4 | Manual Entry | 6 | Hall sensor pattern #4 |
sensor pattern #5 | Manual Entry | 2 | Hall sensor pattern #5 |
sensor pattern #6 | Manual Entry | 3 | Hall sensor pattern #6 |
Process Frequency (kHz) | Must be a valid value | 20.0F | Frequency to perform the process. |
Correction parameter of rotor angle | Must be a valid value | 0.0F | Correction parameter of rotor angle |
Default counts of carrier interrupt | Must be a valid non-negative value. | 300U | Default counts of carrier interrupt during a period of Hall signal change |
Maximum counts of one rotation | Must be a valid non-negative value. | 500U | Maximum counts of carrier interrupt during one rotor rotation |
Target value for pseudo speed (rad/s) | Must be a valid non-negative value. | 100.0 | Target value for pseudo speed (rad/s). |
Target time until the pseudo speed update reaches (msec) | Must be a valid non-negative value. | 300.0 | Target time until the pseudo speed update reaches (msec). |
Rotation counts to start speed estimation | Must be a valid non-negative value. | 2 | Rotation counts to start of speed estimation. |
Carrier counts at startup | Must be a valid non-negative value. | 400 | Carrier counts to wait the start timing of pseudo speed update |
Speed to judge start | Must be a valid non-negative value. | 250.0 | Speed to judge start PI calculation. |
Clock Configuration
Pin Configuration
Usage Notes
Limitations
Developers should be aware of the following limitations when using the motor angle and speed calculation with hall sensors: all configurations should be set as positive values.
Examples
Basic Example
This is a basic example of minimal use of the motor angle and speed calculation with hall sensors in an application.
void motor_sense_hall_basic_example (void)
{
assert(FSP_SUCCESS == err);
{
}
}
◆ motor_sense_hall_input_t
struct motor_sense_hall_input_t |
This stucture is provided to receive speed information.
Data Fields |
float |
f4_ref_speed_rad_ctrl |
Speed Reference [rad/sec]. |
◆ motor_sense_hall_extended_cfg_t
struct motor_sense_hall_extended_cfg_t |
Optional Motor sense hall extension data structure.
Data Fields |
bsp_io_port_pin_t |
port_hall_sensor_u |
Hall U-signal input port. |
bsp_io_port_pin_t |
port_hall_sensor_v |
Hall V-signal input port. |
bsp_io_port_pin_t |
port_hall_sensor_w |
Hall W-signal input port. |
uint8_t |
u1_hall_pattern[MOTOR_SENSE_HALL_SPEED_COUNTS+1] |
The order of hall signal pattern. |
float |
f_pwm_carrier_freq |
PWM carrier frequency (or Decimated frequency at decimation of current process) |
float |
f_angle_correct |
Coefficent to correct angle. |
uint8_t |
u1_trigger_hall_signal_count |
Rotation counts to wait the stability. |
float |
f4_target_pseudo_speed_rad |
Target value for pseudo speed estimates [radian/second]. |
float |
f4_reach_time_msec |
Time until the pseudo speed estimate reaches the target value [msec]. |
uint16_t |
u2_trigger_carrier_count |
Estimated speed 0 until this trigger. |
uint16_t |
u2_default_counts |
Default counts for period of hall signal to reset. |
uint16_t |
u2_maximum_period |
Maximum counts of hall signal period. |
uint8_t |
u1_hall_polepairs |
Hall pole pairs. |
float |
f4_start_speed_rad |
Speed to judge start [radian/second]. |
◆ motor_sense_hall_instance_ctrl_t
struct motor_sense_hall_instance_ctrl_t |
SENSE_HALL control block. DO NOT INITIALIZE. Initialization occurs when motor_angle_api_t::open is called.
Data Fields |
uint32_t |
open |
|
uint8_t |
u1_hall_signal |
Hall signal pattern. |
uint8_t |
u1_last_hall_signal |
Last hall signal pattern. |
motor_sense_hall_direction_t |
direction |
Rotation direction. |
motor_sense_hall_direction_t |
last_direction |
Last rotation direction. |
uint16_t |
u2_carrier_count |
Carrier count. |
uint16_t |
u2_hall_period[MOTOR_SENSE_HALL_SPEED_COUNTS] |
Array of carrier count to calculate 2PI. |
uint8_t |
u1_period_counter |
Counter for above array. |
float |
f_angle |
Rotor angle [radian]. |
float |
f_angle_per_count |
Angle per 1 count. |
float |
f_calculated_speed |
Calculated speed [radian/second]. |
uint8_t |
u1_hall_signal_memory |
Memorized hall signal at startup. |
motor_sense_hall_signal_status_t |
hall_signal_status |
Hall signal status. |
uint8_t |
u1_hall_signal_count |
Rotation counter. |
float |
f4_pseudo_speed_rad |
Pseudo speed used for startup [radian/second]. |
float |
f4_add_pseudo_speed_rad |
Step of pseudo speed to update [radian/second]. |
uint16_t |
u2_startup_carrier_count |
Counter of carrier interrupt for startup. |
motor_sense_hall_input_t |
st_input |
Input parameter structure. |
uint8_t |
u1_startup_flag |
Flag for startup. |
motor_angle_cfg_t const * |
p_cfg |
|
◆ motor_sense_hall_direction_t
Enumerator |
---|
MOTOR_SENSE_HALL_DIRECTION_CW | Rotation direction clockwise.
|
MOTOR_SENSE_HALL_DIRECTION_CCW | Rotation direction counter clockwise.
|
◆ motor_sense_hall_signal_status_t
Enumerator |
---|
MOTOR_SENSE_HALL_SIGNAL_STATUS_INITIAL | Hall signal isn't captured. (Initial)
|
MOTOR_SENSE_HALL_SIGNAL_STATUS_CAPTURED | Hall signal is captured.
|
◆ RM_MOTOR_SENSE_HALL_Open()
Opens and configures the angle hall sensor module. Implements motor_angle_api_t::open.
- Return values
-
FSP_SUCCESS | MTR_ANGL_EST 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. |
◆ RM_MOTOR_SENSE_HALL_Close()
Disables specified Angle Estimation module. Implements motor_angle_api_t::close.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_SENSE_HALL_Reset()
Reset variables of Angle Estimation module. Implements motor_angle_api_t::reset.
- Return values
-
FSP_SUCCESS | Successfully reset. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_SENSE_HALL_CurrentSet()
◆ RM_MOTOR_SENSE_HALL_SpeedSet()
Set Speed Information. Implements motor_angle_api_t::speedSet.
- Return values
-
FSP_SUCCESS | Data get successfully. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_SENSE_HALL_FlagPiCtrlSet()
◆ RM_MOTOR_SENSE_HALL_AngleSpeedGet()
fsp_err_t RM_MOTOR_SENSE_HALL_AngleSpeedGet |
( |
motor_angle_ctrl_t *const |
p_ctrl, |
|
|
float *const |
p_angle, |
|
|
float *const |
p_speed, |
|
|
float *const |
p_phase_err |
|
) |
| |
Gets the current rotor's angle and rotation speed. Implements motor_angle_api_t::angleSpeedGet.
- Return values
-
FSP_SUCCESS | Successful data get. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_ARGUMENT | Output pointer is invalid. |
◆ RM_MOTOR_SENSE_HALL_EstimatedComponentGet()
◆ RM_MOTOR_SENSE_HALL_ParameterUpdate()
Update the parameters of Angle&Speed Estimation. Implements motor_angle_api_t::parameterUpdate.
- Return values
-
FSP_SUCCESS | Successfully data is update. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_MOTOR_SENSE_HALL_InternalCalculate()
◆ RM_MOTOR_SENSE_HALL_AngleAdjust()
◆ RM_MOTOR_SENSE_HALL_EncoderCyclic()
◆ RM_MOTOR_SENSE_HALL_InfoGet()