model-based design of embedded systems
DESCRIPTION
MotoHawk Training. Model-Based Design of Embedded Systems. Course Outline. Why Model-Based Design? The MotoHawk ™ System w/ Demonstration The Simulink ® Model The MotoHawk ™ Way Advanced Software & Hardware Issues Real Application Challenge. Model-Based Design. Hand-Coding. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/1.jpg)
1
Model-Based Design of Embedded Systems
MotoHawk Training
![Page 2: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/2.jpg)
2
Why Model-Based Design? The MotoHawk™ System w/ Demonstration The Simulink® Model The MotoHawk™ Way Advanced Software & Hardware Issues Real Application Challenge
Course Outline
![Page 3: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/3.jpg)
3
Hand-Coding
Model-Based Design
Specification
Modeling
S/W Implementation
S/W Design
S/W Debugging
S/W Verification
H/W Verification against Model
H/W Verification against Specification
Time
Extra Time & Money
Why Model-Based Design?
![Page 4: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/4.jpg)
4
sourcecode
Software Engineers
Sourcecode
CompilerLinker
ApplicationFile
Specification
Application Engineers
Models
Loader
Traditional Application Development
Application Engineers
Models
CodeGen
sourcecode
Sourcecode
CompilerLinker
ApplicationFile
Loader
Model Based Application Development
Interfaces
Development Process Comparison
![Page 5: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/5.jpg)
5
Control Design
PCM
HUD
MotoTune
Key Benefits• Better testing using real ECU hardware• Faster cycle time for adding new features
and enhancing existing features • Improved documentation of system design
via working models of the system• Better ability to control IP development
Key Features• ControlCore enabled• Development is completed on the production capable
ECU and related software• Calibration using MotoTune• Optional HUD • ECU’s available for development, pilot, or production
MotoHawk™ ECU-based Rapid Prototyping
![Page 6: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/6.jpg)
6
Control Design
PCM
HUD
MotoTune
Define Requirements& Architecture
Define Algorithms
Production Code Generation
Hardware In LoopTesting
Environment In Loop Testing
Custom HW Prototype
MotoHawkTM
Prototype
Working Closer to Production
![Page 7: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/7.jpg)
7MotoHawktm
ToolchainCompiler, Linker, Loader, Calibration
CompilerLinker
ApplicationFile
(srec,elf)
Loader
SimulinkBlock
Library(mdl)
CustomBlock
Libraries(mdl)
MotoHawkBlock
Libraries(mdl)
MotoHawkBlock
Code GenScripts
(tlc)
MotoHawkMaster
Code GenScript(tlc)
MotoHawkTemplateMakefile
(tmf)
ApplicationEngineers
Operating System andBoard Support
OSSource(.c,.h) Board
SupportSource(.c,.h)
Mathworks ToolsMatlab, Simulink, Stateflow, Realtime Workshop, Embedded Coder
RealtimeWorkshopCode Gen
sourcecode
sourcecode(c,h)
makefile(mk) make
MatlabLibrarySource(.c,.h)
model(mdl)
Code Generation Process Flow
![Page 8: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/8.jpg)
8
Modeling with MotoHawk™
![Page 9: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/9.jpg)
9
Blinking LED: MotoHawk™
![Page 10: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/10.jpg)
10
Open the model in SimulinkGenerate CodeCompile and LinkDownload to ECURun!
MotoHawk™ Demonstration
![Page 11: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/11.jpg)
11
Trigger
BlockSignal
Subsystem
Port
System
The Standard Simulink® Model
![Page 12: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/12.jpg)
12
Simulink Elements
Systems, Blocks
Port
Signal
Trigger
Software Elements
Functions,
Encapsulation
Interfaces
Values, Variables
Function-calls, Events
Modeling Software with Simulink®
![Page 13: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/13.jpg)
13
Native Simulink block diagrams can represent signal processing very well
Blocks can represent H/W Input & Output Function-call triggers can represent events Library links can represent references and provide
model reuse
Modeling Software with Simulink®
![Page 14: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/14.jpg)
14
“Model the elements of the whole system, including the processor, build environment, memory, and operating system.”
Elements of Simulink®:Modeling & Simulation EnvironmentCode Generation
Elements of MotoHawk™: Input & Output ModelOperating System Model Integrated Build Environment
The MotoHawk™ Way
![Page 15: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/15.jpg)
15
Model blocks for ECU I/O and engine-specific peripherals
Examples:Digital Inputs & OutputsAnalog-to-Digital InputsPWM OutputsSerial Inputs & OutputsCAN Inputs & Outputs
Electronic Spark Timing OutputsEngine Knock InputsFuel Injector Control Outputs
Engine-specific peripherals
MotoHawk™ Input & Output Model:
![Page 16: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/16.jpg)
16
MotoHawk™ Input & Output Model:
![Page 17: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/17.jpg)
17
Model blocks for program flow and triggeringExamples:
Periodic Tasks InterruptsOperating System Events
MotoHawk™ Operating System Model
![Page 18: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/18.jpg)
18
MotoHawk™ Input & Output Model:
![Page 19: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/19.jpg)
19
Whole process, from pictures to working machine, in one environmentSimulationSystem VerificationCode GenerationMakefile GenerationCompile, Link, Locate, and Program Integration with Calibration ToolsDocumentation
MotoHawk™ Build Environment
![Page 20: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/20.jpg)
20
Simulink® is excellent for modeling control lawsNative Simulink® is not very expressive for modeling
general software systemsMotoHawk™ adds real-time software elements to the
Simulink® environment
MotoHawk™ and Simulink® Together
![Page 21: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/21.jpg)
21
Control Law
Design system simulation model
Design MotoHawk™ software model
Reuse control law
Control System Example
![Page 22: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/22.jpg)
22
Control Law Example
![Page 23: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/23.jpg)
23
Simulation with the Control Law
![Page 24: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/24.jpg)
24
The control law should be designed using discrete elements
We would like to allow a continuous plant modelWe would like to take advantage of Variable-Step
simulationWe need to simulate discrete sampling of the control
law
Problems with the diagram
![Page 25: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/25.jpg)
25
Improved System Simulation
![Page 26: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/26.jpg)
26
The control law example specifies ‘what’ to do in the controller, the ‘logic’
To design a system, we need to also specify ‘when’ to execute the control logic
To test the control logic, we would like to simulate the controller with a continuous plant model
Designing a Control System
![Page 27: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/27.jpg)
27
Sample InputsPassive Control Law
Update Outputs
MotoHawk™ Software Model
![Page 28: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/28.jpg)
28
Sampling Inputs from the Hardware
![Page 29: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/29.jpg)
29
Updating Outputs to the Hardware
![Page 30: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/30.jpg)
30
We reused the control law block, which we place into a library
We convert H/W input values to standard units used by the control law
We convert from standard units used by the control law to H/W output values
Reuse & Abstraction
![Page 31: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/31.jpg)
31
We try to separate the controller design from the H/W and S/W issues
Some systems are more complexProbes, calibrations, overriding signalsDistributed systems, with multiple controllersMulti-rate and asynchronous systemsTask preemption and long calculations
Hardware and Software Issues
![Page 32: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/32.jpg)
32
Probes, Calibrations, and Overrides
![Page 33: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/33.jpg)
33
MotoHawk™ seamlessly integrates with MotoTune™, a calibration tool allowing real-time observation and control.
Probes allow monitoring of valuesCalibrations allow adjustment of constantsOverrides allow signal modification for testingThis typical S/W issue has been abstracted into the
model
Probes, Calibrations, and Overrides
![Page 34: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/34.jpg)
34
Calibratable Lookup Tables
![Page 35: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/35.jpg)
35
Used to program the MotoTron ECU(s).Used to interact with the application running on the
ECU.Capable of modifying calibration parameters real-
time.Capable of monitoring and overriding values
throughout the application software.Capable of real-time charting of development data.
MotoTune® Development Tool
![Page 36: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/36.jpg)
36
The MotoTune® Display
![Page 37: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/37.jpg)
37
Distributed Systems, Multiple Controllers
![Page 38: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/38.jpg)
38
The system simulation model may use more than one controller, but still use one plant model
Each controller has its own sampling trigger, possibly at different rates
Each controller will have its own MotoHawk™ software model, for code generation
The controllers may use different target hardware
Distributed Systems, Multiple Controllers
![Page 39: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/39.jpg)
39
Multi-Rate Controllers
![Page 40: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/40.jpg)
40
System simulation uses same picture as the distributed system
Multiple tasks, each modeled as a unique controllerOnly one MotoHawk™ software model, using multiple
triggers, one for each taskThe processor only runs one task at a time, so we
must be aware of task priority and data coherency between tasks
Multi-Rate Controllers
![Page 41: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/41.jpg)
41
If we want to use multiple tasks, we must be very careful about the priority of tasks, and nesting of interrupts
MotoHawk uses ControlCore, MotoTron’s ECU-Based RTOS, with a foreground / background scheduler, and queued interrupt handlers.
Task Preemption
![Page 42: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/42.jpg)
42
BGND TDC CAN
CAN RxInterruptTDCBGND
HardwareInterrupts
Top-half Parsing
ForegroundTasks
BackgroundTasks
Foreground QueueBackground Queue
BG
ND FIFO
CA
N FIFO
Time
Prio
rity
Process BGND
TDC
Process TDC TDC Process CAN
Finish BGND
Task Preemption
![Page 43: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/43.jpg)
43
Lower priority tasks may be delayed by higher priority tasks
The system must be designed to allow for these delays
When a task interruption occurs, all data movement between tasks must be coherent
MotoHawk™ provides Critical Region blocks to handle atomic data transfer between asynchronous tasks
Task Preemption
![Page 44: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/44.jpg)
44
1. Using Slider 1 as a throttle command, read the analog voltage and convert the output value (0-1023) to a 0-5V signal.
2. Read the throttle position from analog input AN4 and convert the output value (0-1023) to a 0-5V signal.
3. Determine the error and use a basic PI controller to provide PWM ETC A with a duty cycle command.
MotoHawk™ Application Challenge
![Page 45: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/45.jpg)
45
Why do model-based rapid-prototyping using MotoHawk™
• Better testing using real ECU hardware• Faster cycle time• Improved documentation of system design• Better ability to control IP development• Calibration using MotoTune• ECU’s available for development, pilot, or production
Conclusion
![Page 46: Model-Based Design of Embedded Systems](https://reader035.vdocuments.us/reader035/viewer/2022062814/5681678b550346895ddca583/html5/thumbnails/46.jpg)
MotoTron Control SolutionsProduction Controls in a Flash