Please use separate e2studio for RA MCUs from RX/RL78/RH850 to avoid modifying toolchain any other development environment settings. e2studio for RA will include FSP, e2studio for other MCUs will include SC.
You may want to use a new dedicated Workspace if starting a big new project.
Long project file path is not recommended. Path names containing space or special characters may cause unexpected issue. It's a good practice that just create a "Workspace" folder as root directory and put project folders under the Workspace folder.
Update to latest SC, FSP, QE revisions might break the existing working project. Please seek Renesas technical help if you cannot figure out the reason, or you could reverse back to the old version. It is typically recommended you update to latest versions when start a new project and stay with these versions for this project.
Here are some key steps to bring up customer motor control using Renesas MCUs. Note this is just given as a typical example. It varies depending on actual applications.
For successful communication from RMW, the correct RMT and MAP files need to be loaded into RMW.
For RX-family code, they are located in project Workspace, in project_name\app\rmw folder.
For RA-family code, they are located in project_name\src\application\user_interfacer\ics folder
In certain situations when the “copy” command in e2studio Post-build Steps is not working properly, the updated MAP file does not appear in the above-mentioned folder after compiling. In this case, you should be able to find the updated MAP in the folder given below to load into RMW.
For RX-family code, in project_name\HardwareDebug folder.
For RA-family code, in project_name\Debug folder.
Modify the “copy” command in e2studio Post-build Steps can copy the MAP file into the default rmw or ics folder automatically after compiling. Here is an example in RX code: xcopy /y ${ProjName}.map ..\app\rmw
Here is an example of how to change RMW to communicate through VCOM port, instead of using the communication board as default.
In RA4T1 Tuner code, need to do two things. 1. #define USE_BUILT_IN (1) and 2. Link "ICS2_RA4T1_Built_in.o" instead of "ICS2_RA4T1.o".
Change the USE_BUILT_IN in r_mtr_ics.h file under src\application\user_interface\ics from default (0) to (1) as below.
Find the Tool Settings in the Project Properties shown as below. Then change the object file in "Other objects" under GNU Arm Cross C Linker => Miscellaneous, from "ICS2_RA4T1.o" to "ICS2_RA4T1_Built_in.o". Click Apply and Close.
Finally update the list under GNU Arm Cross C Linker, in "All options", replace "ICS2_RA4T1_Built_in.o" with "ICS2_RA4T1.o". Click Apply and Close.
If set to the maximum Baud Rate of each MCU, the fastest RMW update rate can be achieved at 50µs for all Renesas MCUs but one (RX13T). These two tables show the settings and maximum RMW update rate.
RX Family
MCU | CPU Clock (MHz) | Supply Clock (UART) (MHz) | Baud Rate (Mbps) | Max. Sampling Time (µs/4ch) | Lib API (ics2_init) 4th argument char speed | Lib API (ics2_init) 5th argument char mode |
RX72T | 200 | 50 | 6.25 | 50 | 0 | 2 |
RX66T | 160 | 40 | 5 | 50 | 0 | 2 |
RX26T | 120 | 60 | 7.5 | 50 | 0 | 2 |
RX24T | 80 | 40 | 5 | 50 | 0 | 2 |
RX23T | 40 | 40 | 5 | 50 | 0 | 2 |
RX13T | 32 | 32 | 1 | 200 | 3 | 2 |
RA Family
MCU | CPU Clock (MHz) | Supply Clock (UART) (MHz) | Baud Rate (Mbps) | Max. Sampling Time (µs/4ch) | Lib API (ics2_init) 3rd argument char speed | Lib API (ics2_init) 4th argument char mode |
RA8T1 | 480 | 120 | 10 | 50 | 1 | 2 |
RA6T3 | 200 | 100 | 16.6 | 50 | 0 | 2 |
RA4T1 | 100 | 100 | 16.6 | 50 | 0 | 2 |
RA6T2 | 240 | 120 | 10 | 50 | 1 | 2 |
RA6T1 | 120 | 120 | 15 | 50 | 0 | 2 |
As an example, in the case of RX66T, data can be displayed in as fast as 50µs with the following settings.
< main.c, row 130>
Before (default): ics2_init((void *)dtc_table, ICS_SCI6_PB0_PB1, ICS_INT_LEVEL,4,1); /* initialize ics */
After: ics2_init((void *)dtc_table, ICS_SCI6_PB0_PB1, ICS_INT_LEVEL,0,2); /* initialize ics */
<mtr_interrupt.c, row365-372>
Before (default):
/****** for ICS ******/
g_u1_cnt_ics++;
if (g_u1_cnt_ics >= 3)
{
g_u1_cnt_ics = 0;
ics2_watchpoint(); /* call ICS */
}
/*********************/
After: Changed to call every cycle
/****** for ICS ******/
//g_u1_cnt_ics++;
//if (g_u1_cnt_ics >= 3)
//{
// g_u1_cnt_ics = 0;
ics2_watchpoint(); /* call ICS */
//}
/*********************/
CustomerHere are some key steps to bring up motor control using Renesas MCUs. Note this is just given as a typical example. It varies depending on actual applications.
Correct motor parameters are important for achieving desired motor control performance, especially in FOC motor control. Please ensure the parameters on Motor Current Controller and Speed Controller are input correctly. If using sensorless control, also need to ensure the parameters in BEMF Observer are correct.
The parameters can be provided by motor manufacture, identified by Renesas RMW Tuner, or measured manually. RWM User’s Manual describes Tuner function and usage. Section 10.8 of MCI-HV-1 APN describes the manual measurement method.
Here are the key motor parameters that are needed for a BLDC motor:
Parameter | Note |
Pole Pairs | If motor spec gives the number of poles, need to divide it by 2 |
. | |
Resistance (ohm) | This is resistance of one phase. If motor spec give line to line resistance, or measure from phase-to-phase resistance, need to divide the value by 2 |
. | |
Inductance of d-axis (H) | These two values will be same for PMSM motor but will be different (Lq > Ld) for IPMSM motor. If motor spec give line to line inductance, or measure from phase-to-phase inductance, need to divide the value by 2 |
. | |
Inductance of q-axis (H) | |
Permanent magnetic flux (Wb) | If motor spec gives BEMF constant (Ke in VkRPM), need to convert it to Flux |
. Flux = Ke/(2πf), where f is the electrical cycle frequency at 1000RPM (f = #Pole Pairs * 1000/60). | |
Rotor inertia (kgm^2) | Need to include load inertia also, not just the motor itself. |
Here are the motor parameters needed for an induction motor:
Parameter | Note |
Pole Pairs | If motor spec gives the number of poles, need to divide it by 2. |
Stator Resistance (ohm) | This is resistance of one phase of stator. If motor spec give line to line resistance, or measure from phase-to-phase resistance, need to divide the value by 2. |
Rotor Resistance (ohm) | This is resistance of one phase of rotor. If motor spec give line to line resistance, or measure from phase-to-phase resistance, need to divide the value by 2. |
Mutual Inductance (H) | This is the interaction inductance from one coil to another coil. |
Stator Leakage Inductance (H) | This is the stator leakage inductance. |
Rotor Leakage Inductance (H) | This is the rotor leakage inductance. |
To enter the correct motor parameters into the code, if using FSP, you can directly enter through FSP by selecting "Motor Speed Controller (rm_motor_speed)" and "Motor Current Controller (rm_motor_current)" (for FOC projects) and entering under Properties=> Settings=> Motor Parameter, as shown below. Remember to update in both places.
Please also check the MTR_MOTOR_PARAMETER define in "r_mtr_motor_parameter.h". It is "0" as default and the motor parameters configured in FSP will be used. However, if it is "1", then the motor parameters configured in FSP will not be used. Instead, the motor parameters in the file "r_mtr_motor_parameter.h" will be used.
#define MTR_MOTOR_PARAMETER (0)
In RX projects, you may directly update the parameters in "r_motor_targetmotor_cfg.h" file in motor_module/cfg, shown as below.
Renesas MCI-LV inverter board has positive polarity on motor current sensing circuit, from shunt through amplifier to the ADC ports. Renesas sample software for MCI-LV inverter board is programmed for positive polarity. The current FSP versions also only support positive polarity.
When using an inverter board with negative polarity, the current detection polarity needs to be properly handled in the software. One example is using Renesas RAA227063 EVB, where gate driver IC’s internal current sense amplifiers have reversed polarity.
As an example, in RA family sensorless FOC motor control sample code, in the FSP generated code file "rm_motor_driver.c", there are negative signs in the phase current ADC readings as below. If you are using an inverter board with negative current sensing polarity, please remove these negative signs, AFTER using FSP to generate code.
p_ctrl->f_iu_ad = -(f_addata[0]) * (p_extend_cfg->f_current_range / p_extend_cfg->f_ad_resolution);
p_ctrl->f_iv_ad = -(f_addata[1]) * (p_extend_cfg->f_current_range / p_extend_cfg->f_ad_resolution);
p_ctrl->f_iw_ad = -(f_addata[2]) * (p_extend_cfg->f_current_range / p_extend_cfg→f_ad_resolution);
To adjust the maximum motor rotating speed, for RA MCUs, change the “Maximum rotational speed (rpm)” of "Motor Speed Controller" in FSP.
And also adjust the "Limit of over speed (rpm)" of "Motor Sensorless Vector Control (rm_motor_sensorless)" in FSP accordingly.
In RX MCU code, change the following parameters settings of:
#define MOTOR_CFG_MAX_SPEED_RPM (2400.0f) /* maximum speed [rpm] (mechanical angle) */
#define SPEED_CFG_SPEED_LIMIT_RPM (2850.0f) /* over speed limit [rpm] (mechanical angle) */
Normally slower speed changes will have better speed control, but too “sluggish” speed changes may not be acceptable in real application.
To adjust motor speed change (acceleration and deceleration) rate, in RA code, modify “Step of speed climbing (rpm)” in Module Motor Speed Controller (rm_motor_speed) as shown below. The unit is rpm per speed control period (0.001 sec in below figure). This applies to both open-loop and close-loop speed control.
Image Added
In RX code, change this parameter in the file "r_motor_module_cfg.h" under motor_module\cfg. The unit is rpm per second.
#define SPEED_CFG_RATE_LIMIT_RPM (1000.0f) /* Rate limit of speed change [rpm/s] */
If observe motor control vibration during FOC Open Loop period, enable “Open-loop damping” in Motor Speed Controller could help.
Image Added
When testing motor control kit with high voltage (such as 110V AC or 220V AC) and connecting your laptop, it is always safer to run the laptop on battery only. Do not connect external power supply or monitor. The goal is to let the laptop ground floating, even the communication interface is isolated.
MCI-HV-1 high-voltage inverter board has a hardware peak current limit as 21.2A (INVERTER_CFG_CURRENT_LIMIT). With a safety margin of 2.0 (MOTOR_COMMON_CFG_OVERCURRENT_MARGIN_MULT, default setting is 2.0), the maximum allowed setting of motor phase RMS current as 7.5A (MOTOR_CFG_NOMINAL_CURRENT_RMS, default setting is 3.3A). If really want to use more current for motor, the safety margin could be reduced slightly, with minimum safe setting of 1.5. The maximum phase RMS current can then be increased to 10.0A with this minimum safety margin.
If encounter compiling error when using sinf and cosf functions for trigonometric calculations, please go to the project properties, find "Settings" under "C/C++ Build". In "Tool Settings" tab, "Library Generator", "Standard Library", check the math.h (C89/C99), as shown in the figure below. Then click "Apply and Close", "Rebuild Index" and rebuild the code.
Image Added
If encounter compiling error when calling library functions, please make sure the library file is added to the Linker. As an example with RX26T, if the ics call functions such as ics_int_sci_rxi() is getting an error, please go to the project properties, find "Settings" under "C/C++ Build". In "Tool Settings" tab, "Linker", click the "Add file" button, select "Library" as the Format and find the "ICS2_RX26T.lib" in the "rmw" folder, as shown in the figure below. Then click "Apply and Close", "Rebuild Index" and rebuild the code.
Image Added
For Windows 11, PC user will get driver error message when USB-Serial cable is connected. This is not seen in Windows 10 and previous versions as correct driver is automatically downloaded and installed by Windows. A way to work around this would be to remove/ uninstall the installed driver and locate previous 2019 version driver. Please contact AE team for driver, if needed.
Running RA4T1 sensorless FOC Tuner sample code with FSP 5.2.0 may get the error of "BSP_CFG_HANDLE_UNRECOVERABLE_ERROR(0);". It is because RA4T1 Tuner project needs a #define modification for this new FSP version. Making a correction on "AIDU_DEADTIME_SET" defined in "r_aid_tuner_gui_user.h" file as below will solve the issue.
#define AIDU_DEADTIME_SET (g_user_motor_driver_extended_cfg.u2_deadtime)
When supply 100 V AC or 200 V AC 50 Hz power to the inverter, the bus voltage is automatically boosted to 390 V DC. If not getting the expected boosted bus voltage, please check below two things:
In file "r_pfc_cfg.h" under src\application\pfc_module\pfc\cfg folder, change
VAC_FREQ from default (50.0f) to (60.0f)
DATA_ARR_SIZE from default (320) to (267)
Image Added
Table of Contents |
---|