UG0659: Encoder Interface User Guide

Encoder Interface
UG0659 User Guide
06 2016
UG0659: Encoder Interface User Guide
Microsemi makes no warranty, representation, or guarantee regarding the information contained herein or the suitability of its
products and services for any particular purpose, nor does Microsemi assume any liability whatsoever arising out of the application or
use of any product or circuit. The products sold hereunder and any other products sold by Microsemi have been subject to limited
testing and should not be used in conjunction with mission-critical equipment or applications. Any performance specifications are
believed to be reliable but are not verified, and Buyer must conduct and complete all performance and other testing of the products,
alone and together with, or installed in, any end-products. Buyer shall not rely on any data and performance specifications or
parameters provided by Microsemi. It is the Buyer’s responsibility to independently determine suitability of any products and to test
and verify the same. The information provided by Microsemi hereunder is provided “as is, where is” and with all faults, and the entire
risk associated with such information is entirely with the Buyer. Microsemi does not grant, explicitly or implicitly, to any party any
patent rights, licenses, or any other IP rights, whether with regard to such information itself or anything described by such
information. Information provided in this document is proprietary to Microsemi, and Microsemi reserves the right to make any
changes to the information in this document or to any products and services at any time without notice.
Microsemi Corporate Headquarters
One Enterprise, Aliso Viejo,
CA 92656 USA
Within the USA: +1 (800) 713-4113
Outside the USA: +1 (949) 380-6100
Sales: +1 (949) 380-6136
Fax: +1 (949) 215-4996
E-mail: [email protected]
www.microsemi.com
About Microsemi
Microsemi Corporation (Nasdaq: MSCC) offers a comprehensive portfolio of semiconductor and system solutions for aerospace &
defense, communications, data center and industrial markets. Products include high-performance and radiation-hardened analog
mixed-signal integrated circuits, FPGAs, SoCs and ASICs; power management products; timing and synchronization devices and precise
time solutions, setting the world's standard for time; voice processing devices; RF solutions; discrete components; enterprise storage
and communication solutions; security technologies and scalable anti-tamper products; Ethernet solutions; Power-over-Ethernet ICs
and midspans; as well as custom design capabilities and services. Microsemi is headquartered in Aliso Viejo, Calif., and has
approximately 4,800 employees globally. Learn more at www.microsemi.com.
©2016 Microsemi Corporation. All rights reserved. Microsemi and the Microsemi logo are registered trademarks of Microsemi
Corporation. All other trademarks and service marks are the property of their respective owners.
50200659-2.06/16 Revision 2
2
UG0659: Encoder Interface User Guide
Revision History
The revision history describes the changes that were implemented in the document. The changes
are listed by revision, starting with the most current publication.
Date and
Revision
Revision 2
(June 2016)
Change
Page
Updated the document based on (SAR 80420)
N/A
Revision 1
(October 2015)
Initial release.
N/A
50200659-2.06/16 Revision 2
3
UG0659: Encoder Interface User Guide
Contents
Revision History.............................................................................................................................. 3
1 Introduction ............................................................................................................................. 7
2 Hardware Implementation..................................................................................................... 11
2.1
Timing Diagram ........................................................................................................................................ 12
2.2
Inputs and Outputs .................................................................................................................................. 12
2.3
Configuration Parameters ........................................................................................................................ 14
2.4
Resource Utilization ................................................................................................................................. 14
3 Product Support ..................................................................................................................... 15
3.1
Customer Service ..................................................................................................................................... 15
3.2
Customer Technical Support Center ........................................................................................................ 15
3.3
Technical Support..................................................................................................................................... 15
3.4
Website .................................................................................................................................................... 15
3.5
Contacting the Customer Technical Support Center ................................................................................ 15
3.6
3.5.1
Email .......................................................................................................................................... 15
3.5.2
My Cases .................................................................................................................................... 16
3.5.3
Outside the U.S. ......................................................................................................................... 16
ITAR Technical Support............................................................................................................................. 16
50200659-2.06/16 Revision 2
4
UG0659: Encoder Interface User Guide
List of Figures
Figure 1 Encoder Signals in Clockwise and Counter-clockwise Directions .................................................................... 7
Figure 2 Edge Detection of Encoder Pulses for Higher Resolution ................................................................................ 8
Figure 3 Theta Output for Positive Direction ................................................................................................................. 9
Figure 4 Theta Output for Negative Direction ............................................................................................................. 10
Figure 5 System-level Block Diagram of Encoder Interface ......................................................................................... 11
Figure 6 Timing Diagram of the Encoder Interface ...................................................................................................... 12
50200659-2.06/16 Revision 2
5
UG0659: Encoder Interface User Guide
List of Tables
Table 1 Inputs and Outputs of Encoder Interface ....................................................................................................... 12
Table 2 Configuration Parameters ............................................................................................................................... 14
Table 3 Resource Utilization Report of Encoder Interface .......................................................................................... 14
50200659-2.06/16 Revision 2
6
UG0659: Encoder Interface User Guide
1 Introduction
Incremental Encoder is the most common sensor used for field oriented control (FOC) of permanent
magnet brushless DC (BLDC) or permanent-magnet synchronous motor (PMSM). This sensor gives
relative angular position as the output in the form of pulses. A quadrature encoder, typically
produces two outputs, which have pulses phase shifted by 90o as shown in Figure 1. The phase shift
between the two signals A and B represents the direction of rotation. The encoder interface logic
uses edge detection on rising edge and falling edge of A and B as shown in Figure 2. This gives a
resolution that is four times the encoder resolution and produces a very high resolution from a low
cost encoder.
Figure 1 shows the encoder signals in clockwise and counter-clockwise directions.
A
Clockwise
B
A
Counter-Clockwise
B
Figure 1 Encoder Signals in Clockwise and Counter-clockwise Directions
Figure 2 shows the edge detection of encoder pulses for higher resolution.
50200659-2.06/16 Revision 2
7
UG0659: Encoder Interface User Guide
A
B
Edge
Detect
Figure 2 Edge Detection of Encoder Pulses for Higher Resolution
After the edge detection, counters are used to get a rotor angular position in terms of an electrical
angle so that, it can be directly used for FOC. The Angle_count_max value represents the total
number of edges that will be detected in one mechanical rotation of the rotor. The angle output
ranges from 0 to 262143, where 262143 represents 360°. The variation of angle output with respect
to the edges is as shown in Figure 3 for positive speed and Figure 4 for negative speed. The speed
output is calculated based on the rate of change of angular position.
Three parameters are used to configure the Encoder Interface:
Angle factor =
Speed factor =
256 ∗ 262144 ∗ Number of pole pairs
Encoder Resolution ∗ 4
384000
384000 ∗ 65536
RPM =
p. u.
Encoder Resolution
Encoder Resolution ∗ Rated Speed
Angle Count Max =
(Encoder Resolution ∗ 4)
−1
(Number of Pole Pairs)
EQ1
EQ2
EQ3
Figure 3 shows the Theta output for the positive direction.
50200659-2.06/16 Revision 2
8
UG0659: Encoder Interface User Guide
A
B
angle_count_max_i*angle_factor_i / 256
Figure 3 Theta Output for Positive Direction
Figure 4 shows the Theta output for the negative direction.
50200659-2.06/16 Revision 2
9
UG0659: Encoder Interface User Guide
A
B
angle_count_max_i*angle_factor_i / 256
Figure 4 Theta Output for Negative Direction
50200659-2.06/16 Revision 2
10
UG0659: Encoder Interface User Guide
2
Hardware Implementation
Figure 5 shows the block diagram of Encoder interface.
reset_i
sys_clk_i
fil_trig_i
direction_config_i
clear_buffer_i
dir_o
sensor_reset_i
qa_i
encoder_interface
omega_out_o
angle_out_o
qb_i
line_count_o
speed_factor_i
angle_factor_i
angle_count_max_i
speed_window_i
filter_factor_i
Figure 5 System-level Block Diagram of Encoder Interface
The encoder interface block converts signals received from QA, QB into its corresponding angle and
speed. The block counts encoder edges till the angle_count_max_i value is attained and then starts
counting from zero again. The angle generated is scaled to 262144 by multiplying it with the
angle_factor_i. A speed counter counts the number of encoder edges in a period of 10ms and scales
it to 65536 by multiplying it with speed_factor_i. Speed is measured by counting the number of
encoder events in a constant time period defined by speed_window_i input. A filter is used to filter
the quantization noise from speed measurement. The filter time constant can be configured using
the filter_factor_i value using the following equation:
Filter time constant = Time Period between successive pulses of pwm_midmatch_i ∗ 2
𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑖𝑖
.
EQ4
The sensor_reset _i input is used to find motor electrical angle by injecting constant current for a
small duration. When the motor has aligned to the injected angle, the encoder output is initialized
with 900 or 2700 based on initial direction of rotation. The encoder edge counting is expected to
start after the falling edge of the sensor_reset_i input is detected.
The clear_buffer_i input can be used to reset the filter buffer, as the filter buffer is expected to be
reset when the motor stops.
50200659-2.06/16 Revision 2
11
UG0659: Encoder Interface User Guide
The direction_config_i input is used to initially detect the motor direction. Once the motor starts
running, the motor direction is detected from the encoder signals and used in generating the angle.
2.1
Timing Diagram
Figure 6 Timing diagram of the Encoder interface.
sys_clk_i
qa_i
qb_i
angle_out_o
0
omega_out_o
0
1
2
3
4
65
45
300
10ms
Figure 6 Timing Diagram of the Encoder Interface
2.2
Inputs and Outputs
Table 1 shows the input and output ports of Encoder interface.
Table 1 Inputs and Outputs of Encoder Interface
Signal Name
Direction
Description
reset_i
Input
Active Low Asynchronous Reset
Signal
sys_clk_i
Input
System Clock
fil_trig_i
Input
direction_config_i
Input
clear_buffer_i
Input
Filter trigger input. A timing pulse of
one clock cycle width should be
provided at this input. The
periodicity of the pulse determines
the sampling time.
Direction configuration bit - used at
calibration time to align the rotor.
When 1, aligns rotor for counter
clockwise starting or,
When 0, aligns rotor for clockwise
starting.
Clears the filter buffer generally
when the motor is stopped.
A pulse of one clock cycle width
should be input each time the motor
stops.
50200659-2.06/16 Revision 2
12
UG0659: Encoder Interface User Guide
Signal Name
Direction
Description
sensor_reset_i
Input
Sensor Reset signal:
When set to 1, rotor angle is reset to
the equivalent of 90 degrees or 270
degrees as determined by the
direction_config_i input.
When set to 0 (zero), normal
operation.
qa_i
Input
Encoder input A
qb_i
Input
Encoder input B
speed_factor_i
Input
Speed output scaling multiplier (see
equation 2)
angle_factor_i
Input
Angle output scaling multiplier (see
equation 1)
angle_count_max_i
Input
Maximum angle count value in terms
of encoder pulse events. (see
equation 3)
speed_window_i
Input
The time window for speed
computation, specified in multiples
of 10 µs. Larger time window gives
better speed resolution but has
higher latency. Smaller time window
should be used for high dynamic
speed response.
filter_factor_i
Input
Filter factor value for filter – if value
is n, the filter time constant is 2^n
times the sampling time of the filter
defined by filt_trig_i.
dir_o
Output
Direction signal generated based on
encoder input signals.
omega_out_o
Output
Rotor speed output after filtering suitable for use as speed feedback in
speed control operation.
angle_out_o
Output
Electrical angle output suitable for
Field Oriented Control.
line_count_o
Output
Specifies the rotor position in terms
of number of encoder lines
(increments) since the last sensor
reset. Suitable for use with position
control operations.
50200659-2.06/16 Revision 2
13
UG0659: Encoder Interface User Guide
2.3
Configuration Parameters
Table 2 shows the description of the configuration parameters used in the hardware
implementation of Encoder interface. These are generic parameters and can be varied as per the
requirement of the application.
Table 2 Configuration Parameters
Signal Name
Description
g_STD_IO_WIDTH
Defines the bit length of data ports.
2.4
Resource Utilization
Encoder interface is implemented on the SmartFusion®2 system-on-chip (SoC) field programmable
gate array (FPGA) device. Table 3 shows the resource utilization report after synthesis with
g_STD_IO_WIDTH value equal to 18.
Table 3 Resource Utilization Report of Encoder Interface
Cell Usage
Count
SLE (Sequential)
246
Combinational Logic
641
MACC
2
RAM1Kx18
0
RAM64x18
0
50200659-2.06/16 Revision 2
14
UG0659: Encoder Interface User Guide
3
Product Support
Microsemi SoC Products Group backs its products with various support services, including Customer
Service, Customer Technical Support Center, a website, electronic mail, and worldwide sales offices.
This appendix contains information about contacting Microsemi SoC Products Group and using these
support services.
3.1
Customer Service
Contact Customer Service for non-technical product support, such as product pricing, product
upgrades, update information, order status, and authorization.
From North America, call 800.262.1060
From the rest of the world, call 650.318.4460
Fax, from anywhere in the world 650. 318.8044
3.2
Customer Technical Support Center
Microsemi SoC Products Group staffs its Customer Technical Support Center with highly skilled
engineers who can help answer your hardware, software, and design questions about Microsemi
SoC Products. The Customer Technical Support Center spends a great deal of time creating
application notes, answers to common design cycle questions, documentation of known issues and
various FAQs. So, before you contact us, please visit our online resources. It is very likely we have
already answered your questions.
3.3
Technical Support
For Microsemi SoC Products Support, visit http://www.microsemi.com/products/fpga-soc/designsupport/fpga-soc-support.
3.4
Website
You can browse a variety of technical and non-technical information on the Microsemi SoC Products
Group home page, at http://www.microsemi.com/products/fpga-soc/fpga-and-soc.
3.5
Contacting the Customer Technical Support Center
Highly skilled engineers staff the Technical Support Center. The Technical Support Center can be
contacted by email or through the Microsemi SoC Products Group website.
3.5.1
Email
You can communicate your technical questions to our email address and receive answers back by
email, fax, or phone. Also, if you have design problems, you can email your design files to receive
assistance. We constantly monitor the email account throughout the day. When sending your
request to us, please be sure to include your full name, company name, and your contact
information for efficient processing of your request.
The technical support email address is [email protected].
50200659-2.06/16 Revision 2
15
UG0659: Encoder Interface User Guide
3.5.2
My Cases
Microsemi SoC Products Group customers may submit and track technical cases online by going to
My Cases.
3.5.3
Outside the U.S.
Customers needing assistance outside the US time zones can either contact technical support via
email ([email protected]) or contact a local sales office. Visit About Us for sales office
listings and corporate contacts.
3.6
ITAR Technical Support
For technical support on RH and RT FPGAs that are regulated by International Traffic in Arms
Regulations (ITAR), contact us via [email protected]. Alternatively, within My Cases, select
Yes in the ITAR drop-down list. For a complete list of ITAR-regulated Microsemi FPGAs, visit the ITAR
web page.
50200659-2.06/16 Revision 2
16