www.mathworks.com Open in urlscan Pro
2.17.179.243  Public Scan

Submitted URL: http://app.go.mathworks.com/e/er?s_v1=48204&elqem=Auto%20Mar23&s=646005169&lid=33971&elqTrackId=a3461220121943d4808da22169ea...
Effective URL: https://www.mathworks.com/help//soc/ug/motor-control-simulation-example.html?s_v1=48204&elqem=Auto%20Mar23
Submission: On March 29 via api from US — Scanned from DE

Form analysis 2 forms found in the DOM

GET /support/search.html

<form id="docsearch_form" action="/support/search.html" method="get" accept-charset="utf-8" data-release="R2023a" data-language="en">
  <div class="input-group">
    <label class="sr-only">Search Help Center</label>
    <input id="suggestion" type="hidden" name="suggestion" value="">
    <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
    <input id="docsearch" class="form-control conjoined_search" type="search" name="q" placeholder="Search Help Center" autocomplete="off">
    <div class="input-group-btn">
      <button type="button" class="btn btn_search_adjacent dropdown-toggle" data-toggle="dropdown"><span class="caret"></span><span class="search_scope_label">Help Center</span></button>
      <ul class="dropdown-menu list-unstyled dropdown-menu-right" role="menu">
        <!--<li data-toggle="collapse" data-target="#search_scope_support"><a href="#">Support</a></li>-->
        <li data-toggle="collapse" data-target="#search_scope_site" class="support_search_scope_trigger"><a href="#">MathWorks</a></li>
      </ul>
      <script>
        $(".support_search_scope_trigger").click(function() {
          $("#search_scope_support").removeClass("in");
          $("#query").val($("#search").val());
        });
      </script>
      <button type="submit" name="submitsearch" id="support_submitsearch" class="btn icon-search btn_search_adjacent btn_search icon_16"></button>
    </div>
  </div>
</form>

Name: searchGET /search/site_search.html

<form name="search" id="site_search" class="site_search" action="/search/site_search.html" method="get">
  <div class="input-group">
    <label class="sr-only">Search MathWorks.com</label>
    <input type="hidden" name="c[]" value="entire_site">
    <input type="search" name="q" id="query" class="form-control conjoined_search" placeholder="Search MathWorks.com" autocomplete="off">
    <div class="input-group-btn">
      <button type="button" class="btn btn_search_adjacent dropdown-toggle" data-toggle="dropdown"><span class="caret"></span><span class="search_scope_label">MathWorks</span></button>
      <ul class="dropdown-menu list-unstyled dropdown-menu-right" role="menu">
        <li data-toggle="collapse" data-target="#search_scope_support" class="site_search_scope_trigger"><a href="#">Help Center</a></li>
      </ul>
      <script>
        $(".site_search_scope_trigger").click(function() {
          $("#search_scope_site").removeClass("in");
          $("#search").val($("#query").val());
        });
      </script>
      <button type="submit" id="searchbutton" class="btn icon-search btn_search_adjacent btn_search icon_16"></button>
    </div>
  </div>
</form>

Text Content

WE VALUE YOUR PRIVACY

We and our partners store and/or access information on a device, such as cookies
and process personal data, such as unique identifiers and standard information
sent by a device for personalised ads and content, ad and content measurement,
and audience insights, as well as to develop and improve products. With your
permission we and our partners may use precise geolocation data and
identification through device scanning. You may click to consent to our and our
partners’ processing as described above. Alternatively you may access more
detailed information and change your preferences before consenting or to refuse
consenting.
Please note that some processing of your personal data may not require your
consent, but you have a right to object to such processing. Your preferences
will apply to this website only. You can change your preferences at any time by
returning to this site or visit our privacy policy.
MORE OPTIONSAGREE
Skip to content
Toggle Main Navigation


 * Sign In to Your MathWorks AccountSign In to Your MathWorks Account
 * Products
 * Solutions
 * Academia
 * Support
 * Community
 * Events
 * Get MATLAB


MATHWORKS MATRIX MENU

 * MATLAB
 * Help Center
 * MathWorks

 * MATLAB Answers
 * File Exchange
 * Videos
 * Online Training
 * Blogs
 * Cody
 * MATLAB Drive
 * ThingSpeak
 * Bug Reports
 * Community

 * Products
 * Solutions
 * Academia
 * Support
 * Community
 * Events

 * Get MATLAB
 * Sign In to Your MathWorks AccountSign In to Your MathWorks Account


 * MATHWORKS MATRIX MENU
   
    * MATLAB
    * Help Center
    * MathWorks
   
    * MATLAB Answers
    * File Exchange
    * Videos
    * Online Training
    * Blogs
    * Cody
    * MATLAB Drive
    * ThingSpeak
    * Bug Reports
    * Community

Help CenterHelp Center

Search Help Center
Help Center
   
 * MathWorks

Search MathWorks.com
MathWorks
 * Help Center

Close Mobile Search
Open Mobile Search
Off-Canvas Navigation Menu Toggle
 * Documentation Home

 * FPGA, ASIC, and SoC Development

 * SoC Blockset
 * System on Chip (SoC)

 * Hardware-Software Partitioning of a Motor Control Algorithm
 * On this page
   
 * Introduction
 * Behavioral Model
 * Hardware-Software Partitioned SoC Model
 * Comparison of Behavioral and SoC Model Simulations
 * Implement on Hardware

 * Documentation
 * Examples
 * Functions
 * Blocks
 * Apps
 * Videos
 * Answers

 * Trial Software
 * Trial Software
 * Product Updates
 * Product Updates

Resources
 * Documentation
 * Examples
 * Functions
 * Blocks
 * Apps
 * Videos
 * Answers


Main Content


HARDWARE-SOFTWARE PARTITIONING OF A MOTOR CONTROL ALGORITHM

This example uses:

 * DSP System ToolboxDSP System Toolbox
 * SoC BlocksetSoC Blockset
 * Simscape ElectricalSimscape Electrical
 * SimscapeSimscape

Copy Command  Copy Code


This example shows how to model a motor controller for SoC devices by
partitioning the control and calibration algorithms between the FPGA and
processor of the SoC.


INTRODUCTION

This example shows how to partition a Field-Oriented Controller (FOC) for a
Permanent Magnet Synchronous Motor (PMSM) onto an SoC device. The following
diagram shows a conceptual closed-loop FOC of PMSM.







In an FOC running in closed-loop, the current control loop needs to run at a
high rate, typically microseconds. In contrast, the velocity control can run at
lower rates, typically milliseconds, but must react to external events, such as
commanded velocity updates. By partitioning the current and velocity controllers
onto the FPGA and processor cores, respectively, both control loops in the FOC
can meet the above requirements.

The first model in this example is used for behavioral simulation of a
closed-loop FOC with an open-loop calibration controller for a PMSM. The second
model shows how the open-loop calibration controller, closed-loop velocity
controller, and closed-loop current controller can be partitioned into an SoC
device using SoC Blockset. A comparison of the simulation results between the
behavioral and SoC models shows the expected behavior of the controller is
maintained.


BEHAVIORAL MODEL

The top-level structure of the behavioral model is shown below. The Plant
subsystem models a PMSM with load with simulated measurements from a motor shaft
encoder and current sensors. The model parameters of the motor, load, and
sensors are based on the AD-FMCMOTCON2-EBZ Evaluation Board from Analog
Devices®. The Controller subsystem contains the closed-loop FOC and the
open-loop calibration controllers.



The Controller is split into two subsystems, an inner Current Control loop and
outer Velocity and Calibration Control loop.

The Current Control subsystem takes a command current value from the Calibration
and Velocity Control subsystem. The current controller uses consecutive Clarke
and Park transforms to convert the AC current and voltage waveform into DC
signals. A Proportional-Integral (PI) controller uses the DC signals to drive
PWM switching signals to the power MOSFETs driving the PMSM.

The Velocity Control subsystem takes external commands to set the mode of the
controller as either calibrating or closed-loop velocity tracking. In the
calibration mode, the Mode_Scheduler spins the motor using an open-loop velocity
controller to identify the zero index of the shaft encoder. Then the controller
commands and holds a zero position to identify the encoder offset. After
determining the encoder offset, the velocity controller is calibrated and can be
switched into closed-loop velocity control. The closed-loop velocity control
also uses a PI controller, similar to the current controller.


HARDWARE-SOFTWARE PARTITIONED SOC MODEL

The structure of the partitioned SoC model is based on the partitioning scheme
shown below. The fast current controller is running on the FPGA and the slow
velocity controller on the processor. The FPGA and processor communicate via AXI
interface.







The original Controller subsystem from the behavioral model has been partitioned
into the processor and FPGA models, which are connected with Register Channel
blocks.



 * Processor

The open-loop calibration and the closed-loop velocity controllers are now
inside a Model block and operate as a task driven by the Task Manager block. As
part of the task iteration, the controller first reads from the AXI registers
using Register Read blocks, iterates the control algorithm, and then writes the
updated outputs to the AXI register using the Register Write blocks. The Task
Manager executes the controller task at a rate of 1kHz with an average execution
duration of 0.2ms.

 * AXI Interface

Register Channel block models the AXI communication between FPGA and Processor
for register read and write operations. The corresponding AXI4-Lite driver
blocks, Register Read/Register Write, are used in Processor Model to represent
AXI4-Lite interface.

 * FPGA

The closed-loop current controller is contained in the Model block representing
the FPGA of the SoC device. Since the current controller exists in the FPGA, it
can write and read directly from the AXI hardware registers. The FPGA uses a
40us clock.


COMPARISON OF BEHAVIORAL AND SOC MODEL SIMULATIONS

1. Open and run the behavioral model. Observe the controller and motor behavior
from the System_Response scope.







2. Open and run the partitioned SoC model. Observe that the controller and motor
behavior matches.

3. Click Data Inspector to open the Simulation Data Inspector (SDI). Signal data
for the previous model runs was automatically captured and archived in the SDI.

4. Select the rotorVelocity from Run 1: soc_motor_behavior and the rotorVelocity
from Run 2: soc_motor_top into each subplot to get the following plot. Both the
behavioral and partitioned models demonstrate equivalent motor velocity
tracking.







5. From Run 2: soc_motor_top, select and display the Velocity_Control_Task and
Core: 0 signals into each subplot to get the following plot. From the plot, you
can observe the task execution time of the velocity controller and the CPU
utilization.








IMPLEMENT ON HARDWARE

You can implement this motor control design on Trenz Electronic Motor Control
Development Kit, based on Xilinx® Zynq® UltraScale+ MPSoC. To see an example go
to Implement Field-Oriented Control on FPGA SoC (SoC Blockset Support Package
for Xilinx Devices).

×


OPEN EXAMPLE

You have a modified version of this example. Do you want to open this example
with your edits?

No, overwrite the modified version Yes

Thank you for your feedback!
What is one thing we can do to improve this information or the software
described on this page? Submit
How useful was this information?
Unrated 1 star 2 stars 3 stars 4 stars 5 stars
×


MATLAB COMMAND

You clicked a link that corresponds to this MATLAB command:



Run the command by entering it in the MATLAB Command Window. Web browsers do not
support MATLAB commands.

Close

×


SELECT A WEB SITE

Choose a web site to get translated content where available and see local events
and offers. Based on your location, we recommend that you select: Deutschland.

Deutschland
 * Switzerland (English)
 * Switzerland (Deutsch)
 * Switzerland (Français)

 * 中国 (简体中文)
 * 中国 (English)

You can also select a web site from the following list:


HOW TO GET BEST SITE PERFORMANCE

Select the China site (in Chinese or English) for best site performance. Other
MathWorks country sites are not optimized for visits from your location.


AMERICAS

 * América Latina (Español)
 * Canada (English)
 * United States (English)


EUROPE

 * Belgium (English)
 * Denmark (English)
 * Deutschland (Deutsch)
 * España (Español)
 * Finland (English)
 * France (Français)
 * Ireland (English)
 * Italia (Italiano)
 * Luxembourg (English)

 * Netherlands (English)
 * Norway (English)
 * Österreich (Deutsch)
 * Portugal (English)
 * Sweden (English)
 * Switzerland
   * Deutsch
   * English
   * Français
 * United Kingdom (English)


ASIA PACIFIC

 * Australia (English)
 * India (English)
 * New Zealand (English)
 * 中国
   * 简体中文
   * English
 * 日本 (日本語)
 * 한국 (한국어)

Contact your local office

 * Trial Software
 * Trial Software
 * Product Updates
 * Product Updates

MathWorks

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for
engineers and scientists.

Discover...

Explore Products

 * MATLAB
 * Simulink
 * Student Software
 * Hardware Support
 * File Exchange

Try or Buy

 * Downloads
 * Trial Software
 * Contact Sales
 * Pricing and Licensing
 * How to Buy

Learn to Use

 * Documentation
 * Tutorials
 * Examples
 * Videos and Webinars
 * Training



Get Support

 * Installation Help
 * Answers
 * Consulting
 * License Center
 * Contact Support

About MathWorks

 * Careers
 * Newsroom
 * Social Mission
 * Customer Stories
 * About MathWorks

 * United States


 * Trust Center
 * Trademarks
 * Privacy Policy
 * Preventing Piracy
 * Application Status




© 1994-2023 The MathWorks, Inc.


 * 
 * 
 * 
 * 
 * 
 * 



Join the conversation