Skip to content
MathWorks - Mobile View
  • MathWorks アカウントへのサインインMathWorks アカウントへのサインイン
  • Access your MathWorks Account
    • マイ アカウント
    • コミュニティのプロファイル
    • ライセンスを関連付ける
    • サインアウト
  • 製品
  • ソリューション
  • アカデミア
  • サポート
  • コミュニティ
  • イベント
  • MATLAB を入手する
MathWorks
  • 製品
  • ソリューション
  • アカデミア
  • サポート
  • コミュニティ
  • イベント
  • MATLAB を入手する
  • MathWorks アカウントへのサインインMathWorks アカウントへのサインイン
  • Access your MathWorks Account
    • マイ アカウント
    • コミュニティのプロファイル
    • ライセンスを関連付ける
    • サインアウト

ビデオ・Webセミナー

  • MathWorks
  • ビデオ
  • ビデオ ホーム
  • 検索
  • ビデオ ホーム
  • 検索
  • 営業へのお問い合わせ
  • 評価版
3:04 Video length is 3:04.
  • Description
  • Full Transcript
  • Related Resources

How to Partition and Schedule with Export Functions in Simulink

From the series: Run-Time Software Modeling

Partition and schedule models with the Export Function modeling style to integrate functions into your software environment easily and have a clear mapping from model to code. This style is contrasted with rate-based modeling.

With Export Functions, the code separates out into functions that can be integrated into a larger system. Partitioning the model for scheduling and easier code integration are two of the main reasons to use these functions for Run-Time Software Modeling.

Export Function modeling style allows you to integrate functions from your model into your software environment easily and provides a clear mapping from model to code. 

To show how this works, I will start with a model of a Throttle Control System in which the desired software functions have already been modeled using subsystems.

In this model, we have Simulated Pedal Input, going into a Throttle Control, which is then being simulated by a model of a Throttle Body acting as a plant. Inside the Throttle Control Subsystem, we have functions for sensors and sensor management, including one for the primary and secondary throttle sensors, and the sensor monitor. We also have a controller and actuator.

To understand the need for Export Function modeling, let us generate the default code for this model. Although I have modeled the desired functions with subsystems, Simulink optimizes the code and in-lines the functions. In addition, function execution order is determined by Simulink’s built-in scheduler. As a result, the code does not reflect the interface of the functions and does not provide the ability to control execution order. This may not match the needs of your software architecture. 

Let’s look at the Export Function modeling version. The model is now architected differently. First, the Throttle Controller subsystem is now a model block with a fixed-step discrete solver, instead of a variable step solver, because it’s intended for software and integration.

And within the model block, they are in function call subsystems. Export Functions allows you to model the interface, where functions that are to be integrated into the architecture are represented as function trigger ports. If we look at the sample time on the function calls, we can see that they are sampled every 5 milliseconds, except for the Throttle Position Sensor Primary, which is sampled at every 10 milliseconds, and the Acceleration Pedal Position Sensor, which has an event which triggers when this will run.

With Export Functions, no inherent scheduler is assumed, allowing you to more flexibly integrate to a custom environment. You can choose to schedule via the ports or the Schedule Editor to make a simple test harness. For simulation purposes, the software scheduler, in this case, is the Schedule Editor.

The Schedule Editor sends an event to the different function calls every 5 or 10 milliseconds based on when the function call needs to be invoked. The Acceleration Pedal Position Sensor is an explicit aperiodic partition that has scheduled hit times. If you use Stateflow to do the scheduling for run-time software modeling, you can use logical constructs to alter when components are called depending on different situations.

A more extensive test harness for unit testing the controllers can be set up, using the Simulink Test product.

When we generate code for the model block, we get code that separates out the functions, which is taken from the names off the function call ports, making software easier to build. More realistic modeling with scheduling and easier code integration are two of the main reasons we use export functions for real-time software modeling.

Related Products

  • Simulink
  • Embedded Coder

3 Ways to Speed Up Model Predictive Controllers

Read white paper

A Practical Guide to Deep Learning: From Data to Deployment

Read ebook

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper

Deep Learning and Traditional Machine Learning: Choosing the Right Approach

Read ebook

Hardware-in-the-Loop Testing for Power Electronics Control Design

Read white paper

Predictive Maintenance with MATLAB

Read ebook

Electric Vehicle Modeling and Simulation - Architecture to Deployment : Webinar Series

Register for Free

How much do you know about power conversion control?

Start quiz

Feedback

Featured Product

Simulink

  • Request Trial
  • Get Pricing

Up Next:

Rate-based subsystems can be partitioned and scheduled as well, allowing you to combine modeling styles with schedulable components.
2:40
How to Combine Modeling Styles with Schedulable Components...
View full series (6 Videos)

Related Videos:

2:06
Scoping Simulink Functions
2:44
Simulink Functions
26:41
Optimizing Transmission Shift Schedule and Powertrain...
36:42
Simulink: Tips and Tricks
41:49
How to Develop Interactive User Interfaces for Simulink...

View more related videos

MathWorks - Domain Selector

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: .

  • 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)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • 営業へのお問い合わせ
  • 評価版

MathWorks

Accelerating the pace of engineering and science

MathWorksはエンジニアや研究者向け数値解析ソフトウェアのリーディングカンパニーです。

ディスカバー…

製品を見る

  • MATLAB
  • Simulink
  • 学生向けソフトウェア
  • ハードウェア サポート
  • File Exchange

製品評価版の入手または製品の購入

  • ダウンロード
  • 評価版ソフトウェア
  • 営業へのお問い合わせ
  • 価格とライセンス
  • MathWorksストア

使い方を学ぶ

  • ドキュメンテーション
  • チュートリアル
  • 例
  • ビデオ・Webセミナー
  • トレーニング

サポートを受ける

  • インストールのヘルプ
  • MATLAB Answers
  • 技術コンサルティング
  • ライセンスセンター
  • サポートへのお問い合わせ

MathWorks について

  • 採用情報
  • ニュースルーム
  • 社会貢献
  • ユーザー事例
  • MathWorks について
  • Select a Web Site United States
  • トラストセンター
  • 商標
  • プライバシー ポリシー
  • 違法コピー防止
  • アプリケーション ステータス

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

MATLAB を語ろう