Sensorless Speed control of 120-degree conducting controlled permanent
magnetic synchronous motor (Implementation)
Summary
This application note aims at explains sample programs driving a permanent magnetic synchronous motor in the 120-
degree conducting method using the RL78/G1G microcontroller.
These control programs are 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 control programs have been checked by using the following device.
RL78/G1G (R5F11EBAAFP)
Target control programs
The target control programs of this application note are as follows.
RL78G1G_MRSSK_SPM_LESS_120_CSP_CA_V100 (IDE:CS+ for CA,CX)
RL78G1G_MRSSK_SPM_LESS_120_CSP_CC_V100 (IDE:CS+ for CC)
RL78G1G_MRSSK_SPM_LESS_120_E2S_CC_V100 (IDE:e2studio)
RL78/G1G Sensorless 120-degree conducting control program for
24V Motor Control Evaluation System and RL78/G1G CPU CARD
Reference
RL78/G1G Group User’s Manual: Hardware (R01UH0499EJ0130)
Application note: ‘120-degree conducting control of permanent magnetic synchronous motor: algorithm’
(R01AN2657EJ0120)
Renesas Solution Starter Kit 24V Motor Control Evaluation System for RX23T User’s Manual
(R20UT3697EJ0100)
R01AN3582EJ0100 Rev.1.00 Page 1 of 46
Jan 13, 2017
Page 2
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
2. System overview ............................................................................................................................... 7
3. Descriptions of the control program ................................................................................................ 14
R01AN3582EJ0100 Rev.1.00 Page 2 of 46
Jan 13, 2017
Page 3
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Microcontroller
Evaluation board
Motor
RL78/G1G
(R5F11EBAAFP)
24V inverter board
(Note 1)
and RL78/G1G CPU Card
(Note 2)
TSUKASA
(Note 3)
TG-55L-KA-24V
CS+ version
Tool chain version
V3.03.00
CA78K0R V5.00.00.03
V4.01.00
CC-RL V1.03.00.00
e2studio version
Tool chain version
5.2.1.016
CC-RL V1.03.00.00
1. Overview
This application note explains how to implement the 120-degree conducting control programs of permanent magnetic
synchronous motor (PMSM) using the RL78/G1G microcontroller. Note that this control programs use the algorithm
described in the application note ‘120-degree conducting control of permanent magnetic synchronous motor: algorithm’.
1.1 Development environment
Table 1-1 and Table 1-2 show development environment of the control programs explained in this application note.
Table 1-1 Development Environment (H/W)
Table 1-2 Development Environment (S/W)
For purchase and technical support contact, Sales representatives and dealers of Renesas Electronics Corporation.
Notes: 1. 24V inverter board (RTK0EM0006S01212BJ) is a product of Renesas Electronics Corporation.
2. RL78/G1G CPU Card (T5104) is a product of Desk Top Laboratories Inc.
Desk Top Laboratories Inc. (http://desktoplab.co.jp/)
3. TG-55L-KA-24V is a product of TSUKASA ELECTRIC.
TSUKASA ELECTRIC. (https://www.tsukasa-d.co.jp/en/)
R01AN3582EJ0100 Rev.1.00 Page 3 of 46
Jan 13, 2017
Page 4
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
R8 (1) Remove
100/0.1W
(2) Connnect
R7
R15 (1) Remove
100/0.1W0/1A
(1) Remove
C9
C8
100pF /50V/J
100pF /50V/J
2930CNB5 (IU)
CNB15 (VR1)
(2) Connect
(1) Remove
1.2 Modifying the Evaluation Board
To support the control programs in this application note, the 24V Inverter Board and RL78/G1G CPU Card should be
modified per below explanations.
1.2.1 Modification of the VR1 input port
(1) Remove R8, R15, C9.
(2) Connect CPU side of R7 and CPU side of R8.
Figure 1-1 Modification of the CPU Card
R01AN3582EJ0100 Rev.1.00 Page 4 of 46
Jan 13, 2017
Figure 1-2 Modification example on the CPU card.
Page 5
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
TH1
Q2
TH2
Q4
TH3
Q6
R50
R72
R97
(2) Remove
(1) Connect
(1) Connect
(2) Remove
1.2.2 Modification when overcurrent detection method is changed
When the overcurrent detection method is changed to "PGA+CMP0, CMP1" from default (INTP0), the 24V Inverter
Board and RL78/G1G CPU Card should be modified per below explanations.
(1) Modification of the 24V Inverter Board
Change 3-Shunt to 1-Shunt.
(1) Connect TH1, TH2 and TH3.
(2) Remove R72 and R97.
Figure 1-3 Change 3-shunt to 1-shunt
R01AN3582EJ0100 Rev.1.00 Page 5 of 46
Jan 13, 2017
Figure 1-4 Modification example on the 24V Inverter Board
Page 6
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
R8
100/0.1W
R7
R15
100/0.1W0/1A
R10 (2) ChangeR16
100/0.1W
NC → 0/1A
→ 1k/0.1W(1) Mount
C9
C8C11
(3) Change
100pF/50V/J
→ 470pF/50V/J
2930CNB5 (IU)
CNB15 (VR1)
CNB7 (IW)
100pF/50V/J
100pF /50V/J
(3) Change
(1) Mount
(2) Change
(2) Modification of the RL78/G1G CPU Card
Modification for the filter circuit of comparator input
(1) Mount 0 Ohms on R16.
(2) Change resister R10 from 100 Ohms to 1k Ohms
(3) Change capacitor C11 from 100pF to 470pF.
Figure 1-5 Modification of the CPU Card
Figure 1-6 Modification example on the CPU card.
R01AN3582EJ0100 Rev.1.00 Page 6 of 46
Jan 13, 2017
Page 7
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
not used in this system.
LED output
P60
P61
V
dc
VR1
GND
LED1
LED2
Inverter circuit
DC 24V input
Up
Vp
Wp
Un
Vn
Wn
TRD output
P15 / TRDIOB0 (Up)
P13 / TRDIOA1 (Vp)
P12 / TRDIOB1 (Wp)
P14 / TRDIOD0 (Un)
P11 / TRDIOC1 (Vn)
P10 / TRDIOD1 (Wn)
Vu
Vv
Vw
Over current
detection input
P01 / PGAI
HV port
HW port
GND port
Vcc port
HU port
ENC_Z port
ENC_B
port
ENC_A
port
GND port
Vcc port
U port
V port
W port
PSPM
A/D converter input
P23 / ANI3
P00 / ANI17
P147 / ANI18
P120 / ANI19
P20 / ANI0
Bus voltage
VU_AIN
VV_AIN
Speed reference
(Note)
Phase voltage
(filtering)
VW_AIN
SW1
SW2
Switch input
P70
P17
Motor start / stop
Error status reset
Phase voltage
(filtering)
VU_AIN
VV_AIN
VW_AIN
RL78/G1G
P137 / INTP0
OC
Over current detection
(by Hardware)
Over current detection
(by PGA+CMP0, CMP1)
Iu
Iv
Iw
Power supply circuit
2. System overview
Overview of this system is explained below.
2.1 Hardware configuration
The hardware configuration is shown below.
Figure 2-1 Hardware Configuration Diagram
Note: the VR1 signal is input to port 20 by modification on the CPU card. (See 1.2.1)
R01AN3582EJ0100 Rev.1.00 Page 7 of 46
Jan 13, 2017
Page 8
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Item
Interface component
Function
Rotational speed
Variable resistance (VR1)
Rotational speed command value input (analog values)
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
RESET
Push switch (RESET1)
System reset
R5F11EBAAFP Port name
Function
P23 / ANI3
Inverter bus voltage measurement
P01 / PGAI
Shunt current input for over-current detection (use PGA+CMP0, CMP1)
(Note1)
P20 / ANI0
For inputting rotational speed command values (analog values)
(Note2)
P70
START / STOP toggle switch
P17
ERROR RESET toggle switch
P60
LED1 ON / OFF control
P61
LED2 ON / OFF control
P00 / ANI17
U Phase voltage measurement (A/D)
P147 / ANI18
V Phase voltage measurement (A/D)
P120 / ANI19
W Phase voltage measurement (A/D)
P10 / TRDIOD1
PORT output / PWM output (Wn)
P11 / TRDIOC1
PORT output / PWM output (Vn)
P12 / TRDIOB1
PORT output / PWM output (Wp)
P13 / TRDIOA1
PORT output / PWM output (Vp)
P14 / TRDIOD0
PORT output / PWM output (Un)
P15 / TRDIOB0
PORT output / PWM output (Up)
P137 / INTP0
PWM emergency stop input at the time of overcurrent detection (use an
external circuit)
(Note1)
2.2 Hardware specifications
2.2.1 User interface
Table 2-1 is a list of user interfaces of this system.
Table 2-1 User Interface
Table 2-2 is a list of port interfaces of RL78/G1G microcontroller of this system.
Table 2-2 Port Interface
Note: 1. Selection of the external circuit or “PGA+CMP1, CMP0” for the detection of overcurrent is set by
compile option.
2. For details on input port, see "1.2 Modifying the Evaluation Board".
R01AN3582EJ0100 Rev.1.00 Page 8 of 46
Jan 13, 2017
Page 9
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Peripheral Function
Purpose
10bit A/D converter
- Rotational speed command value input
- Inverter bus voltage measurement
- Voltage of each phase U, V, and W measurement
Timer Array Unit (TAU)
- 1 [ms] interval timer
- Free-running timer for rotational speed measurement
Timer RD (TRD)
Complementary PWM output
Comparator0 (CMP0)
Overcurrent detection
(Note)
Comparator1 (CMP1)
Overcurrent detection
(Note)
Programmable Gain Amp (PGA)
Overcurrent detection
(Note)
External Interrupt (INTP0)
Overcurrent detection
(Note)
2.2.2 Peripheral functions
Table 2-3 is a list of peripheral functions used in this system.
Table 2-3 List of Peripheral Functions
Note: INTP0 and “PGA+CMP0, CMP1” are used exclusive. (These are selectable by compile option.)
(1) 10-bit A/D converter
The rotational speed command value input, U phase voltage (Vu), V phase voltage (Vv), W phase voltage (Vw),
and inverter bus voltage (Vdc) are measured by using the ‘10-bit A/D converter’.
The operation mode is set as below.
The channel selection mode: the select-mode.
The conversion operation mode: the one-shot conversion mode.
And software trigger is used.
(2) Timer Array Unit (TAU)
a. 1 [ms] interval timer
The channel 0 of Timer Array Unit (TAU) is used as 1 millisecond interval timer.
b. Free-running timer for measuring speed
The channel 1 of Timer Array Unit (TAU) is used as free-running timer for speed measurement.
Note that interrupt is not used.
(3) Timer RD (TRD)
Three-phase PWM output of chopping at the first 60 degrees with dead time (complementary) or without dead time
(non-complementary) is performed using the Complementary PWM Mode. When detecting an overcurrent, the PWM
output ports are set to high impedance output using the pulse output forced cutoff function.
(4) Comparator0 (CMP0)
CMP0 is used to detect overcurrent with PGA (detect falling edge) (when selected).
(5) Comparator1 (CMP1)
CMP1 is used to detect overcurrent with PGA (detect rising edge) (when selected).
R01AN3582EJ0100 Rev.1.00 Page 9 of 46
Jan 13, 2017
Page 10
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
(6) Programmable Gain Amp (PGA)
PGA is used to detect overcurrent with CMP0, CMP1 (when selected).
(7) External interrupt (INTP0)
An overcurrent is detected by an external circuit. (when selected).
R01AN3582EJ0100 Rev.1.00 Page 10 of 46
Jan 13, 2017
Page 11
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Project
Folder
File
Content
RL78G1G_MRSSK_
SPM_LESS_120_C
SP_CA_V100
RL78G1G_MRSSK_
SPM_LESS_120_C
SP_CC_V100
RL78G1G_MRSSK_
SPM_LESS_120_E
2S_CC_V100
inc
main.h
Main function, user interface control header
mtr_common.h
Common definition header
mtr_ctrl_mrssk.h
Board dependent processing part header
mtr_ctrl_rl78g1g.h
RL78/G1G dependent processing part header
mtr_spm_less_120.h
Sensorless 120-degree conducting control dependent part header
control_parameter.h
Control characteristic dependent processing part header
motor_parameter.h
Motor characteristic dependent processing part header
mtr_ctrl_rl78g1g_mrssk.h
RL78/G1G and board dependent processing part header
mtr_feedback.h
Feedback control processing part header
mtr_gmc.h
General motor control function part header
mtr_driver_access.h
Driver access function on part header
mtr_filter.h
Filters processing part header (not used)
lib
R_dsp_rl78_CA.lib
Digital signal controller library for CA tool-chain
(Note)
R_dsp_rl78_CC.lib
Digital signal controller library for CC-RL tool-chain
(Note)
src
main.c
Main function, user interface control
mtr_ctrl_mrssk.c
Board dependent processing part
mtr_ctrl_rl78g1g.c
RL78/G1G dependent processing part
mtr_interrupt.c
Interrupt handler
mtr_spm_less_120.c
Sensorless 120-degree conducting control dependent part
mtr_ctrl_rl78g1g_mrssk.c
RL78/G1G and board dependent processing part
mtr_feedback.c
Feedback control processing
mtr_gmc.c
General motor control function
mtr_driver_access.c
Driver access function
mtr_filter.c
Filters processing (not used)
2.3 Software structure
2.3.1 Software file structure
The folder and file configurations of the control programs are given below.
Table 2-4 Folder and File Configuration
Notes: R_dsp_rl78_CA.lib is included only in RL78G1G_MRSSK_SPM_LESS_120_CSP_CA_V100.
R_dsp_rl78_CC.lib is included in RL78G1G_MRSSK_SPM_LESS_120_CSP_CC_V100 and
RL78G1G_MRSSK_SPM_LESS_120_E2S_CC_V100.
R01AN3582EJ0100 Rev.1.00 Page 11 of 46
Jan 13, 2017
Page 12
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Figure 2-2 and Table 2-5 show module configuration of the control programs.
Figure 2-2 Module Configuration
Table 2-5 Module Configuration
Note: “mtr_interrupt.c” is belong to the motor control layer and H/W control layer.
R01AN3582EJ0100 Rev.1.00 Page 12 of 46
Jan 13, 2017
Page 13
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Item
Content
Control method
120-degree conducting method (chopping at the first 60 degrees)
(Complementary / Non-Complementary)
Motor rotation start / stop
Determined depending on the level of SW1 (P70)
(”Low”: rotation start “High”: stop)
Position detection of rotor
magnetic pole
Position detection by induced voltage with A/D converters. (by 60 degrees)
Input voltage
DC24[V]
Main clock frequency
CPU clock: f
CLK
24[MHz]
TRD clock: f
HOCO
48[MHz]
Carrier frequency (PWM)
20 [kHz]
Dead time
2 [μs]
Control cycle
Speed PI control: every 1 [ms]
Rotational speed control
range
1200 [rpm] to 2650 [rpm]
Both CW and CCW are supported
Optimization
Default
Processing stop for
protection
- Disables the motor control signal output (six outputs), under any of the
following conditions.
1. Inverter bus voltage exceeds 28 V (monitored per 1 [ms])
2. Inverter bus voltage is less than 15 V (monitored per 1 [ms])
3. Rotational speed exceeds 3500 rpm (monitored per 1 [ms])
4. At the time of sensorless drive, zero-crossing is not detected for 50 [ms].
5. Fault detection of virtual Hall sensor pattern (position information)
- The ports executing PWM output are set to high impedance state when an
overcurrent is detected by external circuit (low level edge input occurs in
INTP0 port) or by internal PGA+CMP0, CMP1.
2.4 Software specifications
Table 2-6 shows the basic software specification of this system. For details of 120-degree conducting control, refer to
the application note ‘120-degree conducting control of permanent magnetic synchronous motor: algorithm’.
Table 2-6 Basic Specifications of Software
R01AN3582EJ0100 Rev.1.00 Page 13 of 46
Jan 13, 2017
Page 14
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Item
Conversion ratio
(Command value: A/D conversion value)
Channel
Rotational speed
command value
CW
0 rpm to 3072 rpm: 0200H to 03FFH
ANI0
(Note)
CCW
-3072 rpm to 0 rpm: 0000H to 01FFH
Item
Conversion ratio
(Inverter bus voltage: A/D conversion value)
Channel
Inverter bus voltage
0 V to 111 V: 0000H to 03FFH
ANI3
Item
Conversion ratio
(U, V, and W phase voltage: A/D conversion value)
Channel
U, V, W phase voltage
0 V to 111 V: 0000H to 03FFH
ANI17, ANI18, ANI19
3. Descriptions of the control program
The target control programs of this application note are explained here.
3.1 Contents of control
3.1.1 Motor start/stop
Starting and stopping of the motor are controlled by input from SW1 & VR1.
A general-purpose port is assigned to SW1. The port is read within the main loop. When the port is at a “Low” level,
it is determined that the start switch is being pressed. Conversely, when the level is switched to “High”, the program
determines that the motor should be stopped.
Also, an analog input port is assigned to VR1. The input is A/D converted within the main loop to generate a
rotational speed command value. When the command value is less than 1200 [rpm], the program determines that the
motor should be stopped.
3.1.2 A/D Converter
(1) Motor rotational speed command value
The motor rotational speed command value can be set by A/D conversion of the VR1 output value (analog value).
The A/D converted VR1 value is used as rotational speed command value, as shown below.
The maximum of the command value is set as the value from which maximum rotational speed is generated by the
resolution of the A/D converter.
Table 3-1 Conversion Ratio of the Rotational Speed Command Value
Note: The input channel is ANI0 because the CPU card which is modified as a VR1 signal is input to port 20.
(2) Inverter bus voltage
Inverter bus voltage is measured as given in Table 3-2. It is used for modulation factor calculation and over/under
voltage detection. (When an abnormality is detected, PWM is stopped).
Table 3-2 Inverter Bus Voltage Conversion Ratio
(3) U phase, V phase, and W phase voltage
The U, V, and W phase voltages are measured as shown in Table 3-3 and used for determining zero-crossing.
Table 3-3 Conversion Ratio of U, V, and W Phase Voltage
For more details of A/D conversion characteristics, refer to RL78/G1G User’s Manual: Hardware.
R01AN3582EJ0100 Rev.1.00 Page 14 of 46
Jan 13, 2017
Page 15
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Pattern created from
U phase induced voltage
2p
Timer counter
CheckCheckCheckCheckCheckCheckCheck
Counter value difference
Motor rotational speed [rad/s] = (2π × frequency of timer) / (difference of timer counts)
Pattern created from
V phase induced voltage
Pattern created from
W phase induced voltage
2p
2p
: Voltage command value : Speed command value : Rotational speed
: Speed PI proportional gain : Speed PI integral gain : Laplace operator
3.1.3 Speed control
In this system, the motor rotational speed is calculated from a difference of the current timer value and the timer value
2π [rad] before. The timer values are obtained when patterns are switched after zero-crossing detection, while having
the timer of Timer Array Unit (TAU) channel 1 performed free running.
Figure 3-1 Method of Calculation for Rotational Speed
The control program uses PI control for speed control. A voltage command value is calculated by the following
formula of speed PI control.
For more details of PI control, please refer to specialized books.
R01AN3582EJ0100 Rev.1.00 Page 15 of 46
Jan 13, 2017
Page 16
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Average
voltage
t
V
T
ON
T
OFF
T
ON
+ T
OFF
T
ON
Duty =× 100 [%]
E
V
m
U+
V+
W+
UV-
W-
m: Modulation factor V: Command value voltage E: Inverter bus voltage
3.1.4 Voltage control by PWM
PWM control is used for controlling output voltage. The PWM control is a control method that continuously adjusts
the average voltage by varying the duty of pulse, as shown in Figure 3-2.
Figure 3-2 PWM Control
Modulation factor m is defined as follows.
This modulation factor is reflected in the setting value of the register that determines the PWM duty.
In the target control program, first-60-degree chopping is used to control the output voltage and speed. Figure 3-3 shows
an example of motor control signal output waveforms at Non-complimentary first-60-degree chopping. Figure 3-4 shows an
example of motor control signal output waveforms at Complimentary first-60-degree chopping.
R01AN3582EJ0100 Rev.1.00 Page 16 of 46
Jan 13, 2017
Page 17
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
U+
V+
W+
U-
V-
W-
Figure 3-4 Complimentary first-60-degree Chopping
R01AN3582EJ0100 Rev.1.00 Page 17 of 46
Jan 13, 2017
Page 18
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
SYSTEM MODE
INACTIVE
ERROR
POWER ON/
RESET
[RESET EVENT]
[ACTIVE EVENT]
[INACTIVE EVENT]
[ERROR EVENT]
RUN MODE
INIT
BOOT
Configuration
Control
Cu r re nt
Sp e e d
Po s iti o n
To r q ue
Vol t age
Method
FO C
18 0
WI D E
12 0
Sensor
Le s s
Hall
En c o de r
Re s o lve r
Configuration
Control
Cu r re nt
Sp e e d
Po s iti o n
To r q ue
Vol t age
Method
Sensor
Le s s
Hall
En c o de r
Re s olve r
DRIVE
ACTIVE
[MTR_DRAW_IN_FINISH ==
g_u1_state_draw_in]
[MTR_VOFF_SET_STATUS_FINISH ==
g_u1_state_v_offset]
[ERROR EVENT]
[RESET EVENT]
FO C
18 0
WI D E
12 0
INACTIVE
ACTIVE
ERROR
RESET
SYSTEM MODE
INACTIVEACTIVEERROR
INACTIVE
INACTIVEINACTIVE
ACTIVE
ERRORERROR
ERROR
ERROR
ERROR
INACTIVE
ACTIVE
ERROR
[MTR_V_PI_OUTPUT
== g_u2_state_voltage_ref]
EVENT
EVENT name
Occurrence factor
INACTIVE
by user operation
ACTIVE
by user operation
ERROR
when the system detects an error
RESET
by user operation
3.1.5 State transition
Figure 3-5shows state transition diagrams of sensorless 120-degree conducting control software.
Figure 3-5 State Transition Diagram of Sensorless 120-degree Conducting Control 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 table in Figure 3-5, per
that “EVENT”.
Table 3-4 List of EVENT
R01AN3582EJ0100 Rev.1.00 Page 18 of 46
Jan 13, 2017
Page 19
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
MTR_V_OPENLOOP
(3)
Voltage
[V]
RUN MODE
0
0
Voltage reference status
Speed reference status
MTR_SPEED_OPENLOOP_1
(1)
Speed
[rad/s]
MTR_MODE_DRIVE
MTR_OL_MODE1_CHANGE_RPM
MTR_SPEEDOPEN_LOOP_2
(2)
MTR_SPEED_OPENLOOP3
(3)
MTR_SPEED_CHANGE
(4)
MTR_V_PI_OUTPUT
(4)
MTR_OL_START_REFV
MTR_OL_MODE2_CHANGE_RPM
g_u2_ref_speed_rad
OpenloopSpeed PI control
MTR_OL_MODE3_MAX_REFV
MTR_BOOT_REF_V
MTR_V_UP
(1)
MTR_V_UP
(1)
MTR_V_CONST
(2)
MTR_V_CONST
(2)
MTR_V_ZERO_CONST
(0)
MTR_SPEED_ZERO_CONST
(0)
MTR_MODE_BOOTMTR_MODE_INIT
3.1.6 Start-up method
In Sensorless 120-degree conducting control, the position of the magnetic poles (the rotor) is estimated every 60
degrees per the induced voltage which is generated the change of magnetic flux due to the rotation of the permanent
magnet (rotor). However, the induced voltage is not generated when the rotor doesn’t move. Therefore, it is impossible
to estimate the position of the rotor at start-up, and enough rotational speed is necessary to estimate the position of the
rotor (because the induced voltage cannot be caught without enough speed).
Therefore, as a start-up method, there is a method to lead the synchronous speed by generating a rotating magnetic
field by forcibly switching conduction patterns regardless of position of the permanent magnet.
Figure 3-6 shows the start-up method in the control program. In “MTR_MODE_BOOT”, the rotor is drawn in and the
overcurrent at start-up is prevented.
Figure 3-6 Start-up Method (Example)
R01AN3582EJ0100 Rev.1.00 Page 19 of 46
Jan 13, 2017
Page 20
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Threshold value
Comparator internal
reference setting
Channel
PGA Gain
CMP1: 2 [A]
CMP1: 120
PGA out
× 4 is selected
CMP0: -2 [A]
CMP0: 83
3.1.7 System protection function
This system has the following types of error status and enables emergency stop functions in case of occurrence of
respective error. Refer to Table 3-5, Table 3-6 for settings.
- Overcurrent error
The overcurrent is detected with the method using the external circuit or the method using the internal PGA+CMP0,
CMP1. Using method is selectable by a compile option.
a. External hardware
High impedance output is made to the PWM output port in response to an emergency stop signal (overcurrent
detection) from the hardware.
b. Internal PGA+CMP0, CMP1
High impedance output is made to the PWM output port in response to an emergency stop signal (overcurrent
detection) from the internal PGA+CMP0, CMP1 detection.
The setting of PGA+CMP0, CMP1 are given below.
Table 3-5 Setting for overcurrent detection
- Overvoltage error
The inverter bus voltage is monitored at the overvoltage monitoring cycle. When an over voltage is detected (when
the voltage exceeds the limit), CPU performs an emergency stop. The threshold value of the overvoltage is set in
consideration of the error of resistance value of the detection circuit.
- Low voltage error
The inverter bus voltage is monitored at the under voltage monitoring cycle. When an under voltage is detected
(when the voltage lowers the limit), CPU performs an emergency stop. The threshold value of the low voltage is set in
consideration of the error of resistance value of the detection circuit.
- Rotational speed error
The rotational speed is monitored at the rotational speed monitoring cycle. When the speed exceeds the limit, CPU
performs an emergency stop.
- Timeout error of zero-cross detection
When no pattern switching is happened by zero-crossing during timeout period, CPU performs an emergency stop.
- Virtual Hall sensor pattern (position information) error
When an error is detected in virtual Hall sensor patterns (position information) generated from each of U, V, and W
phase voltage, CPU performs an emergency stop.
R01AN3582EJ0100 Rev.1.00 Page 20 of 46
Jan 13, 2017
Page 21
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Error name
Threshold
Overcurrent error
(Note)
Overcurrent limit [A]
±2.0
Overvoltage error
Overvoltage limit [V]
28
Monitoring cycle [ms]
1
Low voltage error
Under voltage limit [V]
15
Monitoring cycle [ms]
1
Rotational speed error
Speed limit [rpm]
3500
Monitoring cycle [ms]
1
Timeout error of zero-cross detection
Timeout value [ms]
50
Table 3-6 Setting Value of Each System Protection Function
Note: The threshold when detecting an overcurrent by PGA+CMP0,1.
R01AN3582EJ0100 Rev.1.00 Page 21 of 46
Jan 13, 2017
Page 22
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
File name
Function name
Process overview
main.c
main
Input: None
Output: None
- Hardware initialization function call
- User interface initialization function call
- Initialization function call of the variables used in the
main process
- Waiting for stability of the bus voltage function call
- Status transition and event execution function call
- Main process
User interface call
Watchdog timer clear function call
board_ui
Input: None
Output: None
- Motor status change
- Determination of rotational speed command value
software_init
Input: None
Output: None
Initialization of variables used in the main process
File name
Function name
Process overview
mtr_ctrl_mrssk.c
R_MTR_ChargeCapacitor
Input: None
Output: None
Wait for stability of the bus voltage
get_vr1
Input: None
Output: (uint16) u2_ad_data / A/D conversion result
Output: (uint16) u2_temp0 / over speed error flag (when error happens)
Check over speed error
mtr_get_duty
Input: (volatile int16) s2_v_ref / reference voltage
(volatile int16) s2_vdc_ad / bus voltage A/D conversion value
Output: (int16) s2_temp / rate of PWM duty
Calculate PWM duty
mtr_generate_pattern
Input: (uint16) u2_vu_ad / U phase voltage A/D conversion value
(uint16) u2_vv_ad / V phase voltage A/D conversion value
(uint16) u2_vw_ad / W phase voltage A/D conversion value
(uint16) u2_vn_ad / 3 phase average A/D conversion value
Output: (uint8) u1_temp / pseudo Hall sensor pattern
Generate pseudo Hall
sensor pattern
mtr_check_timeout_error
Input: (uint16) u2_cnt_timeout / counter of timeout
(uint16) u2_timeout_limit / timeout limit
Output: (uint16) u2_temp0 / flag of timeout error (when error happens)
Check timeout error
Table 3-13 List of Functions “mtr_gmc.c”
R01AN3582EJ0100 Rev.1.00 Page 25 of 46
Jan 13, 2017
Page 26
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
File name
Function name
Process overview
mtr_interrupt.c
mtr_oc_intp0_interrupt
Input: None
Output: None
Overcurrent detection process (Hardware detection)
- Disable INTP0 interrupt servicing
- Event processing selection function call (Generate error event)
- Changing the motor status (Set the flag of error about overcurrent)
mtr_oc_cmp0_interrupt
Input: None
Output: None
Overcurrent detection process (CMP0 interrupt)
- Disable CMP0, CMP1 interrupt servicing
- Event processing selection function call (Generate error event)
- Changing the motor status (Set the flag of error about overcurrent)
mtr_oc_cmp1_interrupt
Input: None
Output: None
Overcurrent detection process (CMP1 interrupt)
- Disable CMP0, CMP1 interrupt servicing
- Event processing selection function call (Generate error event)
- Changing the motor status (Set the flag of error about overcurrent)
mtr_carrier_interrupt
Input: None
Output: None
Calling every 50 [μs]
- Measure invertor bus voltage
- Measure voltage of each phase and cancel offset
- Calculate pseudo center voltage
- Detect zero-cross
- Calculate the rotational speed
- Set delay to change pattern
- Change pattern per pseudo Hall pattern call
- Drive process for open loop call
- Clearing compare match flag A function call
mtr_1ms_interrupt
Input: None
Output: None
Calling every 1 [ms]
- Run mode management
Setting speed reference
Setting voltage reference
Setting PWM duty
- Error check function call
- Motor stop detection function call
Table 3-14 List of Functions “mtr_interrupt.c”
R01AN3582EJ0100 Rev.1.00 Page 26 of 46
Jan 13, 2017
Page 27
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Set voltage pattern complementary first 60 degree
PWM
Table 3-16 List of Functions “mtr_spm_less_120.c” [2/2]
R01AN3582EJ0100 Rev.1.00 Page 28 of 46
Jan 13, 2017
Page 29
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Variable name
Type
Scale
Content
Remarks
g_u2_max_speed_rpm
uint16
-
Rotational speed command
maximum value
Mechanical angle [rpm]
g_u2_min_speed_rpm
uint16
-
Rotational speed command
minimum value
Mechanical angle [rpm]
g_u2_margin_min_speed_rpm
uint16
-
Rotational speed command
minimum value for motor stop
Mechanical angle [rpm]
g_u2_ref_speed_rpm
uint16
-
User setting rotational speed
Mechanical angle [rpm]
g_u1_rot_dir
uint8 - User setting rotation direction
0: CW
1: CCW
g_u1_motor_status
uint8 - User motor status management
0: Stop
1: Rotating
2: Error
g_u1_reset_req
uint8 - Reset request flag
0: Turning SW2 ON in error status
1: Turning SW2 OFF in error status
g_u1_sw1_cnt
uint8 - SW1 determination counter
Chattering removal
g_u1_sw2_cnt
uint8 - SW2 determination counter
Chattering removal
g_u1_stop_req
uint8 - VR1 stop command flag
g_s2_v_ref
int16
Q7
Voltage command value
Speed PI control output value [V]
g_s2_vdc_ad
int16
Q7
Inverter bus voltage A/D value
[V]
g_u2_pwm_duty
uint16
-
PWM duty
g_u2_ref_speed_rad
uint16
Q3
Speed reference (user selected)
value
Electrical angle [rad/s]
g_u2_speed_rad
uint16
Q3
Measured rotational speed
Electrical angle [rad/s]
g_s2_speed_lpf_k
int16
Q14
Speed LPF parameter
st_speed
MTR_PI
_CTRL
-
Structure for speed PI control
g_u2_vu_ad
uint16
-
U phase voltage A/D value
g_u2_vv_ad
uint16
-
V phase voltage A/D value
g_u2_vw_ad
uint16
-
W phase voltage A/D value
g_u2_vn_ad
uint16
-
Three-phase voltage average
A/D value
g_u2_cnt_ol_ctrl
uint16
-
Counter for open-loop process
3.3 List of variables of sensorless 120-degree conducting control software
Lists of variables used in this control program are given below. However, note that the local variables are not
mentioned.
In the control programs in this application note use fixed-point calculation. Therefore, some variables are already
established with fixed-point calculation. Bits number in fractional part of fixed-point number is expressed in the Q
format. For example, a "Q3" number has 3 fractional bits. "Qn" number is indicated on "Scale" column in below table.
Table 3-17 List of variables [1/4]
R01AN3582EJ0100 Rev.1.00 Page 29 of 46
Jan 13, 2017
Page 30
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
0x00: None error
0x01: Overcurrent error
0x02: Over voltage error
0x04: Over speed error
0x08: Hall signal time out error
0x10: BEMF time out error
0x20: Hall pattern error
0x40: BEMF pattern error
0x80: Under voltage error
0xFF: Undefined error
g_u1_mode_system
uint8 - State management
0x00: Inactive mode
0x01: Active mode
0x02: Error mode
g_u1_state_v_offset
uint8 - State management of voltage
offset process
0x00: None
0x01: Measure with PWM off
0x02: Measure with PWM on
0x03: Finish measurement
(Reflect offset value)
g_u1_state_draw_in
uint8 - State management of draw-in at
start-up
0x00: None
0x01: Draw-in 1st time
0x02: Draw-in 2nd time
0x03: Finish
g_u2_state_voltage_ref
uint16
-
State management of voltage
setting
0: Voltage zero
1: Increase voltage
2: Voltage constant
3: Open loop
4: PI output
g_u2_state_speed_ref
uint16
-
State management of speed
setting
0: Speed zero
1: Open loop mode1
2: Open loop mode2
3: Open loop mode3
4: Speed controlled
g_u2_sensor_conf
uint16
-
Sensor configuration
0x01: Sensorless
0x02: Hall sensor
0x04: Encoder
0x08: Resolver
g_u2_method_conf
uint16
-
Control method configuration
0x00: FOC (Fields Oriented Control)
0x01: 180 degree control
0x02: Wide angle electricity control
0x03: 120 degree control
Table 3-18 List of variables [2/4]
R01AN3582EJ0100 Rev.1.00 Page 30 of 46
Jan 13, 2017
Page 31
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Variable name
Type
Scale
Content
Remarks
g_u2_ctrl_conf
uint16
-
Control configuration
0x01: Current control
0x02: Speed control
0x04: Position control
0x08: Torque control
0x10: Voltage control
g_u1_cnt_speed_pi
uint8 - Decimation counter for speed PI control
function call
g_u1_flg_wait_stop
uint8 - Flag to wait motor rotation stop
0x00: motor stopped
0x01: waiting motor stop
g_u1_flag_charge_cap
uint8 - Flag of finish capacitor charge
g_u2_ref_speed_rad_ctrl
uint16
Q3
Speed command value
Electrical angle [rad/s]
g_s2_kp_speed
int16
Q16
Speed PI control proportional gain
g_s2_ki_speed
int16
Q22
Speed PI control integral gain
g_s2_lim_v
int16
Q7
Limit of speed PI control
[V]
g_s4_ilim_v
int32
Q26
Limit for integral part of speed PI control
[V]
g_s2_limit_speed_change
int16
Q3
Increase step of speed command
Electrical angle [rad/s]
g_s2_ol_freq
int16 - Frequency of open loop
[Hz]
g_u2_cnt_zerocross
uint16
-
Counter to start speed calculation
g_s2_ol_speed_rpm
int16 - Speed of open loop
Mechanical angle [rpm]
g_u2_cnt_ol_pattern_set
uint16
-
Counter for open loop
g_s2_ol_start_rpm
int16 - Start speed of open loop
Mechanical angle [rpm]
g_s2_ol_mode1_change_rpm
int16 - Change speed of open loop mode1
Mechanical angle [rpm]
g_s2_ol_mode2_change_rpm
int16 - Change speed of open loop mode2
Mechanical angle [rpm]
g_s2_ol_start_refv
int16
Q7
Reference voltage of start open loop
[V]
g_s2_ol_mode1_rate_rpm
int16 - Increase step of speed at open loop mode1
Mechanical angle [rpm]
g_s2_ol_mode2_rate_refv
int16
Q7
Increase step of voltage at open loop mode2
[V]
g_s2_ol_mode2_rate_rpm
int16 - Increase step of speed at open loop mode2
Mechanical angle [rpm]
g_s2_ol_mode3_rate_refv
int16
Q7
Increase step of voltage at open loop mode3
[V]
g_s2_ol_mode3_max_refv
int16
Q7
Maximum voltage of open loop3
[V]
g_s2_ol_start_freq
int16 - Start frequency of open loop
[Hz]
g_s2_ol_mode1_change_freq
int16 - Change frequency of open loop mode1
[Hz]
g_s2_ol_mode2_change_freq
int16 - Change frequency of open loop mode2
[Hz]
g_u2_cnt_draw_in
uint16
-
Counter for draw-in
g_s2_boot_ref_v
int16
Q7
Voltage reference at draw-in
[V]
g_u2_v_up_time
uint16
-
Time to increase voltage step at draw-in
g_s2_v_up_step
int16 - Voltage step at draw-in
g_u2_v_const_period
uint16
-
Period of constant voltage at draw-in
[ms]
g_u1_bemf_signal
uint8 - Pseudo Hall pattern generated
g_u1_pre_bemf_signal
uint8 - Previous Hall pattern generated
g_u1_v_pattern
uint8 - Conduction pattern
g_u1_flag_pattern_change
uint8 - Zero-cross detection flag
g_u2_cnt_timeout
uint16
-
Counter for timeout
g_u1_direction
uint8 - Rotation direction
CW: 0
CCW: 1
g_u2_motor_pp
uint16
-
Motor pole pairs
Table 3-19 List of variables [3/4]
R01AN3582EJ0100 Rev.1.00 Page 31 of 46
Jan 13, 2017
Page 32
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Variable name
Type
Scale
Content
Remarks
g_u2_bemf_timer_cnt
uint16
-
Free run timer count
g_u2_pre_bemf_timer_cnt
uint16
-
Previous free run timer count
g_u2_timer_cnt_sum
uint16
-
Sum of free runt timer count as 2π
g_u2_timer_cnt_buf[6]
uint16
-
Free run timer count buffer for 6 times
g_u1_timer_cnt_num
uint8 - Counter for g_u2_timer_cnt_buf
g_u2_bemf_delay
uint16
-
Delay counts for change pattern from the zerocross detected
g_s2_angle_shift_adjust
int16 - Adjustment value for delay from zero-cross
detected
g_u2_cnt_carrier
uint16
-
Carrier cycle interruption counter
g_u2_pre_cnt_carrier
uint16
-
Previous carrier interruption counter value
g_u1_v_pattern_num
uint8 - Control number for forced conduction pattern at
open loop
g_u1_v_pattern_open[2][7]
uint8 - Array of forced conduction patterns at open loop
g_u2_offset_calc_time
uint16
-
Counts for measurement of voltage offset
g_u2_offset_calc_cnt
uint16
-
Counter for measurement of voltage offset
g_u2_offset_vu
uint16
-
Voltage offset value of U phase at PWM on
g_u2_offset_vv
uint16
-
Voltage offset value of V phase at PWM on
g_u2_offset_vw
uint16
-
Voltage offset value of W phase at PWM on
g_u2_offset_off_vu
uint16
-
Voltage offset value of U phase at PWM off
g_u2_offset_off_vv
uint16
-
Voltage offset value of V phase at PWM off
g_u2_offset_off_vw
uint16
-
Voltage offset value of W phase at PWM off
g_u2_sum_vu_ad
uint16
-
Sum of voltage offset value of U phase
g_u2_sum_vv_ad
uint16
-
Sum of voltage offset value of V phase
g_u2_sum_vw_ad
uint16
-
Sum of voltage offset value of W phase
g_u4_inv_offset_calc
uint32
-
Variable to calculate voltage offset
Inverse of
g_u2_offset_calc_time
Table 3-20 List of variables [4/4]
R01AN3582EJ0100 Rev.1.00 Page 32 of 46
Jan 13, 2017
Page 33
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Structure
Member
Type
Scale
Content
Remarks
MTR_PI_CTRL
s2_err
int16
Q3
Error
s2_kp
int16
Q16
PI control proportional gain
s2_ki
int16
Q22
PI control integral gain
s4_refi
int32
Q7
Integral output value
s4_ilimit
int32
Q26
Integral output limit
3.4 List of sensorless 120-degree conducting control software structure
Lists of structure used in this control program are given below.
Table 3-21 List of structure
R01AN3582EJ0100 Rev.1.00 Page 33 of 46
Jan 13, 2017
Page 34
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
File name
Macro name
Definition value
Remarks
motor_parameter.h
MP_POLE_PAIRS
2
Number of pole pairs
MP_MAGNETIC_FLUX
0.02159f
Flux [Wb] (not used)
MP_RESISTANCE
6.447f
Resistance [Ω] (not used)
MP_D_INDUCTANCE
0.0045f
d-axis Inductance [H] (not used)
MP_Q_INDUCTANCE
0.0045f
q-axis Inductance [H] (not used)
File name
Macro name
Definition value
Remarks
control_parameter.h
CP_OFFSET_CALC_TIME
10000
Counts for measurement of voltage offset
CP_BOOT_REF_V
5.0f * 0x80
Voltage reference at draw-in [V]
CP_V_UP_TIME
250
Time to increase voltage step at draw-in
[ms]
CP_V_CONST_TIME
125
Period of constant voltage at draw-in [ms]
CP_MAX_SPEED_RPM
2650
Maximum of rotational speed command
Mechanical angle [rpm]
CP_MIN_SPEED_RPM
1200
Minimum of rotational speed command
Mechanical angle [rpm]
CP_LIMIT_SPEED_CHANGE
0.30f * 0x08
Step to increase speed reference
Electrical angle [rad/s]
CP_OL_START_RPM
185
Speed of open loop at start-up
Mechanical angle [rpm]
CP_OL_MODE1_CHANGE_RPM
400
Speed to change open loop mode1
Mechanical angle [rpm]
CP_OL_MODE2_CHANGE_RPM
600
Speed to change open loop mode2
Mechanical angle [rpm]
CP_OL_START_REFV
5.0f * 0x80
Voltage reference of open loop at start-up
[V]
CP_OL_MODE1_RATE_RPM
8
Increase step of speed at open loop
mode1 [rpm/control period]
CP_OL_MODE2_RATE_REFV
0.01f * 0x80
Increase step of voltage at open loop
mode2 [V]
CP_OL_MODE2_RATE_RPM
6
Increase step of speed at open loop
mode2 [rpm/control period]
CP_OL_MODE3_RATE_REFV
0.01f * 0x80
Increase step of voltage at open loop
mode3 [V]
CP_OL_MODE3_MAX_REFV
5.00f * 0x80
Maximum voltage of open loop [V]
CP_SPEED_PI_KP
0.0200f * 0xFFFF
Proportional gain
CP_SPEED_PI_KI
0.0006f * 0x400000
Integral gain
CP_SPEED_LPF_K
1.0f * 0x40
Speed LPF parameter
MTR_FIRST60
1
Non-Complementary First 60 degree PWM
(default)
MTR_FIRST60_COMP
0
Complementary First 60 degree PWM
3.5 Macro definitions of sensorless 120-degree conducting control software
Lists of macro definitions used in this control program are given below.
Table 3-22 List of Macro definitions “motor_parameter.h”
Table 3-23 List of Macro definitions “control_parameter.h”
R01AN3582EJ0100 Rev.1.00 Page 34 of 46
Jan 13, 2017
Page 35
File name
Macro name
Definition value
Remarks
main.h
M_CW
0
Rotation direction
M_CCW
1
VOFFSET_MEASURE_CNT
CP_OFFSET_CALC_TIME
Counts for measurement of voltage offset [ms]
BOOT_REF_V
CP_BOOT_REF_V
Voltage reference at draw-in [V]
V_UP_PERIOD
CP_V_UP_TIME
Time to increase voltage step at draw-in [ms]
V_CONST_PERIOD
CP_V_CONST_TIME
Period of constant voltage at draw-in [ms]
MAX_SPEED
CP_MAX_SPEED_RPM
Maximum of rotational speed command
Mechanical angle [rpm]
MIN_SPEED
CP_MIN_SPEED_RPM
Minimum of rotational speed command
Mechanical angle [rpm]
MARGIN_SPEED
50.0f
Rotational speed command minimum value
creation constants for stop
Mechanical angle [rpm]
MARGIN_MIN_SPEED
MIN_SPEED - MARGIN_SPEED
Minimum of rotational speed to control motor stop
Mechanical angle [rpm]
OL_START_RPM
CP_OL_START_RPM
Speed of open loop at start-up
Mechanical angle [rpm]
OL_MODE1_CHANGE_RPM
CP_OL_MODE1_CHANGE_RPM
Speed to change open loop mode1
Mechanical angle [rpm]
OL_MODE2_CHANGE_RPM
CP_OL_MODE2_CHANGE_RPM
Speed to change open loop mode2
Mechanical angle [rpm]
OL_START_REFV
(int16) CP_OL_START_REFV
Voltage reference of open loop at start-up [V]
OL_MODE1_RATE_RPM
CP_OL_MODE1_RATE_RPM
Increase step of speed at open loop mode1
[rpm/control period]
OL_MODE2_RATE_REFV
(int16)
CP_OL_MODE2_RATE_REFV
Increase step of voltage at open loop mode2 [V]
OL_MODE2_RATE_RPM
CP_OL_MODE2_RATE_RPM
Increase step of speed at open loop mode2
[rpm/control period]
OL_MODE3_RATE_REFV
(int16)
CP_OL_MODE3_RATE_REFV
Increase step of voltage at open loop mode3 [V]
OL_MODE3_MAX_REFV
(int16)
CP_OL_MODE3_MAX_REFV
Maximum voltage of open loop [V]
LIMIT_SPEED_CHANGE
(int16)
CP_LIMIT_SPEED_CHANGE
Step to increase speed reference
Electrical angle [rad/s]
SPEED_PI_KP
(int16) CP_SPEED_PI_KP
Speed proportional gain
SPEED_PI_KI
(int16) CP_SPEED_PI_KI
Speed Integral gain
SPEED_LPF_K
(int16) CP_SPEED_LPF_K
Speed LPF parameter
SW_ON
0
Active in case of “Low”
SW_OFF
1
CHATTERING_CNT
10
Counts to remove chattering
VR1_SCALING
(MAX_SPEED + 422) / 0x200
Speed command value creation constant
ADJUST_OFFSET
0x1FF
Speed command value offset adjustment constant
POLE_PAIR
MP_POLE_PAIRS
Pole pairs
REQ_CLR
0
Clear VR1 stop command flag
REQ_SET
1
Set VR1 stop command flag
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Table 3-24 List of Macro definitions “main.h”
R01AN3582EJ0100 Rev.1.00 Page 35 of 46
Jan 13, 2017
Page 36
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
File name
Macro name
Definition value
Remarks
mtr_ctrl_rl78g1g.h
MTR_OC_USE_INTP
1
Select the external circuit to detect overcurrent
(default)
MTR_OC_USE_PGACMP
0
Select PGA+CMP0, CMP1 to detect overcurrent
MTR_OC_DETECT_CMP0
83
Comparator internal reference voltage to detect
overcurrent (CMP0)
MTR_OC_DETECT_CMP1
120
Comparator internal reference voltage to detect
overcurrent (CMP1)
R01AN3582EJ0100 Rev.1.00 Page 43 of 46
Jan 13, 2017
Page 44
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
[DRIVE MODE]
[BOOT MODE]
Calculatespeed reference
Calculate voltage reference
Set PWM duty
Set conduction pattern
to draw-in the rotor
Finish draw-in?
Go to DRIVE MODE
Go to BOOT MODE
Finish offset
process?
Calculate voltage reference
Calculate speed reference
Mode of voltage
reference
Set PWM duty
[INIT MODE]
1 ms interrupt
SYSTEM MODE
RUM MODE
Error check
Wait motor stop
End
[INACTIVE]
[ACTIVE]
[NO]
[OPEN LOOP]
[YES]
[PI control]
[Yet]
[Finished]
3.6.3 1 [ms] interrupt handling
Figure 3-9 1 [ms] Interrupt Handling
R01AN3582EJ0100 Rev.1.00 Page 44 of 46
Jan 13, 2017
Page 45
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
Overcurrent detectioninterrupt
(Hardware)
End
Generate error event
Disable INTP0 interrupt servicing
Set the flag of error about overcurrent
Overcurrent detection interrupt
( internal PGA+CMP0, CMP1)
End
Generate error event
Disable CMP0, 1 interrupt servicing
Set the flag of error about overcurrent
3.6.4 Overcurrent interrupt handling
Figure 3-10 Overcurrent detection process (Hardware detection)
Figure 3-11 Overcurrent detection process (PGA+CMP0, 1 interrupt)
R01AN3582EJ0100 Rev.1.00 Page 45 of 46
Jan 13, 2017
Page 46
RL78/G1G Sensorless Speed control of 120-degree conducting controlled permanent magnetic synchronous motor (Implementation)
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.
R01AN3582EJ0100 Rev.1.00 Page 46 of 46
Jan 13, 2017
Page 47
Rev.
Date
Description
Page
Summary
1.00
Jan.13.2017
-
First edition issued
Revision History
Page 48
1. 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
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. Unused pins should be
handled as described under Handling of Unused Pins in the manual.
2. Processing at Power-on
The state of the product is undefined at the moment 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 moment 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 moment 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 moment when power is supplied until the power reaches
the level at which resetting has been specified.
3. Prohibition of Access to Reserved Addresses
Access to reserved addresses is prohibited.
The reserved addresses are provided for the possible future expansion of functions. Do not
access these addresses; the correct operation of LSI is not guaranteed if they are accessed.
4. Clock Signals
After applying a reset, only release the reset line after the operating clock signal has become
stable. When switching the clock signal during program execution, wait until the target clock signal
has 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. Moreover, 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.
5. Differences between Products
Before changing from one product to another, i.e. to a product with a different part number, confirm
that the change will not lead to problems.
The characteristics of Microprocessing unit or Microcontroller unit products in the same group
but having a different part number may differ in terms of the 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.
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.
Page 49
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 of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use
of these circuits, software, or information.
2. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics does not warrant that such information is error free. Renesas Electronics
assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein.
3. Renesas Electronics does not assume any liability for infringement of 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. 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 should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics assumes no responsibility for any losses incurred by you or
third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics product.
5. Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The recommended 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; and industrial robots etc.
"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; anti-crime systems; and safety equipment etc.
Renesas Electronics products are neither intended nor 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 damages (nuclear reactor control systems, military equipment etc.). You must check the quality grade of each Renesas Electronics product before using it
in a particular application. You may not use any Renesas Electronics product for any application for which it is not intended. Renesas Electronics shall not be in any way liable for any damages or losses
incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics.
6. You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics, especially with respect to the maximum rating, operating supply voltage
range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or damages arising out of the
use of Renesas Electronics products beyond such specified ranges.
7. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and
malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to guard them against the
possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas Electronics product, 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,
please evaluate 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. Please use Renesas Electronics
products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive. Renesas Electronics assumes
no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.
9. Renesas Electronics products and technology may 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 should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the
development of weapons of mass destruction. When exporting the Renesas Electronics products or technology described in this document, you should comply with the applicable export control laws and
regulations and follow the procedures required by such laws and regulations.
10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or otherwise places the product with a third party, to notify such third party in advance of the
contents and conditions set forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics
products.
11. This document may not be 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, or if you have any other inquiries.
(Note 1) "Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries.
(Note 2) "Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics.
http://www.renesas.com
Refer to "http://www.renesas.com/" for the latest and detailed information.
Renesas Electronics America Inc.
2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A.
Tel: +1-408-588-6000, Fax: +1-408-588-6130
Renesas Electronics Canada Limited
9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3
Tel: +1-905-237-2004
Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333
Tel: +86-21-2226-0888, Fax: +86-21-2226-0999
Renesas Electronics Hong Kong Limited
Unit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong Kong
Tel: +852-2265-6688, Fax: +852 2886-9022
Renesas Electronics Taiwan Co., Ltd.
13F, No. 363, Fu Shing North Road, Taipei 10543, Taiwan
Tel: +886-2-8175-9600, Fax: +886 2-8175-9670
Renesas Electronics Singapore Pte. Ltd.
80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949
Tel: +65-6213-0200, Fax: +65-6213-0300
Renesas Electronics Malaysia Sdn.Bhd.
Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, Malaysia
Tel: +60-3-7955-9390, Fax: +60-3-7955-9510