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
Loading...
+ 27 hidden pages