Renesas RX72T APPLICATION NOTE

APPLICATION NOTE
R01AN4721EJ0100 Rev.1.00 Page 1 of 37 Mar 29. 2019
RX72T
Abstract
This application note aims to explain the sample programs for a permanent magnet synchronous motor with encoder, by using functions of RX72T. The explanation includes, how to use the library of ‘Renesas Motor Workbench’ tool, that is support tool for motor control development.
The target software of this application note is only to be used as reference and Renesas Electronics Corporation does not guarantee the operations. Please use them after carrying out a thorough evaluation in a suitable environment.
Operation Checking Device
Operations of the target software of this application note are checked by using the following device.
- RX72T (R5F572TKCDFB)
Target Software
The target programs of this application note are as follows.
- RX72T_MRSSK_SPM_ENCD_FOC_CSP_RV100 (IDE: CS+)
- RX72T_MRSSK_SPM_ENCD_FOC_E2S_RV100 (IDE: e2studio)
Vector control with encoder software for ‘24V Motor Control Evaluation System for RX23T’ and ‘RX72T CPU Card’
Reference
- RX72T Group User’s Manual: Hardware (R01UH0803)
- Application note: Vector control for permanent magnet synchronous motor with encoder (Algorithm) (R01AN3789)
- Renesas Motor Workbench V.1.00 User’s Manual (R21UZ0004)
- Renesas Solution Starter Kit 24V Motor Control Evaluation System for RX23T Users Manual (R20UT3697)
R01AN4721EJ0100
Rev.1.00
Mar 29. 2019
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 2 of 37 Mar 29. 2019
Contents
1. Overview .......................................................................................................................................... 3
2. System overview ............................................................................................................................. 4
3. Descriptions of the Control Program .......................................................................................... 10
4. Motor Control Development Support Tool ‘Renesas Motor Workbench’ ................................ 29
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 3 of 37 Mar 29. 2019

1. Overview

This application note aims to explain the sample programs for a permanent magnet synchronous motor with encoder, by using functions of RX72T. The explanation includes, how to use the library of ‘Renesas Motor Workbench’ tool, that is support tool for motor control development.
Note that these sample programs use the algorithm described in the application note Vector control for permanent magnet synchronous motor with encoder (Algorithm).

1.1 Development environment

Table 1-1 and Table 1-2 show development environment of the sample programs explained in this application note.
Table 1-1 Hardware Development Environment
Microcontroller
Evaluation board
Motor
RX72T(R5F572TKCDFB)
24V inverter board & RX72T CPU Card
(Note 1)
FH6S20E-X81
(Note 2)
Table 1-2 Software Development Environment
Toolchain version
CC-RX V3.01.00
For purchase and technical support, contact sales representatives and dealers of Renesas Electronics Corporation.
Notes:1. 24V inverter board & RX72T CPU Card are product of Renesas Electronics Corporation.
2. FH6S20E-X81 is a product of NIDEC SERVO CORPORATION. NIDEC SERVO (http://www.nidec-servo.com/)
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 4 of 37 Mar 29. 2019

2. System overview

Overview of this system is explained below.

2.1 Hardware configuration

The hardware configuration is shown below.
A/D converter input
Bus voltage
Rotation speed command
PWM output
Over current detection
Power supply circuit
Switch input
Motor rotation start/stop
Error reset
LED output
Over current detection input
Inverter circuit
Phase current
detection
Phase current
Encoder input
RX72T
V
dc
GND
Input DC24V
VR1
SW1
SW2
LED1 LED2
U
p
V
p
W
p
V
n
U
n
W
n
OC
V
u
V
vVw
I
u
I
w
P35
PA0
P63 / AN209
P43 / AN003
PC5
PC6
P71 / MTIOC3B / GTIOC4A(Up)
P72 / MTIOC4A / GTIOC5A(Vp)
P73 / MTIOC4B / GTIOC6A(Wp)
P74 / MTIOC3D / GTIOC4B(Un)
P75 / MTIOC4C / GTIOC5B(Vn)
P76 / MTIOC4D / GTIOC6B(Wn)
P70 / POE0#
PMSM
P40 / AN000
IU_AIN
I
v
P42 / AN002
IW_AIN
LED3
P34
PA7 / MTCLKA
PA6 / MTCLKB
Hall Input
P23 / IRQ11
P24 / IRQ4
P25 / IRQ10
U port
W port
V port
HU port
HW port
HV port
GND port
V
cc
port
ENC_Z port
ENC_A port
ENC_B port
GND port
V
cc
port
Figure 2-1 Hardware Configuration Diagram
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 5 of 37 Mar 29. 2019

2.2 Hardware specifications

2.2.1 User interfaces

List of user interfaces of this system is given in Table 2-1.
Table 2-1 User Interfaces
Item
Interface component
Function
Rotation position / speed
Variable resistor (VR1)
Reference value of rotation position / speed input (analog value)
START/STOP
Toggle switch (SW1)
Motor rotation start/stop command
ERROR RESET
Toggle switch (SW2)
Command of recovery from error status
LED1
Yellow green LED
- At the time of motor rotation: ON
- At the time of stop: OFF
LED2
Yellow green LED
- At the time of error detection: ON
- At the time of normal operation: OFF
LED3
Yellow green LED
- Complete of positioning: ON
- Uncomplete of positioning: OFF RESET
Push switch
System reset
List of port interfaces of this system is given in Table 2-2.
Table 2-2 Port Interfaces
R5F572TKCDFB port name
Function
P63 / AN209
Inverter bus voltage measurement
P43 / AN003
For position / speed command value input (analog value)
P35
START/STOP toggle switch
PA0
ERROR RESET toggle switch
PC5
LED1 ON/OFF control
PC6
LED2 ON/OFF control
P34
LED3 ON/OFF control
P40 / AN000
U phase current measurement
P42 / AN002
W phase current measurement
P71 / MTIOC3B / GTIOC4A
PWM output (Up)
P72 / MTIOC4A / GTIOC5A
PWM output (Vp)
P73 / MTIOC4B / GTIOC6A
PWM output (Wp)
P74 / MTIOC3D / GTIOC4B
PWM output (Un)
P75 / MTIOC4C / GTIOC5B
PWM output (Vn)
P76 / MTIOC4D / GTIOC6B
PWM output (Wn)
P23 / IRQ11
Hall Phase-U signal input
P24 / IRQ4
Hall Phase-V signal input
P25 / IRQ10
Hall Phase-W signal input
PA7 / MTCLKA
Encoder Phase-A signal input
PA6 / MTCLKB
Encoder Phase-B signal input
P70 / POE0#
PWM emergency stop input at the time of over-current detection
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 6 of 37 Mar 29. 2019

2.2.2 Peripheral functions

List of the peripheral functions used in this system is given in Table 2-3.
Table 2-3 List of the Peripheral Functions
12-bit A/D
CMT
MTU3 / GPTW
POE3B
- Rotation speed command value input
- Current of each phase U and W
measurement
- Inverter bus voltage measurement
500 [µs] interval timer
- Complementary PWM output
- Encoder phase counter
- Encoder count capture
Set PWM output ports to high impedance state to stop the PWM output.
(1) 12-bit A/D converter (S12ADH)
U phase current (Iu), W phase current (Iw), inverter bus voltage (Vdc) and rotation speed reference are measured by using the single scan mode (use hardware trigger). The sample-and-hold function is used for U phase current (Iu) and W phase current (Iw) measurement.
(2) Compare match timer (CMT)
The channel 0 of the compare match timer is used as 500 [µs] interval timer.
(3) Multi-function timer pulse unit 3 (MTU3d)
The operation mode varies depending on channels. On the channels 3 and 4, output (active level: high) with dead time is performed by using the complementary PWM mode.
The channel 1 of MTU3 operate in phase counting mode, the counter is incremented or decremented according to the phase difference between Phase-A and Phase-B signals from the encoder.
(4) General PWM Timer (GPTW)
The operation mode varies depending on channels. On the channels 4, 5 and 6, output (active level: high) with dead time is performed by using the PWM Output Operating mode.
The channel 3 operate in phase counting mode, the counter is incremented or decremented according to the phase difference between Phase-A and Phase-B signals from the encoder.
The channel 9 is used as free-run timer for speed measurement.
(5) Port output enable 3 (POE3B)
PWM output ports are set to high impedance state when an overcurrent is detected (when a falling edge of the POE0# port is detected) and when an output short circuit is detected.
The setting of the PWM output timer is selected by the following macro definition.
Table 2-4 List of Macro Definitions r_mtr_ctrl_rx72t.h
File name
Macro name
Definition value
Remarks
r_mtr_ctrl_rx72t.h
MTR_GPT
0
0:MTU 1:GPT
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 7 of 37 Mar 29. 2019

2.3 Software configuration

2.3.1 Software file configuration

Folder and file configuration of the sample programs are given below.
Figure 2-2 Folder and file configuration
middle
driver
user_interface
application
main
ics
board
interface
common
control
inverter
mcu
sensor
main.h, main.c: main function
r_mtr_ics.h, r_mtr_ics.c: Function definition of Analyzer
note1
UI
r_mtr_board.h, r_mtr_board.c: Function definition of board UI
ICS2_RX72T.lib: Tool communication library
ICS2_RX72T.h: Function definition of tool communication
(Project Folder)
r_mtr_driver_access.h, r_mtr_driver_access.c: Function definition of user access
r_mtr_common.h: Common definition
r_mtr_filter.h, r_mtr_filter.c: Function definition of general purpose filter
r_mtr_fluxwkn.h, r_mtr_fluxwkn.objc : Function definition for flux weakening control
r_mtr_pi_control.h, r_mtr_pi_control.c: Function definition of PI controller r_mtr_transform.h, r_mtr_transform.c: Function definition of coordinate transformation r_mtr_volt_err_comp.h, r_mtr_volt_err_comp.obj: Function definition of voltage error
compensation
r_mtr_mod.h, r_mtr_mod.c: Function definition of modulation r_mtr_statemachine.h, r_mtr_statemachine.c: Function definition of state machine
r_mtr_parameter.h: Function definition of various parameter
r_mtr_ctrl_gain_calc.obj: Function definition of control gain calculation r_mtr_foc_action.c: Function definition of event action r_mtr_interrupt_carrier.c: Function definition of carrier interrupt r_mtr_interrupt_timer.c: Function definition of periodic interrupt r_mtr_interrupt_sensor.c: Function definition of sensor signal interrupt r_mtr_foc_control_encd_position.h, r_mtr_foc_control_encd_position.c
: Function definition of FOC control
r_mtr_foc_current.h, r_mtr_foc_current.c: Function definition of current control r_mtr_foc_speed.h, r_mtr_foc_speed.c: Function definition of speed control r_mtr_foc_position.h, r_mtr_foc_position.c: Function definition of position control r_mtr_position_profiling.h, r_mtr_position_profiling.c
:
Function definition of position profiling
r_mtr_speed_observer.h, r_mtr_speed_observer.obj:
Function definition of speed observer
r_mtr_ipd.h, r_mtr_ipd.obj: Function definition of IPD controller
r_mtr_ctrl_mrssk.h, r_mtr_ctrl_mrssk.c: Function definition depends on inverter board
r_mtr_ctrl_encoder.h, r_mtr_ctrl_encoder.c: Function definition of encoder
r_mtr_ctrl_hall.h, r_mtr_ctrl_hall.c: Function definition of hall
config
Notes: 1. Regarding the specification of Analyzer function in the motor control development support tool
‘Renesas Motor Workbench’, please refer to the chapter 4. The identifier ‘ics/ICS’(ICS is
previous motor control development support tool ‘In Circuit Scope’) is attached to the name of
folders, files, functions, variables related to ‘Renesas Motor Workbench’.
r_mtr_config.h: Common definition for software configuration
r_mtr_motor_parameter.h: Configuration definition for motor parameters r_mtr_inverter_parameter.h: Configuration definition for inverter parameters r_mtr_control_parameter.h: Configuration definition for control parameters
r_mtr_encoder_parameter.h: Configuration definition for encoder parameters
r_mtr_interrupt.c: Interrupt function definition
r_mtr_ctrl_rx72t.h, mtr_ctrl_rx72t.c: Function definition depends on MCU r_mtr_ctrl_mcu.h: Common definition depends on MCU auto_generation: Folder for auto generation files
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 8 of 37 Mar 29. 2019

2.3.2 Module configuration

Module configuration of the sample programs is described below.
Figure 2-3 Module Configuration
Application Layer (User Application)
main.c
User Interface Module
Main
r_mtr_ics.c
r_mtr_board.c
Middle Layer (Motor Control Process)
r_mtr_driver_access.c
Interface Module
Control Module (FOC, Feedback Loop Control)
r_mtr_interrupt_carrier.c
r_mtr_foc_control_encd_position.c
r_mtr_foc_current.c
r_mtr_interrupt_timer.
r_mtr_interrupt_sensor.c
r_mtr_foc_speed.c
r_mtr_foc_position.c
Other Control Modules
Device Layer (MCU Register Access, Inverter Driver, Sensor Driver)
r_mtr_ctrl_mrssk.c
r_mtr_ctrl_encoder.c
r_mtr_ctrl_hall.c
r_mtr_interrupt.c
r_mtr_ctrl_rx72t.c
H/W Layer (MCU Inverter)
Function Call
Function Call
Set User Command to Buffer
Set Control Gain & Command
Set PWM duty
Get Voltage, Current & Angle/Speed
Interrupt Process Modules
Control Modules
Get A/D Converter Data & Sensor Signal
Output PWM Signal
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 9 of 37 Mar 29. 2019

2.4 Software specifications

Table 2-5 shows basic software specification of this system. For details of the vector control, refer to the application note ‘Vector control of permanent magnet synchronous motor with encoder: algorithm’.
Table 2-5 Basic Specifications of Vector Control PMSM with Encoder Software
Item
Content
Control method
Vector control
Motor control start/stop
Determined depending on the level of SW1 (“Low”: control start “High”: stop) or input from Analyzer
Position detection of rotor magnetic pole
Incremental encoder (A-B Phase), Hall sensor (UVW Phase) Input voltage
DC 24 [V]
Carrier frequency (PWM)
20 [kHz] (carrier cycle: 50[µs])
Dead time
2 [μs]
Control cycle (Current loop)
50 [μs]
Control cycle (Speed and Position loop)
500 [µs]
Management of position command value
Board UI
Position command generation: Direct input of VR1 (input range)
-180°180°
ICS UI
Position command generation: Position profile of trapezoidal curve for speed command value (input range)
- 32768°32767° (Max speed) CW / CCW: 2000[rpm]
Management of speed command value
CW: 0 [rpm] to 2000rpm] CCW: 0 [rpm] to 2000rpm]
Accuracy of position
0.3° (Encoder pulse: 300[ppr] 4 for multiplying 1200[cpr])
Dead band of position
(Note)
Encoder count ±1 [cpr] (±0.3°)
Natural frequency of each control system
Current control system:300Hz Speed control system:30Hz Position control system:10Hz
Optimization setting for compiler
Optimization level
2 (-optimize=2) (default)
Optimization method
Size priority (default)
ROM/RAM size
ROM: 21.0KB RAM: 4.8KB
Processing stop for protection
Motor control signal outputs (six outputs) will be disabled, under any of the following conditions.
1. Current of each phase exceeds 3.28 [A] (monitored every 50 [μs])
2. Inverter bus voltage exceeds 28 [V] (monitored every 50 [μs])
3. Inverter bus voltage is less than 14 [V] (monitored every 50 [μs])
4. Rotation speed exceeds 3000 [rpm] (monitored every 50 [μs])
When an external over current signal is detected (when a falling edge of the POE0# port is detected) and when the output short circuit is detected, the PWM output ports are set to high impedance state.
Note: Dead zone is provided to prevent hunting in positioning.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 10 of 37 Mar 29. 2019

3. Descriptions of the Control Program

The target sample programs of this application note are explained here.

3.1 Contents of Control

3.1.1 Motor Start/Stop

The start and stop of the motor are controlled by input from Analyzer function of ‘Renesas Motor Workbench’ or SW1 switch of RSSK board.
A general-purpose port is assigned to SW1. The port is read within the main loop. When the port is at a Low level, the software determines that the motor should be started. Conversely, when the level is switched to High, the program determines that the motor should be stopped.

3.1.2 A/D Converter

(1) Motor Rotation Position and Speed Command Value
The motor rotation position and speed command value can be set by Analyzer input or A/D conversion of the VR1 output value (analog value). The A/D converted VR1 value is used as rotation speed command value, as shown below.
Table 3-1 Conversion Ratio of the Rotation Position and Speed Command Value
Item
Conversion ratio (Command value: A/D conversion value)
Channel
Rotation position command value
CW
180°:0800H0FFFH
AN003 CCW
0 °~-180°:07FFH0000H
Rotation speed command value
CW
0 [rpm]2000[rpm]:0800H~0FFFH
CCW
0 [rpm]2000[rpm]:07FFH0000H
(2) Inverter Bus Voltage
Inverter bus voltage is measured as given in エラー! 参照元が見つかりません。. It is used for modulation factor calculation, under-voltage detection and over-voltage detection. (When an abnormality
is detected, PWM is stopped.)
Table 3-2 Inverter Bus Voltage Conversion Ratio
Item
Conversion ratio (Inverter bus voltage: A/D conversion value)
Channel
Inverter bus voltage
0 [V] to 111 [V]: 0000H to 0FFFH
AN209
(3) U, W Phase Current
The U and W phase currents are measured as shown in エラー! 参照元が見つかりません。 and used for vector control.
Table 3-3 Conversion Ratio of U and W Phase Current
Item
Conversion ratio (U, W phase current: A/D conversion value)
Channel
U, W phase current
-10 [A] to 10 [A]: 0000H to 0FFFH
(Note 1)
Iu: AN000 Iw: AN002
Notes:1 For more details of A/D conversion characteristics, refer to RX72T Group User’s Manual: Hardware. .
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 11 of 37 Mar 29. 2019

3.1.3 Position Profile Generation (Position Profile of Trapezoidal Curve for Speed Command Value)

In vector control software for PMSM with encoder, the position profile generation is used to create command value (input position value). The implementation of command value is each control cycle is used as method of managing acceleration and the maximum speed value with respect to target position value.
Figure 3-1 Position Profile Generation
Enter the following variables from the Analyzer to create a command value.
Position reference [degree] (com_s2_ref_position_deg) Acceleration time (com_f4_accel_time) Maximum speed command value (com_f4_accel_max_ref_speed_rad) Position stabilization wait time (com_u2_ref_pos_interval_time)
u1_ref_pos_status
u1_ref_pos_mode
Time[s]
Time[s]
Speed
Position
Constant Speed
com_s2_max_speed_rpm
com_u2_ref_pos_interval_time
MTR_CTRL_TRIANGLE
MTR_CTRL_TRAPEZOIDAL
MTR_CTRL_TRIANGLE f4_accel_max_ref_speed_rad * f4_accel_time >= f4_dt_pos_rad
MTR_CTRL_TRAPEZOIDAL f4_accel_max_ref_speed_rad * f4_accel_time < f4_dt_pos_rad
com_s2_ref_position_deg
MTR_POSITION_STEADY_STATE
MTR_POSITION_TRANSITION_STATEE
MTR_POSITION_STEADY_STATE
MTR_POSITION_TRANSITION_STATE
E
com_s2_ref_position_deg
Reference Position
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 12 of 37 Mar 29. 2019

3.1.4 Speed Measurement

In order to obtain better real-time performance and higher speed resolution at low speed, this system use encoder signal edge interval to calculate speed, the speed extrapolation is used in PI control calculation. In addition, taking the difference between rise time and fall time and the accuracy of quadrature of encoder signal into consideration, the speed is calculated with time elapsed and angle changed in one period of encoder Phase-A or Phase-B signals.
(1) Speed Calculation
2π/Pulses per Rotation
Timer Counter
Capture Capture
Counter Difference
Phase-A
Encoder Signal
Phase-B
Encoder Signal
2π/Pulses per Rotation
CaptureCaptureCaptureCaptureCapture
󰇟󰇠 
󰇡


󰇢󰇡


󰇢
Figure 3-2 Speed Calculation using Encoder
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 13 of 37 Mar 29. 2019

3.1.5 Modulation

The target software of this application note uses pulse width modulation (hereinafter called PWM) to generate the input voltage to the motor. And the PWM waveform is generated by the triangular wave comparison method.
(1) Triangular Wave Comparison Method
The triangular wave comparison method is used to output the voltage command value. By this method, the pulse width of the output voltage can be determined by comparing the carrier waveform (triangular wave) and voltage command value waveform. The voltage command value of the pseudo sinusoidal wave can be output by turning the switch on or off when the voltage command value is larger or smaller than the carrier wave respectively.
U V W
ωt
ωt
ωt
ωt
Modulation wave: command voltage Carrier wave (triangular wave): PWM timer count
U phase switching
waveform
V phase switching
waveform
Voltage between U – V
Lines: (U phase waveform)
(V phase waveform)
Figure 3-3 Conceptual Diagram of the Triangular Wave Comparison Method
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 14 of 37 Mar 29. 2019
Here, as shown in the Figure 3-4, ratio of the output voltage pulse to the carrier wave is called duty.
Average
voltage
t
V
T
ON
T
OFF
T
ON
+ T
OFF
T
ON
Duty =
× 100 [%]
Figure 3-4 Definition of Duty
Modulation factor m is defined as follows.
E
V
m =
m: Modulation factor V: Voltage command value E: Inverter bus voltage
The voltage command can be generated by setting PWM compare register properly to obtain the desired duty.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 15 of 37 Mar 29. 2019

3.1.6 State Transition

Figure 3-5 is a state transition diagram of the vector control software. In the target software of this application note, the
software state is managed by ‘SYSTEM MODE’ and ‘RUN MODE’. And ‘Control Config’ shows the active control
system in the software.
SYSTEM MODE
INACTIVE
ERROR
POWER ON/
RESET
[RESET EVENT]
[ACTIVE EVENT]
[INACTIVE EVENT]
[ERROR EVENT]
RUN MODE
INIT
BOOT
Control Config
Cu r re n t
Sp e ed
Po s it i on
To r qu e
Vo l ta g e
DRIVE
ACTIVE
[MTR_ID_ZERO_CONST
== st_g.u1_flag_id_ref]
[g_f4_offset_calc_time
== st_g.u2_cnt_adjust]
[ERROR EVENT]
[RESET EVENT]
EVENT
INACTIVE
ACTIVE
ERROR
RESET
MODE
INACTIVE ACTIVE ERROR
INACTIVE
INACTIVE INACTIVE
ACTIVE
ERROR ERROR
ERROR
ERROR
ERROR
INACTIVE
ACTIVE
ERROR
[MTR_LOOP_POSITION ==
com_u1_ctrl_loop_mode]
[MTR_LOOP_SPEED ==
com_u1_ctrl_loop_mode]
Control Config
Cu r re n t
Sp e ed
Po s it i on
To r qu e
Vo l ta g e
Control Config
Cu r re n t
Sp e ed
Po s it i on
To r qu e
Vo l ta g e
Figure 3-5 State Transition Diagram of Vector Control PMSM with Encoder Software
(1). SYSTEM MODE
‘SYSTEM MODE’ indicates the operating states of the system. The state transits on occurrence of each event (EVENT).
‘SYSTEM MODE’ has 3 states that are motor drive stop (INACTIVE), motor drive (ACTIVE), and abnormal condition
(ERROR).
(2). RUN MODE
‘RUN MODE’ indicates the condition of the motor control. ‘RUN MODE’ transits sequentially as shown in Figure 3-5 when ‘SYSTEM MODE’ is ‘ACTIVE’.
(3). EVENT When ‘EVENT’ occurs in each ‘SYSTEM MODE’, ‘SYSTEM MODE’ changes as shown the table in Figure 3-5,
according to that ‘EVENT’.
Table 3-1 List of EVENT
EVENT name
Occurrence factor
INACTIVE
by user operation
ACTIVE
by user operation
ERROR
when the system detects an error
RESET
by user operation
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 16 of 37 Mar 29. 2019

3.1.7 Startup Method

Figure 3-6 shows the software implementation of d-axis and encoder alignment method. The d-axis alignment method used as startup control of position control method, in initialization mode (MTR_MODE_INIT) and Boot mode (MTR_MODE_BOOT). In drive mode (MTR_MODE_DRIVE) vector control is implemented for PMSM with Encoder. Each reference value setting of d-axis current, q-axis current and speed is managed by respective status.
MTR_ID_CONST
(1)
Id reference[A]
Iq reference[A]
Speed reference
[rpm]
com_f4_ref_id
MTR_ID_ZERO_CONST
(3)
Id=0 control
MTR_MODE_BOOT
RUN MODE
Id reference status
speed PI output
0
0
0
Iq reference status
Speed reference status
MTR_MODE_INIT
MTR_ID_UP
(0)
MTR_ID_ZERO_CONST
(3)
MTR_IQ_ZERO_CONST
(0)
MTR_SPEED_ZERO_CONST
(0)
MTR_IQ_SPEED_PI_OUTPUT
(1)
MTR_POSITION_CONTROL_OUTPUT
(1)
MTR_MODE_DRIVE
MTR_ID_CONST
(1)
MTR_ID_UP
(0)
MTR_POSITION_CONST
(0)
Position reference status
MTR_POSITION_TRAPEZOID
(1)
Position reference
[degree]
0
com_s2_ref_position_deg
[s]
[s]
[s]
[s]
Figure 3-6 Startup Position Control of Vector Control PMSM with Encoder Software
MTR_ID_CONST
(1)
Id reference[A]
Iq reference[A]
Speed reference
[rpm]
com_f4_r ef_id
MTR_ID_ZERO_CONST
(3)
z
Id=0 control
MTR_MODE _BOOT
RUN MODE
Id reference status
speed PI output
0
0
0
Iq reference status
Speed reference status
MTR_MODE _INIT
MTR_ID_UP
(0)
MTR_ID_ZERO_CONST
(3)
MTR_IQ_ZERO_CONST
(0)
MTR_SPEED_ZERO_CONST
(0)
MTR_IQ_SPEED_PI_O UTPUT
(1)
MTR_SPEED_CHANGE
(2)
MTR_MODE _DRIVE
MTR_ID_CONST
(1)
MTR_ID_UP
(0)
[s]
[s]
[s]
com_s2_r ef_speed_rpm
Figure 3-7 Startup Speed Control of Vector Control PMSM with Encoder Software
For details of the position control of a vector controlled PMSM using encoder, refer to the application note ‘Vector control of permanent magnet synchronous motor with encoder: algorithm’.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 17 of 37 Mar 29. 2019

3.1.8 System Protection Function

This control program has the following error status and executes emergency stop functions in case of occurrence of respective errors. Table 3-4 shows each setting value for the system protection function.
Over-current error
The over current detection is performed by both hardware detection method as well as software detection method. In response to over-current detection an emergency stop signal is generated from the hardware (hardware detection). When the emergency stop signal is generated, the PWM output ports are set to high impedance state.
In addition, U, V, and W phase currents are monitored in over current monitoring cycle. When an over current is detected, the CPU executes emergency stop (software detection). The over current limit value is calculated from the nominal current of the motor [MP_NOMINAL_CURRENT_RMS].
Over-voltage error
The inverter bus voltage is monitored in over-voltage monitoring cycle. When an over-voltage is detected, the CPU performs emergency stop. Here, the over-voltage limit value is set in consideration of the error of resistance value of the detect circuit.
Under-voltage error
The inverter bus voltage is monitored in under-voltage monitoring cycle. The CPU performs emergency stop when under-voltage is detected. Here, the low voltage limit value is set in consideration of the error of resistance value of the detect circuit.
Over-speed error
The rotation speed is monitored in rotation speed monitoring cycle. The CPU performs emergency stop when the speed is over the limit value.
Table 3-4 Setting Values of the System Protection Function
Over-current error Over-current limit value [A]
3.82
Monitoring cycle [s]
50
Over-voltage error Over-voltage limit value [V]
28
Monitoring cycle [s]
50
Under-voltage error Under-voltage limit value [V]
14
Monitoring cycle [s]
50
Over-speed error Speed limit value [rpm]
3000
Monitoring cycle [s]
50
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 18 of 37 Mar 29. 2019

3.2 Function Specifications of Vector Control using Encoder Software

The control process of the target software of this application note is mainly consisted of 50[µs] period interrupt (carrier interrupt) and 500[µs] period interrupt. As following Figure 3-8, the control process in the red broken line part is executed every 50[µs] period, and the control process in the blue broken line part is executed every 500[µs] period.
Decoupling
Control
PWM
Current
PI
Speed
PI
dq
UVW
dq
UVW
Encoder
ω*
id*
ω
iq*
vd*
θ
i
d
i
q
i
u
iw
θ
v
u
v
v
v
w
+
-
+
+
Position P
+ Speed FF
θ*
θ
i
q
i
d
vd**
vq**
Voltage
Limit
iq**
vq* vq*
M
Voltage
error
Compen
-sation
v
u
v
v
v
w
Hall
Encoder Interrupt
Carrier Interrupt
Switch Position & Speed
Calculation Mode
ω
θ
Switch
Position/Speed
Loop mode
Speed
Observer
Position Profiling
θ_reference
IPD Controler
+ Position P + Speed FF
Switch
Position/Speed Loop Controller
Carrier Interrupt Process
500us Interrupt Process
Encoder Interrupt Process
Encoder
A/B
Phase
signal
ω*
ω*
iq*id*
ω_reference
Hall Interrupt
Process
Rotor Angle
Detection
Switch Angle Adjust mode
Figure 3-8 System Block of Vector Control with Encoder
This chapter shows the specification of 4 interrupt functions and functions executed in each interrupt cycle. In the following tables, only essential functions of the vector control are listed. Regarding the specification of functions not listed in following tables, refer to source codes.
Table 3-5 List of Control Functions mtr_interrupt.c
File name
Function name
Process overview
r_mtr_interrupt_carrier.c
mtr_foc_carrier_interrupt Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
Calling every 50 [μs]
- Current and voltage monitoring
-Error detection
- Current offset detection
- Vector calculation
- Current PI control
r_mtr_interrupt_timer.c
mtr_foc_500us_interrupt Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control
Output: None
Calling every 500 [µs]
- Startup control
- d-axis/q-axis current and speed reference set
- Speed PI control
r_mtr_interrupt_sensor.c
mtr_angle_adj_hall_interrupt Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control
Output: None
Called when the Hall phase signals (Phase-U/V/W)
- Get Hall signal
- Rotor phase calculation
- Hall error process
- Disable Hall interrupt
mtr_encd_pos_speed_calc_interrupt Input: (mtr_foc_control_t *) st_foc / FOC motor structure
Output: None
Called when the encoder phase counts (Phase-A and B)
- Rotor phase calculation
- Speed calculation
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 19 of 37 Mar 29. 2019
Table 3-6 List of Functions for 50us interrupt [1/2]
File name
Function name
Process overview
r_mtr_ctrl_mrssk.c
mtr_get_current_iuiw Input: (float*) f4_iu_ad / U phase current A/D conversion value
(float*) f4_iw_ad / W phase current A/D conversion value (uint8_t) u1_id / Motor ID
Output: None
Obtaining the UVW phase current
mtr_get_vdc Input: (uint8_t) u1_id / Motor ID Output: (float) f4_temp_vdc / Vdc value
Obtaining the Vdc
r_mtr_foc_control_enc d_position.c
mtr_error_check Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
Error monitoring
mtr_current_offset_adjustment Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
UVW phase current offset adjustment
mtr_calib_current_offset Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
UVW phase current offset calculation
mtr_encd_pos_speed_calc Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
Position and speed calculation for encoder pulse
mtr_foc_voltage_limit Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
Voltage command value limit
mtr_angle_speed Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control Output: None
Rotor phase and speed related process (Switching calculation method)
r_mtr_foc_current.c
mtr_current_pi_control Input: (mtr_foc_control_t * )st_foc / Structure pointer for vector control Output: None
Current PI
mtr_decoupling_control Input: (mtr_foc_control_t *) st_foc / Structure pointer for vector control
(float)f4_speed_rad / speed (mtr_parameter_t*)mtr_para / motor parameter structure
Output: None
Decupling control
r_mtr_transform.c
mtr_transform_uvw_dq_abs Input: (const mtr_rotor_angle_t *) p_angle /
Structure pointer for phase management (const float*)f4_uvw / UVV phase pointer (float*)f4_dq / dq-axis pointer
Output: None
Coordinate transform UVW to dq
mtr_transform_dq_uvw_abs Input: (const mtr_rotor_angle_t *) p_angle /
Structure pointer for phase management (const float*)f4_dq / dq-axis pointer (float*)f4_uvw / UVW phase pointer
Output : None
Coordinate transform dq to UVW
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 20 of 37 Mar 29. 2019
Table 3-7 List of Functions for 50us Interrupt [2/2]
File name
Function name
Process overview
r_mtr_volt_err_comp.c
mtr_volt_err_comp_main Input:(mtr_volt_comp_t *) st_volt_comp / Voltage error
compensation structure
(float*) p_f4_v_array / Three phase voltage compensation
value array pointer
(float*) p_f4_i_array / Three phase current compensation
value array pointer
(float)f4_vdc / Vdc value
Output: None
Voltage error compensation
r_mtr_ctrl_rx72t.c
mtr_inv_set_uvw Input:(float) f4_modu / U phase modulation factor
(float) f4_modv / V phase modulation factor (float) f4_modw / W phase modulation factor (uint8_t) u1_id / Motor ID
Output: None
PWM output setting
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 21 of 37 Mar 29. 2019
Table 3-8 List of Functions for 500us Interrupt
File name
Function name
Process overview
r_mtr_ctrl_hall.c
mtr_angle_adj_hall_init Input:(mtr_hall_t *) st_hc / Hall sensor structure Output:(float) f4_hall_angle_rad / angle of signal detection for Hall
sensor
Initialize rotor angle detection for Hall sensor
r_mtr_ctrl_encoder.c
mtr_set_encd_tcnt Input:(uint8_t) u1_id / Motor ID
(uint16_t) u2_cnt_value / counter value
Output: None
Set for encoder count resister
mtr_encd_cnt_reset Input:(uint8_t) u1_id / Motor ID
(uint16_t) u2_cnt_value / counter value
Output: None
Initialize encoder timer counter value
r_mtr_ctrl_rx72t.c
mtr_speed_calc_timer_start Input:(uint8_t) u1_id / Motor ID Output: None
Start for encoder timer
mtr_irq_interrupt_enable Input:(uint8_t) u1_id / Motor ID Output: None
Enable Hall interrupt
r_mtr_foc_control_encd_p osition.c
mtr_hall_error Input:(mtr_foc_control_t *) st_foc / FOC motor structure
(float) f4_hall_angle_rad / angle of Hall
Output: None
Hall sensor error process mtr_set_pos_ref Input:(mtr_foc_control_t *) st_foc / FOC motor structure Output:(float32) f4_ref_pos_rad_calc / position command value
Setting the command value for position control
mtr_set_speed_ref Input:(mtr_foc_control_t *) st_foc / FOC motor structure Output:(float32) f4_speed_ref_rad _calc / speed command value
Setting the command value for speed control
mtr_set_iq_ref Input:(mtr_foc_control_t *) st_foc / FOC motor structure Output:(float32) f4_iq_ref_calc / q-axis current command value
Setting the q axis current command value
mtr_set_id_ref Input:(mtr_foc_control_t *) st_foc / FOC motor structure Output:(float32) f4_id_ref_calc / d-axis current command value
Setting the d axis current command value
r_mtr_fluxwkn.obj
R_FLUXWKN_Run Input: (fluxwkn_t *) p_fluxwkn
/ Structure pointer for flux weakening control
(float) f4_speed_rad / Rotation speed (const float*) p_f4_idq
/ dq-axis current pointer (float*) p_f4_idq_ref / dq-axis current reference pointer Output: (uint16_t) u2_fw_status / Status of flux-weakening control
Flux-weakening control
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 22 of 37 Mar 29. 2019

3.3 Macro Definitions of Vector Control Software Using Encoder

Lists of macro definitions used in this control program are given below.
Table 3-9 List of Macro Definitions r_mtr_motor_parameter.h
File name
Macro name
Definition value
Remarks
r_mtr_motor_parameter.h
MP_POLE_PAIRS
7
Number of pole pairs
MP_MAGNETIC_FLUX
0.006198f
Flux [Wb]
MP_RESISTANCE
0.453f
Resistance [Ω]
MP_D_INDUCTANCE
0.0009447f
d-axis Inductance [H]
MP_Q_INDUCTANCE
0.0009447f
q-axis Inductance [H]
MP_ROTOR_INERTIA
0.00000962f
Rotor inertia [kgm^2]
MP_NOMINAL_CURRENT_RMS
1.8f
Nominal torque [Arms]
Table 3-10 List of Macro Definitions r_mtr_control_parameter.h
File name
Macro name
Definition value
Remarks
r_mtr_control_parameter.h
CP_CURRENT_OMEGA
300.0f
Natural frequency of the current loop[Hz]
CP_CURRENT_ZETA
1.0f
Damping ratio of the current loop
CP_SPEED_OMEGA
30.0f
Natural frequency of the speed loop[Hz]
CP_SPEED_ZETA
1.0f
Damping ratio of the speed loop
CP_POS_OMEGA
10.0f
Natural frequency of the position loop[Hz]
CP_SOB_OMEGA
200.0f
Natural frequency of the speed observer[Hz]
CP_SOB_ZETA
1.0f
Damping ratio of the speed observer
CP_MIN_SPEED_RPM
0
Minimum speed (mechanical) [rpm]
CP_MAX_SPEED_RPM
2000
Maximum speed (mechanical) [rpm]
CP_SPEED_LIMIT_RPM
3000
Limit speed (mechanical) [rpm]
CP_OL_ID_REF
1.5f
d-axis current command value [A]
Table 3-11 List of Macro Definitions r_mtr_inverter_parameter.h
File name
Macro name
Definition value
Remarks
r_mtr_inverter_parameter.h
IP_DEADTIME
2.0f
Deadtime [µs]
IP_CURRENT_RANGE
20.0f
current sensing range
IP_VDC_RANGE
111.0f
voltage sensing range
IP_INPUT_V
24.0f
input DC voltage [V]
IP_CURRENT_LIMIT
5.0f
Current limit[A]
(Note)
IP_OVERVOLTAGE_LIMIT
28.0f
Over voltage limit [V]
IP_UNDERVOLTAGE_LIMIT
14.0f
Under voltage limit [V]
Note: This value is calculated from the rated power of the shunt resistance.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 23 of 37 Mar 29. 2019
Table 3-12 List of Macro Definitions r_mtr_config.h
File name
Macro name
Definition value
Remarks
r_mtr_config.h
IP_MRSSK
-
Inverter select macro
RX72T_MRSSK
-
MCU select macro
MP_FH6S20EX81
-
Motor select macro
CP_FH6S20EX81
-
RP_FH6S20EX81
-
CONFIG_DEFAULT_UI
ICS_UI
Select default UI ICS_UI: Use the Analyzer for RMW BOARD_UI: Use board interface
FUNC_ON
1
Enable
FUNC_OFF
0
Disable
DEFAULT_FLUX_WEAKENI NG
FUNC_OFF
Flux weakening control
DEFAULT_VOLT_ERR_CO MP
FUNC_ON
Voltage error compensation
ANGLE_ADJUST_MODE
MTR_ANGLE_ADJ_EXCIT
Select angle adjust mode MTR_ANGLE_ADJ_EXCIT: Forced
excitation mode MTR_ANGLE_ADJ_HALL: Hall mode
POS_CTRL_MODE
MTR_CTRL_IPD
Select position control mode MTR_CTRL_PID: PID controller MTR_CTRL_IPD: IPD controller
LOOP_MODE
MTR_LOOP_POSITION
Select control loop mode MTR_LOOP_SPEED: speed loop MTR_LOOP_POSITION: position loop
GAIN_MODE
MTR_GAIN_DESIGN_MODE
Gain mode MTR_GAIN_DESIGN_MODE:
PI gain design mode
MTR_GAIN_DIRECT_MODE:
PI gain direct input mode
MOD_METHOD
MOD_METHOD_SVPWM
modulation method MOD_METHOD_SPWM:
Sinusoidal PWM
MOD_METHOD_SVPWM:
Space Vector PWM
Table 3-13 List of Macro Definitions r_mtr_encoder_parameter.h
File name
Macro name
Definition value
Remarks
r_mtr_encoder_parameter.h
EP_PULSE_PER_REV
300
Pulse par revolution [ppr]
Table 3-14 List of Macro Definitions ‘r_mtr_common.h’
File name
Macro name
Definition value
Remarks
r_mtr_common.h
MTR_TFU_OPTIMIZE
1
1:Use TFU code 0:Use Standard library code
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 24 of 37 Mar 29. 2019

3.4 Control Flowcharts

3.4.1 Main Process

Main process
Initialization of
peripheral functions
Initialization of
user interface
Initialization of variables used
in the main process
Initialization of sequence
process
Initialization of Analyzer
Watchdog timer clear
UI ?
[Board]
[Analyzer]
LED control
Determine rotation position.
Reset process
Power supply voltage
stabilization wait
Change motor operation mode
according to SW status.
Rotation position command
value setting
Input parameters.
Change motor operation mode
based on the value of
com_u1_mode_system.
LED control
Figure 3-9 Main Process Flowchart
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 25 of 37 Mar 29. 2019

3.4.2 Carrier Synchronous Interrupt Handling (Vector Control using Encoder)

Carrier synchronous interrupt
End
(UVW)- (d-q) Transform
PWM register setting
Current PI control
Get U phase and W phase current values
Get inverter bus voltage value.
Angle and speed related Process
Decoupling control
PWM duty calculation
Voltage limit
U phase and W phase current
offset adjustment
Error check
SYSTEM MODE
offset adjustment
[ACTIVE]
[INACTIVE]
[confirmed]
[unconfirmed]
Current offset detection
Calculate V-phase current
Voltage error compensation
(d-q)-(UVW) Transform
Angle and speed calculation
Encoder counter processing
Phase-lead compensation
Figure 3-10 50 [μs] Cycle Interrupt Handling
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 26 of 37 Mar 29. 2019

3.4.3 500 [µs] Interrupt Handling

500 [us] interrupt
SYSTEM MODE
End
[INACTIVE]
[ACTIVE]
RUN MODE
Position reference setting
Current offset adjustment
[INIT MODE]
[BOOT MODE]
[DRIVE MODE]
[Unconfirmed]
[Confirmed]
d-axis current const setting
Run mode transition to DRIVE MODE
[Unconfirmed]
[Confirmed]
Speed reference setting
q-axis current reference setting
d-Axis current reference setting
Position reference setting
Speed reference setting
q-axis current reference setting
d-Axis current reference setting
Decide direction
To BOOT MODE
To DRIVE MODE
Magnetic pole position
detection mode
Detection of Hall initial angle
Error handling of Hall detection angle
Initialize encoder counter
Encoder timer start
Enable Hall interrupt
[Initial position
detection by Hall]
[Forced excitation]
Figure 3-11 500 [µs] Interrupt Handling
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 27 of 37 Mar 29. 2019

3.4.4 Over Current Detection Interrupt Handling

The over current detection interrupt occurs when POE0# pin detects falling-edge or when output levels of the MTU complementary PWM output pins are compared and simultaneous active-level output continues for one cycle or more. Therefore, when this interrupt process is executed, PWM output pins are already in high-impedance state and the output to the motor is stopped.
Over current detection interrupt
End
Motor stop process
Clearing high impedance status
Figure 3-12 Over Current Detection Interrupt Handling

3.4.5 Encoder Count Capture Interrupt Handling

Encoder count capture interrupt
End
Encoder alignment finished
Encoder phase counter cumulation
Encoder position calculation
Encoder speed calculation
[YES]
[NO]
Encoder edge interval cumulation
Zero speed detection
Encoder edge interval moving average
Figure 3-13 Encoder Count Capture Interrupt Handling
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 28 of 37 Mar 29. 2019

3.4.1 Hall Signal Interrupt Handling

Hall signal interrupt
End
RUN MODE
[DRIVE MODE]
[Other than
DRIVE MODE]
Detection of Hall signal
Disable Hall interrupt
Error handling of Hall detection angle
Calculate of rotor angle
Figure 3-14 Hall Signal Interrupt Handling
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 29 of 37 Mar 29. 2019

4. Motor Control Development Support Tool Renesas Motor Workbench

4.1 Overview

‘Renesas Motor Workbench’ is support tool for development of motor control system. ‘Renesas Motor Workbench’ can
be used with target software of this application note to analyze the control performance. The user interfaces of ‘Renesas Motor Workbench’ provide functions like rotating/stop command, setting rotation speed reference, etc. Please refer to Renesas Motor Workbench User’s Manual’ for usage and more details. ‘Renesas Motor Workbench’ can be
downloaded from Renesas Electronics Corporation website.
Figure 4-1 Renesas Motor Workbench – Appearance
Set up for ‘Renesas Motor Workbench’
(1) Start ‘Renesas Motor Workbench’ by clicking this icon.
(2) Click on [ File ] and select [Open RMT File(O)] from drop down Menu.
Select the RMT file from following location of e2studio/CS+ project folder.
‘[Project Folder]/ application/user_interface/ics/’ (3) Use the ‘Connection’ [COM] select menu to choose the COM port. (4) Click on the ‘Analyzer’ icon of Select Tool panel to open Analyzer function window. (5) Please refer to ‘4.3Operation Example for Analyzer’ for motor driving operation.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 30 of 37 Mar 29. 2019

4.2 List of Variables for Scope Function ‘Analyzer’

Table 4-1 is a list of variables for Analyzer. These variable values are reflected to the protect variables when the same values as of g_u1_enable_write are written to com_u1_enable_write. However, note that variables with (*) do not depend on com_u1_enable_write.
Table 4-1 List of Variables for Analyzer
Variable name
Type
Content
com_u1_sw_userif (*)
uint8_t
User interface switch 0: ICS user interface use (default) 1: Board user interface use
com_u1_mode_system(*)
uint8_t
State management 0: Stop mode
1: Run mode 3: Reset
com_u1_direction
uint8_t
Rotation direction 0: CW 1: CCW
com_u1_ctrl_loop_mode
uint8_t
Control loop mode switch 0: Speed control
1: Position control (default)
com_u1_ctrl_method_mode
uint8_t
Control method switch 0: PID control (Position P/Speed PI/Current PI)
1:IPD control(positionSpeed IPD
+Position FF+ Speed FF+Position P/ Current PI) (default)
FF:Feed-forward control
com_u1_position_input_mode
uint8_t
Position reference input mode switch 0:0 output
1:Direct input 2:Position profiling (default)
com_u1_encd_angle_adj_mode
uint8_t
Angle detection mode switch 0: Forced excitation(default)
1: Position detection using Hall signal
com_s2_ref_position_deg
int16_t
Position command value [degree]
com_s2_ref_speed_rpm
int16_t
Speed command value [rpm]
com_u2_min_speed_rpm
uint16_t
Minimum speed [[rpm]
com_u2_max_speed_rpm
uint16_t
Maximum speed [rpm]
com_u2_speed_limit_rpm
uint16_t
Overspeed Limit [rpm]
com_u2_hs_change_speed_rpm
uint16_t
Speed calculation mode switch speed [rpm]
com_u2_hs_change_margin_rpm
uint16_t
Speed calculation mode switch margin speed [rpm]
com_u2_pos_interval_time
uint16_t
Time interval of the position command changes [s]
com_u2_pos_dead_band
uint16_t
Dead band of position
com_u2_pos_band_limit
uint16_t
Positioning complete range
com_u2_encd_cpr
uint16_t
Encoder pulse count (4 for multiplying)
com_u2_offset_calc_time
uint16_t
Current offset value calculation time [ms]
com_u2_mtr_pp
uint16_t
Number of pole pairs
com_f4_mtr_r
float
Resistance [Ω]
com_f4_mtr_ld
float
d-axis Inductance [H]
com_f4_mtr_lq
float
q-axis Inductance [H]
com_f4_mtr_m
float
Flux [Wb]
com_f4_mtr_j
float
Inertia [kgm^2]
com_f4_nominal_current_rms
float
Nominal current [Arms]
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 31 of 37 Mar 29. 2019
Table 4-2 List of Variables for Analyzer
Variable name
Type
Content
com_f4_current_omega
float
Natural frequency of the current loop[Hz]
com_f4_current_zeta
float
Damping ratio of the current loop
com_f4_speed_omega
float
Natural frequency of the speed loop[Hz]
com_f4_speed_zeta
float
Damping ratio of the speed loop
com_f4_pos_omega
float
Natural frequency of the position loop[Hz]
com_f4_sob_omega
float
Natural frequency of the speed observer [Hz]
com_f4_sob_zeta
float
Damping ratio of the speed observer
com_f4_id_kp
float
d axis current PI control proportional term gain
com_f4_id_ki
float
d axis current PI control integral term gain
com_f4_iq_kp
float
q axis current PI control proportional term gain
com_f4_iq_ki
float
q axis current PI control integral term gain
com_f4_speed_kp
float
Speed PI control proportional term gain
com_f4_speed_ki
float
Speed PI control integral term gain
com_f4_pos_kp
float
Position control proportional term gain
com_f4_ipd_speed_k_ratio
float
Speed control gain ratio for IPD
com_f4_ipd_pos_kp_ratio
float
Position control proportional term gain ratio for IPD
com_f4_ipd_err_limit_1
float
Position error limit for IPD
com_f4_ipd_err_limit_2
float
Position error limit for IPD
com_f4_accel_time
float
Acceleration time [s] (for position control)
com_f4_ol_ref_id
float
d-axis current command value [A]
com_f4_id_up_time
float
d-axis current command value addition time [ms]
com_ f4_speed_rate_limit
float
Acceleration limit [s] (for speed control)
com_u1_enable_write
uint8_t
Enabled to rewriting variables
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 32 of 37 Mar 29. 2019
The primary variables that are frequently observed when the motor driving evaluation are listed in Table 4-3. Please refer when using Analyzer function. Regarding variables not listed in Table 4-3, refer to source codes.
Table 4-3 List of Primary variable for Encoder Vector Control
Name of primary variable for Encoder Vector Control
Type
Content
g_st_foc.u2_error_status
uint16_t
error status
g_st_foc.st_cc.f4_id_ref
float
d-axis current command value [A]
g_st_foc.st_cc.f4_id_ad
float
d-axis current [A]
g_st_foc.st_cc.f4_iq_ref
float
q-axis current command value [A]
g_st_foc.st_cc.f4_iq_ad
float
q-axis current [A]
g_st_foc.f4_iu_ad
float
W phase current A/D conversion value [A]
g_st_foc.f4_iv_ad
float
V phase current A/D conversion value [A]
g_st_foc.f4_iw_ad
float
W phase current A/D conversion value [A]
g_st_foc.st_cc.f4_vd_ref
float
d-axis output voltage command value [V]
g_st_foc.st_cc.f4_vq_ref
float
q-axis output voltage command value [V]
g_st_foc.f4_refu
float
U phase voltage command value [V]
g_st_foc.f4_refv
float
V phase voltage command value [V]
g_st_foc.f4_refw
float
W phase voltage command value [V]
g_st_foc.st_sc.f4_ref_speed_rad_ctrl
float
Command value for speed PI control (Electrical) [rad/s]
g_st_foc.st_sc.f4_speed_rad
float
Speed (Electrical) [rad/s]
g_st_foc.st_pc.f4_ref_pos_rad_ctrl
float
Command value for Position control (Electrical) [rad]
g_st_foc.st_pc.f4_pos_rad
float
Position (Electrical) [rad]
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 33 of 37 Mar 29. 2019

4.3 Operation Example for Analyzer

This section shows an example below for motor driving operation using Analyzer. Operation is using 'Control Window' of analyzer. Regarding specification of ‘Control Window, refer to Renesas Motor Workbench User’s Manual’.
- Driving the motor
Confirm the check-boxes of column [W?] for ‘com_u1_mode_system’, ‘com_s2_ref_speed_rpm’,
com_u1_enable_write
Input a reference speed value in the [Write] box of com_s2_ref_speed_rpm.Click the Write button.Click the Read button. Confirm the [Read] box of com_s2_ref_speed_rpm, g_u1_enable_write.Set a same value of g_u1_enable_write’ in the [Write] box of ‘com_u1_enable_write.Write ‘1’ in the [Write] box of com_u1_mode_system’.Click the Write button.
Write reference speed
Cick Read button
Check
Write (0or 1”)
③⑦Cick Write button
Write 1
Figure 4-2 Procedure - Driving the motor
- Stop the motor
Write 0 in the [Write] box of com_u1_mode_systemClick the Write button.
Cick Write button
Write 0
Figure 4-3 Procedure - Stop the motor
- Error cancel operation
Write ‘3 in the [Write] box of com_u1_mode_systemClick the Write button.
Cick Write button
Write 3
Figure 4-4 Procedure - Error cancel operation
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 34 of 37 Mar 29. 2019

4.4 Operation Example for User Button

The section shows an example below for motor driving operation using User Button.
- Driving or Stop the motor in position control mode
By setting as shown in Figure 4-5, driving and stopping change each time the button is pressed.
Figure 4-5 Driving or Stop the Motor in position control mode
- Change position
By setting as shown in Figure 4-6, enter the command position and press the button to change the position.
Figure 4-6 Change position
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 35 of 37 Mar 29. 2019
- Driving or Stop the motor in speed control mode
By setting as shown in Figure 4-7, driving and stopping change each time the button is pressed.
Figure 4-7 Driving or Stop the Motor in speed control mode
- Change speed
By setting as shown in Figure 4-8, enter the command speed and press the button to change the speed.
Figure 4-8 Change speed
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 36 of 37 Mar 29. 2019
Website and Support
Renesas Electronics Website
http://www.renesas.com/
Inquiries
http://www.renesas.com/contact/
All trademarks and registered trademarks are the property of their respective owners.
RX72T Vector Control for Permanent Magnet Synchronous Motor with Encoder (Implementation)
R01AN4721EJ0100 Rev.1.00 Page 37 of 37 Mar 29. 2019

Revision History

Rev.
Date
Description
Page
Summary
1.00
Mar. 29, 2019
-
First edition issued

General Precautions in the Handling of Microprocessing Unit and Microcontroller Unit Products

The following usage notes are applicable to all Microprocessing unit and Microcontroller unit products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products.
1. Precaution against Electrostatic Discharge (ESD)
A strong electrical field, when exposed to a CMOS device, can cause destruction of the gate oxide and ultimately degrade the device operation. Steps must be taken to
stop the generation of static electricity as much as possible, and quickly dissipate it when it occurs. Environmental control must be adequate. When it is dry, a
humidifier should be used. This is recommended to avoid using insulators that can easily build up static electricity. Semiconductor devices must be stored and
transported in an anti-static container, static shielding bag or conductive material. All test and measurement tools including work benches and floors must be grounded.
The operator must also be grounded using a wrist strap. Semiconductor devices must not be touched with bare hands. Similar precautions must be taken for printed
circuit boards with mounted semiconductor devices.
2. Processing at power-on
The state of the product is undefined at the time when power is supplied. The states of internal circuits in the LSI are indeterminate and the states of register settings
and pins are undefined at the time when power is supplied. In a finished product where the reset signal is applied to the external reset pin, the states of pins are not
guaranteed from the time when power is supplied until the reset process is completed. In a similar way, the states of pins in a product that is reset by an on-chip
power-on reset function are not guaranteed from the time when power is supplied until the power reaches the level at which resetting is specified.
3. Input of signal during power-off state
Do not input signals or an I/O pull-up power supply while the device is powered off. The current injection that results from input of such a signal or I/O pull-up power
supply may cause malfunction and the abnormal current that passes in the device at this time may cause degradation of internal elements. Follow the guideline for
input signal during power-off state as described in your product documentation.
4. Handling of unused pins
Handle unused pins in accordance with the directions given under handling of unused pins in the manual. The input pins of CMOS products are generally in the
high-impedance state. In operation with an unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of the LSI, an associated
shoot-through current flows internally, and malfunctions occur due to the false recognition of the pin state as an input signal become possible.
5. Clock signals
After applying a reset, only release the reset line after the operating clock signal becomes stable. When switching the clock signal during program execution, wait
until the target clock signal is stabilized. When the clock signal is generated with an external resonator or from an external oscillator during a reset, ensure that the
reset line is only released after full stabilization of the clock signal. Additionally, when switching to a clock signal produced with an external resonator or by an
external oscillator while program execution is in progress, wait until the target clock signal is stable.
6. Voltage application waveform at input pin
Waveform distortion due to input noise or a reflected wave may cause malfunction. If the input of the CMOS device stays in the area between VIL (Max.) and VIH
(Min.) due to noise, for example, the device may malfunction. Take care to prevent chattering noise from entering the device when the input level is fixed, and also in
the transition period when the input level passes through the area between VIL (Max.) and VIH (Min.).
7. Prohibition of access to reserved addresses
Access to reserved addresses is prohibited. The reserved addresses are provided for possible future expansion of functions. Do not access these addresses as the
correct operation of the LSI is not guaranteed.
8. Differences between products
Before changing from one product to another, for example to a product with a different part number, confirm that the change will not lead to problems. The
characteristics of a microprocessing unit or microcontroller unit products in the same group but having a different part number might differ in terms of internal
memory capacity, layout pattern, and other factors, which can affect the ranges of electrical characteristics, such as characteristic values, operating margins, immunity
to noise, and amount of radiated noise. When changing to a product with a different part number, implement a system-evaluation test for the given product.
© 2019 Renesas Electronics Corporation. All rights reserved.

Notice

1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products
and application examples. You are fully responsible for the incorporation or any other use of the circuits, software, and information in the design of your product or system. Renesas Electronics disclaims any and all liability for any losses and damages incurred by you or third parties arising from the use of these circuits, software, or information.
2. Renesas Electronics hereby expressly disclaims any warranties against and liability for infringement or any other claims involving patents, copyrights, or
other intellectual property rights of third parties, by or arising from the use of Renesas Electronics products or technical information described in this document, including but not limited to, the product data, drawings, charts, programs, algorithms, and application examples.
3. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or
others.
4. You shall not alter, modify, copy, or reverse engineer any Renesas Electronics product, whether in whole or in part. Renesas Electronics disclaims any
and all liability for any losses or damages incurred by you or third parties arising from such alteration, modification, copying or reverse engineering.
5. Renesas Electronics products are classified according to the following two quality grades: “Standard” and “High Quality”. The intended applications for
each Renesas Electronics product depends on the product’s quality grade, as indicated below. "Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home
electronic appliances; machine tools; personal electronic equipment; industrial robots; etc.
"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale communication equipment; key
financial terminal systems; safety control equipment; etc. Unless expressly designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas Electronics document, Renesas Electronics products are not intended or authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems; surgical implantations; etc.), or may cause serious property damage (space system; undersea repeaters; nuclear power control systems; aircraft control systems; key plant systems; military equipment; etc.). Renesas Electronics disclaims any and all liability for any damages or losses incurred by you or any third parties arising from the use of any Renesas Electronics product that is inconsistent with any Renesas Electronics data sheet, user’s manual or other Renesas Electronics document.
6. When using Renesas Electronics products, refer to the latest product information (data sheets, user’s manuals, application notes, “General Notes for Handling and Using Semiconductor Devices” in the reliability handbook, etc.), and ensure that usage conditions are within the ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat dissipation characteristics, installation, etc. Renesas Electronics disclaims any and all liability for any malfunctions, failure or accident arising out of the use of Renesas Electronics products outside of such specified ranges.
7. Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products, semiconductor products have specific characteristics, such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Unless designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas Electronics document, Renesas Electronics products are not subject to radiation resistance design. You are responsible for implementing safety measures to guard against the possibility of bodily injury, injury or damage caused by fire, and/or danger to the public in the event of a failure or malfunction of Renesas Electronics products, such as safety design for hardware and software, including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult and impractical, you are responsible for evaluating the safety of the final products or systems manufactured by you.
8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. You are responsible for carefully and sufficiently investigating applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive, and using Renesas Electronics products in compliance with all these applicable laws and regulations. Renesas Electronics disclaims any and all liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.
9. Renesas Electronics products and technologies shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. You shall comply with any applicable export control laws and regulations promulgated and administered by the governments of any countries asserting jurisdiction over the parties or transactions.
10. It is the responsibility of the buyer or distributor of Renesas Electronics products, or any other party who distributes, disposes of, or otherwise sells or transfers the product to a third party, to notify such third party in advance of the contents and conditions set forth in this document.
11. This document shall not be reprinted, reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products.
(Note1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its directly or indirectly controlled
subsidiaries.
(Note2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.
(Rev.4.0-1 November 2017)
Corporate Headquarters
Contact information
TOYOSU FORESIA, 3-2-24 Toyosu, Koto-ku, Tokyo 135-0061, Japan
www.renesas.com
For further information on a product, technology, the most up-to-date version of a document, or your nearest sales office, please visit:
www.renesas.com/contact/.
Trademarks
Renesas and the Renesas logo are trademarks of Renesas Electronics Corporation. All trademarks and registered trademarks are the property of their respective owners.
Loading...