<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Module 8: Speed Control in Model-Based Design Toolbox (MBDT)</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727476#M1570</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 22px;"&gt;&lt;SPAN style="color: #717171;"&gt;&lt;STRONG&gt;Electric Motors in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #717171;"&gt;&lt;STRONG&gt;Automotive – Speed Control Is Everywhere&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32047i7A29CAFA0750CB48/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;INTRODUCTION&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Permanent-magnet synchronous motors (PMSM) are widely used for many automotive applications due to their high torque, high power density and high efficiency.&amp;nbsp;In a typical modern car there are numerous functionalities that are driven by PMSM type of motors and most of these functionalities need to operate at various speed levels that must be controlled precisely. Besides car industry, there are many other areas of industrial control that require the motor speed control capabilities to ensure a proper system operation: just think about a&amp;nbsp;bottling factory conveyor belt system, or an airport walkway, or why not an car assembly line. All these would not be possible without an appropriate way to control various&amp;nbsp;motors speed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;The main topic of this 8th module of&amp;nbsp;&lt;/SPAN&gt;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/464336" rel="noopener noreferrer" style="color: #5e89c1; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox&lt;/A&gt;&amp;nbsp;is about PMSM Speed Controllers and how to build a reliable control system based on FOC that will perform under various load conditions and should be able to reject external disturbances that might occur in such systems.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The purpose of this article is to&amp;nbsp;build a closed loop speed control system based on position sensor feedback. The user will be able to set a speed reference and the control system implemented with the help of S32K14x MCU will drive the PMSM to&amp;nbsp;the command set point and will have to maintain it there until the user command changes. The control system shall deal with all system disturbances automatically by adjusting the FOC flux and torque commands to keep the rotor in synchronism and to operate at its optimal operating points.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In this module we are going to&amp;nbsp;describe how to:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Implement a speed and position estimator based on low-cost Hall effect sensors;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Regulate the motor speed by implemented a dedicated PI control system;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Interconnect Speed and Torque (developed in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;) modes of operations;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="border: 0px; color: #51626f; font-weight: inherit;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In Fig. 1, which represent the global application mapping diagram as discussed in&lt;/SPAN&gt;&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/465758" rel="noopener noreferrer" style="color: #5e89c1; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;Module 3: System Partitioning&lt;/A&gt;&amp;nbsp;,&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;are shown the new hardware blocks that are going to be configured and used to perform the PMSM Sensored Speed Control highlighted in green relative to the ones already configured so far in the previous modules of this workshop.&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;SPAN style="color: #333333;"&gt;This time we are going to configure the GPIO to generate interrupts each time the Hall sensors change their state allowing us to compute the rotor position and motor speed using a simple estimation approach based on counting the time between Hall transitions.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="border: 0px; color: #333333; font-weight: inherit;"&gt;Furthermore, we are going to reuse and enhance the model developed in&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;The interactions between host PC and hardware will be done via OpenSDA serial communication that will be used to download the code generated from MATLAB and to visualize various control signals with FreeMASTER. In addition, the user can start and control the motor speed from the SW2 and SW3 push buttons that are present on the&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.nxp.com%2Fproducts%2Fprocessors-and-microcontrollers%2Farm-based-processors-and-mcus%2Fs32-automotive-platform%2Fs32k144-evaluation-board%3AS32K144EVB" rel="noopener noreferrer" style="color: #2989c5; border: 0px; font-weight: inherit; text-decoration: none; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;S32K144 Evaluation Board|NXP&lt;/A&gt;&amp;nbsp;. A three color LED will be used to signal the control states and faults.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_11.png"&gt;&lt;IMG alt="pastedImage_11.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32048i7366E715E15F8389/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_11.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Fig. 1:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333; background-color: #ffffff; border: 0px; font-size: 13px; padding: 0px;"&gt;&amp;nbsp;Application Mapping -&amp;nbsp; new HW &amp;amp; SW modules&amp;nbsp;used for Sensored Speed Control&amp;nbsp;are highlighted in green&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;This example uses the HALL Sensors to implement a simple position estimator. The usage of HALL Sensors should not be mistaken with 6-step commutation technique used to control the BLDC. In this case the HALL sensors are used just for estimation and correction of the electric angle used for FOC&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;CLOSED LOOP SPEED CONTROL SYSTEM&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The Speed Control system requires the actual/real motor speed in order to perform the calculation for finding the appropriate value for the Torque reference (Iq*) used to&amp;nbsp;accelerate or&amp;nbsp;decelerate the PMSM rotor so that the real speed is maintained as closed as possible within the user specified range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In Fig. 2, is shown the block diagram of&amp;nbsp;a typical closed loop speed control system proposed for implementation. The control system is made of two cascaded loops that use information about currents and rotor position to regulate the PMSM rotor speed to a desired set point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;DIV class="" style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; font-weight: inherit; margin: 0px 0px 2px;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit; font-weight: inherit;"&gt;&lt;TR style="font-weight: inherit; height: 346px;"&gt;&lt;TD style="padding: 5px; text-align: center; height: 346px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;IMG alt="pastedImage_7.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32049iB95AC4794D415E61/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; height: 25px;"&gt;&lt;TD style="padding: 5px; text-align: center; height: 25px;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 13px;"&gt;Fig. 2:&amp;nbsp;Closed loop speed control system - Block Diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;The Field Oriented Control shown in Fig. 3, is computed in the FAST CONTROL LOOP block that is executed based on a ADC triggers at each 100 microseconds. This subsystem receives the reference values for currents in Q (torque) and D (flux) axis and use as feedback the Ia,Ib and Ic currents measured from the ADC that are transformed from the fixed reference frame (abc) to the orthogonal rotating frame (dq) based on the angle&amp;nbsp;&lt;/SPAN&gt;θ provided from position sensors and PARK and CLARKE transformations. The FAST CONTROL LOOP outputs via the Space Vector Modulation technique the&amp;nbsp;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;PWM duty cycles commands that control the 3-phase inverter which applies the corrective voltages directly to the PMSM windings.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_12.png"&gt;&lt;IMG alt="pastedImage_12.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32066i6B05860F30322995/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_12.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 3: Field Oriented Control -&amp;nbsp;Block diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;For flexibility, the actual electric angle&amp;nbsp;θe used in FOC calculations is derived from the position sensor measurements and estimations based on application software configuration global variables: MODE and CONTROL TYPE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;CONTROL TYPE&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;global variable allows users to choose between:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;SPEED CONTROL = 1 that performs the closed loop speed control based on sensor feedback&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;TORQUE CONTROL = 0 that performs the control system designed in&lt;/SPAN&gt;&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The TORQUE CONTROL operation is very important at this time because it will allows us to perform various tests with the speed and position estimator prior of closing the&amp;nbsp;speed control loop.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The second global variable,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;MODE&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is generated internally by the software algorithm and it is used to control the motor startup process and zero crossing during change of rotation direction. Since we are dealing with an estimator we need to cope with low speed ranges and 0 crossing when changing the motor speeds from clockwise (CW) to counter clockwise (CCW) directions. This variable has three possible values (see Fig. 27 for a graphical representation):&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;FORCE MODE = 0 where the motor is control in open loop with an imposed electric angle reference&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;TRACKING MODE = 1 where the motor is still control in open loop but the speed controller will act in parallel to charge the integral part in order to deal with handover from open to closed loop transition&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;SENSOR/SENSORLESS MODE = 2 where the motor operates as a closed loop system and the electrical angle is derived from the actual rotor position sensors.&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;We will discuss about the importance of these modes in the next workshop modules where we will focus on SENSORLESS control system.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Furthermore,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;t&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;he Toque (Iq*) and Flux (id*) references are computed in the SLOW CONTROL LOOP block that is triggered at each 1 millisecond based on the same ADC events.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The block diagram of the SLOW CONTROL LOOP is shown in Fig. 4. As can be seen, the same software configuration based on MODE and CONTROL TYPE is used here as well to select between TORQUE and SPEED control types.&amp;nbsp;The speed commands&amp;nbsp;&lt;SPAN style="color: #404040;"&gt;ω*&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are received via the UART or from on board push buttons and&amp;nbsp;feed into a PI controller together with the actual rotor speed feedback&amp;nbsp;&lt;SPAN style="color: #404040;"&gt;ω. The PI Speed Controller implements a standard Simulink PI parallel controller that takes as input the error between the speed set point and the actual rotor speed and computes the appropriate torque command Iq* that compensates for the speed error.&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;IMG alt="pastedImage_2.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32067i6D11E0643B463F9E/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 4: Closed Loops Speed Control - Block diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;As can be seen in Fig. 2, Fig. 3 and Fig. 4 the key information needed for speed closed loop control is the actual rotor position information. Therefore, lets see how can we obtain such information.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;SPEED &amp;amp; POSITION ESTIMATOR&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;In general for an accurate closed loop speed control system we need to have a dedicated position (optical encoder or resolver)&amp;nbsp; or speed (tachometer) sensors that can provide relative or absolute rotor position information. Unfortunately many of these sensors are expensive and require additional dedicated hardware and PCB space for signal conditioning or may of them need dedicated software routines to allow data read outs.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Fortunately, most of the motors can be equipped with low resolution Hall-effect sensors that are very cheap and widely used in many PMSM based applications. In general three Hall sensors are used in one PMSM to&amp;nbsp;provide the rotor position with a coarse resolution of 60 electrical degrees. A detailed description&amp;nbsp;about how Hall-effect sensors operates can be found in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/453198" rel="noopener noreferrer" target="_blank"&gt;Motor Control Class: Lecture 5 - Hall Sensors&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;In case of the&amp;nbsp;&lt;A href="https://www.nxp.com/support/developer-resources/hardware-development-tools/ultra-reliable-mcus-development-platform/low-cost-motor-control-solution-for-devkit-platform:DEVKIT-MOTORGD" rel="nofollow noopener noreferrer noopener noreferrer" style="color: #2989c5; text-decoration: none;" target="_blank"&gt;DevKit MotorGD&lt;/A&gt;&amp;nbsp;the Hall sensors are connected via JP1 connector on the motor shield as shown in Fig. 5. The JP1 connector provides 5V power supply to the motor Hall sensors and reads back the digital signals in range of 0 - 5V.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_72.png"&gt;&lt;IMG alt="pastedImage_72.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32073i4BA46BF566BEC6E5/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_72.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 5: DevKit MotorGD pins used for Hall sensors&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;The signals from Hall sensors are then sent to the S32K144 Evaluation board via the J5 header as shown in Fig. 6 and the S32K MCU will read those from the PTA15, PTA16 and PTA1 digital inputs pins.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_592.png"&gt;&lt;IMG alt="pastedImage_592.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32075i57CFEE5AA7C913E3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_592.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 6: S32K144 Evaluation Board MCU Signal Assignment&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Getting the actual values of the Hall signals is a piece of cake when using the NXP Model-Based Design tools. Using a simple digital input block you can read each hall signal individually and store it in a global variable as shown in Fig. 7.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_669.png"&gt;&lt;IMG alt="pastedImage_669.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32079i3040063893EEA885/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_669.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 7: Simulink model for reading the Hall Sensors with S32K14x MCU&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;On S32K14x Evaluation Board these signals are inverted. To get the same logic value as the true Hall input we need to invert the acquired value in software.&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Using the Simulink model shown in Fig. 7 we can read the Hall signals variation in time for a PMSM rotating at a constant speed. Fig. 8 shows the three Hall signals that are phase out with 120 electrical degrees in between each other while each hall signal is ON/OFF for 180 electrical degrees.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32080i4D202D60DB2384A2/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 8: HALL sensors signals&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Based on these considerations, it is easy to understand that for each 360 electrical degrees (THETA) we will have six Hall sensor transitions as shown in Fig. 9. These six transitions give us the possibility to measure the position of the PMSM rotor with an accuracy of 60 electrical degrees for any speed range.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_13.png"&gt;&lt;IMG alt="pastedImage_13.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32083iA058551DAA6C72EC/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_13.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 9: Hall sensors transitions versus one complete electrical rotation (-pi: pi) radians&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Speed Estimation Based on Hall Sensors Transitions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Since we know how many radians are between two consecutive Hall sensors transitions, we can easily compute the speed of the motor as:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 88.5048%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;IMG alt="pastedImage_2.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32086iD1B4F1505F327D54/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 10%;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: right;"&gt;Eg. 1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Therefore, reading the value of&amp;nbsp;a&amp;nbsp;timer/counter on each hall transition should give us an accurate information about how fast the rotor is spinning, right ?&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In Fig. 10 we have captured such use-case. On the top of the figure we have the Hall sensors variation captured as a Hall sSector representation in decimal form and on the bottom we have the timer values for each Hall sensors transitions. In this capture you can see that even if the motor is commanded to spin in torque control at constant speed the time counted between consecutive hall transitions presents a variation.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32088i8053AD58CA0B4EB3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 10: Hall sector change timings&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;This variation is mainly cause by the undefined&amp;nbsp;installation error of the three hall sensors which are not at a perfect 120 electrical degrees apart of each other.&amp;nbsp;If we would try to build a speed estimator based on this approach we will have to deal with a lot of variations that are induced by this poor mechanical hall installation that might vary from one motor to the other.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In Fig.11 is shown the speed estimation results in case of counting the time between each hall sensors transitions. In this case the motor was commanded to spin in Torque Control at a constant 1000 rpm demanded speed using open loop control. As you can see the estimated speed (SPEED_FBK blue) has a large variation around the set point.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_272.png"&gt;&lt;IMG alt="pastedImage_272.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32091i0C8CC31AC00C9BCE/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_272.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 11: Speed estimation by counting the time between each hall sensor transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Such speed estimation signal may be filtered out but to smooth down such large variations it might required a large sample data as history and that may introduce phase delays in the final closed loop control system that may create control system instability. Therefore it must be a different way - a better one!&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;After analyzing the system response we have reached to the conclusion that would be better to count the time between a single hall transitions over 360 electrical degrees. This way we can get rid of additional sources of errors that might affect the speed estimator like:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;wrong placement of the hall sensor near a stator coil that might interfere with rotor magnetic flux&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;misalignment of rotor permanent magnets that might influence the North vs South magnetic poles spread&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The new Simulink model that is supposed to handle this scenario is shown in Fig. 12. Each time there is transition from HIGH to LOW on the HALL C (is has been selected since from PCB point of view it is all the time routed to the MCU)&amp;nbsp;the new estimated speed is getting computed.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; width: 99.8747%;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 838px;"&gt;&lt;TD style="text-align: center; width: 100%; height: 838px;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32094iF7EDDD28ABEA7EB1/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32119i60A81AA872512A15/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 12: Simulink model used to compute the estimated speed based on one hall signal transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;The formula implemented in the Compute Estimated Speed block is based on:&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 85.3336%;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_11.png"&gt;&lt;IMG alt="pastedImage_11.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32172i8AE1166621089865/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_11.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="font-size: 22.0pt;"&gt;&lt;SPAN style="font-size: 15px;"&gt;∆t&lt;/SPAN&gt;&lt;SPAN style="font-size: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;is the time passing between 2 transitions of Hall C signal or 360 electrical degrees.&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;pp is the motor pole pairs&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;0.0001 is the fast loop sampling time of 100 usec since the TIME_CNT is incremented in that loop&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD style="width: 11.6664%; text-align: right;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eq. 2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Using this approach we can estimate the actual motor speed far more cleaner that before. Fig. 13 shows the estimation results in the same conditions&amp;nbsp;as the one from Fig. 11.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; width: 99.9136%; border-width: 1px; border-color: #ffffff;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 100%; text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_15.png"&gt;&lt;IMG alt="pastedImage_15.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32176iD99D66EF9E1DF520/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_15.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 100%; text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 13:&amp;nbsp;Speed estimation by counting the time between one Hall signal transitions over 360 electrical degrees&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The dynamic results of the Speed Estimator are shown in Fig. 14 and Fig. 15 for startup and change of direction with zero crossing.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; width: 99.8747%;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="text-align: justify;"&gt;&lt;TD style="text-align: center; width: 100%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_19.png"&gt;&lt;IMG alt="pastedImage_19.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32177i9157F57C086B29CA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_19.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="text-align: justify;"&gt;&lt;TD style="text-align: center; width: 100%;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 14: Top: Reference (green) vs Estimated (red) Speeds, Bottom: Speed error between the reference and estimated speeds during motor startup&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;As can be seen, we have an expected larger error at startup until the motor starts to move constantly. Then during acceleration and steady state regime the error between the reference and estimated values are quite small +/-20 rpm which I think is quite good for this kind of approach relative to solution costs.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_23.png"&gt;&lt;IMG alt="pastedImage_23.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32181i3B4ADC54A7CC99E7/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_23.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 15:&amp;nbsp;Top: Reference (green) vs Estimated (red) Speeds, Bottom: Speed error between the reference and estimated speeds during&amp;nbsp;change of direction with zero crossing&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;At this point I think we can say the speed estimator based on a single Hall sensor signal transitions is accurate enough for our purpose. The next question that rise now is: how to obtain the electrical angle that is used for FOC transformations that ultimately controls the rotor position?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Position Estimation Based on Hall Sensors Transitions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;For FOC, the 60 electrical degrees resolution is not good enough to control the rotor position using sinusoidal control approuch. We will need to find a way to improve this accuracy in order to be able to reuse the Hall sensor information for PMSM sinusoidal control.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;With the PMSM rotating&amp;nbsp;at a constant speed like Fig.&amp;nbsp;16 shows, the Hall&amp;nbsp;sensors values change regularly.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_21.png"&gt;&lt;IMG alt="pastedImage_21.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32182iA88B00D057786D24/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_21.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 16: Hall sensors changing at constant speed - comparison between hall change (black), hall sector (blue)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;and open loop electric angle (red)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Any&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;changes of Hall sensors value could be captured by the&amp;nbsp;MCU via dedicated GPIO Interrupts&amp;nbsp;and then the&amp;nbsp;software application could&amp;nbsp;reads the three Hall sensors values to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;judge in which section edge the rotor is. The Simulink model that implements the Hall sensors change capture is shown in Fig. 17. As can be seen, dedicated GPIO ISR blocks are used to trigger a subsystem execution each time the Hall sensor changes its state LOW to HIGH or HIGH to LOW.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #FFFFFF;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32186iC128F3C32216E475/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 17: Simulink model for capturing the Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;For instance, when the MCU captures a Hall sensor value changing&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;from 110&amp;nbsp;to 010 then it is easy to know that θ is equal with 60 electrical degrees apart of phase A magnetic axis. The whole 360 electrical degrees spectrum can be divided into&amp;nbsp;six&amp;nbsp;areas, each one spreading over 60 electrical degrees. This concept was discussed in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/466420" rel="noopener noreferrer" target="_blank"&gt;Module 4: Space Vector Modulation&lt;/A&gt;&amp;nbsp;during Space Vector Modulation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 292px;"&gt;&lt;TD style="height: 292px; text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32187i5014262A6796B75A/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px; text-align: center;"&gt;&lt;SPAN&gt;Fig. 18: Hall sensors&amp;nbsp;states vs. PMSM rotor angle&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Using only the six Hall sensors transitions we can build a simple model to estimate the rotor position with a resolution of 60 electrical degrees as shown in Fig. 19.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 445px;"&gt;&lt;TD style="text-align: center; height: 445px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_10.png"&gt;&lt;IMG alt="pastedImage_10.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32191iDD0D261568B3D889/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_10.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="text-align: center; height: 25px;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 19:&amp;nbsp;Coarse&amp;nbsp;estimated rotor position (green) vs. Ideal rotor position (red) when using Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;But how to estimate the rotor angle within&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;these six sections is an important problem which can be solved by using the estimated speed. Looking at the Fig. 18, we can see that the rotor position can be approximated quite precisely in case we know how fast the PMSM rotates.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;In FOC algorithm, the rotary speed of last 360 electrical degrees section is used to predict the rotor position for the next 60 electrical degrees section now which of course implies that the speed used until next Hall changes is not the real speed at the present moment.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 87.9862%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_15.png"&gt;&lt;IMG alt="pastedImage_15.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32226i925D78085E6B2086/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_15.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 10.1124%; text-align: right;"&gt;Eq. 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The predicted rotor&amp;nbsp;angle may&amp;nbsp;contains&amp;nbsp;errors if the motor speed is not constant, (e.g.: the PMSM is accelerating or decelerating). So&amp;nbsp;the electrical angle estimation result may have some deformity when the PMSM speed is fluctuating.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The&amp;nbsp;coarse estimated rotor position shown in green within Fig. 19, can be easily computed with a simple SWITCH in Simulink as shown in Fig. 20.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_16.png"&gt;&lt;IMG alt="pastedImage_16.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32227iC2F5375FD229D08F/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_16.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 20: Simulink model used to compute the&amp;nbsp;coarse rotor position with 60 electrical degrees resolution based on Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;This is a simple implementation that assumes a specific Hall switching pattern as shown in Fig. 19. For any other motor this part of the model must be updated.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;The position angle increment computation is shown in Fig. 12 and is computed in the same time with the estimated&amp;nbsp; speed as a simple multiplication with a scaling factor from rpm to rad/s and of course the sampling time of the fast loop&lt;BR /&gt;where the Hall transitions timer is incremented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Applying all these knowledge we can compute a more accurate rotor position based on actual Hall sensors transitions and the estimated speed of the PMSM. Fig. 21 shows a comparison between the ideal rotor position (THETA) and the predicted position (THETA_CORRECTED) based on the algorithm discussed above.&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_21.png"&gt;&lt;IMG alt="pastedImage_21.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32238i6A21105248949CFA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_21.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 21: PMSM rotor position comparison:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(red) represents the ideal rotor position which is imposed in open loop Torque Control&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(green) represents the coarse estimated rotor position with a 60 electrical degrees resolution based on Hall sensors transitions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(blue) represents the rotor predicted position based on Eq. 3 that includes the speed prediction&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;If we check the Fig. 21, we can spot a few things that needs to be addressed:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px; text-align: justify;"&gt;the predicted position (blue) must be scaled to be withing the (-pi:pi) radians range.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px; text-align: justify;"&gt;compensate the offset between ideal (red) and predicted (blue) positions&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The first issue can be easily&amp;nbsp;addressed in software and Fig. 22&amp;nbsp;shows how to deal with&amp;nbsp;such aspects in Simulink.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_184.png"&gt;&lt;IMG alt="pastedImage_184.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32239i6A83171BF6EAFAB6/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_184.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 22: Bounding the estimated rotor position to (-pi:pi) radians using standard Simulink blocks&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Regarding the second issue, the things are a bit more complicated than they seems and to explain it, we need to have a deeper understanding of the PMSM internals: phase voltage, back-emf and Hall sensor mounting. Lets discuss all these in the next section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Phase Lag and&amp;nbsp;Phase-Angle Advance Compensation&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;One of the most important control system design challenges is the phase lag between the commanded phase voltage impose via SVM and the resultant sine-wave phase current for that naturally occurs in an PMSM/BLDC&amp;nbsp;motor. The&amp;nbsp;PMSM&amp;nbsp;can operate satisfactorily, but the overall efficiency will be reduced (as shown in Fig. 39&lt;SPAN style="color: #333333;"&gt;)&lt;/SPAN&gt;, defeating much of the purpose of implementing a&amp;nbsp;FOC control scheme that by definition should drive the motor at its optimal operating point.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The source of this inefficiency is&amp;nbsp;not&amp;nbsp;the phase lag between motor phase voltage and phase which some might think but rather the phase lag between phase current and the induced back-EMF voltage as it is shown in Fig. 23.&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The Hall sensors&amp;nbsp;are mounted in such way that when the induced back-EMF reaches its maximum value a Hall transition will happen. In this case, since we can measure directly the back-EMF with our model, it is safe to assume that back-EMF is synchronized with Hall transitions.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32241iE903C05A8DBEBEED/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 23: Phase lag between phase voltage (U_A_Ref) and phase current (Ia) and the Hall A transitions that are synchronized with back-EMF in phase A&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In order to eliminate this lag between the back-EMF (Hall A) and the phase current (Ia) we need to&amp;nbsp;introduce a phase-angle advance to the sinusoidal drive current to ensure its peak coincides with that of the back EMF (Hall transition). This phase-angle advance can be easily deducted based on the FreeMASTER recorded captures and in my case it seems to be 1/6 from a Hall half period (the dotted areas) which can be translated in a pi/6 radians or 30 electrical degrees.&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;In general, the phase-angle advance is typically set to increase linearly with the&amp;nbsp;phase command voltage, which determines the motor speed. Since our scope is to introduce general concepts and show how to implement them with Simulink rather than building a dedicated speed control system targeted for a particular motor - in this module we are going to use a constant electrical angle offset to compensate for this lag and drive the motor to its peak efficiency within a specific speed range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Depending on your application you might need to consider this aspect.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;The compensation of the electrical angle (Fig. 24) for clockwise and counter clockwise direction is implemented on the slow control loop and uses constant offsets that are added to the corrected electrical angle as shown in Fig. 21.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32243iA7C47FC4E173F09D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 24: Electric angle offset calculation for phase lag compensation&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;By using all these tricks we should be able to predict the rotor position quite accurately in both clockwise or counter clockwise directions as shown in Fig. 25 and Fig. 26.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_22.png"&gt;&lt;IMG alt="pastedImage_22.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32245i779D6A61E2C8A193/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_22.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 25: PMSM rotor position corrected (blue) with phase-angle advance of 30 electrical degree for clockwise direction&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_288.png"&gt;&lt;IMG alt="pastedImage_288.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32308i059D7E77BF94E443/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_288.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 26: PMSM rotor position corrected (blue) with phase-angle advance of 30 electrical degree for counter clockwise direction&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Fig. 26 shows a 180 degrees angle shift between the coarse angle obtained from Hall sensors (green) and the electrical angle corrected due to the mechanism used for calculations. To keep the same algorithm implementation for both directions, the corrected angle is shifted in software with (pi-pi/6) radians&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;As can be seen in both Fig. 25 &amp;amp; 26, there is a small jitter present on the predicted rotor position which is due to keeping the same angle increment over 360 electrical degrees and small variations with the estimated speed, but that should not be an issue for the control system.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Overall, taking into account the accuracy of predictions for both speed and position on one hand side and the cost of such basic type of sensors we can conclude at this point that this kind of method is quite suitable for motor control applications.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;SPEED CONTROL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Before we start to implement the speed controller that take governance over the system, we need to clarify a few things. As has been demonstrated before (Fig. 14 &amp;amp;15) such speed and position estimators work quite well in steady state regime and pose some design challenges when dealing with dynamic regimes due to their intrinsic algorithm that use previous states as a base for estimating the new values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Taking into account these factors we need to consider:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;startup process - where due to lack of Hall pulses is quite difficult to accurately predict the rotor position and that might lead to oscillations an possible lost of synchronism.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;zero crossing - is somehow similar with startup process in terms of missing the accuracy in hall transitions but we also need to consider the behavior of the PI type controllers that needs to empty the integral part in order to change direction. To have a smooth transition thru 0 we will need to offload the integral sum or at least to provide a mechanism to allow the controller to accommodate the change in directions.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;In industry there are&amp;nbsp;two main techniques to cope with such situations:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;STRONG&gt;BLDC Startup&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- at low speed the control is switch from FOC (sinusoidal) to 6-step commutation BLDC (trapezoidal) and only when the speed is high enough the control is switch back to FOC sinusoidal. Such type of control adds additional software complexities since we need to change the PWM strategy on the fly.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;STRONG&gt;Force&amp;nbsp;Startup&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- for a selected speed range the motor is driven in open loop by imposing a constant electric angle increment. The transition to closed loop is then made via a second region called Tracking Region where the Speed Controller works in parallel with the Open Loop control allowing enough time to accumulate the integral term in order to have a smooth transition from open to closed loop.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Depending on your application requirements you may choose between one or the other method. For this module we are going to implement the Force Startup since it is more common and less complex than the BLDC Startup. If you are interested in BLDC control theory you may want to check&amp;nbsp;&lt;A href="https://community.nxp.com/thread/450817" rel="noopener noreferrer" target="_blank"&gt;BLDC Motor Control with Model Based Design&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Fig. 27 shows the speed range partitioning for the Force Startup approach.The speed limits are available for changing in the Model Workspace associated with the Simulink Model File.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32311i3E5B02B0992F02BA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 27: Force Startup speed zones and speed limits between transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The Simulink model is built to take into consideration these transitions and change the Speed Feedback (SPEED_FBK) and Electric Angle (THETA) used for FOC according with the speed area in which the motor operates. In order to accommodate this mechanism some changes had to be made to both SLOW and FAST LOOP Subsystems.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;IMG alt="pastedImage_3.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32423i80B89314D9C6BCDB/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_3.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 30: FAST CONTROL LOOP Simulink Model: Note the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Rotor Position&lt;/STRONG&gt;&amp;nbsp;subsystem that computes the angle needed for PARK transformations.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32431i2EDA2040DD725A7F/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 31: Rotor Position Conditioning for addressing all application use-cases:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Speed Control vs. Torque Control&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Open Loop vs. Closed Loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Normal Operations vs. Rotor Alignment&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The actual speed control is implemented as normal in the slow loop using the Simulink model shown in Fig. 32.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33430i12086F5DC2866919/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 32: SLOW LOOP CONTROL Simulink Model&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The speed is regulated with the help of standard parallel form PI controller that is setting the motor torque reference&amp;nbsp; IQ_REF based on the error between the SPEED_REF computed as the output of the RAMP block and the actual motor speed estimated from HALL C sensor transitions (SPEED_FBK). The controller output is limited in order to avoid a high current thru the motor and anti-windup based on clamping strategy is enabled.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32527iE8D8FEF8103780F2/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 33: PI Speed Controller implementation with additional signal conditioning for handling startup and zero crossing&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The final model used for closed loop speed control is shown in Fig. 34. This model is more or less universal and represent the basic form of any speed control system based on Field Oriented Control and cascaded loops for dealing with electrical and mechanical parts of the PMSM or any motor in general.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32528iCE788F3C41C295FD/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 34: Simulink model of the Closed Loop Speed Control system for PMSM with S32K14x MCU&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;RESULTS and CONCLUSIONS&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The PI speed controller was tuned manually for the best results. If you prefer a more rigorous mathematical approach then you can check&amp;nbsp;&lt;A href="https://community.nxp.com/thread/455225" rel="noopener noreferrer" target="_blank"&gt;Motor Control Class: Lecture 11 - Closed Loop Control&lt;/A&gt;&amp;nbsp;that explains the theory behind pole placement method starting from motor transfer function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The next figures shows the closed loop system response under various conditions. Fig. 35 &amp;amp; 36 shows the system response during startup and various speed levels. Note how the PI speed controller is able to maintain the rotor speed with very good precision with a narrow band of less that +/- 100 rpm during accelerations, decelerations and steady-state regimes.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32529i114231CBB3C8E88D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 35: System startup: TOP- reference vs. actual motor speed [rpm], MIDDLE - speed error [rpm], BOTTOM - PI Speed Controller output torque reference [Amps]&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;IMG alt="pastedImage_7.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32530i5F93F8A6D1D9AF66/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 36: Field Oriented Control algorithm responses for the profile shown in Fig. 36&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- TOP 2 graphs: Q Axis Torque Controller inputs (IQ_REF, IQ) and output voltage command (UQ_REF)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- BOTTOM 2 graphs: D Axis Flux Controller inputs (ID_REF, ID) and output voltage command (UD_REF)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Fig. 36, demonstrates how the current controllers operates under acceleration and deceleration regimes. Note how the D-axis current controller is adjusting the control voltage in D-axis to compensate for additional back-EMF in oder to keep a zero magnetization current ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Fig. 37, shows the system response during startup and change of direction. Note how the handover is done between closed loop and open loop control strategies and how the rotor stops for a moment when changing directions.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32531i4F1F297D9224F8B6/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 37: Motor Startup and Zero Crossing (same quantities as in Fig. 35)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all the results above were perform under no load conditions, the Fig. 38, shows the system response under the effect of disturbances. The motor is kept at a constant 2000 rpm speed level when suddenly random load torque are applied on the rotor shaft. The Speed Controller reacts very quickly increasing the demanded torque to compensate for the lost in speed.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32532i50C79249751C86CB/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 38: Speed Controller perturbation rejection&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Another interesting aspect that relates to FOC efficiency is shown in Fig. 39, where is presented the effect of phase angle compensation offset over the motor torque. By changing the value of the compensation, the motor is still able to maintain the desired speed profile within the same limits but this time with a larger current needed for producing the appropriate torque to spin the rotor. This demonstrate how important is the rotor position in FOC. A small 30 degrees deviations and the torque demanded is almost 3 times higher to maintaining the same conditions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32533iBF7F30B1E2392113/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(a)&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;IMG alt="pastedImage_3.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32535i9FBEA62ADC11BFF9/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_3.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(b)&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32536i2DAB19749DB5F210/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(c)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 39: Phase angle compensation offset influence over FOC efficiency for the same speed profile and load:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(a) pi/6 offset (as computed from Fig. 23 results), torque current is ~0.75Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(b) arbitrary 15 degrees off the optimal point, torque current is ~1.2Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(c) arbitrary 30 degrees off the optimal point, torque current is ~2.5Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We hope you have found plenty of useful information in this module that will allow you to build your own speed control system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update revisions:&lt;/P&gt;&lt;P&gt;March 19, 2018&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;insert a note to clarify the usage of HALL Sensors as a simple alternative for a position sensors&lt;/LI&gt;&lt;LI&gt;update Fig. 32&lt;/LI&gt;&lt;LI&gt;update the M8.zip model. This Simulink model is tuned for the LINIX 45ZWN24-40 motor as part of&amp;nbsp;&lt;A class="link-titled" href="https://www.nxp.com/products/power-management/motor-drivers/h-bridges/3-phase-pmsm-development-kit-with-nxp-s32k144-mcu:MTRDEVKSPNK144" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="https://www.nxp.com/products/power-management/motor-drivers/h-bridges/3-phase-pmsm-development-kit-with-nxp-s32k144-mcu:MTRDEVKSPNK144"&gt;S32K144 3-phase PMSM Development Kit|NXP&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #800000; background-color: #ffffff; border: 0px; font-weight: bold;"&gt;&lt;STRONG&gt;Update January 28th 2019 -&amp;nbsp;&lt;SPAN style="background-color: #ffffff; border: 0px; font-weight: inherit;"&gt;This&amp;nbsp;Simulink model is now available on MATLAB 2018b and MBDT for S32K14x 2018.R1 release&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff;"&gt;Before using the new models make sure you apply all the hot-patches from here:&amp;nbsp;&lt;/SPAN&gt;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/489947" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;HotFix: MBD Toolbox 2018.R1 for S32K&lt;/A&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: 16px;"&gt;&lt;STRONG&gt;Update revisions&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 11.5pt;"&gt;March&amp;nbsp;18, 2019&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px 0.0001pt;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;update the model&amp;nbsp;to work with&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="102" href="https://community.nxp.com/docs/DOC-342724" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; font-size: 16px; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;&lt;SPAN style="color: blue; border: 0px; font-weight: inherit; font-size: 16px;"&gt;Model-Based Design Toolbox for MPC57xx Automotive Version 3.0.0&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; .&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 11.5pt;"&gt;May 06, 2020&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px 0.0001pt;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;update the model&amp;nbsp;to work with&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="102" href="https://community.nxp.com/docs/DOC-346265" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; font-size: 16px; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;&lt;SPAN style="color: blue; border: 0px; font-weight: inherit; font-size: 16px;"&gt;Model-Based Design Toolbox for MPC57xx Automotive Version 3.2.0&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; .&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 14:02:56 GMT</pubDate>
    <dc:creator>Daniel_Popa</dc:creator>
    <dc:date>2020-11-02T14:02:56Z</dc:date>
    <item>
      <title>Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727476#M1570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 22px;"&gt;&lt;SPAN style="color: #717171;"&gt;&lt;STRONG&gt;Electric Motors in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #717171;"&gt;&lt;STRONG&gt;Automotive – Speed Control Is Everywhere&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32047i7A29CAFA0750CB48/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;INTRODUCTION&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Permanent-magnet synchronous motors (PMSM) are widely used for many automotive applications due to their high torque, high power density and high efficiency.&amp;nbsp;In a typical modern car there are numerous functionalities that are driven by PMSM type of motors and most of these functionalities need to operate at various speed levels that must be controlled precisely. Besides car industry, there are many other areas of industrial control that require the motor speed control capabilities to ensure a proper system operation: just think about a&amp;nbsp;bottling factory conveyor belt system, or an airport walkway, or why not an car assembly line. All these would not be possible without an appropriate way to control various&amp;nbsp;motors speed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;The main topic of this 8th module of&amp;nbsp;&lt;/SPAN&gt;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/464336" rel="noopener noreferrer" style="color: #5e89c1; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox&lt;/A&gt;&amp;nbsp;is about PMSM Speed Controllers and how to build a reliable control system based on FOC that will perform under various load conditions and should be able to reject external disturbances that might occur in such systems.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The purpose of this article is to&amp;nbsp;build a closed loop speed control system based on position sensor feedback. The user will be able to set a speed reference and the control system implemented with the help of S32K14x MCU will drive the PMSM to&amp;nbsp;the command set point and will have to maintain it there until the user command changes. The control system shall deal with all system disturbances automatically by adjusting the FOC flux and torque commands to keep the rotor in synchronism and to operate at its optimal operating points.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In this module we are going to&amp;nbsp;describe how to:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Implement a speed and position estimator based on low-cost Hall effect sensors;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Regulate the motor speed by implemented a dedicated PI control system;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: inherit; margin: 0.5ex 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;Interconnect Speed and Torque (developed in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;) modes of operations;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="border: 0px; color: #51626f; font-weight: inherit;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In Fig. 1, which represent the global application mapping diagram as discussed in&lt;/SPAN&gt;&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/465758" rel="noopener noreferrer" style="color: #5e89c1; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;Module 3: System Partitioning&lt;/A&gt;&amp;nbsp;,&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;are shown the new hardware blocks that are going to be configured and used to perform the PMSM Sensored Speed Control highlighted in green relative to the ones already configured so far in the previous modules of this workshop.&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;SPAN style="color: #333333;"&gt;This time we are going to configure the GPIO to generate interrupts each time the Hall sensors change their state allowing us to compute the rotor position and motor speed using a simple estimation approach based on counting the time between Hall transitions.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;&lt;SPAN style="border: 0px; color: #333333; font-weight: inherit;"&gt;Furthermore, we are going to reuse and enhance the model developed in&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;The interactions between host PC and hardware will be done via OpenSDA serial communication that will be used to download the code generated from MATLAB and to visualize various control signals with FreeMASTER. In addition, the user can start and control the motor speed from the SW2 and SW3 push buttons that are present on the&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.nxp.com%2Fproducts%2Fprocessors-and-microcontrollers%2Farm-based-processors-and-mcus%2Fs32-automotive-platform%2Fs32k144-evaluation-board%3AS32K144EVB" rel="noopener noreferrer" style="color: #2989c5; border: 0px; font-weight: inherit; text-decoration: none; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;S32K144 Evaluation Board|NXP&lt;/A&gt;&amp;nbsp;. A three color LED will be used to signal the control states and faults.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_11.png"&gt;&lt;IMG alt="pastedImage_11.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32048i7366E715E15F8389/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_11.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Fig. 1:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333; background-color: #ffffff; border: 0px; font-size: 13px; padding: 0px;"&gt;&amp;nbsp;Application Mapping -&amp;nbsp; new HW &amp;amp; SW modules&amp;nbsp;used for Sensored Speed Control&amp;nbsp;are highlighted in green&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;This example uses the HALL Sensors to implement a simple position estimator. The usage of HALL Sensors should not be mistaken with 6-step commutation technique used to control the BLDC. In this case the HALL sensors are used just for estimation and correction of the electric angle used for FOC&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;CLOSED LOOP SPEED CONTROL SYSTEM&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The Speed Control system requires the actual/real motor speed in order to perform the calculation for finding the appropriate value for the Torque reference (Iq*) used to&amp;nbsp;accelerate or&amp;nbsp;decelerate the PMSM rotor so that the real speed is maintained as closed as possible within the user specified range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;In Fig. 2, is shown the block diagram of&amp;nbsp;a typical closed loop speed control system proposed for implementation. The control system is made of two cascaded loops that use information about currents and rotor position to regulate the PMSM rotor speed to a desired set point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;DIV class="" style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; font-weight: inherit; margin: 0px 0px 2px;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit; font-weight: inherit;"&gt;&lt;TR style="font-weight: inherit; height: 346px;"&gt;&lt;TD style="padding: 5px; text-align: center; height: 346px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;IMG alt="pastedImage_7.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32049iB95AC4794D415E61/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; height: 25px;"&gt;&lt;TD style="padding: 5px; text-align: center; height: 25px;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 13px;"&gt;Fig. 2:&amp;nbsp;Closed loop speed control system - Block Diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;The Field Oriented Control shown in Fig. 3, is computed in the FAST CONTROL LOOP block that is executed based on a ADC triggers at each 100 microseconds. This subsystem receives the reference values for currents in Q (torque) and D (flux) axis and use as feedback the Ia,Ib and Ic currents measured from the ADC that are transformed from the fixed reference frame (abc) to the orthogonal rotating frame (dq) based on the angle&amp;nbsp;&lt;/SPAN&gt;θ provided from position sensors and PARK and CLARKE transformations. The FAST CONTROL LOOP outputs via the Space Vector Modulation technique the&amp;nbsp;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;PWM duty cycles commands that control the 3-phase inverter which applies the corrective voltages directly to the PMSM windings.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_12.png"&gt;&lt;IMG alt="pastedImage_12.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32066i6B05860F30322995/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_12.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 3: Field Oriented Control -&amp;nbsp;Block diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;For flexibility, the actual electric angle&amp;nbsp;θe used in FOC calculations is derived from the position sensor measurements and estimations based on application software configuration global variables: MODE and CONTROL TYPE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;CONTROL TYPE&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;global variable allows users to choose between:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;SPEED CONTROL = 1 that performs the closed loop speed control based on sensor feedback&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;TORQUE CONTROL = 0 that performs the control system designed in&lt;/SPAN&gt;&amp;nbsp;&lt;A href="https://community.nxp.com/thread/469934" rel="noopener noreferrer" target="_blank"&gt;Module 7: Torque Control&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The TORQUE CONTROL operation is very important at this time because it will allows us to perform various tests with the speed and position estimator prior of closing the&amp;nbsp;speed control loop.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The second global variable,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;MODE&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is generated internally by the software algorithm and it is used to control the motor startup process and zero crossing during change of rotation direction. Since we are dealing with an estimator we need to cope with low speed ranges and 0 crossing when changing the motor speeds from clockwise (CW) to counter clockwise (CCW) directions. This variable has three possible values (see Fig. 27 for a graphical representation):&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;FORCE MODE = 0 where the motor is control in open loop with an imposed electric angle reference&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;TRACKING MODE = 1 where the motor is still control in open loop but the speed controller will act in parallel to charge the integral part in order to deal with handover from open to closed loop transition&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;SENSOR/SENSORLESS MODE = 2 where the motor operates as a closed loop system and the electrical angle is derived from the actual rotor position sensors.&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;We will discuss about the importance of these modes in the next workshop modules where we will focus on SENSORLESS control system.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Furthermore,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;t&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;he Toque (Iq*) and Flux (id*) references are computed in the SLOW CONTROL LOOP block that is triggered at each 1 millisecond based on the same ADC events.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333; border: 0px; font-weight: inherit;"&gt;The block diagram of the SLOW CONTROL LOOP is shown in Fig. 4. As can be seen, the same software configuration based on MODE and CONTROL TYPE is used here as well to select between TORQUE and SPEED control types.&amp;nbsp;The speed commands&amp;nbsp;&lt;SPAN style="color: #404040;"&gt;ω*&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are received via the UART or from on board push buttons and&amp;nbsp;feed into a PI controller together with the actual rotor speed feedback&amp;nbsp;&lt;SPAN style="color: #404040;"&gt;ω. The PI Speed Controller implements a standard Simulink PI parallel controller that takes as input the error between the speed set point and the actual rotor speed and computes the appropriate torque command Iq* that compensates for the speed error.&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;IMG alt="pastedImage_2.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32067i6D11E0643B463F9E/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 4: Closed Loops Speed Control - Block diagram&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;As can be seen in Fig. 2, Fig. 3 and Fig. 4 the key information needed for speed closed loop control is the actual rotor position information. Therefore, lets see how can we obtain such information.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;SPEED &amp;amp; POSITION ESTIMATOR&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;In general for an accurate closed loop speed control system we need to have a dedicated position (optical encoder or resolver)&amp;nbsp; or speed (tachometer) sensors that can provide relative or absolute rotor position information. Unfortunately many of these sensors are expensive and require additional dedicated hardware and PCB space for signal conditioning or may of them need dedicated software routines to allow data read outs.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Fortunately, most of the motors can be equipped with low resolution Hall-effect sensors that are very cheap and widely used in many PMSM based applications. In general three Hall sensors are used in one PMSM to&amp;nbsp;provide the rotor position with a coarse resolution of 60 electrical degrees. A detailed description&amp;nbsp;about how Hall-effect sensors operates can be found in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/453198" rel="noopener noreferrer" target="_blank"&gt;Motor Control Class: Lecture 5 - Hall Sensors&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;In case of the&amp;nbsp;&lt;A href="https://www.nxp.com/support/developer-resources/hardware-development-tools/ultra-reliable-mcus-development-platform/low-cost-motor-control-solution-for-devkit-platform:DEVKIT-MOTORGD" rel="nofollow noopener noreferrer noopener noreferrer" style="color: #2989c5; text-decoration: none;" target="_blank"&gt;DevKit MotorGD&lt;/A&gt;&amp;nbsp;the Hall sensors are connected via JP1 connector on the motor shield as shown in Fig. 5. The JP1 connector provides 5V power supply to the motor Hall sensors and reads back the digital signals in range of 0 - 5V.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_72.png"&gt;&lt;IMG alt="pastedImage_72.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32073i4BA46BF566BEC6E5/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_72.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 5: DevKit MotorGD pins used for Hall sensors&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;The signals from Hall sensors are then sent to the S32K144 Evaluation board via the J5 header as shown in Fig. 6 and the S32K MCU will read those from the PTA15, PTA16 and PTA1 digital inputs pins.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_592.png"&gt;&lt;IMG alt="pastedImage_592.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32075i57CFEE5AA7C913E3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_592.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 6: S32K144 Evaluation Board MCU Signal Assignment&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Getting the actual values of the Hall signals is a piece of cake when using the NXP Model-Based Design tools. Using a simple digital input block you can read each hall signal individually and store it in a global variable as shown in Fig. 7.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_669.png"&gt;&lt;IMG alt="pastedImage_669.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32079i3040063893EEA885/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_669.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 7: Simulink model for reading the Hall Sensors with S32K14x MCU&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;On S32K14x Evaluation Board these signals are inverted. To get the same logic value as the true Hall input we need to invert the acquired value in software.&lt;/SPAN&gt;&lt;/P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;Using the Simulink model shown in Fig. 7 we can read the Hall signals variation in time for a PMSM rotating at a constant speed. Fig. 8 shows the three Hall signals that are phase out with 120 electrical degrees in between each other while each hall signal is ON/OFF for 180 electrical degrees.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32080i4D202D60DB2384A2/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 8: HALL sensors signals&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Based on these considerations, it is easy to understand that for each 360 electrical degrees (THETA) we will have six Hall sensor transitions as shown in Fig. 9. These six transitions give us the possibility to measure the position of the PMSM rotor with an accuracy of 60 electrical degrees for any speed range.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_13.png"&gt;&lt;IMG alt="pastedImage_13.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32083iA058551DAA6C72EC/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_13.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 9: Hall sensors transitions versus one complete electrical rotation (-pi: pi) radians&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Speed Estimation Based on Hall Sensors Transitions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Since we know how many radians are between two consecutive Hall sensors transitions, we can easily compute the speed of the motor as:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 88.5048%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;IMG alt="pastedImage_2.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32086iD1B4F1505F327D54/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 10%;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: right;"&gt;Eg. 1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Therefore, reading the value of&amp;nbsp;a&amp;nbsp;timer/counter on each hall transition should give us an accurate information about how fast the rotor is spinning, right ?&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In Fig. 10 we have captured such use-case. On the top of the figure we have the Hall sensors variation captured as a Hall sSector representation in decimal form and on the bottom we have the timer values for each Hall sensors transitions. In this capture you can see that even if the motor is commanded to spin in torque control at constant speed the time counted between consecutive hall transitions presents a variation.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32088i8053AD58CA0B4EB3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 10: Hall sector change timings&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;This variation is mainly cause by the undefined&amp;nbsp;installation error of the three hall sensors which are not at a perfect 120 electrical degrees apart of each other.&amp;nbsp;If we would try to build a speed estimator based on this approach we will have to deal with a lot of variations that are induced by this poor mechanical hall installation that might vary from one motor to the other.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In Fig.11 is shown the speed estimation results in case of counting the time between each hall sensors transitions. In this case the motor was commanded to spin in Torque Control at a constant 1000 rpm demanded speed using open loop control. As you can see the estimated speed (SPEED_FBK blue) has a large variation around the set point.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_272.png"&gt;&lt;IMG alt="pastedImage_272.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32091i0C8CC31AC00C9BCE/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_272.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 11: Speed estimation by counting the time between each hall sensor transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Such speed estimation signal may be filtered out but to smooth down such large variations it might required a large sample data as history and that may introduce phase delays in the final closed loop control system that may create control system instability. Therefore it must be a different way - a better one!&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;After analyzing the system response we have reached to the conclusion that would be better to count the time between a single hall transitions over 360 electrical degrees. This way we can get rid of additional sources of errors that might affect the speed estimator like:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;wrong placement of the hall sensor near a stator coil that might interfere with rotor magnetic flux&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;misalignment of rotor permanent magnets that might influence the North vs South magnetic poles spread&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The new Simulink model that is supposed to handle this scenario is shown in Fig. 12. Each time there is transition from HIGH to LOW on the HALL C (is has been selected since from PCB point of view it is all the time routed to the MCU)&amp;nbsp;the new estimated speed is getting computed.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; width: 99.8747%;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 838px;"&gt;&lt;TD style="text-align: center; width: 100%; height: 838px;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32094iF7EDDD28ABEA7EB1/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32119i60A81AA872512A15/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 12: Simulink model used to compute the estimated speed based on one hall signal transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;The formula implemented in the Compute Estimated Speed block is based on:&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 85.3336%;"&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_11.png"&gt;&lt;IMG alt="pastedImage_11.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32172i8AE1166621089865/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_11.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="font-size: 22.0pt;"&gt;&lt;SPAN style="font-size: 15px;"&gt;∆t&lt;/SPAN&gt;&lt;SPAN style="font-size: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;is the time passing between 2 transitions of Hall C signal or 360 electrical degrees.&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;pp is the motor pole pairs&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;0.0001 is the fast loop sampling time of 100 usec since the TIME_CNT is incremented in that loop&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD style="width: 11.6664%; text-align: right;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eq. 2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Using this approach we can estimate the actual motor speed far more cleaner that before. Fig. 13 shows the estimation results in the same conditions&amp;nbsp;as the one from Fig. 11.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; width: 99.9136%; border-width: 1px; border-color: #ffffff;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 100%; text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_15.png"&gt;&lt;IMG alt="pastedImage_15.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32176iD99D66EF9E1DF520/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_15.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 100%; text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 13:&amp;nbsp;Speed estimation by counting the time between one Hall signal transitions over 360 electrical degrees&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The dynamic results of the Speed Estimator are shown in Fig. 14 and Fig. 15 for startup and change of direction with zero crossing.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #ffffff; width: 99.8747%;"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="text-align: justify;"&gt;&lt;TD style="text-align: center; width: 100%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_19.png"&gt;&lt;IMG alt="pastedImage_19.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32177i9157F57C086B29CA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_19.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="text-align: justify;"&gt;&lt;TD style="text-align: center; width: 100%;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 14: Top: Reference (green) vs Estimated (red) Speeds, Bottom: Speed error between the reference and estimated speeds during motor startup&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;As can be seen, we have an expected larger error at startup until the motor starts to move constantly. Then during acceleration and steady state regime the error between the reference and estimated values are quite small +/-20 rpm which I think is quite good for this kind of approach relative to solution costs.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_23.png"&gt;&lt;IMG alt="pastedImage_23.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32181i3B4ADC54A7CC99E7/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_23.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 15:&amp;nbsp;Top: Reference (green) vs Estimated (red) Speeds, Bottom: Speed error between the reference and estimated speeds during&amp;nbsp;change of direction with zero crossing&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;At this point I think we can say the speed estimator based on a single Hall sensor signal transitions is accurate enough for our purpose. The next question that rise now is: how to obtain the electrical angle that is used for FOC transformations that ultimately controls the rotor position?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Position Estimation Based on Hall Sensors Transitions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;For FOC, the 60 electrical degrees resolution is not good enough to control the rotor position using sinusoidal control approuch. We will need to find a way to improve this accuracy in order to be able to reuse the Hall sensor information for PMSM sinusoidal control.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;With the PMSM rotating&amp;nbsp;at a constant speed like Fig.&amp;nbsp;16 shows, the Hall&amp;nbsp;sensors values change regularly.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_21.png"&gt;&lt;IMG alt="pastedImage_21.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32182iA88B00D057786D24/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_21.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 16: Hall sensors changing at constant speed - comparison between hall change (black), hall sector (blue)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;and open loop electric angle (red)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Any&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;changes of Hall sensors value could be captured by the&amp;nbsp;MCU via dedicated GPIO Interrupts&amp;nbsp;and then the&amp;nbsp;software application could&amp;nbsp;reads the three Hall sensors values to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;judge in which section edge the rotor is. The Simulink model that implements the Hall sensors change capture is shown in Fig. 17. As can be seen, dedicated GPIO ISR blocks are used to trigger a subsystem execution each time the Hall sensor changes its state LOW to HIGH or HIGH to LOW.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #FFFFFF;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32186iC128F3C32216E475/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 17: Simulink model for capturing the Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;For instance, when the MCU captures a Hall sensor value changing&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;from 110&amp;nbsp;to 010 then it is easy to know that θ is equal with 60 electrical degrees apart of phase A magnetic axis. The whole 360 electrical degrees spectrum can be divided into&amp;nbsp;six&amp;nbsp;areas, each one spreading over 60 electrical degrees. This concept was discussed in&amp;nbsp;&lt;A href="https://community.nxp.com/thread/466420" rel="noopener noreferrer" target="_blank"&gt;Module 4: Space Vector Modulation&lt;/A&gt;&amp;nbsp;during Space Vector Modulation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 292px;"&gt;&lt;TD style="height: 292px; text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32187i5014262A6796B75A/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px; text-align: center;"&gt;&lt;SPAN&gt;Fig. 18: Hall sensors&amp;nbsp;states vs. PMSM rotor angle&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Using only the six Hall sensors transitions we can build a simple model to estimate the rotor position with a resolution of 60 electrical degrees as shown in Fig. 19.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="height: 445px;"&gt;&lt;TD style="text-align: center; height: 445px;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_10.png"&gt;&lt;IMG alt="pastedImage_10.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32191iDD0D261568B3D889/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_10.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="text-align: center; height: 25px;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 19:&amp;nbsp;Coarse&amp;nbsp;estimated rotor position (green) vs. Ideal rotor position (red) when using Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;But how to estimate the rotor angle within&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;these six sections is an important problem which can be solved by using the estimated speed. Looking at the Fig. 18, we can see that the rotor position can be approximated quite precisely in case we know how fast the PMSM rotates.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;In FOC algorithm, the rotary speed of last 360 electrical degrees section is used to predict the rotor position for the next 60 electrical degrees section now which of course implies that the speed used until next Hall changes is not the real speed at the present moment.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="width: 87.9862%;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_15.png"&gt;&lt;IMG alt="pastedImage_15.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32226i925D78085E6B2086/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_15.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 10.1124%; text-align: right;"&gt;Eq. 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The predicted rotor&amp;nbsp;angle may&amp;nbsp;contains&amp;nbsp;errors if the motor speed is not constant, (e.g.: the PMSM is accelerating or decelerating). So&amp;nbsp;the electrical angle estimation result may have some deformity when the PMSM speed is fluctuating.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The&amp;nbsp;coarse estimated rotor position shown in green within Fig. 19, can be easily computed with a simple SWITCH in Simulink as shown in Fig. 20.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_16.png"&gt;&lt;IMG alt="pastedImage_16.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32227iC2F5375FD229D08F/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_16.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 20: Simulink model used to compute the&amp;nbsp;coarse rotor position with 60 electrical degrees resolution based on Hall sensors transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;This is a simple implementation that assumes a specific Hall switching pattern as shown in Fig. 19. For any other motor this part of the model must be updated.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;The position angle increment computation is shown in Fig. 12 and is computed in the same time with the estimated&amp;nbsp; speed as a simple multiplication with a scaling factor from rpm to rad/s and of course the sampling time of the fast loop&lt;BR /&gt;where the Hall transitions timer is incremented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Applying all these knowledge we can compute a more accurate rotor position based on actual Hall sensors transitions and the estimated speed of the PMSM. Fig. 21 shows a comparison between the ideal rotor position (THETA) and the predicted position (THETA_CORRECTED) based on the algorithm discussed above.&lt;/SPAN&gt;&lt;SPAN style="color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_21.png"&gt;&lt;IMG alt="pastedImage_21.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32238i6A21105248949CFA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_21.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 21: PMSM rotor position comparison:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(red) represents the ideal rotor position which is imposed in open loop Torque Control&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(green) represents the coarse estimated rotor position with a 60 electrical degrees resolution based on Hall sensors transitions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;(blue) represents the rotor predicted position based on Eq. 3 that includes the speed prediction&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;If we check the Fig. 21, we can spot a few things that needs to be addressed:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px; text-align: justify;"&gt;the predicted position (blue) must be scaled to be withing the (-pi:pi) radians range.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px; text-align: justify;"&gt;compensate the offset between ideal (red) and predicted (blue) positions&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The first issue can be easily&amp;nbsp;addressed in software and Fig. 22&amp;nbsp;shows how to deal with&amp;nbsp;such aspects in Simulink.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_184.png"&gt;&lt;IMG alt="pastedImage_184.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32239i6A83171BF6EAFAB6/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_184.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 22: Bounding the estimated rotor position to (-pi:pi) radians using standard Simulink blocks&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Regarding the second issue, the things are a bit more complicated than they seems and to explain it, we need to have a deeper understanding of the PMSM internals: phase voltage, back-emf and Hall sensor mounting. Lets discuss all these in the next section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 22px;"&gt;&lt;STRONG&gt;Phase Lag and&amp;nbsp;Phase-Angle Advance Compensation&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;One of the most important control system design challenges is the phase lag between the commanded phase voltage impose via SVM and the resultant sine-wave phase current for that naturally occurs in an PMSM/BLDC&amp;nbsp;motor. The&amp;nbsp;PMSM&amp;nbsp;can operate satisfactorily, but the overall efficiency will be reduced (as shown in Fig. 39&lt;SPAN style="color: #333333;"&gt;)&lt;/SPAN&gt;, defeating much of the purpose of implementing a&amp;nbsp;FOC control scheme that by definition should drive the motor at its optimal operating point.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The source of this inefficiency is&amp;nbsp;not&amp;nbsp;the phase lag between motor phase voltage and phase which some might think but rather the phase lag between phase current and the induced back-EMF voltage as it is shown in Fig. 23.&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The Hall sensors&amp;nbsp;are mounted in such way that when the induced back-EMF reaches its maximum value a Hall transition will happen. In this case, since we can measure directly the back-EMF with our model, it is safe to assume that back-EMF is synchronized with Hall transitions.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32241iE903C05A8DBEBEED/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 23: Phase lag between phase voltage (U_A_Ref) and phase current (Ia) and the Hall A transitions that are synchronized with back-EMF in phase A&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In order to eliminate this lag between the back-EMF (Hall A) and the phase current (Ia) we need to&amp;nbsp;introduce a phase-angle advance to the sinusoidal drive current to ensure its peak coincides with that of the back EMF (Hall transition). This phase-angle advance can be easily deducted based on the FreeMASTER recorded captures and in my case it seems to be 1/6 from a Hall half period (the dotted areas) which can be translated in a pi/6 radians or 30 electrical degrees.&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;In general, the phase-angle advance is typically set to increase linearly with the&amp;nbsp;phase command voltage, which determines the motor speed. Since our scope is to introduce general concepts and show how to implement them with Simulink rather than building a dedicated speed control system targeted for a particular motor - in this module we are going to use a constant electrical angle offset to compensate for this lag and drive the motor to its peak efficiency within a specific speed range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Depending on your application you might need to consider this aspect.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;The compensation of the electrical angle (Fig. 24) for clockwise and counter clockwise direction is implemented on the slow control loop and uses constant offsets that are added to the corrected electrical angle as shown in Fig. 21.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32243iA7C47FC4E173F09D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 24: Electric angle offset calculation for phase lag compensation&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;By using all these tricks we should be able to predict the rotor position quite accurately in both clockwise or counter clockwise directions as shown in Fig. 25 and Fig. 26.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_22.png"&gt;&lt;IMG alt="pastedImage_22.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32245i779D6A61E2C8A193/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_22.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 25: PMSM rotor position corrected (blue) with phase-angle advance of 30 electrical degree for clockwise direction&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_288.png"&gt;&lt;IMG alt="pastedImage_288.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32308i059D7E77BF94E443/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_288.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 26: PMSM rotor position corrected (blue) with phase-angle advance of 30 electrical degree for counter clockwise direction&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Fig. 26 shows a 180 degrees angle shift between the coarse angle obtained from Hall sensors (green) and the electrical angle corrected due to the mechanism used for calculations. To keep the same algorithm implementation for both directions, the corrected angle is shifted in software with (pi-pi/6) radians&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;As can be seen in both Fig. 25 &amp;amp; 26, there is a small jitter present on the predicted rotor position which is due to keeping the same angle increment over 360 electrical degrees and small variations with the estimated speed, but that should not be an issue for the control system.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Overall, taking into account the accuracy of predictions for both speed and position on one hand side and the cost of such basic type of sensors we can conclude at this point that this kind of method is quite suitable for motor control applications.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;SPEED CONTROL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Before we start to implement the speed controller that take governance over the system, we need to clarify a few things. As has been demonstrated before (Fig. 14 &amp;amp;15) such speed and position estimators work quite well in steady state regime and pose some design challenges when dealing with dynamic regimes due to their intrinsic algorithm that use previous states as a base for estimating the new values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Taking into account these factors we need to consider:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;startup process - where due to lack of Hall pulses is quite difficult to accurately predict the rotor position and that might lead to oscillations an possible lost of synchronism.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;zero crossing - is somehow similar with startup process in terms of missing the accuracy in hall transitions but we also need to consider the behavior of the PI type controllers that needs to empty the integral part in order to change direction. To have a smooth transition thru 0 we will need to offload the integral sum or at least to provide a mechanism to allow the controller to accommodate the change in directions.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;In industry there are&amp;nbsp;two main techniques to cope with such situations:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px; text-align: justify;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;STRONG&gt;BLDC Startup&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- at low speed the control is switch from FOC (sinusoidal) to 6-step commutation BLDC (trapezoidal) and only when the speed is high enough the control is switch back to FOC sinusoidal. Such type of control adds additional software complexities since we need to change the PWM strategy on the fly.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;SPAN style="color: #333333;"&gt;&lt;STRONG&gt;Force&amp;nbsp;Startup&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- for a selected speed range the motor is driven in open loop by imposing a constant electric angle increment. The transition to closed loop is then made via a second region called Tracking Region where the Speed Controller works in parallel with the Open Loop control allowing enough time to accumulate the integral term in order to have a smooth transition from open to closed loop.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Depending on your application requirements you may choose between one or the other method. For this module we are going to implement the Force Startup since it is more common and less complex than the BLDC Startup. If you are interested in BLDC control theory you may want to check&amp;nbsp;&lt;A href="https://community.nxp.com/thread/450817" rel="noopener noreferrer" target="_blank"&gt;BLDC Motor Control with Model Based Design&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;Fig. 27 shows the speed range partitioning for the Force Startup approach.The speed limits are available for changing in the Model Workspace associated with the Simulink Model File.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32311i3E5B02B0992F02BA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 27: Force Startup speed zones and speed limits between transitions&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The Simulink model is built to take into consideration these transitions and change the Speed Feedback (SPEED_FBK) and Electric Angle (THETA) used for FOC according with the speed area in which the motor operates. In order to accommodate this mechanism some changes had to be made to both SLOW and FAST LOOP Subsystems.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;IMG alt="pastedImage_3.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32423i80B89314D9C6BCDB/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_3.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 30: FAST CONTROL LOOP Simulink Model: Note the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Rotor Position&lt;/STRONG&gt;&amp;nbsp;subsystem that computes the angle needed for PARK transformations.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32431i2EDA2040DD725A7F/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 31: Rotor Position Conditioning for addressing all application use-cases:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Speed Control vs. Torque Control&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Open Loop vs. Closed Loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- Normal Operations vs. Rotor Alignment&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The actual speed control is implemented as normal in the slow loop using the Simulink model shown in Fig. 32.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33430i12086F5DC2866919/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 32: SLOW LOOP CONTROL Simulink Model&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The speed is regulated with the help of standard parallel form PI controller that is setting the motor torque reference&amp;nbsp; IQ_REF based on the error between the SPEED_REF computed as the output of the RAMP block and the actual motor speed estimated from HALL C sensor transitions (SPEED_FBK). The controller output is limited in order to avoid a high current thru the motor and anti-windup based on clamping strategy is enabled.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32527iE8D8FEF8103780F2/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 33: PI Speed Controller implementation with additional signal conditioning for handling startup and zero crossing&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The final model used for closed loop speed control is shown in Fig. 34. This model is more or less universal and represent the basic form of any speed control system based on Field Oriented Control and cascaded loops for dealing with electrical and mechanical parts of the PMSM or any motor in general.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32528iCE788F3C41C295FD/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 34: Simulink model of the Closed Loop Speed Control system for PMSM with S32K14x MCU&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="border: 0px; padding: 0in; color: #333399; font-weight: bold; font-size: 30px;"&gt;&lt;STRONG&gt;RESULTS and CONCLUSIONS&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The PI speed controller was tuned manually for the best results. If you prefer a more rigorous mathematical approach then you can check&amp;nbsp;&lt;A href="https://community.nxp.com/thread/455225" rel="noopener noreferrer" target="_blank"&gt;Motor Control Class: Lecture 11 - Closed Loop Control&lt;/A&gt;&amp;nbsp;that explains the theory behind pole placement method starting from motor transfer function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;The next figures shows the closed loop system response under various conditions. Fig. 35 &amp;amp; 36 shows the system response during startup and various speed levels. Note how the PI speed controller is able to maintain the rotor speed with very good precision with a narrow band of less that +/- 100 rpm during accelerations, decelerations and steady-state regimes.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32529i114231CBB3C8E88D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 35: System startup: TOP- reference vs. actual motor speed [rpm], MIDDLE - speed error [rpm], BOTTOM - PI Speed Controller output torque reference [Amps]&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;IMG alt="pastedImage_7.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32530i5F93F8A6D1D9AF66/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 36: Field Oriented Control algorithm responses for the profile shown in Fig. 36&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- TOP 2 graphs: Q Axis Torque Controller inputs (IQ_REF, IQ) and output voltage command (UQ_REF)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;- BOTTOM 2 graphs: D Axis Flux Controller inputs (ID_REF, ID) and output voltage command (UD_REF)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Fig. 36, demonstrates how the current controllers operates under acceleration and deceleration regimes. Note how the D-axis current controller is adjusting the control voltage in D-axis to compensate for additional back-EMF in oder to keep a zero magnetization current ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Fig. 37, shows the system response during startup and change of direction. Note how the handover is done between closed loop and open loop control strategies and how the rotor stops for a moment when changing directions.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32531i4F1F297D9224F8B6/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 37: Motor Startup and Zero Crossing (same quantities as in Fig. 35)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all the results above were perform under no load conditions, the Fig. 38, shows the system response under the effect of disturbances. The motor is kept at a constant 2000 rpm speed level when suddenly random load torque are applied on the rotor shaft. The Speed Controller reacts very quickly increasing the demanded torque to compensate for the lost in speed.&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32532i50C79249751C86CB/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 38: Speed Controller perturbation rejection&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Another interesting aspect that relates to FOC efficiency is shown in Fig. 39, where is presented the effect of phase angle compensation offset over the motor torque. By changing the value of the compensation, the motor is still able to maintain the desired speed profile within the same limits but this time with a larger current needed for producing the appropriate torque to spin the rotor. This demonstrate how important is the rotor position in FOC. A small 30 degrees deviations and the torque demanded is almost 3 times higher to maintaining the same conditions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY style="border: inherit solid inherit;"&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32533iBF7F30B1E2392113/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(a)&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;IMG alt="pastedImage_3.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32535i9FBEA62ADC11BFF9/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_3.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(b)&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/32536i2DAB19749DB5F210/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;(c)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: inherit solid inherit;"&gt;&lt;TD style="border: inherit solid inherit; font-size: inherit; padding: 5px;"&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;Fig. 39: Phase angle compensation offset influence over FOC efficiency for the same speed profile and load:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(a) pi/6 offset (as computed from Fig. 23 results), torque current is ~0.75Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(b) arbitrary 15 degrees off the optimal point, torque current is ~1.2Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 13px;"&gt;(c) arbitrary 30 degrees off the optimal point, torque current is ~2.5Amps&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We hope you have found plenty of useful information in this module that will allow you to build your own speed control system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update revisions:&lt;/P&gt;&lt;P&gt;March 19, 2018&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;insert a note to clarify the usage of HALL Sensors as a simple alternative for a position sensors&lt;/LI&gt;&lt;LI&gt;update Fig. 32&lt;/LI&gt;&lt;LI&gt;update the M8.zip model. This Simulink model is tuned for the LINIX 45ZWN24-40 motor as part of&amp;nbsp;&lt;A class="link-titled" href="https://www.nxp.com/products/power-management/motor-drivers/h-bridges/3-phase-pmsm-development-kit-with-nxp-s32k144-mcu:MTRDEVKSPNK144" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="https://www.nxp.com/products/power-management/motor-drivers/h-bridges/3-phase-pmsm-development-kit-with-nxp-s32k144-mcu:MTRDEVKSPNK144"&gt;S32K144 3-phase PMSM Development Kit|NXP&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #800000; background-color: #ffffff; border: 0px; font-weight: bold;"&gt;&lt;STRONG&gt;Update January 28th 2019 -&amp;nbsp;&lt;SPAN style="background-color: #ffffff; border: 0px; font-weight: inherit;"&gt;This&amp;nbsp;Simulink model is now available on MATLAB 2018b and MBDT for S32K14x 2018.R1 release&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert"&gt;&lt;P&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff;"&gt;Before using the new models make sure you apply all the hot-patches from here:&amp;nbsp;&lt;/SPAN&gt;&lt;A _jive_internal="true" data-objecttype="1" href="https://community.nxp.com/thread/489947" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;HotFix: MBD Toolbox 2018.R1 for S32K&lt;/A&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: 16px;"&gt;&lt;STRONG&gt;Update revisions&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 11.5pt;"&gt;March&amp;nbsp;18, 2019&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px 0.0001pt;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;update the model&amp;nbsp;to work with&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="102" href="https://community.nxp.com/docs/DOC-342724" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; font-size: 16px; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;&lt;SPAN style="color: blue; border: 0px; font-weight: inherit; font-size: 16px;"&gt;Model-Based Design Toolbox for MPC57xx Automotive Version 3.0.0&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; .&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 2pt 0in;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 11.5pt;"&gt;May 06, 2020&lt;/SPAN&gt;&lt;/P&gt;&lt;UL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px 0.0001pt;"&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: 12pt;"&gt;update the model&amp;nbsp;to work with&amp;nbsp;&lt;A _jive_internal="true" data-objecttype="102" href="https://community.nxp.com/docs/DOC-346265" rel="noopener noreferrer" style="color: #3d9ce7; background-color: transparent; border: 0px; font-weight: inherit; font-size: 16px; padding: 1px 0px 1px calc(12px + 0.35ex);" target="_blank"&gt;&lt;SPAN style="color: blue; border: 0px; font-weight: inherit; font-size: 16px;"&gt;Model-Based Design Toolbox for MPC57xx Automotive Version 3.2.0&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp; .&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:02:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727476#M1570</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2020-11-02T14:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727477#M1571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The setup used to run the M8 Simulink model is shown below:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33916iDE244C8FF48CC832/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert" modifiedtitle="true"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Make sure the motor and phase/sensors connections are correct.&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steps to run the application on&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A data-content-finding="Community" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.nxp.com%2Fproducts%2Fpower-management%2Fmotor-drivers%2Fh-bridges%2F3-phase-pmsm-development-kit-with-nxp-s32k144-mcu%3AMTRDEVKSPNK144" rel="noopener noreferrer" style="color: #5e89c1; background-color: #ffffff; border: 0px; text-decoration: none; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;S32K144 3-phase PMSM Development Kit|NXP&lt;/A&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Connect the microUSB between S32K EVB and PC&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Power on the MotorGD with 12Vdc&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Build and Download the Simulink model attached to the M8 module. Make sure you are using the latest &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-335555" rel="noopener noreferrer" target="_blank"&gt;MBDT&lt;/A&gt; and all &lt;A _jive_internal="true" href="https://community.nxp.com/thread/467438" rel="noopener noreferrer" target="_blank"&gt;patches&lt;/A&gt; are installed&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Press the RESET button on S32K EVB - the green LED shall be&amp;nbsp;green&lt;/LI&gt;&lt;LI&gt;To start the application press on SW3 once. The motor align procedure shall start and the LED shall blink green&lt;/LI&gt;&lt;LI&gt;The motor shall start spinning in clockwise direction. The LED will blink blue if the motor is spinning otherwise will stay blue&lt;/LI&gt;&lt;LI&gt;Use SW2/SW3 to change the motor speed&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using FreeMASTER project attached you can visualize the motor behavior in real time:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Startup speed comparison and speed error for clockwise direction&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;IMG alt="pastedImage_4.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33379i7C359B4CD8932705/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Speed controller response&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;IMG alt="pastedImage_1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33483iA2832BCA36C3F48D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Current controllers response in case of disturbance&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;IMG alt="pastedImage_2.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33951i2A2EC72E50CB4B7C/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="warning" __jive_macro_name="alert" alert="warning" class="jive_text_macro jive_macro_alert" modifiedtitle="true"&gt;&lt;P&gt;Due to motor backEMF, the limited amount of DC voltage and the current measurement technique, do not exceed 1200rpm with the current setup since the motor might stall due to voltage saturation.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_6.png"&gt;&lt;IMG alt="pastedImage_6.png" src="https://community.nxp.com/t5/image/serverpage/image-id/33764iA2B96889EBD762CA/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:02:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727477#M1571</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2020-11-02T14:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727478#M1572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,@&lt;A _jive_internal="true" data-content-finding="Community" data-userid="27829" data-username="dumitru-daniel.popa" href="https://community.nxp.com/people/dumitru-daniel.popa" style="color: #5e89c1; background-color: #ffffff; border: 0px; font-weight: 600; font-size: 11.9994px;"&gt;dumitru-daniel.popa&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;Thank you for your hard work. It's very valuable to us. There is one point I didn't understand:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;There is a hint in the article.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff; border: 0px;"&gt;Fig. 26 shows a 180 degrees angle shift between the coarse angle obtained from Hall sensors (green) and the electrical angle corrected due to the mechanism used for calculations. To keep the same algorithm implementation for both directions, the corrected angle is shifted in software with (pi-pi/6) radians&lt;/SPAN&gt;&lt;SPAN style="color: #0f7198; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/723i6ABB51727E7EF40C/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Why is there a 180 degree shift, can you explain it further?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;wangxuan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 07:57:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727478#M1572</guid>
      <dc:creator>wangxuan</dc:creator>
      <dc:date>2018-03-23T07:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727479#M1573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="padding: 0px;"&gt;Hi wangxuan,&amp;nbsp;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;To answer your question i'm going to use on picture from a motor manufacturer catalog - to be easier&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/17085i5DCFFA0BAD6D0C74/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;/P&gt;&lt;P&gt;Keep in mind that we are using the Hall sensors just to get the motor position coarse angle. For that we have built a table shown in Fig 16 to know which hall patterns corresponds to a clockwise direction. The hall pattern: 1-5-4-6-2-3 (same as the one shown in&amp;nbsp;above picture&amp;nbsp;but from right to left).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, look at the rotor magnetic field N-S poles. If you want to change the direction - then you need to&amp;nbsp;reverse the poles - which are at 180 electrical degrees one of the others.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2018 11:36:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727479#M1573</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2018-03-26T11:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727480#M1574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All the steps are done as you meantioned&amp;nbsp; above and the HW is same as yours&amp;nbsp;,but the LED stays blue and the motor does not spin.Besides,only&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt; downloading the Simulink model&amp;nbsp;&lt;/SPAN&gt;in Module 7 can the motor spin ,while the motor fails to spin when downloading the model in Module 8,6,or 5.Can you help me to find out the problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Apr 2018 10:06:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727480#M1574</guid>
      <dc:creator>ponyhuang</dc:creator>
      <dc:date>2018-04-01T10:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727481#M1575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pony Huang,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for delays - we were out of office for a while.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is your motor performing the alignment? (does it moves a bit while the green LED flashes?)&lt;/P&gt;&lt;P&gt;Are you using the same motor or a different one ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please upload some screenshots from FreeMASTER with the startup ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2018 13:48:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727481#M1575</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2018-04-11T13:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727482#M1576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It's the same motor and does move&amp;nbsp; a bit when the green LED flashes,but it stops and produces noise as long as the LED turns blue.Below are the screenshots about the motor behavior&amp;nbsp;.&lt;span class="lia-inline-image-display-wrapper" image-alt="P1.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8048iDEEF3947996899AE/image-size/large?v=v2&amp;amp;px=999" role="button" title="P1.PNG" alt="P1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P2.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8095iCBC75A390AA8E7EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="P2.PNG" alt="P2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P3.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8120iBC7774194995CB73/image-size/large?v=v2&amp;amp;px=999" role="button" title="P3.PNG" alt="P3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P4.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8100i40D5216659685330/image-size/large?v=v2&amp;amp;px=999" role="button" title="P4.PNG" alt="P4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Pony Huang&lt;/P&gt;&lt;P&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2018 12:05:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727482#M1576</guid>
      <dc:creator>ponyhuang</dc:creator>
      <dc:date>2018-04-12T12:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727483#M1577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pony Huang,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see that the UQREF is saturated at 0.4. Are you sure you are using the last model. Can you try by downloading once again the model attached?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, before starting the motor, can you try with a lower speed - let say 250rpm. Does is spin ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Apr 2018 06:10:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727483#M1577</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2018-04-13T06:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727484#M1578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Hi Daniel,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I download the model again and set SPEED_CMD at 250rpm,but the motor still does not spin.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P1.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8309iE780A5C5177BE9E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="P1.PNG" alt="P1.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P2.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8339i1BDF135D2AB6639F/image-size/large?v=v2&amp;amp;px=999" role="button" title="P2.PNG" alt="P2.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="P3.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/8397i761047C4589B068C/image-size/large?v=v2&amp;amp;px=999" role="button" title="P3.PNG" alt="P3.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Best regards&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Pony Huang&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:07:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727484#M1578</guid>
      <dc:creator>ponyhuang</dc:creator>
      <dc:date>2018-04-13T13:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727485#M1579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hallo &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is time to implement the Speed control !&lt;/P&gt;&lt;P&gt;For that I've mounted a magnetic Rotary sensor and I'm able to read the actual Position in the fast Loop like in the Image.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Winkel in der Fast Loop abgestastet mit Recorder aus dem Hochlauf.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/12484i129F80754DD068AF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Winkel in der Fast Loop abgestastet mit Recorder aus dem Hochlauf.PNG" alt="Winkel in der Fast Loop abgestastet mit Recorder aus dem Hochlauf.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now I want to calculate the Speed in rpm from this Signal.&lt;/P&gt;&lt;P&gt;For that I've this simulink model:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/13162iBF274BBB77E2AC62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But any time I activate the "Test Pin" Option of the "Speed [rpm]" Signal the code isn't running any more.&lt;/P&gt;&lt;P&gt;Also a additional testpin at any other place leads to the Problem.&lt;/P&gt;&lt;P&gt;The three testpins DSPI Receive, Angle and Angle [rad] are fine.&lt;/P&gt;&lt;P&gt;Without the additional test pin everything is fine and the Motor spins at 1000rpm.&lt;/P&gt;&lt;P&gt;What is wrong here ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I'm not sure if the calculation of the Speed is correct.&lt;/P&gt;&lt;P&gt;So for that my idea was to store the last angle and to make an Addition of tha actual and the last value.&lt;/P&gt;&lt;P&gt;the result is the difference between them. because the fast Loop is called every 100us i have the changing of the angle in 100 us. to get the result in rpm&amp;nbsp;this have to be multiplied with a factor.&amp;nbsp;*60/2pi correct ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2018 12:54:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727485#M1579</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-04-27T12:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727486#M1580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed the model a Little bit to become clearer.&lt;/P&gt;&lt;P&gt;It works until I activate the marked test pin, so I expect a Problem in the add block ??&lt;/P&gt;&lt;P&gt;How could that be ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/12437i81192C3E736ECC08/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I've found a Memory block in the library.&lt;/P&gt;&lt;P&gt;where is the difference between the delay and the Memory ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also if I want to store the actual value in a Memory block the code isn't running.&lt;/P&gt;&lt;P&gt;I don't know what to do and hopefully you could help me ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/12397iBB97361875D6EDA7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:25:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727486#M1580</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-04-27T13:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727487#M1581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hallo &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you give me some recommendations or do you have an idea why the code isn't running after download to the target if I activate the test pin or want tp use a data store memory block ?&lt;/P&gt;&lt;P&gt;How&amp;nbsp;would it be possible to store the last values for calculations ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only using the Delay or Memory block works and also I'm able to see the values with FreeMaster.&lt;/P&gt;&lt;P&gt;But if I want to store the actual value in a data store Memory there are some bad circumstances.&lt;/P&gt;&lt;P&gt;Also if I want to activate the test pin Option for freemaster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2018 07:17:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727487#M1581</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-05-02T07:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727488#M1582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because I'm not able to connect with freemaster any time I have a add block in the model for dspi I think that the add block is the problem.&lt;/P&gt;&lt;P&gt;I tried to change some Settings in the add block, obviously without having success. I tried all of the integer rounding methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example I simple want to add "1" like in the post above.&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/thread/471093#comment-1009815"&gt;https://community.nxp.com/thread/471093#comment-1009815&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/38927i0B0828D52A3E233D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help for me ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2018 12:22:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727488#M1582</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-05-02T12:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727489#M1583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Leon,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for long delay - i was out of office for a while.&lt;/P&gt;&lt;P&gt;Let's take step by step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Also I'm not sure if the calculation of the Speed is correct.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;So for that my idea was to store the last angle and to make an Addition of tha actual and the last value.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;the result is the difference between them. because the fast Loop is called every 100us i have the changing of the angle in 100 us. to get the result in rpm&amp;nbsp;this have to be multiplied with a factor.&amp;nbsp;*60/2pi correct ?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, the formula to transform form RAD/sec -&amp;gt; RPM is correct. For example let's assume that the motor spin at a constant speed of 1000rpm or the equivalent 104.71 rad/s. Then the formula is: 104.71(rad/s) * 60/2/pi = 999.9 rpm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still, there is a second option to check if the computation is correct. You have the SPI angle readout in FreeMASTER and you can measure the period of the signal in steady-state&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/52373i12E14D7CB9E4844D/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Let's say that value is T = ~0.6secs (based on this graph)&lt;/P&gt;&lt;P&gt;Then the speed of the motor can be computed easily if you know how many pole pairs the motor have with the formula:&lt;/P&gt;&lt;P&gt;n (rpm) = 60*f (Hz) / pp&lt;/P&gt;&lt;P&gt;If we assume pp =&amp;nbsp;2 then the motor speed will be: n = 60 * (1/0.6) / 2 = 50rpm (at that point in time)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, you double check your computations you could speed up the motor at a constant speed and them compare the Simulink results against the one obtained with the FreeMASTER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;But any time I activate the "Test Pin" Option of the "Speed [rpm]" Signal the code isn't running any more.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Also a additional testpin at any other place leads to the Problem.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;The three testpins DSPI Receive, Angle and Angle [rad] are fine.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Without the additional test pin everything is fine and the Motor spins at 1000rpm.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;What is wrong here ?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How did you configure the test pin? I would use is as a global volatile variable. Perhaps there is an issue with the generated code from Simulink. A comparison of the generated files with and without a test pin should clarify what is the influence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;where is the difference between the delay and the Memory ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://www.mathworks.com/help/simulink/slref/unitdelay.html"&gt;Here&lt;/A&gt; you can find the difference between them. The Unit Delay (1/z) works on both discrete and continuous sample times same as memory block but in addition allows you set the sample time (like 100 microseconds). The memory block does not allows you this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case i would go with the Unit Delay block instead of memory. The other option is to save and read back in a data store block. Hence - your issue might be with optimizations here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can you provide 2 projects source files? one when it works and the second when it does not works - ideally change a single parameter between them in order to be able to compare the generated code easily.&lt;/P&gt;&lt;P&gt;This way we should figure it out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2018 06:44:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727489#M1583</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2018-05-03T06:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727490#M1584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;How did you configure the test pin?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I didn't made any further changings... So the testpin is Simulink.Signal (Auto) like any other testpin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Can you provide 2 projects source files? one when it works and the second when it does not works - ideally change a single parameter between them in order to be able to compare the generated code easily.&lt;/P&gt;&lt;P&gt;This way we should figure it out.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But yesterday I made a discovery: If I replace the Add Block with a sum, multiply-add or subtract block the code works.&lt;/P&gt;&lt;P&gt;Two files are attached for this. One with the add block and one with a subtract block.&lt;/P&gt;&lt;P&gt;Also I have&amp;nbsp;commented out&amp;nbsp;the Abs block because if it is in the model the code does also not run any more.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Encoder.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/57058iC1621CB4EC2030ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="Encoder.PNG" alt="Encoder.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I have further Problems. If I visible the Speed [rpm] in FreeMASTER with 1000rpm I get this result:&lt;/P&gt;&lt;P&gt;So the calculation between two time steps does not work so far. Do you have some recommendation here ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Drehzahl.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58309i136BBC835D61ACAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Drehzahl.PNG" alt="Drehzahl.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My next idea was count the calls of the fast Loop in one Revolution of the Motor similar you did in this module 8 of the Workshop.&lt;/P&gt;&lt;P&gt;So I wanted to implement a if Action Subsystem at the value 4095 which is the greatest possible value of the Encoder.&lt;/P&gt;&lt;P&gt;But if i comment in the estimated Speed Subsystem&amp;nbsp;the code doesn't run any more.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="If Action.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58310i2D5E3CD6C013F9B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="If Action.PNG" alt="If Action.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The Content of the Subsystem doesn't madder, it could be empty.&lt;/P&gt;&lt;P&gt;For the Moment it is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Estimated Speed Subsystem.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/57902iA0EC5638451345B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Estimated Speed Subsystem.PNG" alt="Estimated Speed Subsystem.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is it possible to use the dspi module for generating an Interrupt, if the value on&amp;nbsp;"SIN" pin changes from 4095 to 0 or 0 to 4095 ?&lt;/P&gt;&lt;P&gt;At this Moment the magnetic rotor sensor has done one Rotation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2018 08:24:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727490#M1584</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-05-03T08:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727491#M1585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Leon,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before going further, can you please run a Profiler_Function for each of the control loops. You need to transform the blocks into atomic subsystems and place a Profiler_Function in each of the them (FAST and SLOW loops)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm afraid you are spending too much time in the FAST loop performing all the computations and that is why at some point it starts to crash. FYI, i checked the generated code for the FAST loop and you are using 9 x fmod() function calls as results of conversions on float. That is going to kill the performance of the CPU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 07:14:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727491#M1585</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2018-05-07T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727492#M1586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now the torque and Speed control is working so far ! And I didn't run profiler functions yet.&lt;/P&gt;&lt;P&gt;So I want to share my observations, there seems to be some bugs in the kv library working with dspi ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)&lt;/P&gt;&lt;P&gt;signals receiving from dspi can't be stored in a data store Memory&lt;/P&gt;&lt;P&gt;also it isn't possible to lead them out of a Subsystem with an ouput port&lt;/P&gt;&lt;P&gt;--&amp;gt; instead you have to use go to / from, then it works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;signals receiving from dspi can't be calculated with a "add" block.&lt;/P&gt;&lt;P&gt;--&amp;gt;instead you can choose sum, subtract, multiply add&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)&lt;/P&gt;&lt;P&gt;it isn't possible to work with the "abs" block in the signalflow of dspi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My last idea to call a Subsystem for getting the rotor Speed seems to work.&lt;/P&gt;&lt;P&gt;Between two time steps the difference fro the dspi is too small, so the calculated Speed is 0.&lt;/P&gt;&lt;P&gt;So I calculate the rotor Speed any time if the difference between two dspi receives is greater than e.g. 3250, which means that the rotor has done one Revolution.&lt;/P&gt;&lt;P&gt;because my magnetic rotor sensor has a 12 bit Resolution there are possible values between 0 and 4095.&lt;/P&gt;&lt;P&gt;if the difference&amp;nbsp;greater than&amp;nbsp;e.g. 3250 between the last and the actual value there is an Overflow and one Revolution is done.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/39168iDF15CF11AF871D06/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now here is my result for alignment, +1000rpm and changing direction to -2500rpm&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Unbenannt2.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/56322i00758FED8DF8F2E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt2.PNG" alt="Unbenannt2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2018 09:25:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727492#M1586</guid>
      <dc:creator>lethuer</dc:creator>
      <dc:date>2018-05-09T09:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727493#M1587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have installed MBDT ver 3.0.0 and all the patches posted here (&lt;A href="https://community.nxp.com/thread/467438"&gt;HotFix: MBD Toolbox rev3.0.0 for S32K&lt;/A&gt;&amp;nbsp;). However, when I try to build it and download to the board, I received the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Generation 6 45&lt;BR /&gt;Elapsed: 28 sec&lt;BR /&gt;### Generating code into build folder: C:\Study\EI\Master\Masterarbeit\Mdl\NXP\S32\M8_FOC Speed Control\Updated\FOC_SC_mbd_rtw&lt;BR /&gt;Parameter precision loss occurred for 'Value' of 'FOC_SC/ADC1_IRQ/MEAS_Get3PhCurrent/Constant4'. The parameter's value cannot be represented exactly using the run-time data type. A small quantization error has occurred. To disable this warning or error, in the Configuration Parameters &amp;gt; Diagnostics &amp;gt; Data Validity pane, set the 'Detect precision loss' option in the Parameters group to 'none'. [29 similar]&lt;BR /&gt;Component:Simulink | Category:BlockwarningSuppress this warning &lt;BR /&gt;If the inport 'FOC_SC/ADC1_IRQ/MEAS_Get3PhCurrent/ADC_Phase_Currents' of subsystem 'FOC_SC/ADC1_IRQ/MEAS_Get3PhCurrent' involves direct feedback, then an algebraic loop exists, which Simulink cannot remove. Consider clearing the 'Minimize algebraic loop occurrences' parameter to avoid this warning. [3 similar]&lt;BR /&gt;Component:Simulink | Category:Blockwarning&lt;BR /&gt;Converting 'Reusable function' setting of subsystem 'FOC_SC/FocFastLoop' to 'Nonreused function' because a child system has either been explicitly marked as nonreused, or is used in a configuration that must be nonreused. Please generate the HTML report during code generation and see the "Subsystems" section for more information [2 similar]&lt;BR /&gt;Component:Simulink | Category:Blockwarning&lt;BR /&gt;Self-transition #246 could be removed. 'B' has no children, and it does not cause any action or side-effect.&lt;BR /&gt;Component:Stateflow | Category:Coderwarning&lt;BR /&gt;### Invoking Target Language Compiler on FOC_SC.rtw&lt;BR /&gt;### Using System Target File: C:\Users\Aurour\Documents\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\code\mbdtbx_s32k14\mbdtbx_s32k14\mbd_s32k14.tlc&lt;BR /&gt;Warning: Directory already exists. [10 similar]&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\clock_S32K1xx.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\clock_S32K1xx.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\pcc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\pmc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\scg_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\sim_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\smc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_gpio_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_port_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_port_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\power_manager.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_manager_S32K1xx.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_manager_S32K1xx.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_smc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_smc_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_common.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_common.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_ic_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_ic_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_mc_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_mc_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_oc_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_oc_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_pwm_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_pwm_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_qd_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_qd_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_irq.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_irq.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\devices\callbacks.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\adc\adc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pdb\pdb_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pdb\pdb_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpit\lpit_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpit\lpit_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\trgmux\trgmux_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\trgmux\trgmux_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\mbdtbx_s32k14\AMMCLIB_s32k14\include\GFLIB_Log10.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\mbdtbx_s32k14\AMMCLIB_s32k14\include\GFLIB_VLog10.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\clock_S32K1xx.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\clock_S32K1xx.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\pcc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\pmc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\scg_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\sim_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\clock\S32K1xx\smc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_gpio_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_port_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pins\pins_port_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\power_manager.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_manager_S32K1xx.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_manager_S32K1xx.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_smc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\power\S32K1xx\power_smc_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_common.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_common.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_ic_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_ic_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_mc_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_mc_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_oc_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_oc_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_pwm_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_pwm_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\inc\ftm_qd_driver.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\ftm\ftm_qd_driver.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpuart\lpuart_irq.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_irq.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\edma\edma_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\devices\callbacks.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\adc\adc_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pdb\pdb_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\pdb\pdb_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpit\lpit_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\lpit\lpit_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\trgmux\trgmux_hw_access.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\S32_Platform_SDK\platform\drivers\src\trgmux\trgmux_hw_access.c&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\mbdtbx_s32k14\AMMCLIB_s32k14\include\GFLIB_Log10.h&lt;BR /&gt;COPY CATCH: Das System kann die angegebene Datei nicht finden.&lt;BR /&gt;: &amp;gt;&amp;gt; C:\MBDToolbox\mbdtbx_S32K\mbdtbx_s32k14\AMMCLIB_s32k14\include\GFLIB_VLog10.h&lt;BR /&gt;### Loading TLC function libraries&lt;BR /&gt;### Generating TLC interface API for custom data&lt;BR /&gt;### Initial pass through model to cache user defined code&lt;BR /&gt;### Caching model source code&lt;BR /&gt;...............................................................................&lt;BR /&gt;...............................................................................&lt;BR /&gt;...............................................................................&lt;BR /&gt;### Writing source file FOC_SC.c&lt;BR /&gt;### Writing header file FOC_SC_private.h&lt;BR /&gt;.&lt;BR /&gt;### Writing header file FOC_SC.h&lt;BR /&gt;### Writing header file FOC_SC_types.h&lt;BR /&gt;### Writing header file freemaster_cfg.h&lt;BR /&gt;### Writing header file freemaster_interface_init.h&lt;BR /&gt;### Writing source file freemaster_interface_init.c&lt;BR /&gt;.&lt;BR /&gt;### Writing header file rtwtypes.h&lt;BR /&gt;### Writing source file PositionMode.c&lt;BR /&gt;### Writing header file PositionMode.h&lt;BR /&gt;### Writing source file FOC_SC_data.c&lt;BR /&gt;### Writing source file mbd_main.c&lt;BR /&gt;.&lt;BR /&gt;### TLC code generation complete.&lt;BR /&gt;.&lt;BR /&gt;### Processing Template Makefile: C:\Users\Aurour\Documents\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\code\mbdtbx_s32k14\mbdtbx_s32k14\mbd_s32k14.tmf&lt;BR /&gt;### FOC_SC.mk which is generated from C:\Users\Aurour\Documents\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\code\mbdtbx_s32k14\mbdtbx_s32k14\mbd_s32k14.tmf is up to date&lt;BR /&gt;### Building FOC_SC: .\FOC_SC.bat&lt;BR /&gt;. &lt;BR /&gt;C:\Study\EI\Master\Masterarbeit\Mdl\NXP\S32\M8_FOC Speed Control\Updated\FOC_SC_mbd_rtw&amp;gt;set MATLAB=C:\Program Files\MATLAB\R2016b &lt;BR /&gt; &lt;BR /&gt;C:\Study\EI\Master\Masterarbeit\Mdl\NXP\S32\M8_FOC Speed Control\Updated\FOC_SC_mbd_rtw&amp;gt;"C:\Program Files\MATLAB\R2016b\bin\win64\gmake" -f FOC_SC.mk COPY_MDLREF_INCLUDES=0 GENERATE_ERT_S_FUNCTION=0 INCLUDE_MDL_TERMINATE_FCN=0 COMBINE_OUTPUT_UPDATE_FCNS=1 MULTI_INSTANCE_CODE=0 INTEGER_CODE=0 TARGET_SYSTEM_CLOCK="80" MCU_CRYSTAL_FREQ="External 8" TARGET_MEMORY="FLASH" GCC_TARGET_DEFAULT_LCF=1 GCC_TARGET_USER_LCF="S32K144_64_flash.ld" GHS_TARGET_DEFAULT_LCF=1 GHS_TARGET_USER_LCF="S32K144_64_flash.ld" IAR_TARGET_DEFAULT_LCF=1 IAR_TARGET_USER_LCF="S32K144_64_flash.icf" PIL_DOWNLOAD=0 RBL_DOWNLOAD=1 ISPROTECTINGMODEL=NOTPROTECTING &lt;BR /&gt;Cleaning...&lt;BR /&gt;RELATIVE_PATH_TO_ANCHOR is ..&lt;BR /&gt;==== Removing object files from build directory ====&lt;BR /&gt;Copying necessary files to build directory...&lt;BR /&gt;Compiler details : "C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O1 -g -gstrict-dwarf -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__FPU_USED=1 -D__NVIC_PRIO_BITS=FEATURE_NVIC_PRIO_BITS -o SetupFiles -DCPU_S32K144HFT0VLLT -I. -I.. -IC:\PROGRA~1\MATLAB\R2016b\simulink\include\sf_runtime -IC:\Study\EI\Master\MASTER~1\Mdl\NXP\S32\M8_FOC~1\Updated\FOC_SC_mbd_rtw -IC:\Study\EI\Master\MASTER~1\Mdl\NXP\S32\M8_FOC~1\Updated -I"C:\Program Files\MATLAB\R2016b\simulink\include" -I"C:\Program Files\MATLAB\R2016b\extern\include" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src" -I"C:\Program Files\MATLAB\R2016b\rtw\c\libsrc" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\tcpip" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\serial" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\custom" -I"C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/arm-none-eabi/include" -I"./common" -I"./inc" -I"./src/clock/S32K1xx" -I"./src/sim/S32K144" -I"./src/power/S32K1xx" -I"../common" -I"../inc" -I"../src/clock/S32K1xx" -I"../src/sim/S32K144" -I"../src/power/S32K1xx" -I"./S32K144/include"&lt;BR /&gt;Assembler details : "C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/bin/arm-none-eabi-as" -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -o SetupFiles&lt;BR /&gt;Building file startup_S32K144.o... &lt;BR /&gt;"C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/bin/arm-none-eabi-as" -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -o startup_S32K144.o startup_S32K144.s&lt;BR /&gt;Building file FOC_SC.o... &lt;BR /&gt;"C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O1 -g -gstrict-dwarf -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__FPU_USED=1 -D__NVIC_PRIO_BITS=FEATURE_NVIC_PRIO_BITS -o FOC_SC.o -DCPU_S32K144HFT0VLLT -I. -I.. -IC:\PROGRA~1\MATLAB\R2016b\simulink\include\sf_runtime -IC:\Study\EI\Master\MASTER~1\Mdl\NXP\S32\M8_FOC~1\Updated\FOC_SC_mbd_rtw -IC:\Study\EI\Master\MASTER~1\Mdl\NXP\S32\M8_FOC~1\Updated -I"C:\Program Files\MATLAB\R2016b\simulink\include" -I"C:\Program Files\MATLAB\R2016b\extern\include" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src" -I"C:\Program Files\MATLAB\R2016b\rtw\c\libsrc" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\tcpip" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\serial" -I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\custom" -I"C:/NXP/S32DS_ARM_v1.3/Cross_Tools/gcc-arm-none-eabi-4_9/arm-none-eabi/include" -I"./common" -I"./inc" -I"./src/clock/S32K1xx" -I"./src/sim/S32K144" -I"./src/power/S32K1xx" -I"../common" -I"../inc" -I"../src/clock/S32K1xx" -I"../src/sim/S32K144" -I"../src/power/S32K1xx" -I"./S32K144/include" FOC_SC.c&lt;BR /&gt;In file included from FOC_SC.c:22:0:&lt;BR /&gt;FOC_SC.h:31:28: fatal error: ftm_pwm_driver.h: No such file or directory&lt;BR /&gt; #include "ftm_pwm_driver.h"&lt;BR /&gt; ^&lt;BR /&gt;compilation terminated.&lt;BR /&gt;gmake: *** [FOC_SC.o] Error 1&lt;BR /&gt;### Build procedure for model: 'FOC_SC' aborted due to an error.&lt;BR /&gt;Error(s) encountered while building "FOC_SC"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2018 06:20:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727493#M1587</guid>
      <dc:creator>shaomuzhu</dc:creator>
      <dc:date>2018-09-18T06:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727494#M1588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a same problem.&lt;/P&gt;&lt;P&gt;I downloaded M8 zip file and execute, but the motor is not spinning.&lt;/P&gt;&lt;P&gt;The LED is keep&amp;nbsp;BLUE&amp;nbsp;after blinking many times with GREEN color.&lt;/P&gt;&lt;P&gt;I am using same demo kit and LINIX motor.&lt;/P&gt;&lt;P&gt;How did you solve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know how did you solve this problem.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my FreeMaster images&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="m8_1.JPG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/76100i6F6937759CF90DF4/image-size/large?v=v2&amp;amp;px=999" role="button" title="m8_1.JPG" alt="m8_1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="M8_2.JPG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/76145i3F08FDE0B55E06C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="M8_2.JPG" alt="M8_2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="M8_3.JPG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/76183i5806CD09BAFD5F8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="M8_3.JPG" alt="M8_3.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Nov 2018 15:14:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727494#M1588</guid>
      <dc:creator>yongcheolshin</dc:creator>
      <dc:date>2018-11-16T15:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Module 8: Speed Control</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727495#M1589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌,&lt;BR /&gt;I am using the 2018b version of the project along with&amp;nbsp;&lt;STRONG style="background-color: transparent; color: #000000; text-decoration: none; font-size: 11pt; "&gt;MTRDEVKSBNK144 kit.&lt;/STRONG&gt;&lt;BR /&gt;During&amp;nbsp;&lt;STRONG&gt;Build&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;Phase&lt;/STRONG&gt; I encountered about 30 warnings related to '&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;Parameter precision loss occurred'.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After I upload the code, the S32 LED turns green only in certain rotor positions - even if i press on the RESET button several times.&lt;/P&gt;&lt;P&gt;Even if the LED starts GREEN, after I press SW3 or SW3 the LED instantly goes RED, triggering the FAULT STATE.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do you have any ideas that might help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86953i0D87F150860FD229/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86954i12F782D4B56E8600/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Andrei Cador&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:47:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Module-8-Speed-Control/m-p/727495#M1589</guid>
      <dc:creator>andreicador13</dc:creator>
      <dc:date>2019-06-13T14:47:26Z</dc:date>
    </item>
  </channel>
</rss>

