Calculation process for the motor control on RA MCUs. This module implements the Motor driver Interface.
The motor driver module is used to translate phase voltage to PWM duty and output PWM, and detect phase current and main line voltage. This module should be called cyclically at included A/D Conversion finish interrupt.
The Motor Driver Module has below features.
The following build time configurations are defined in fsp_cfg/rm_motor_driver_cfg.h:
This module can be added to the Stacks tab via New Stack > Motor > ADC and PWM Modulation (rm_motor_driver).
Configuration | Options | Default | Description |
General |
Name | Name must be a valid C symbol | g_motor_driver0 | Module name. |
Shunt type |
| 2 shunt | Select shunt type |
Modulation method |
| SVPWM | Select PWM modulation method |
PWM output port UP | Manual Entry | 0 | PWM output port UP |
PWM output port UN | Manual Entry | 0 | PWM output port UN |
PWM output port VP | Manual Entry | 0 | PWM output port VP |
PWM output port VN | Manual Entry | 0 | PWM output port VN |
PWM output port WP | Manual Entry | 0 | PWM output port WP |
PWM output port WN | Manual Entry | 0 | PWM output port WN |
PWM Timer Frequency (MHz) | Must be a valid non-negative value. | 120 | GPT PWM timer frequency |
PWM Carrier Period (Microseconds) | Must be a valid non-negative value. | 50 | GPT PWM carrier period |
Dead Time (Raw Counts) | Must be a valid non-negative value. | 240 | GPT PWM dead time |
Current Range (A) | Must be a valid value | 27.5F | Current range to measure(Maximum input current) |
Voltage Range (V) | Must be a valid value | 111.0F | Voltage range to measure(Maximum input Main Line Voltage) |
Counts for current offset measurement | Must be a valid non-negative value. | 500 | How many times to measure current offset |
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 (channel availability varies by MCU) |
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 (channel availability varies by MCU) |
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 (channel availability varies by MCU) |
A/D conversion channel for V Phase current | Value must be a supported channel number | 1 | Specify the A/D channel for V phase current (channel availability varies by MCU) |
A/D conversion channel for sin signal | Value must be a supported channel number | 27 | Specify the A/D channel for sin signal of induction sensor (channel availability varies by MCU) |
A/D conversion channel for cos signal | Value must be a supported channel number | 28 | Specify the A/D channel for cos signal of induction sensor (channel availability varies by MCU) |
Using ADC Scan Group | Manual Entry | 0 | For MCUs with ADC_B, select the scan group used. |
A/D conversion unit for U Phase current | Manual Entry | 0 | Select the A/D conversion module for U phase current (only valid with adc module) |
A/D conversion unit for W Phase current | Manual Entry | 0 | Select the A/D conversion module for W phase current (only valid with adc module) |
A/D conversion unit for main line voltage | Manual Entry | 0 | Select the A/D conversion module for main line voltage (only valid with adc module) |
A/D conversion unit for V Phase current | Manual Entry | 0 | Select the A/D conversion module for V phase current (only valid with adc module) |
A/D conversion unit for sin signal | Manual Entry | 0 | Select the A/D conversion module for sin signal of induction sensor (only valid with adc module) |
A/D conversion unit for cos signal | Manual Entry | 0 | Select the A/D conversion module for cos signal of induction sensor (only valid with adc module) |
ADC interrupt module |
| 1st | Select from which module ADC intterupt happens (only valid with adc module) |
Adjustment value to current A/D | Must be a valid non-negative value. | 20.0 | Value to adjust 1shunt A/D double buffer |
Minimum difference of PWM duty | Must be a valid non-negative value. | 300 | Minimum difference of PWM duty |
Adjustment delay of A/D conversion | Must be a valid non-negative value. | 240 | Adjustment delay of A/D conversion |
1shunt interrupt phase |
| PHASE_U | Select the phase which occures ADC end interrupt. (Only valid with 1shunt) |
Input Voltage (V) | Must be a valid value | 24.0F | Input 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 value | 0.66F | Conversion level of A/D conversion for voltage |
GTIOCA Stop Level |
-
Pin Level Low
-
Pin Level High
| Pin Level High | Select the behavior of the output pin when the timer is stopped. |
GTIOCB Stop Level |
-
Pin Level Low
-
Pin Level High
| Pin Level High | Select the behavior of the output pin when the timer is stopped. |
Modulation |
Maximum Duty | Must be a valid value | 0.9375F | 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.
When shared ADC instance is used, please perform below sequence.
Basically no limitation exists.
This is a basic example of minimal use of the Motor Driver in an application.