On April 1st, 2010, NEC Electronics Corporation merged with Renesas Technology
Corporation, and Renesas Electronics Corporation took over all the business of both
companies. Therefore, although the old company name remains in this document, it is a valid
Renesas Electronics document. We appreciate your understanding.
Send any inquiries to http://www.renesas.com/inquiry.
Notice
1. All information included in this document is current as of the date this document is issued. Such information, however, is
subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please
confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to
additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website.
2. 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.
3. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part.
4. 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.
5. When exporting the 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. You should not use Renesas
Electronics products or the 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. 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.
6. 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.
7. Renesas Electronics products are classified according to the following three quality grades: “Standard”, “High Quality”, and
“Specific”. The recommended applications for each Renesas Electronics product depends on the product’s quality grade, as
indicated below. 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 categorized as “Specific” without the prior
written consent of Renesas Electronics. Further, you may not use any Renesas Electronics product for any application for
which it is not intended without the prior written consent of Renesas Electronics. 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 an
application categorized as “Specific” or for which the product is not intended where you have failed to obtain the prior written
consent of Renesas Electronics. The quality grade of each Renesas Electronics product is “Standard” unless otherwise
expressly specified in a Renesas Electronics data sheets or data books, etc.
“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.
crime systems; safety equipment; and medical equipment not specifically designed for life support.
“Specific”: Aircraft; aerospace equipment; submersible repeaters; nuclear reactor control systems; medical equipment or
systems for life support (e.g. artificial life support devices or systems), surgical implantations, or healthcare
intervention (e.g. excision, etc.), and any other applications or purposes that pose a direct threat to human life.
8. 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.
9. 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 system
manufactured by you.
10. 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.
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.
Application Note
Inverter Control by V850 Series
120° Excitation Method Control by Zero-Cross Detection
V850E/IA1
V850E/IA2
V850E/IA3
V850E/IA4
V850E/MA3
Document No. U17209EJ1V0AN00 (1st edition)
Date Published September 2004 N CP(K)
2004
Printed in Japan
[MEMO]
2
Application Note U17209EJ1V0AN
NOTES FOR CMOS DEVICES
1
VOLTAGE APPLICATION WAVEFORM AT INPUT PIN
Waveform distortion due to input noise or a reflected wave may cause malfunction. If the input of the
IL
CMOS device stays in the area between V
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 V
IH
(MIN).
V
HANDLING OF UNUSED INPUT PINS
2
Unconnected CMOS device inputs can be cause of malfunction. If an input pin is unconnected, it is
possible that an internal input level may be generated due to noise, etc., causing malfunction. CMOS
devices behave differently than Bipolar or NMOS devices. Input levels of CMOS devices must be fixed
high or low by using pull-up or pull-down circuitry. Each unused pin should be connected to V
via a resistor if there is a possibility that it will be an output pin. All handling related to unused pins must
be judged separately for each device and according to related specifications governing the device.
3
PRECAUTION AGAINST ESD
A strong electric field, when exposed to a MOS device, can cause destruction of the gate oxide and
ultimately degrade the device operation. Steps must be taken to stop generation of static electricity as
much as possible, and quickly dissipate it when it has occurred. Environmental control must be
adequate. When it is dry, a humidifier should be used. It is recommended to avoid using insulators that
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 should be grounded. The operator should be grounded using a wrist strap.
Semiconductor devices must not be touched with bare hands. Similar precautions need to be taken for
PW boards with mounted semiconductor devices.
(MAX) and VIH (MIN) due to noise, etc., the device may
IL
(MAX) and
DD
or GND
4
STATUS BEFORE INITIALIZATION
Power-on does not necessarily define the initial status of a MOS device. Immediately after the power
source is turned ON, devices with reset functions have not yet been initialized. Hence, power-on does
not guarantee output pin levels, I/O settings or contents of registers. A device is not initialized until the
reset signal is received. A reset operation must be executed immediately after power-on for devices
with reset functions.
5
POWER ON/OFF SEQUENCE
In the case of a device that uses different power supplies for the internal operation and external
interface, as a rule, switch on the external power supply after switching on the internal power supply.
When switching the power supply off, as a rule, switch off the external power supply and then the
internal power supply. Use of the reverse power on/off sequences may result in the application of an
overvoltage to the internal elements of the device, causing malfunction and degradation of internal
elements due to the passage of an abnormal current.
The correct power on/off sequence must be judged separately for each device and according to related
specifications governing the device.
6
INPUT OF SIGNAL DURING POWER OFF STATE
Do not input signals or an I/O pull-up power supply while the device is not powered. 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.
Input of signals during the power off state must be judged separately for each device and according to
related specifications governing the device.
Application Note U17209EJ1V0AN
3
These commodities, technology or software, must be exported in accordance
with the export administration regulations of the exporting country.
Diversion contrary to the law of that country is prohibited.
•
The information in this document is current as of July, 2004. The information is subject to change
without notice. For actual design-in, refer to the latest publications of NEC Electronics data sheets or
data books, etc., for the most up-to-date specifications of NEC Electronics products. Not all
products and/or types are available in every country. Please check with an NEC Electronics sales
representative for availability and additional information.
No part of this document may be copied or reproduced in any form or by any means without the prior
•
written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may
appear in this document.
•
NEC 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 NEC Electronics products listed in this document
or any other liability arising from the use of such products. No license, express, implied or otherwise, is
granted under any patents, copyrights or other intellectual property rights of NEC Electronics or others.
Descriptions of circuits, software and other related information in this document are provided for illustrative
•
purposes in semiconductor product operation and application examples. The incorporation of these
circuits, software and information in the design of a customer's equipment shall be done under the full
responsibility of the customer. NEC Electronics assumes no responsibility for any losses incurred by
customers or third parties arising from the use of these circuits, software and information.
•
While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products,
customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To
minimize risks of damage to property or injury (including death) to persons arising from defects in NEC
Electronics products, customers must incorporate sufficient safety measures in their design, such as
redundancy, fire-containment and anti-failure features.
•
NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and
"Specific".
The "Specific" quality grade applies only to NEC Electronics products developed based on a customerdesignated "quality assurance program" for a specific application. The recommended applications of an NEC
Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of
each NEC Electronics product before using it in a particular application.
"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.
systems, anti-crime systems, safety equipment and medical equipment (not specifically designed
for life support).
"Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life
support systems and medical equipment for life support, etc.
The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC
Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications
not intended by NEC Electronics, they must contact an NEC Electronics sales representative in advance to
determine NEC Electronics' willingness to support a given application.
(Note)
(1) "NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its
majority-owned subsidiaries.
(2) "NEC Electronics products" means any product developed or manufactured by or for NEC Electronics (as
defined above).
M8E 0 2. 11-1
4
Application Note U17209EJ1V0AN
Regional Information
Some information contained in this document may vary from country to country. Before using any NEC
Electronics product in your application, pIease contact the NEC Electronics office in your country to
obtain a list of authorized representatives and distributors. They will verify:
•
Device availability
•
Ordering information
•
Product release schedule
•
Availability of related technical literature
•
Development environment specifications (for example, specifications for third-party tools and
components, host computers, power plugs, AC supply voltages, and so forth)
•
Network requirements
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary
from country to country.
Santa Clara, California
Tel: 408-588-6000
800-366-9782
N
EC Electronics (Europe) GmbH
Duesseldorf, Germany
Tel: 0211-65030
•
Sucursal en España
Madrid, Spain
Tel: 091-504 27 87
•
Succursale Française
Vélizy-Villacoublay, France
Tel: 01-30-67 58 00
•
Filiale Italiana
Milano, Italy
Tel: 02-66 75 41
•
Branch The Netherlands
Eindhoven, The Netherlands
Tel: 040-244 58 45
•
Tyskland Filial
Taeby, Sweden
Tel: 08-63 80 820
•
United Kingdom Branch
Milton Keynes, UK
Tel: 01908-691-133
NEC Electronics Hong Kong Ltd.
Hong Kong
Tel: 2886-9318
NEC Electronics Hong Kong Ltd.
Seoul Branch
Seoul, Korea
Tel: 02-558-3737
NEC Electronics Shanghai Ltd.
Shanghai, P.R. China
Tel: 021-5888-5400
NEC Electronics Taiwan Ltd.
Taipei, Taiwan
Tel: 02-2719-2377
NEC Electronics Singapore Pte. Ltd.
Novena Square, Singapore
Tel: 6253-8311
J04.1
Application Note U17209EJ1V0AN
5
INTRODUCTION
Target Readers This application note is intended for users who understand the functions of the
V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, and V850E/MA3, and who design
application systems that use these microcontrollers. The applicable products are shown
below.
PurposeThe purpose of this application note is to help the user understand how a brushless DC
motor is controlled via the 120° sensorless drive excitation method that uses PWM
output and A/D converter input as a system example of the timer/counter function of the
V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, and V850E/MA3.
OrganizationThis application note is divided into the following sections.
• Control method • Software configuration
• Hardware configuration • Program list
How to Use This ManualIt is assumed that the reader of this application note has general knowledge in the fields
of electrical engineering, logic circuits, and microcontrollers.
Cautions 1. Application examples in this manual are intended for the “standard”
quality models for general-purpose electronic systems. When using
an example in this manual for an application that requires the
“special” quality grade, evaluate each component and circuit to be
actually used to see if they satisfy the required quality standard.
2. To use this manual for special-grade products, read the part
Conventions Data significance: Higher digits on the left and lower digits on the right
Active low representation: xxx (overscore over pin or signal name)
Memory map address: Higher addresses on the top and lower addresses on
the bottom
Note: Footnote for item marked with Note in the text
Caution: Information requiring particular attention
Remark: Supplementary information
Numeric representation: Binary ... xxxx or xxxxB
Decimal ... xxxx
Hexadecimal ... xxxxH
Prefix indicating the power
of 2 (address space,
memory capacity): K (kilo): 2
M (mega): 2
G (giga): 2
4.5.14 Link directive file for V850E/MA3................................................................................................188
Application Note U17209EJ1V0AN
11
CHAPTER 1 CONTROL METHOD
1.1 Outline of Brushless DC Motor Control
A brushless DC (BLDC) motor consists of a stator, coil, and rotor. The rotor, which includes a permanent magnet,
is rotated by the action of the magnetic field generated by the coil of the stator.
The magnetic field is generated by exciting the coil wound around the stator in a specific sequence. By controlling
the intensity and cycle of the magnetic field with a microcontroller, the torque response and the number of revolutions
of the motor can be controlled.
This section explains how to control a BLDC motor without a sensor by using the V850E/IA1, V850E/IA2,
V850E/IA3, V850E/IA4, or V850E/MA3.
Figure 1-3 shows an example of the circuit of a three-phase brushless DC motor. The internal PWM output
function of the microcontroller is used to control the current that flows through the motor, by using a transistor array
consisting of six transistors.
The magnetic field is generated by controlling the excitation pattern of the six transistors as shown in Table 1-1.
Table 1-1. Excitation Pattern
Upper Arm Lower Arm Excitation
Pattern
<1> Active Inactive Inactive Inactive Active Inactive U → V
<2> Active Inactive Inactive Inactive Inactive Active U → W
<3> Inactive Active Inactive Inactive Inactive Active V → W
<4> Inactive Active Inactive Active Inactive Inactive V → U
<5> Inactive Inactive Active Active Inactive Inactive W → U
<6> Inactive Inactive Active Inactive Active Inactive W → V
U V W U V W
Excitation
Direction
12
Application Note U17209EJ1V0AN
CHAPTER 1 CONTROL METHOD
Figure 1-1. Three-Phase DC Motor Voltage Waveform
<1><2><3><4><5><6>
U phase
U phase
Driving voltage
waveform
V phase
V phase
W phase
W phase
U phase
Induced voltage
waveform
V phase
W phase
Application Note U17209EJ1V0AN
13
Magnetic
flux
CHAPTER 1 CONTROL METHOD
Figure 1-2. Rotor Position Detection Principle
CC
V
N
U
A
W-phase stator
is located in the
center of the N pole
and S pole of a
S
magnet rotor
S
V
CC
N
U
A
S
V
W
V
WC
N
(a) Rotor position <1> … U-phase stator: S pole
V-phase stator: N pole
W-phase stator: Center point
S
U
N
N
V
W
V
WC
A
V
CC
S
= 0
= 0
S
V
VC
= 0
V
W
N
(b) Rotor position <2> … U-phase stator: S pole
V-phase stator: Center point
W-phase stator: N pole
S
U
V
N
CC
V
N
W
S
V
UC
= 0
A
(d) Rotor position <4> … U-phase stator: N pole
V-phase stator: S pole
W-phase stator: Center point
S
U
N
V
VC
= 0
V
W
S
A
(e) Rotor position <5> … U-phase stator: N pole
V-phase stator: Center point
W-phase stator: S pole
14
(c) Rotor position <3> … U-phase stator: Center point
V-phase stator: S pole
W-phase stator: N pole
N
U
S
V
UC
= 0
Return to (a)
N
V
S
V
CC
A
W
N
V
CC
(f) Rotor position <6> … U-phase stator: Center point
V-phase stator: N pole
W-phase stator: S pole
Application Note U17209EJ1V0AN
CHAPTER 1 CONTROL METHOD
Figure 1-3. Configuration of Three-Phase Brushless DC Motor
TrU
TrU
1
TrV
1
OnOffOff
U
V
2
TrV
2
OffOnOff
PWM control
TrW
TrW
1
U
W
V
W
2
U
Zero-cross point detection
V
W
Application Note U17209EJ1V0AN
15
CHAPTER 1 CONTROL METHOD
The 120° control method for a BLDC motor without a sensor is described below.
To control a BLDC motor, the rotor position must be known.
To control a BLDC motor without a senso r, the rotor position is estimated using induced voltage.
The induced voltage is in phase with the driving voltage waveform and its waveform is close to a sine wave, as
shown in Figure 1-1. Figure 1-2 illustrates how the polarity of the stator of the motor is switched and how the magnet
rotor revolves.
As shown in Figures 1-1 and 1-2, a three-phase DC motor rotates its rotor by switching the three driving current
patterns on the three coil phases.
During period <1> in Figure 1-1, for example, transistor Tr U
1 in Figure 1-3 is turned on by the U-phase dr iving pin,
and TrV2 is turned on by the V-phase driving pin, causing the current to flow from the U-phase driving pin toward the Vphase driving pin. At this time, the W-phase coil seems to be disconnected from the driver circuit and induced voltage
is generated.
This induced voltage is used to detect the rotor position.
To control the number of revolutions of the motor, the voltage applied to the motor is controlled to change the
current flowing through the coil. To change the voltage, a waveform that is controlled by PWM is applied to the
transistor.
The voltage is changed by applying a waveform (PWM waveform) in proportion to the voltage to be applied, to the
transistors on the lower arm side (TrU
2, TrV2, and TrW2) while the transistors on the upper arm side (TrU1, TrV1, and
TrW1) are on.
16
Application Note U17209EJ1V0AN
CHAPTER 2 HARDWARE CONFIGURATI ON
This chapter describes the hardware configuration.
2.1 Configuration
The reference system’s main functions are described below. In this reference system, when the revolution
specification switch is pressed after power application, the motor starts revolving in the direction specified.
Figure 2-1. Overall System Configuration
Volume for
speed control
Driver IC
Reset circuit
Revolution
specification SW
LED display
3
13
A/D converter
RESET
Port
Timer
Microcontroller
WDT
6
V-U
V-V
V-W
Interrupt
Position
detection
Position
detection
Position
detection
M
Current voltage
conversion
Current voltage
conversion
V-U
V-V
V-W
Application Note U17209EJ1V0AN
17
CHAPTER 2 HARDWARE CONFIGURATION
(1) Volume for speed control
Volume for increasing and decreasing the number of revolutions of the motor
(2) Revolution specification SW
CW, CCW, and STOP switches
(3) LED display
LED displaying the number of revolutions, operation time, etc.
(4) WDT
Watchdog timer
(5) Driver IC
Driver for driving motor
(6) Current voltage converter
Converting the motor driving current to voltage, used for detecting overcurrent
(7) Position detector
Rotor position estimation signal output from the induced voltage
18
Application Note U17209EJ1V0AN
CHAPTER 2 HARDWARE CONFIGURATION
2.2 Circuit Diagram
Figures 2-2 to 2-6 show diagrams of the sample reference system circuit.
This sample reference system circuit diagram includes the V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, or
V850E/MA3, a reset circuit, oscillator, a pin handling microcontroller peripheral block, operation mode switch block,
LED output block, watchdog timer circuit block, drive circuit block, motor controller, and motor revolution indicator.
(1) Microcontroller and microcontroller peripheral block
The V850E/IA1, V850E/IA2, V850E/IA3, V850E/IA4, or V850E/MA3 includes a reset circuit, an oscillator that
uses a resonator, and a block for handling the MODE pin and unused pins.
(2) Operation mode switch block
This includes switches that set the operation mode as CW or CCW operation.
(3) LED output block
This block includes 16 LEDs, which are used to indicate the revolution speed (rpm), errors, etc.
(4) Watchdog timer circuit block
This block uses the
V850E/IA3, V850E/IA4, or V850E/MA3 stops for one ms or longer.
(5) Drive circuit block
The 6-phase outputs from the inverter timer are converted to U-, V-, and W-phase output for the motor driver.
This drive circuit is not shown in detail in this example, since it varies depending on the motor’s specifications.
(6) Motor controller
This block includes the HPS-3-AS, LM324, and other devices that are used to measure the motor’s U and V
drive currents via A/D conversion.
(7) Motor rotation indicator
This block includes a volume adjuster and the LM324 for setting the motor’s revolution speed (rpm).
µ
PD74HC123A to output stop signals when pulse output from the V 850E/IA1, V850E/IA2,
Figure 3-1 shows a diagram of the software control block of the reference system.
Figure 3-1. Diagram of Software Control Block of Reference System
Control by microcontroller
<6>
A/D
conver-
<7>
Current
monitor
sion
A/D
conver-
sion
iu
iv
u
<3>
Speed
control
v
PWM
conver-
sion
Driver
circuit
<1>
Target
speed
(volume)
+
<2>
−
Speed
<5>
w
u, v, w
detection
<1> The volume is loaded by the A/D converter as a target speed.
<2> The speed to be calculated is determined by the difference from the present speed.
<3> Values of phases U, V, and W are set.
<4> The zero-cross point is detected by an induced voltage (by hardware).
<5> The speed is calculated by the interval of zero-cross point in each phase.
<6> An overcurrent is detected by the A/D converter.
<7> The speed is controlled by a current value.
Motor
<4>
External
zero-cross
point
detection
Application Note U17209EJ1V0AN
31
CHAPTER 3 SOFTWARE CONFIGURATION
3.2 Peripheral I/O
The following types of peripheral I/O functions are used in this reference system.
Inverter timers are used to output PWM waveforms.
In this application circuit example, the settings are as shown below.
• 20 kHz symmetrical triangular waveform mode
• Dead time: 6
µ
s
• Inverter timer output: Low active
• When ESO0, TOQ0OFF, or INTP000 pin input is at high level, PWM output is stopped.
(b) Motor control timer
Motor control timers are used to issue interrupts at a 50
(c) 10 ms timer
10 ms timers are used to issue interrupts at a 10 ms interval.
(d) Speed measuring timer
Used for measuring the revolution speed of the motor.
(e) Current value input
ANI00, ANI0 (V850E/MA3 only): U-phas e current value (−5 to +5 A)
ANI10, ANI1 (V850E/MA3 only): V-phase current value (−5 to +5 A)
(f) Speed specification volume value input
ANI01 or ANI4 (V850E/MA3 only) is used to input a value from 0 to 1,023.
µ
s interval.
Application Note U17209EJ1V0AN
33
CHAPTER 3 SOFTWARE CONFIGURATION
3.3 Software Processing Structure
The software processing structure is shown below.
Figure 3-2. Main Processing Structure
CW
revolution
processing
CW
revolution operation
Operation
(STOP CW)
Processing
during
deceleration
Detection time
processing
STOP processing
Operation
(STOP CCW)
CCW
revolution
processing
CCW
revolution operation
34
Application Note U17209EJ1V0AN
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-3. Interrupt Processing Structure
(a) Motor control processing (b) Control pin selection processing (c) Wait timer processing
U, V, W change
interrupt
50 s interval interrupt
µ
Motor control
processing
Control pin
selection
processing
Wait timer
processing
10 ms interval interrupt
The status of the operation mode switch is monitored by the main processing, and processing is transferred to CW,
CCW, and stop status. The motor is control led in the specified status by using a 50
µ
s interval interrupt.
There are the following three motor control statuses.
• Stop status
The motor is not controlled.
• Initial operation status
Estimated revolution control is performed up to the speed at which the zero-cross point of electromotive force can
be detected.
• Speed control status
Feedback revolution control is performed so that the indication speed is attained.
Application Note U17209EJ1V0AN
35
CHAPTER 3 SOFTWARE CONFIGURATION
3.4 Flowchart
3.4.1 Main processing
Figure 3-4 shows the flowchart of the main processing.
36
Application Note U17209EJ1V0AN
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-4. Main Processing
START
: Refer to 4.1.5, 4.2.5, 4.3.5, 4.4.5, 4.5.5 Main processing function.
(hardware initialization)
C
(used area initialization)
hinit
ainit
Enable interrupts
SW CW pressed?
Yes
SW mode = CW
: Refer to Figure 3-20 Hardware Initialization.
: Refer to Figure 3-21 Common Area Initialization.
No
SW CCW pressed?
Yes
SW mode = CCW
No
SW STOP pressed?
Yes
SW mode = STOP
No
Case?
(case 0 to case 7)
0
1
2
3
4
5
6
Application Note U17209EJ1V0AN
37
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-5. Case 0 (Processing During Stoppage)
0
SW mode = CW?
Yes
Disable interrupts
Initialize target speed and request
CCW initialization
Enable interrupts Enable interrupts
Processing number 1
No
Disable interrupts
Initialize target speed and request
CCW initialization
Processing number 4
A
38
Application Note U17209EJ1V0AN
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-6. Case 1 (CW Acceleration Processing)
1
No
Re-set acceleration/deceleration counter
Target speed < Indication speed?
Set speed monitor start timer to 5 seconds
Initialization of
acceleration/deceleration
counter 0 ends?
Yes
Yes
Increase target speed
No
Target speed > Indication speed?
Yes
Decrease target speed
Set speed monitor start timer to 5 seconds
No
Processing number 2
SW mode = CCW or STOP?
Yes
Processing number 3
No
A
Application Note U17209EJ1V0AN
39
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-7. Case 2 (CW Constant-Speed Processing)
Indication speed as target speed
SW mode = CCW or STOP?
Processing number 3
2
No
Yes
A
Figure 3-8. Case 3 (CW Stop Processing)
3
No
Acceleration/deceleration c ou n ter = 0?
Yes
Re-set acceleration/deceleration counter
Target speed > Indication speed?
Yes
Decrease target speed
Set speed monitor start time to 5 seconds
No
Set stop flag to on and processing
number to 0
A
40
Application Note U17209EJ1V0AN
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-9. Case 4 (CCW Acceleration Processing)
4
No
Set speed monitor start time to 5 seconds
Initial operation ends with
acceleration/deceleration cou nte r = 0?
Yes
Re-set acceleration/deceleration counter
Target speed < Indication speed?
Yes
Increase target speed
SW mode = CCW or STOP?
Yes
No
Target speed > Indication speed?
Yes
Decrease target speed
Set speed monitor start time to 5 seconds
No
No
Processing number 5
Processing number 6
A
Application Note U17209EJ1V0AN
41
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-10. Case 5 (CCW Constant-Speed Processing)
5
Target speed = (– indication speed)
SW mode = CW or STOP?
Yes
Processing number 6
No
A
Figure 3-11. Case 6 (CCW Stop Processing)
No
Acceleration/deceleration counter = 0?
Re-set acceleration/deceleration counter
6
Yes
42
Target speed < (− indication speed)?
Yes
Increase target speed
Set speed monitor start t ime to 5 se co nds
A
Application Note U17209EJ1V0AN
No
Set stop flag to on and processing
number to 0
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-12. Detect Wait (1/2)
A
No
No
No
Processing number 2 or 5?
Yes
Speed monitor starts?
Yes
Present speed < Error speed?
Yes
Set error number ERR_NO3
Stop flag on
PWM output off
B
Application Note U17209EJ1V0AN
43
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-12. Detect Wait (2/2)
B
No
Display average counter = 0?
Yes
Set display average counter to 100
led_num
(Present average speed
indication)
led_num
(Control period indication)
led_num
(Interrupt processing
time indication)
led_num
(Operation processing
time indication)
44
No
Error flag on?
Yes
7-segment display off
500 ms?
Yes
Error number 1?
Yes
“1” displayed on 7-segment
500 ms?
Yes
Application Note U17209EJ1V0AN
No
C
No
No
“2” displayed on 7-segment
3.4.2 Motor control processing
Figure 3-13. Control Interrupt Processing (1/5)
CHAPTER 3 SOFTWARE CONFIGURATION
Motor_CONT
fcalcu
(speed calculation)
Convert radian to rpm value
No
Calculate total speed value from present
Speed counter = 0?
Yes
Re-set speed counter
value of speed counter
: Refer to 4.1.7, 4.2.7, 4.3.7, 4.4.7, 4.5.7 Motor control
interrupt processing function.
Clear total speed value
1
Application Note U17209EJ1V0AN
45
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-13. Control Interrupt Processing (2/5)
1
Stop flag on?
Yes
All phases of PWM port off
5
No
3
No
Operation start output
Get display timer start value
Clear PWM output prohibition
Reset watchdog timer
Initial flag on?
Initial revolution processing
Yes
Increment initial counter
46
No
5
Initial counter > Output time?
Yes
Clear initial counter
CW?
Yes
Extract output value from initial CW
revolution pattern table
Count up pattern extraction
Same output pattern continues to be output
the number of times specified by the table.
No
Extract output value from initial CCW
revolution pattern table
Count up pattern extraction
2
Application Note U17209EJ1V0AN
U phase high side output on?
U phase comparison value = 0
V and W phase comparison
values = Initial value
High side is valid by
clearing the value to 0.
Write PWM output pattern
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-13. Control Interrupt Processing (3/5)
2
No
Yes
V phase high side output on?
Yes
V phase comparison value = 0
U and W phase comparison
values = Initial value
No
W phase comparison value = 0
U and V phase comparison
values = Initial value
Pattern extraction counter ≥ 6?
Yes
Clear pattern extraction counter
init_upco > 14?
Yes
Initial flag off
No
No
To select and output six types of output patterns
End if value of number of revolutions table
counter is 14 or more
Increment init_upco by 1
3
Application Note U17209EJ1V0AN
47
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-13. Control Interrupt Processing (4/5)
3
Speed difference =
Target speed – Present speed
Calculate PWM output value
Speed integral value > MAX. value?
Yes
Speed integral value = MAX. value
PWM value < 0?
Yes
PWM value as 1
Normal revolution processing
No
Speed integral value < −MAX. value?
Yes
Speed integral value = −MAX. value
No
PWM value > MAX.?
Yes
No
Speed integral value
calculation
No
PWM value as MAX.
4
Remarks 1. PWM = (Present speed × ksp) + (Speed difference × ksp/10) + Speed integral value + Speed
offset value
2. Speed integral value = Speed integral value + (Speed difference × ksi)
3. ksp: Speed proportion gain
ksi: Speed integral gain
48
Application Note U17209EJ1V0AN
CHAPTER 3 SOFTWARE CONFIGURATION
Figure 3-13. Control Interrupt Processing (5/5)
Read present PWM output pattern
4
U phase high side output on?
Yes
U phase comparison value = 0
Set V and W phase comparison values
EXIT
No
U phase high side output on?
V phase comparison value = 0
Set U and W phase comparison
values
No
Yes
W phase comparison value = 0
Set U and V phase comparison
values
Application Note U17209EJ1V0AN
49
CHAPTER 3 SOFTWARE CONFIGURATION
3.4.3 U zero-cross point interrupt processing
Figure 3-14. U Zero-Cross Point Interrupt Processing
int_p20
No
Initial flag off and stop flag off?
Yes
Capture speed measuring timer value and restart
Set reference position from other phase status
Target revolution CCW?
Yes
Extract output pattern from CCW table according
to present zero-cross point status
U phase high side output on?
Yes
U phase comparison value = 0
Set V and W phase comparison values
cont_time unsigned short Interrupt processing time 1 µs units
cont_time1 unsigned short Operation time 1
disp_co unsigned short Average speed counter for display
volume unsigned short Speed volume value
timer_count unsigned short Time wait counter 10 ms units
accel_count unsigned short
stop_flag unsigned short Stop flag
before_posi[21][2] signed short Position buffer
total_sa signed short Position total difference
sum_speed unsigned int
speed_co unsigned int Counter for average speed calculation 0, 1, …
now_speed signed int Present speed rpm
object_speed signed int Target speed rpm
d_speed signed int Display speed rpm
iua signed short U-phase current
iva signed short V-phase current
o_iqai signed int Speed integral value
base_position signed int Speed estimation reference point
sa_time unsigned int For speed measurement
timer_count unsigned short Time wait counter
init_co unsigned short
init_pat unsigned char Initial revolution output pattern number 0 to 5
init_upco unsigned short Initial revolution output table number 0 to 10
int_co unsigned int U, V, W interrupt counter 0, 1, …
pwm_value signed int PWM output value Output bit pattern
Acceleration/deceleration operation time
counter
Total value area for average speed
calculation
Output selection monitor counter during
initial revolution
0: No error
ERR_NO1: Overcurrent
ERR_NO3: Speed difference error
ON: Initial revolution in progress
OFF: Stop or normal revolution in progress
µ
s units
10 ms units
ON: Stopped
OFF: Revolving
0, 1, …
0, 1, …
Application Note U17209EJ1V0AN
59
CHAPTER 3 SOFTWARE CONFIGURATION
3.6 Tables
(1) LED output pattern
Contains display pattern data 0 to 9.
unsigned short led_pat[10] = { 0xfc. 0x60, ~ };
(2) Initial CW output pattern
Contains an output pattern for CW initial operation.
The underlined values differ depending on the target microcontroller.
Note
Note
Application Note U17209EJ1V0AN
61
CHAPTER 3 SOFTWARE CONFIGURATION
3.7 Constant Definitions
The following table shows the major constants used by the reference system.
Symbol Usage Value
PAI
TH_U Radian value, jack-up constant 1000
RAD Radian value of one revolution 2 × PAI × TH_U
OFFSET Original point OFFSET 1945
RPM_RADS rpm → radian conversion constant 2 × PAI × TH_U/60
KSP Speed proportion constant 917
KSI Speed integral constant 0
P Number of motor poles 2
KSPGETA Speed proportion constant jack-up constant 10
KSIGETA Speed integral constant jack-up constant 14
SGETA sin jack-up constant 14
PWM_TS PWM cycle 50
PWM_DATA PWM set value PWM_TS/0.05
SPEED_MAX Maximum speed 500 (3000 rpm)
SPEED_MINI Minimum speed 100 (600 rpm)
SPEED_INIT Initial revolution speed 700 rpm
SA_SPEED_MAX Maximum speed difference 800
IQMAX Maximum speed integral value 200000
MAX_I Maximum current value 800
TS Motor control period 800
ACCEL_TIME Acceleration/deceleration time constant, 10 ms 1
ACCEL_DATA Number of acceleration/deceleration incremental revolutions 40 rpm
WATCH_START Speed monitor start time, 10 ms 500
ACCEL_VAL_1ST Initial acceleration/deceleration time constant 50
ACCEL_VAL Acceleration/deceleration time constant 3
ACCEL_SPD Acceleration/deceleration constant 50
PWM_INIT PWM initial value PWM_DATA/4
extern unsigned char error_flag ; /* Error flag */
extern unsigned char init_flag ; /* Initial flag */
extern unsigned short cont_time ; /* Interrupt control time uSEC */
extern unsigned short cont_time1 ; /* Vector operation time uSEC */
extern unsigned short disp_co ; /* Interrupt control time display timer */
extern unsigned short volume ; /* Volume value */
extern unsigned short timer_count ; /* Time wait counter */
extern unsigned short accel_count ; /* Acceleration/deceleration operation */
/* time counter */
extern unsigned char stop_flag ; /* Stop flag */
Application Note U17209EJ1V0AN
63
CHAPTER 4 PROGRAM LIST
extern signed short before_posi[21][2] ; /* Position buffer */
extern signed short total_sa ; /* Position total difference */
extern signed int sum_speed ;
extern signed int speed_co ;
extern signed int now_speed ; /* Present speed rms */
extern signed int object_speed ; /* Target speed rms */
extern unsigned int d_speed ; /* Display speed rms */
extern unsigned char ram_end ;
#pragma section const begin
extern const unsigned short led_pat[] ;;
#pragma section const end
/****************************************************************************** /
/* Motor common definition */
/****************************************************************************** /
extern signed short iua ; /* U-phase current */
extern signed short iva ; /* V-phase current */
extern signed int o_iqai ; /* Speed integral value area */
extern signed int base_position ; /* Speed estimation value reference point */
extern unsigned int sa_time ; /* Speed measurement value */
extern unsigned short timer_count ; /* Time wait counter */
extern unsigned short accel_count ; /* Acceleration/deceleration operation */
/* time counter */
extern unsigned short init_co ; /* Initial interrupt counter */
extern unsigned char init_pat ; /* Initial pattern counter */
extern unsigned short init_upco ; /* Initial speed-up counter */
extern unsigned int int_co ; /* UVW interrupt counter */
extern signed int pwm_value ; /* PWM output value */
#define SA_SPEED_MAX 800 /* Maximum speed difference rpm */
Application Note U17209EJ1V0AN
65
CHAPTER 4 PROGRAM LIST
#define IQAMAX 200000 /* Maximum speed integral value */
#define MAX_I 800 /* Maximum current value */
#define TS 200 /* Motor control time interval uSEC */
#define ACCEL_TIME 1 /* Acceleration/deceleration time */
/* constant 10 mSEC */
#define ACCEL_DATA 40 /* Number of acceleration/deceleration */
#define PWM_INIT PWM_DATA/4 /* PWM initial value */
/****************************************************************************** /
/* Function constant */
/****************************************************************************** /
void fcalcu( signed int *wrm, signed int *trm );
void OUT_data( unsigned short reg, unsigned short data );
unsigned short IN_data( int reg );
void led_num( int no, long data ) ;
/****************************************************************************** /
/* Motor-related common area */
/****************************************************************************** /
signed short iua ; /* U-phase current */
signed short iva ; /* V-phase current */
signed int o_iqai ; /* Speed integral value area */
signed int base_position ; /* Speed estimation value reference point */
unsigned int sa_time ; /* Speed measurement value */
unsigned int before_time ; /* Previous speed measuring timer value */
unsigned short accel_count ; /* Acceleration/deceleration operation time counter */
unsigned short init_co ; /* Initial interrupt counter */
unsigned char init_pat ; /* Initial pattern counter */
unsigned short init_upco ; /* Initial speed-up counter */
unsigned int int_co ; /* UVW interrupt counter */
signed int di ;
signed int pwm_value ; /* PWM output value */
#=============================================================================
# DESCRIPTIONS:
# This assembly program is a sample of start-up module for ca850.
# If you modified this program, you must assemble this file, and
# locate a given directory.
#
# Unless -G is specified, sections are located as the following.
#
# | : |
# | : |
# tp -> -+-------------- + _ _start _ _tp_TEXT
# | start up |
# |-------------- |
# text section | |
# | user program |
# | |
# |-------------- |
# | library |
# -+-------------- +
# | |
#----------------------------------------------------------------------------# C program main function
#---------------------------------------------------------------------------- .extern _main
#----------------------------------------------------------------------------# dummy data declaration for creating sbss section
#---------------------------------------------------------------------------- .sbss
.lcomm _ _sbss_dummy, 0, 0
#----------------------------------------------------------------------------# start up
# pointers: tp - text pointer
# gp - global pointer
# sp - stack pointer
# ep - element pointer
# exit status is set to r10
#---------------------------------------------------------------------------- .text
.align 4
.globl _ _start
.globl _exit
.globl _ _exit
_ _start:
mov 0x12,r10
st.b r10,VSWC[r0] -- Set peripheral I/O wait
/****************************************************************************** /
/* Common area */
/****************************************************************************** /
unsigned char ram_start ;
unsigned char error_flag ; /* Error flag */
unsigned char init_flag ; /* Initial flag */
unsigned short cont_time ; /* Interrupt control time uSEC */
unsigned short cont_time1 ; /* Vector operation time uSEC */
unsigned short disp_co ; /* Interrupt control time display timer */
unsigned short volume ; /* Volume value */
unsigned short timer_count ; /* Time wait counter */
unsigned short accel_count ; /* Acceleration/deceleration operation time */
/* counter */
unsigned char stop_flag ; /* Stop flag */
signed short before_posi[21][2] ; /* Position buffer */
signed short total_sa ; /* Position total difference */
signed int sum_speed ;
signed int speed_co ;
signed int now_speed ; /* Present speed rms */
signed int object_speed ; /* Target speed rms */
unsigned int d_speed ; /* Display speed rms */
unsigned char ram_end ;
#pragma section const begin
const unsigned short led_pat[10] = { 0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6, 0xbe, 0xe0,
0xfe, 0xe6 } ;
#pragma section const end
/****************************************************************************** /
/* Common flags */
/****************************************************************************** /
extern unsigned char ram_start ;
extern unsigned char error_flag ; /* Error flag */
extern unsigned char init_flag ; /* Initial flag */
extern unsigned short cont_time ; /* Interrupt control time uSEC */
extern unsigned short cont_time1 ; /* Vector operation time uSEC */
extern unsigned short disp_co ; /* Interrupt control time display timer */
extern unsigned short volume ; /* Volume value */
extern unsigned short timer_count ; /* Time wait counter */
extern unsigned short accel_count ; /* Acceleration/deceleration operation */
/* time counter */
extern unsigned char stop_flag ; /* Stop flag */
extern signed short before_posi[21][2] ; /* Position buffer */
extern signed short total_sa ; /* Position total difference */
extern signed int sum_speed ;
Application Note U17209EJ1V0AN
89
CHAPTER 4 PROGRAM LIST
extern signed int speed_co ;
extern signed int now_speed ; /* Present speed rms */
extern signed int object_speed ; /* Target speed rms */
extern unsigned int d_speed ; /* Display speed rms */
extern unsigned char ram_end ;
#pragma section const begin
extern const unsigned short led_pat[] ;;
#pragma section const end
/****************************************************************************** /
/* Motor common definition */
/****************************************************************************** /
extern signed short iua ; /* U-phase current */
extern signed short iva ; /* V-phase current */
extern signed int o_iqai ; /* Speed integral value area */
extern signed int base_position ; /* Speed estimation value reference point */
extern unsigned int sa_time ; /* Speed measurement value */
extern unsigned short timer_count ; /* Time wait counter */
extern unsigned short accel_count ; /* Acceleration/deceleration operation */
/* time counter */
extern unsigned short init_co ; /* Initial interrupt counter */
extern unsigned char init_pat ; /* Initial pattern counter */
extern unsigned short init_upco ; /* Initial speed-up counter */
extern unsigned int int_co ; /* UVW interrupt counter */
extern signed int pwm_value ; /* PWM output value */
#define PWM_INIT PWM_DATA/4 /* PWM initial value */
/****************************************************************************** /
/* Function constant */
/****************************************************************************** /
void fcalcu( signed int *wrm, signed int *trm );
void OUT_data( unsigned short reg, unsigned short data );
unsigned short IN_data( int reg );
void led_num( int no, long data ) ;
/****************************************************************************** /
/* Motor-related common area */
/****************************************************************************** /
signed short iua ; /* U-phase current */
signed short iva ; /* V-phase current */
signed int o_iqai ; /* Speed integral value area */
signed int base_position ; /* Speed estimation value reference point */
unsigned int sa_time ; /* Speed measurement value */
unsigned short timer_count ; /* Time wait counter */
unsigned short accel_count ; /* Acceleration/deceleration operation time counter */
unsigned short init_co ; /* Initial interrupt counter */
unsigned char init_pat ; /* Initial pattern counter */
unsigned short init_upco ; /* Initial speed-up counter */
unsigned int int_co ; /* UVW interrupt counter */
signed int di ;
signed int pwm_value ; /* PWM output value */
#=============================================================================
# DESCRIPTIONS:
# This assembly program is a sample of start-up module for ca850.
# If you modified this program, you must assemble this file, and
# locate a given directory.
#
# Unless -G is specified, sections are located as the following.
#
# | : |
# | : |
# tp -> -+-------------- + _ _start _ _tp_TEXT
# | start up |
# |-------------- |
# text section | |
# | user program |
# | |
# |-------------- |
# | library |
# -+-------------- +
# | |
# sdata section | |
# | |
#----------------------------------------------------------------------------# C program main function
#---------------------------------------------------------------------------- .extern _main
#----------------------------------------------------------------------------# dummy data declaration for creating sbss section
#---------------------------------------------------------------------------- .sbss
.lcomm _ _sbss_dummy, 0, 0
#----------------------------------------------------------------------------# system stack
#----------------------------------------------------------------------------# start up
# pointers: tp - text pointer
# gp - global pointer
# sp - stack pointer
# ep - element pointer
# exit status is set to r10
#---------------------------------------------------------------------------- .text
.align 4
.globl _ _start
.globl _exit
.globl _ _exit
_ _start:
mov 0x02,r10
st.b r10,VSWC[r0] -- Set peripheral I/O wait