Broenink et al, 2007 WMC – HLSLA 20071 University of Twente
A Model-Driven Approach to Embedded Control System Implementation
Jan F. Broenink, Marcel A. Groothuis, Peter M. Visser, Bojan Orlic
Control Engineering, CTIT, Faculty EE-M-CS,
University of Twente, Enschede, Netherlandse-mail: [email protected], web: www.ce.utwente.nl/bnk
WMC – HLSLA 20072 University of TwenteBroenink et al, 2007
Overview• Introduction
– Embedded Control Systems– Goal and Benefit
• Design Approach – Mechatronic Systems, Embedded Control Software– Model-based design; Verification by Simulation
• Modeling formalisms– Port-based (bond) graphs – plant – CSP diagrams – software
• Embedded Control System Implementation– Controller Models, Workflow– Stepwise Refinement – Tools, Distributed Simulation Framework
• Case– Try-outs at lab
WMC – HLSLA 20073 University of TwenteBroenink et al, 2007
Embedded Control Systems
• Essential properties– Loop controllers hard real time– Dynamic behavior of plant essential
» Latency small compared to time constants plant» Whole system must be considered
– Intrinsically concurrent• Software
– User Interfacing, Data processing, Plant control (20-30% of code)– Reliable, safe, timing guaranteed – Triggering: bounded jitter (isochronous)
• Hardware– Computer hardware & I/O interfacing– Programmable devices– Distributed and heterogeneous
• Plant– Machine, Sensors, Actuators, Power Amplifiers
Computer I/O Plant
WMC – HLSLA 20074 University of TwenteBroenink et al, 2007
Goal, Benefit, Approach• Problem
– Developing Reliable and Robust Embedded Control Software is too costly and too time consuming.
• Reasons– Complexity– Heterogeneity– Lack of Predictability– Late Integration
• Approach– Virtual prototyping =
Simulation– Model-level integration
discipline-specific issues– Property-preserving
code generation Shorten design timeBetter quality product
WMC – HLSLA 20075 University of TwenteBroenink et al, 2007
Design Approach, Tools
• Tools needed– Extendable / updatable software– Total system (embedded + embedding!)
• Embedded Control Systems– Dynamic behavior of plant– Layered structure of controllers– Stepwise refinement
» Physical Systems modeling» Control law Design» Embedded Control System Implementation
• Gradually enhance laws to code» Realization
– Verification by Simulation & Formal Checking
PhysicalSystem
Modeling
ControlLaw
Design
EmbeddedControl SystemImplementation
Verificationby
Simulation / Model Check
RealizationValidation
andTesting
Verificationby
Simulation
Verificationby
Simulation
WMC – HLSLA 20076 University of TwenteBroenink et al, 2007
Used Model Formalisms• Demands
– Overview - Hierarchy– Reusability - Interfaces,
- Implementation independent of connection– Simulate-ability - Total model!
• Essential solution– Object Orientation, Components– Port-based Interfaces
• Choices– CSP Diagrams
» Software structure, CSP-based, DFD, compositional– VHDL
» Configurable: design I/O functionality as if it were software– Port-based (Bond) Graphs
» Object-oriented physical systems modeling
WMC – HLSLA 20077 University of TwenteBroenink et al, 2007
Port-based (Bond) Graphs – Plant• Bond Graphs
– Relevant dynamic behavior as diagram» Directed graph: submodels & ideal connections
– Domain-independent » Analogies between physical domains
– Restricted number of elements» Per physical basic concept 1 bond-graph element
• Encapsulation of contents– Interface: ports with 2 variables
» (u, i): voltage & current; (F, v): force & velocity; – Equations as equalities (math. Equations)
» Not as algorithm: u = i * R -> u := i * R of i := u / R
• Simulation (tool)– Compile to differential equations (statements)– Simulation = repeatedly execution of statements
I
C
1
R
MSe
20-sim
WMC – HLSLA 20078 University of TwenteBroenink et al, 2007
CSP Diagrams – Software Structure
• Dataflow diagrams - CSP– Kind of block diagram– Communicating Processes– Connections (= channels) transport only– Formally verify-able– Theory: CSP (Hoare)– Checkers – FDR2
• Encapsulation– Implementation independent of communication
» Channel connections as ports– Scheduling at rendezvous: in application
• Process operators – PAR, ALT, SEQ– PRI-PAR, PRI-ALT, EXC– Compositional semantics
• Events– Atomic– Instantaneous: no duration– Variable v over channel c: c.v– Direction specific: in?x and out!x
WMC – HLSLA 20079 University of TwenteBroenink et al, 2007
Embedded Control System Implementation
• Models– Controller (CSP) -> code on target– Plant (bond graphs) -> simulation
• Co-simulation– Discrete Event & Continuous Time
• Steps in the method1. Physical Systems modeling2. Control law Design3. Embedded Control System
Implementation4. Realization
WMC – HLSLA 200710 University of TwenteBroenink et al, 2007
Embedded Control System Implementation II
• Step 3 in the method– Plant model OK; Control laws OK– Gradually enhance laws to code
» Integrate control laws» Safety, error & maintenance facilities» Capture non-ideal components
Working Order1. Internal checks2. Formal Check process logic3. Include (control) algorithms4. Check target code
ECSStructure
Formal CheckFDR2
Connect, Compile,Configure, ControlCTC++ lib
1
2
3
CSPm gCSP
CTC++
ControlAlgorithms
4
Step 1, 2Step 3
WMC – HLSLA 200711 University of TwenteBroenink et al, 2007
• 20-sim– Bond Graphs, Block Diagrams– Continuous Time Simulator
• gCSP– CSP Diagrams– Software Structures– FDR2
• CTC++– CSP concurrency– Middleware
• NWsim– Discrete Event / Network Simulator – CTC++ based
• ForSee– Configure, Compile– Command, Control
Tools
20-sim
gCSP
CTC++
NWsim
ForSee (4C)
WMC – HLSLA 200712 University of TwenteBroenink et al, 2007
20-Sim
Modeling& simulation– Bond graphs– Ideal Physical Models– Block Diagrams– Continuous Time Simulation– Animation – Basic Controller Design– Code Generation
» C (CTC++)» Token Replacement
• %NUMBER_OUTPUTS%
– Commercially Available
WMC – HLSLA 200713 University of TwenteBroenink et al, 2007
gCSP
Parallel Software Modeling
– Software Structure» Composition» Communication
– Code Generation» CSPm» CTC++» occam
– Prototype
WMC – HLSLA 200714 University of TwenteBroenink et al, 2007
CT-library: CSP-based Software Framework• CSP Process
– Active object: One thread of control• CTC++ software library
– Implements as building block-components– Connections as channels (synchronous, rendezvous)
» Link Drivers– Scheduler included (kernel-like)– Runs on Windows, DOS, RTAI (linux), ADSP
– Prototype
Process A Process BData-flow model
Data ->
rendezvousProcess A Process B
System 1
readwrite
System 2
distributed / heterogeneous
WMC – HLSLA 200715 University of TwenteBroenink et al, 2007
NWsim: Distributed Simulation Framework
• CSP approach– All parts are CT processes– Remote Channels couple to Fieldbus– Network Simulator based on
TrueTime• Time Synchronization
– Prioritized Parallel– Rendezvous in Timer Channels– SimTimer advances time
• Interaction continuous –discrete parts
– Basic integration methods (continuous part)
– Plant model calculations on demand
– 1st try out
WMC – HLSLA 200716 University of TwenteBroenink et al, 2007
Network Simulator - Case
• Simulator OK– compared with traditional
• Network parameters– Influence behavior– Optimal via simulation
WMC – HLSLA 200717 University of TwenteBroenink et al, 2007
ForSee: Connect, Compile, Configure, Command
Code -> Target– Connect
» Model variables to target signals
• Token replacement» Keeps model free of
target anomalies– Guides
» Compilation, Configuration, Logging specification
– Prototype
gCSPgCSP OtherOther2020--SimSim
codegeneration
Target ConnectorTarget Connector
Compiler assistant
Deployment manager
Real-time loggerTargetTarget
Target template:HW descriptionsTarget options
Logging capabilitiescodeprocessing
(cross)compilation
Send to target(s)
log
data
Start/stopModify
parameters
1
2
3
45
6
7
gCSPgCSPgCSPgCSP OtherOtherOtherOther2020--SimSim2020--SimSim
codegeneration
Target ConnectorTarget Connector
Compiler assistant
Deployment manager
Real-time loggerTargetTarget
Target template:HW descriptionsTarget options
Logging capabilities
Target template:HW descriptionsTarget options
Logging capabilitiescodeprocessing
(cross)compilation
Send to target(s)
log
data
Start/stopModify
parameters
1
2
3
45
6
7
WMC – HLSLA 200718 University of TwenteBroenink et al, 2007
ForSee: Connect, Compile, Configure, ControlCode
generatorModel SourcesCode
compiler ExecutableDeploy-
mentRunning
task
WMC – HLSLA 200719 University of TwenteBroenink et al, 2007
ForSee: Connect, Compile, Configure, Control
Deployment manager– Check target (status)– Upload
» Executable» Configuration
(parameters/hardware)– Task control
» Start/Stop» Data logging control
– Retrieve log data– Modify/inspect parameters
Code generatorModel Sources
Code compiler Executable
Deploy-ment
Runningtask
WMC – HLSLA 200720 University of TwenteBroenink et al, 2007
ForSee: Connect, Compile, Configure, Control
– Real-time logging– Work in progress
3D model follows real
setup
model
0 0.5 1 1.5 2 2.5 3 3.5 4time {s}
0
0.05
0.1
0.15 xPositionPID {m}PositionLQG {m}
WMC – HLSLA 200721 University of TwenteBroenink et al, 2007
Further tool integration
• Current tools cover design flow– Cooperate smoothly– Still separated per discipline
• Real cooperative design– One-model – One-tool approach too optimistic yet
» Multiple view modeling (& tools)– Tightly coupling needed also on model level
» Check cross-domain aspect relations – Co-simulation on execution level
WMC – HLSLA 200722 University of TwenteBroenink et al, 2007
Multi-view Integration Framework
Tool neutral format:core model
requirements
Continuous time Discrete event
Parameters
Data repository
Versioncontrol test patterns
Software related Hardware related
dependencies
Coremodel A Coremodel B
Inter-viewData storage
Translation/coupling
Tool integrationlayer
ToolsCo-simulationengine Consistency
checking
TranslatorsDependency
couplingCombined
code generation
Appliance
I/OComputer&
Software
Motor
Motor
Motor
Tool 1
Tool 2
extension/plugin extension/plugin
Data mapping Model updateData bus
Data mapping Model update
Tools, viewpoints &views
Data exchange
WMC – HLSLA 200723 University of TwenteBroenink et al, 2007
Example: Co-Simulation
Tool neutral format:core model
requirements
Continuous time Discrete event
parameters
Data repository
versioncontrol test patterns
Software related:interfaces
Hardware related:interfaces
dependencies
Coremodel A Coremodel B
Inter-viewData storage
Translation/coupling
Tool integrationlayer
Appliance
I/OComputer&
Software
Motor
Motor
Motor
Tool 1
Tool 2
extension/plugin extension/plugin
Data mapping Model updateData bus
Data mapping Model update
Tools, viewpoints &views
Data exchange
Time synchronizationCo-simulation engineData flow coupling
WMC – HLSLA 200724 University of TwenteBroenink et al, 2007
Case: twin-axes device JIWY
• Characteristics– 2 motor encoder pairs– Timed belt driven
Toplevel model (step 1 & 2)
Configuration
Joystick controller Plantio
WMC – HLSLA 200726 University of TwenteBroenink et al, 2007
Cases: Observations
• JIWY & Tools– 4th Yr EE elective course on Real-Time Software
» Preparation exercises to follow the workflow» “Doing right first time” on real setup succeeded
• Tools– Shorting of design time observed– 2nd Yr EE students, mechatronics project
» ECS completely hidden (only 20-sim, 4C)– MSc projects
» Robotics / Mechatronics: effective use» ECS: stress testing parts of the chain
Top Related