MICROCHIP v4.2 Encoder Interface User Guide

June 13, 2024
MICROCHIP

Encoder Interface v4.2
User Guide

Introduction

(Ask a Question)
Incremental encoder is the most common sensor used for Field Oriented Control (FOC) of Permanent Magnet Brush Less 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 90°, 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.
The following figure shows the encoder signals in clockwise and counter- clockwise directions.
Figure 1. Encoder Signals in Clockwise and Counter-Clockwise DirectionsMICROCHIP v4.2 Encoder Interface - Counter-
Clockwise The following figure shows the edge detection of encoder pulses for higher resolution.
Figure 2. Edge Detection of Encoder Pulses for Higher ResolutionMICROCHIP v4.2 Encoder Interface - 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 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:MICROCHIP v4.2
Encoder Interface - configure the encoder interface

The following figure shows the Theta output for the positive direction.
Figure 3. Theta Output for Positive DirectionMICROCHIP v4.2 Encoder
Interface - Positive Direction The following figure shows the Theta output for the negative direction.

Figure 4. Theta Output for Negative DirectionMICROCHIP v4.2 Encoder
Interface - Theta Output for Negative Direction

Summary (Ask a Question)
The following table provides a summary of the Encoder Interface IP characteristics.

Core Version This document applies to Encoder Interface v4.2.
Supported Device Families • PolarFire®  SoC

• PolarFire
• RTG4™
• IGLOO® 2
• SmartFusion® 2
Supported Tool Flow| Requires Libero®  SoC v11.8 or later releases.
Licensing| Complete encrypted RTL code is provided for the core, enabling the core to be instantiated with SmartDesign. Simulation, Synthesis, and Layout can be performed with Libero software.
Encoder Interface is licensed with encrypted RTL that must be purchased separately. For more information, see Encoder Interface.

Features (Ask a Question)
Encoder Interface has the following key features:

  • Computes the relative angular position
  • Computes the filtered speed output

Implementation of IP Core in Libero Design Suite (Ask a Question)
IP core must be installed to the IP Catalog of the Libero® SoC software. This is done automatically through the IP Catalog update function in the Libero SoC software, or the IP core can be manually downloaded from the catalog.
Once the IP core is installed in the Libero SoC software IP Catalog, the core can be configured, generated, and instantiated within the SmartDesign tool for inclusion in the Libero project list.
Device Utilization and Performance(Ask a Question)
The following table lists the device utilization used for Encoder Interface.
Table 1. Encoder Interface Utilization

Device Details| Resources| Performance (MHz)| RAMs| Math Blocks| Chip Globals
---|---|---|---|---|---
Family| Device| LUTs| DFF| LSRAM| μSRAM
PolarFire® SoC| MPFS250T| 398| 285| 200| 0| 0| 2| 0
PolarFire| MPF300T| 387| 285| 200| 0| 0| 2| 0
SmartFusion® 2| M2S150| 400| 285| 140| 0| 0| 2| 0

Important:

  1. The data in this table is captured using typical synthesis and layout settings. CDR reference clock source was set to Dedicated with other configurator values unchanged.
  2. Clock is constrained to 200 MHz while running the timing analysis to achieve the performance numbers.

Functional Description

(Ask a Question)
The following figure shows the block diagram of encoder interface.
Figure 1-1. System-Level Block Diagram of Encoder InterfaceMICROCHIP
v4.2 Encoder Interface - 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. 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_factori value using the following equation:
**Filter time constant = Time period between successive pulses of pwm midmatch
i × 2 filter_factor_i**

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 90° or 270° 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.
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.

Encoder Interface Parameters and Interface Signals

(Ask a Question)
This section discusses the parameters in the Encoder Interface GUI configurator and I/O signals.

2.1 Inputs and Outputs Signals(Ask a Question)
The following table lists the input and output ports 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 Filter trigger input. A timing pulse of one clock cycle

width must be provided at this input. The periodicity of the pulse determines the sampling time.
direction_config_i| Input| 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.
clear_buffer_i| Input| Clears the filter buffer generally when the motor is stopped.
A pulse of one clock cycle width must be input each time the motor stops.
sensor_reset_i| Input| Sensor Reset signal:
When set to 1, rotor angle is reset to the equivalent of 90° or 270° 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
angle_factor_i| Input| Angle output scaling multiplier
angle_count_max_i| Input| Maximum angle count value in terms of encoder pulse events.
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 must 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.
speed_done_o| Output| Indicates speed computation is ready for filtering (at the end of speed window). A pulse of one sys_clk_i cycle width is generated.
speed_filter_done_o| Output| Indicates speed output after filtering is valid (at omega_out_o output port). A pulse of one sys_clk_i cycle width is generated.
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 FOC.
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.

Timing Diagrams

(Ask a Question)
This section discusses encoder interface timing diagram.
The following figure shows the timing diagram of encoder interface.
Figure 3-1. Encoder Interface Timing DiagramMICROCHIP v4.2 Encoder
Interface - Encoder Interface Timing Diagram

Testbench

(Ask a Question)
A unified testbench is used to verify and test Encoder Interface called as user testbench. Testbench is provided to check the functionality of the Encoder Interface IP.

4.1 Simulation(Ask a Question)
The following steps describe how to simulate the core using the testbench:

  1. Open Libero SoC, click Catalog tab, and then click Solutions-MotorControl.

  2. Double-click Encoder Interface and then click OK. The documentation associated with the IP are listed under Documentation.
    Important: If you do not see the Catalog tab, click View, open Windows menu, and then click Catalog to make it visible.
    Figure 4-1. Encoder Interface IP Core in Libero SoC CatalogMICROCHIP
v4.2 Encoder Interface - Libero SoC Catalog

  3. On the Stimulus Hierarchy tab, click the testbench ( encoder_interface_tb.v), point to Simulate PreSynth Design, and then click Open Interactively.

Important: If you do not see the Stimulus Hierarchy tab, click View, open Windows menu, and then click Stimulus Hierarchy to make it visible.

Figure 4-2. Simulating Pre-Synthesis DesignMICROCHIP v4.2 Encoder
Interface - Synthesis Design

ModelSim opens with the testbench file as shown in the following figure.

Figure 4-3. ModelSim Simulation Window![MICROCHIP v4.2 Encoder Interface

  • Simulation Window](https://manuals.plus/wp- content/uploads/2023/10/MICROCHIP-v4.2-Encoder-Interface-Simulation- Window.jpg)

Important: If the simulation is interrupted due to the runtime limit specified in the .do file, use the run -all command to complete the simulation.

Revision History

(Ask a Question)
The revision history describes the changes that were implemented in the document. The changes are listed by revision, starting with the most current publication.

Table 5-1. Revision History

Revision Date Description
A 03/2023 The following are the list of changes in revision A of the

document:
• Migrated the document to the Microchip template.
• Updated the document number to DS00004913A from 50200659.
• Added 3. Timing Diagrams.
• Added 4. Testbench.
3.0| —| The following is a summary of changes made in this revision:
• Added the IP version to the document title.
• Added speed_done_o and speed_filter_done_o output signals.
• Removed Configuration Parameter section from Hardware Implementation.
2.0| —| Updated the document with the new output signals.
1.0| —| Revision 1.0 was the first publication of this document.

Microchip FPGA Support

(Ask a Question)
Microchip FPGA products group backs its products with various support services, including Customer Service, Customer Technical Support Center, a website, and worldwide sales offices. Customers are suggested to visit Microchip online resources prior to contacting support as it is very likely that their queries have been already answered.
Contact Technical Support Center through the website at www.microchip.com/support. Mention the FPGA Device Part number, select appropriate case category, and upload design files while creating a technical support case.
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

Microchip Information

(Ask a Question)

The Microchip Website(Ask a Question)

Microchip provides online support via our website at www.microchip.com/. This website is used to make files and information easily available to customers. Some of the content available includes:

  • Product Support – Data sheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
  • General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip design partner program member listing
  • Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives

Product Change Notification Service(Ask a Question)
Microchip’s product change notification service helps keep customers current on Microchip products. Subscribers will receive email notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest.
To register, go to www.microchip.com/pcn and follow the registration instructions.

Customer Support(Ask a Question)
Users of Microchip products can receive assistance through several channels:

  • Distributor or Representative
  • Local Sales Office
  • Embedded Solutions Engineer (ESE)
  • Technical Support

Customers should contact their distributor, representative or ESE for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in this document.
Technical support is available through the website at: www.microchip.com/support

Microchip Devices Code Protection Feature(Ask a Question)
Note the following details of the code protection feature on Microchip products:

  • Microchip products meet the specifications contained in their particular Microchip Data Sheet.
  • Microchip believes that its family of products is secure when used in the intended manner, within operating specifications, and under normal conditions.
  • Microchip values and aggressively protects its intellectual property rights. Attempts to breach the code protection features of Microchip product is strictly prohibited and may violate the Digital Millennium Copyright Act.
  • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of its code. Code protection does not mean that we are guaranteeing the product is “unbreakable”. Code protection is constantly evolving. Microchip is committed to continuously improving the code protection features of our products.

Legal Notice(Ask a Question)

This publication and the information herein may be used only with Microchip products, including to design, test, and integrate Microchip products with your application. Use of this information in any other manner violates these terms. Information regarding device applications is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. Contact your local Microchip sales office for additional support or, obtain additional support at www.microchip.com/en-us/support/design-help/client-support- services.

THIS INFORMATION IS PROVIDED BY MICROCHIP “AS IS”. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE, OR WARRANTIES RELATED TO ITS CONDITION, QUALITY, OR PERFORMANCE.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE INFORMATION OR ITS USE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP’S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THE INFORMATION OR ITS USE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THE INFORMATION.
Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights unless otherwise stated.

Trademarks (Ask a Question)
The Microchip name and logo, the Microchip logo, Adaptec, AVR, AVR logo, AVR Freaks, BesTime, BitCloud, CryptoMemory, CryptoRF, dsPIC, flexPWR, HELDO, IGLOO, JukeBlox, KeeLoq, Kleer, LANCheck, LinkMD, maXStylus, maXTouch, MediaLB, megaAVR, Microsemi, Microsemi logo, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, PolarFire, Prochip Designer, QTouch, SAM-BA, SenGenuity, SpyNIC, SST, SST Logo, SuperFlash, Symmetricom, SyncServer, Tachyon, TimeSource, tinyAVR, UNI/O, Vectron, and XMEGA are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
AgileSwitch, APT, ClockWorks, The Embedded Control Solutions Company, EtherSynch, Flashtec, Hyper Speed Control, HyperLight Load, Libero, motorBench, mTouch, Powermite 3, Precision Edge, ProASIC, ProASIC Plus, ProASIC Plus logo, Quiet- Wire, SmartFusion, SyncWorld, Temux, TimeCesium, TimeHub, TimePictra, TimeProvider, TrueTime, and ZL are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, Augmented Switching, BlueSky, BodyCom, Clockstudio, CodeGuard, CryptoAuthentication, CryptoAutomotive, CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, Espresso T1S, EtherGREEN, GridTime, IdealBridge, In-Circuit Serial Programming, ICSP, INICnet, Intelligent Paralleling, IntelliMOS, Inter-Chip Connectivity, JitterBlocker, Knob-on-Display, KoD, maxCrypto, maxView, memBrain, Mindi, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PowerSmart, PureSilicon, QMatrix, REAL ICE, Ripple Blocker, RTAX, RTG4, SAM-ICE, Serial Quad I/O, simpleMAP, SimpliPHY, SmartBuffer, SmartHLS, SMART-I.S., storClad, SQI, SuperSwitcher, SuperSwitcher II, Switchtec, SynchroPHY, Total Endurance, Trusted Time, TSHARC, USBCheck, VariSense, VectorBlox, VeriPHY, ViewSpan, WiperLock, XpressConnect, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
The Adaptec logo, Frequency on Demand, Silicon Storage Technology, and Symmcom are registered trademarks of Microchip Technology Inc. in other countries.
GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.
©2023, Microchip Technology Incorporated and its subsidiaries. All Rights Reserved.
ISBN: 978-1-6683-2164-5

Quality Management System(Ask a Question)
For information regarding Microchip’s Quality Management Systems, please visit www.microchip.com/quality.

Worldwide Sales and Service

AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE

Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
www.microchip.com/support
Web Address:
www.microchip.com
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Tel: 317-536-2380
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Tel: 951-273-7800
Raleigh, NC
Tel: 919-844-7510
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Tel: 408-436-4270
Canada – Toronto
Tel: 905-695-1980
Fax: 905-695-2078| Australia – Sydney
Tel: 61-2-9868-6733
China – Beijing
Tel: 86-10-8569-7000
China – Chengdu
Tel: 86-28-8665-5511
China – Chongqing
Tel: 86-23-8980-9588
China – Dongguan
Tel: 86-769-8702-9880
China – Guangzhou
Tel: 86-20-8755-8029
China – Hangzhou
Tel: 86-571-8792-8115
China – Hong Kong SAR
Tel: 852-2943-5100
China – Nanjing
Tel: 86-25-8473-2460
China – Qingdao
Tel: 86-532-8502-7355
China – Shanghai
Tel: 86-21-3326-8000
China – Shenyang
Tel: 86-24-2334-2829
China – Shenzhen
Tel: 86-755-8864-2200
China – Suzhou
Tel: 86-186-6233-1526
China – Wuhan
Tel: 86-27-5980-5300
China – Xian
Tel: 86-29-8833-7252
China – Xiamen
Tel: 86-592-2388138
China – Zhuhai
Tel: 86-756-3210040| India – Bangalore
Tel: 91-80-3090-4444
India – New Delhi
Tel: 91-11-4160-8631
India – Pune
Tel: 91-20-4121-0141
Japan – Osaka
Tel: 81-6-6152-7160
Japan – Tokyo
Tel: 81-3-6880- 3770
Korea – Daegu
Tel: 82-53-744-4301
Korea – Seoul
Tel: 82-2-554-7200
Malaysia – Kuala Lumpur
Tel: 60-3-7651-7906
Malaysia – Penang
Tel: 60-4-227-8870
Philippines – Manila
Tel: 63-2-634-9065
Singapore
Tel: 65-6334-8870
Taiwan – Hsin Chu
Tel: 886-3-577-8366
Taiwan – Kaohsiung
Tel: 886-7-213-7830
Taiwan – Taipei
Tel: 886-2-2508-8600
Thailand – Bangkok
Tel: 66-2-694-1351
Vietnam – Ho Chi Minh
Tel: 84-28-5448-2100| Austria – Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark – Copenhagen
Tel: 45-4485-5910
Fax: 45-4485-2829
Finland – Espoo
Tel: 358-9-4520-820
France – Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Germany – Garching
Tel: 49-8931-9700
Germany – Haan
Tel: 49-2129-3766400
Germany – Heilbronn
Tel: 49-7131-72400
Germany – Karlsruhe
Tel: 49-721-625370
Germany – Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany – Rosenheim
Tel: 49-8031-354-560
Israel – Ra’anana
Tel: 972-9-744-7705
Italy – Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy – Padova
Tel: 39-049-7625286
Netherlands – Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Norway – Trondheim
Tel: 47-72884388
Poland – Warsaw
Tel: 48-22-3325737
Romania – Bucharest
Tel: 40-21-407-87-50
Spain – Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden – Gothenberg
Tel: 46-31-704-60-40
Sweden – Stockholm
Tel: 46-8-5090-4654
UK – Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820

© 2023 Microchip Technology Inc.
and its subsidiaries
DS00004913A

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

Related Manuals