RA Flexible Software Package Documentation
Release v5.6.0
|
|
Calculation process for the motor control on RA MCUs. This module implements the Motor 120-Degree Driver Interface.
The motor 120 degree driver module is used to translate phase voltage to PWM duty and output PWM, and detect phase current, voltage and main line voltage. This module should be called cyclically at included A/D conversion finish interrupt.
The motor 120 degree driver module has below features.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
ADC_B Support |
| Disabled | Select ADC_B module support. |
Shared ADC support |
| Disabled | Select Shared ADC support. |
Support Motor Number | Must be greater than 1. | 1 |
Configuration | Options | Default | Description |
---|---|---|---|
General | |||
Name | Name must be a valid C symbol | g_motor_120_driver0 | Module name. |
120 degree control type |
| Sensorless | 120 degree control type |
PWM output port UP | Manual Entry | BSP_IO_PORT_06_PIN_01 | PWM output port UP |
PWM output port UN | Manual Entry | BSP_IO_PORT_06_PIN_00 | PWM output port UN |
PWM output port VP | Manual Entry | BSP_IO_PORT_01_PIN_13 | PWM output port VP |
PWM output port VN | Manual Entry | BSP_IO_PORT_01_PIN_14 | PWM output port VN |
PWM output port WP | Manual Entry | BSP_IO_PORT_01_PIN_11 | PWM output port WP |
PWM output port WN | Manual Entry | BSP_IO_PORT_01_PIN_12 | PWM output port WN |
PWM timer frequency (MHz) | Must be a valid positive integer. | 120 | GPT PWM timer frequency |
PWM carrier period (Microseconds) | Must be a valid positive integer. | 50 | GPT PWM carrier period |
Dead time (Raw counts) | Must be a valid positive integer. | 240 | GPT PWM dead time |
Current range (A) | Must be a valid non-negative value. | 27.5 | Current range to measure(Maximum input current) |
Voltage range (V) | Must be a valid non-negative value. | 111.0 | Voltage range to measure(Maximum input main line voltage) |
Resolution of A/D conversion | Must be a valid Resolution of ADC. | 0xFFF | Resolution of A/D conversion |
Offset of A/D conversion for current | Must be a valid non-negative value. | 0x745 | Offset of A/D conversion for current |
Conversion level of A/D conversion for voltage | Must be a valid non-negative value. | 0.66 | Conversion level of A/D conversion for voltage |
Counts for current offset measurement | Must be a valid positive integer. | 500 | How many times to measure current offset |
Input voltage | Must be a valid non-negative value. | 24.0 | Input voltage |
A/D conversion channel for U phase current | Value must be a supported channel number | 0 | Specify the A/D channel for U phase current |
A/D conversion channel for W phase current | Value must be a supported channel number | 2 | Specify the A/D channel for W phase current |
A/D conversion channel for main line voltage | Value must be a supported channel number | 5 | Specify the A/D channel for main line voltage |
A/D conversion channel for U phase voltage | Value must be a supported channel number | 18 | Specify the A/D channel for U phase voltage |
A/D conversion channel for V phase voltage | Value must be a supported channel number | 20 | Specify the A/D channel for V phase voltage |
A/D conversion channel for W phase voltage | Value must be a supported channel number | 6 | Specify the A/D channel for W phase voltage |
A/D conversion unit for U phase current | Must be a valid non-negative value. | 0 | Specify the A/D unit for U phase current |
A/D conversion unit for W phase current | Must be a valid non-negative value. | 0 | Specify the A/D unit for W phase current |
A/D conversion unit for main line voltage | Must be a valid non-negative value. | 0 | Specify the A/D unit for main line voltage |
A/D conversion unit for U phase voltage | Must be a valid non-negative value. | 0 | Specify the A/D unit for U phase voltage |
A/D conversion unit for V phase voltage | Must be a valid non-negative value. | 0 | Specify the A/D unit for V phase voltage |
A/D conversion unit for W phase voltage | Must be a valid non-negative value. | 0 | Specify the A/D unit for W phase voltage |
GTIOCA stop level |
| Pin Level High | Select the behavior of the output pin when the timer is stopped. |
GTIOCB stop level |
| Pin Level High | Select the behavior of the output pin when the timer is stopped. |
ADC interrupt module |
| 1st | Select from which module ADC intterupt happens |
Modulation | |||
Maximum duty | Must be a valid non-negative value. | 0.9375 | Maximum duty of PWM |
Interrupts | |||
Callback | Name must be a valid C symbol | NULL | A user callback function. If this callback function is provided, it is called at A/D conversion finish interrupt. |
Set used clock with included GPT timer.
Depend on included GPT three phase module and ADC module.
Basically no limitation exists.
This is a basic example of minimal use of the Motor 120 degree driver in an application.
Data Structures | |
struct | motor_120_driver_shared_instance_ctrl_t |
struct | motor_120_driver_modulation_t |
struct | motor_120_driver_extended_cfg_t |
Enumerations | |
enum | motor_120_driver_select_adc_instance_t |
enum | motor_120_driver_status_t |
enum | motor_120_driver_type_t |
struct motor_120_driver_shared_instance_ctrl_t |
struct motor_120_driver_modulation_t |
struct motor_120_driver_extended_cfg_t |
Extended configurations for motor 120 driver
Data Fields | ||
---|---|---|
adc_instance_t const * | p_adc_instance | ADC module instance. |
three_phase_instance_t const * | p_three_phase_instance | PWM output module instance (GPT three phase) |
motor_120_driver_type_t | motor_120_type | 120 degree control type |
adc_channel_t | iu_ad_ch | A/D channel for U phase current. |
adc_channel_t | iw_ad_ch | A/D channel for W phase current. |
adc_channel_t | vdc_ad_ch | A/D channel for main line voltage. |
adc_channel_t | vu_ad_ch | A/D channel for U phase voltage. |
adc_channel_t | vv_ad_ch | A/D channel for V phase voltage. |
adc_channel_t | vw_ad_ch | A/D channel for W phase voltage. |
uint8_t | iu_ad_unit | Used A/D unit number for U phase current. |
uint8_t | iw_ad_unit | Used A/D unit number for W phase current. |
uint8_t | vdc_ad_unit | Used A/D unit number for main line voltage. |
uint8_t | vu_ad_unit | Used A/D unit number for U phase voltage. |
uint8_t | vv_ad_unit | Used A/D unit number for V phase voltage. |
uint8_t | vw_ad_unit | Used A/D unit number for W phase voltage. |
bsp_io_port_pin_t | port_up | PWM output port UP. |
bsp_io_port_pin_t | port_un | PWM output port UN. |
bsp_io_port_pin_t | port_vp | PWM output port VP. |
bsp_io_port_pin_t | port_vn | PWM output port VN. |
bsp_io_port_pin_t | port_wp | PWM output port WP. |
bsp_io_port_pin_t | port_wn | PWM output port WN. |
uint32_t | u4_pwm_timer_freq | PWM timer frequency (MHz) |
float | u4_pwm_carrier_freq | PWM carrier frequency (kHz) [DEPRECATED]. |
float | pwm_carrier_freq | PWM carrier frequency (kHz) |
uint32_t | u4_deadtime | PWM deadtime (usec) |
float | f_current_range | A/D current measure range (max current) (A) |
float | f_vdc_range | A/D main line voltage measure range (max voltage) (V) |
float | f_ad_resolution | A/D resolution. |
float | f_ad_current_offset | A/D offset (Center value) |
float | f_ad_voltage_conversion | A/D conversion level. |
uint32_t | u4_offset_calc_count | Calculation counts for current offset. |
motor_120_driver_modulation_t | mod_param | Modulation parameter. |
motor_120_driver_select_adc_instance_t | interrupt_adc | Select which interrupt to use. |
motor_120_driver_extended_shared_cfg_t const * |
p_shared_cfg | shared extended config |
fsp_err_t RM_MOTOR_120_DRIVER_Open | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
motor_120_driver_cfg_t const *const | p_cfg | ||
) |
Opens and configures the motor 120 driver module. Implements motor_120_driver_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_DRIVER_Close | ( | motor_120_driver_ctrl_t *const | p_ctrl | ) |
Disables specified motor 120 driver module. Implements motor_120_driver_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_DRIVER_Run | ( | motor_120_driver_ctrl_t *const | p_ctrl | ) |
Run motor (Start motor rotation). Implements motor_120_driver_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_DRIVER_Stop | ( | motor_120_driver_ctrl_t *const | p_ctrl | ) |
Stop motor (Stop motor rotation). Implements motor_120_driver_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_DRIVER_Reset | ( | motor_120_driver_ctrl_t *const | p_ctrl | ) |
Reset variables of motor 120 driver module. Implements motor_120_driver_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_DRIVER_PhaseVoltageSet | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
float const | u_voltage, | ||
float const | v_voltage, | ||
float const | w_voltage | ||
) |
Set phase voltage data to calculate PWM duty. Implements motor_120_driver_api_t::phaseVoltageSet.
Example:
FSP_SUCCESS | Successfully data is set. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_120_DRIVER_PhasePatternSet | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
motor_120_driver_phase_pattern_t const | pattern | ||
) |
Set phase voltage pattern. Implements motor_120_driver_api_t::phasePatternSet.
Example:
FSP_SUCCESS | Successfully data is set. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_MOTOR_120_DRIVER_CurrentGet | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
motor_120_driver_current_status_t *const | p_current_status | ||
) |
Get calculated phase current, Vdc & Va_max data. Implements motor_120_driver_api_t::currentGet.
Example:
FSP_SUCCESS | Successful data get. |
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_DRIVER_CurrentOffsetCalc | ( | motor_120_driver_ctrl_t *const | p_ctrl | ) |
current offset detection. Implements motor_120_driver_api_t::currentOffsetCalc
Example:
FSP_SUCCESS | Successful data get. |
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_DRIVER_FlagCurrentOffsetGet | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
motor_120_driver_flag_offset_calc_t *const | p_flag_offset | ||
) |
Get the flag of finish current offset detection. Implements motor_120_driver_api_t::flagCurrentOffsetGet.
Example:
FSP_SUCCESS | Successful data get. |
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_DRIVER_ParameterUpdate | ( | motor_120_driver_ctrl_t *const | p_ctrl, |
motor_120_driver_cfg_t const *const | p_cfg | ||
) |
Update the parameters of 120 driver module. Implements motor_120_driver_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. |