Concurrent Design of Embedded Software Third International Workshop on Multi-Paradigm Modeling MPM`09, 06-10-2009 Marcel Groothuis, Jan Broenink University of Twente, The Netherlands Raymond Frijns, Jeroen Voeten Eindhoven University of Technology, The Netherlands 07/10/2009 Concurrent Design of Embedded Software 1
Contents Introduction Mechatronic systems design challenges Embedded Systems software Model-driven Design Methodology Case study Results & Conclusions Concurrent Design of Embedded Software 2
Introduction Mechatronics challenges Developing Reliable and Robust Embedded Software for mechatronic applications is too costly and too time consuming. Reasons: Complexity, Heterogeneity, Lack of Predictability, Late Integration Approaches to tackle the problem Concurrent Engineering, Model Driven Design, Early Integration Sequential Concurrent Model-driven concurrent Trade-off between concurrency design process (a) design process (b) design process(c) efficiency and integration efficiency (d) Specs Specs Specs Specs Design Time Continuous Time Discrete Event Continuous Time Integration Discrete Event Continuous Time Integration Discrete Event Continuous Time 1 Integration Discrete Event 2 3 Integration Trade-off concurrent design flow integration efficiency Concurrent Design of Embedded Software 3
Mechatronics: Embedded Systems Essential Properties Embedded Software Dynamic behavior of the physical system essential for SW Real-time constraints with low-latency requirement Dependability: Safety, Reliability Layered Software structure Embedded software Non real-time Soft real-time Hard real-time I/O hardware Power D/A amplifier Physical system Actuators Physical process A/D Filtering/ Scaling Sensors Model-driven Design Heterogeneous modeling Multiple Models of Computation Multiple Modeling formalisms Concurrent Design of Embedded Software 4
ECS Design Methodology Aim Efficient Concurrent Design Fast Integration Reliable Result Approach: Model-Driven Design Concurrent Design Code Synthesis Concurrent Design of Embedded Software 5
ECS Design Methodology Way of Working Abstraction Hierarchy Split into subsystems Cope with complexity Model-driven design Design Space Exploration Aspect models Make choices Limit solution space Step-wise refinement Add detail Lower abstraction Implementation Realization Concurrent design trajectory Mechanics, Electronics, SW: Discrete Event, Continuous Time Model-level Early Integration where needed Concurrent Design of Embedded Software 6
Design Methodology Discrete Event Approach Stepwise & local refinement Verification by simulation & model checking Way of working System partitioning into concurrent actors C-model : Abstract interactions between concurrent actors M-model : Interaction between different MoCs R-model : Timing low-level behavior Property preserving code synthesis Characteristics Concurrency Multi MoC Real-time Models C-model M-model R-model Abstraction level High Low Concurrent Design of Embedded Software 7
Design Methodology Continuous Time Approach Stepwise & local refinement From model towards controller code Verification by simulation Physical System Modeling Verification by Simulation Way of Working Model & Understand Physical system dynamics Simplify model, derive the control laws Interfaces & target Add non-ideal components (AD, DA, PC) Dependability: Safety, Reliability, Integrate control laws into ES Scaling/conversion factors Via local refinement: {Software/Processor/Hardware}-In the Loop Concurrent Design of Embedded Software 8 Law Design Embedded System Implementation Realization Verification by Simulation Verification by Simulation / Model Check Validation and Testing
Case study Overview Goals Apply our methodology Real-world setup with industrial complexity Concurrent model-driven design Trade-off integrated design flow partial separated design flow Integration efficiency analysis Comparison with other test cases on the same setup Concurrent Design of Embedded Software 9
Gearhead 43:1 Gearhead 43:1 Magnet Gearhead 18:1 Encoder Case Study Production cell Extraction buffer Encoder Motor 150W Extraction unit Production cell demonstrator Based on: Stork Plastics Molding machine Extraction belt Rotation unit Molder unit Molder door Al Motor 70W Feeder belt Architecture CPU (ECS) + FPGA (digital I/O) Distributed possible Embedded PC CPU + FPGA Motor 150W Encoder Sensor Block movement direction Feeder unit 6 Production Cell units Action in the production process Molding, Extraction, Transportation, Storage Synchronize with neighbors Deadlock possible on > 7 blocks Concurrent Design of Embedded Software 10
Case Study Production cell Embedded System Software Design Jointly Specs, partitioning, interfaces Concurrently SW partitions Jointly SW integration & testing Design Time Model-driven concurrent design process Specs Continuous Time 1 Integration Discrete Event 2 3 User interface Supervisory control & Interaction Sequence control Loop control Safety layer Concurrent Design of Embedded Software 11
Gearhead 43:1 Motor 150W Encoder Encoder Motor 150W Gearhead 43:1 Magnet Al Gearhead 18:1 Motor 70W Encoder Case Study Partitioning & Hierarchy Embedded Software Discrete Event partition Continuous/Discrete Time partition Extraction buffer Extraction unit Gearhead 15:1 Motor 150W Encoder Extraction belt Based on Top level system model Production Cell Units (PCUs) Rotation unit Feeder belt Molder unit Molder door Layered Software structure Embedded PC CPU + FPGA Sensor Gearhead 15:1 Motor 150W Encoder Block movement direction Feeder unit DE CT/DT CT Interface User interface Supervisory control & Interaction Sequence control Loop control Safety layer Interface definitions Concurrent Design of Embedded Software 12
Discrete Event Software Design Modeling tools : SHESim/Rotalumis POOSL: Parallel Object-Oriented Specification Language SHESim: Graphical tool for model construction and simulation Rotalumis: Fast execution engine built in C++ C-model : handshake diagram formalized in POOSL model Partitions design into a set of concurrent actors Actors synchronize action by a handshake sequence Models untimed abstract interactions between actors Concurrent Design of Embedded Software 13
Discrete Event Software Design M-model: Refinement of C-model Adds interfaces to low-level behavior Focuses on interactions between high-level DE-control and DT/CT loop control (MoC interaction) Externally observable behavior is kept the same Concurrent Design of Embedded Software 14
Discrete Event Software Design R-model: Refinement of M-model Adds low-level behavior Both DT and DE behavior Adds timing Again, externally observable functional behavior is kept the same Automatic code synthesis: Automatic mapping to target platform Property-preserving code generation Building blocks with common interface Mathematically proven timing relation between model and implementation Discrete()() sel [ (curstate) & (prestate=false) ] sensor! on { prestate := curstate } or [ (prestate) & (curstate=false) ] sensor! off { prestate := curstate } les; Discrete()(). Continuous()() [ curstate = prestate ] curstate := sensor Read; delay 0.01; Continuous()(). Concurrent Design of Embedded Software 15
Continuous Time Software Design Goal Loop ler Algorithm in C++ POOSL dataclass Low Level Safety & Sanity Check Event Interface (start/stop/error ) Modeling Tools & Languages: 20-sim Physical System Model: ODE, bond graphs, data flow Code Synthesis: template based C/C++ Physical System Modeling Law Design Embedded System Implementation Realization Verification by Simulation Verification by Simulation Verification by Simulation / Model Check Validation and Testing ler MotionprofileFWBW finished Z -1 Delay1 Sample1 Gain_FF_acceleration K K Gain_FF_velocity PID PID2 D A PWM Encoder 1 K Attenuate1 DutyCyleLimiter Plant motor_out pos_in PWM Position Plant model rotation robot H-bridge model K HBridgeVoltage PWM (1.0=100%) 1 8.233e-005s +0.3172 LinearSystem1 SignalLimiter1 K_Motor Encoder pulses (2000/motor rev) MagnetPower ToEncoderPulses K K MotorCoil I MSe f MSe ArmWithMagnetI HangingBlock I 1 Motor and transmission GY TF 1 Motor C1 C R MotorResistance Arm with magnet + block p MTF MTF Gravity 1 Se RollerBearing TF 0 R TF BeltPulley C Cbelt I Roller R Rbreak Concurrent Design of Embedded Software 16
Gearhead 43:1 Motor 150W Encoder Encoder Motor 150W Gearhead 43:1 Continuous Time Software Design 0.4 0.3 0.2 0.1 led Motion Rotation Robot Ref Position {m} Extraction buffer 0 E 5 Motor current {A} 0-5 500 Rotation velocity {rad/s} 0-500 0.5 0 PWM Output {x100%) Embedded PC -0.5 CPU + FPGA F 3 Real Pos {rad} 2 1 0 0.0005 0 Error {m} DE software Loop + Safety FPGA HW -0.0005 1.5 1 0.5 0 1.5 1 0.5 0 Forward Finished Backward Finished 0 0.5 1 1.5 2 time {s} class ler_rotation: public PooslDataClass { /* the model functions */ void Initialize (double *u, double *y, double time); void Read (double *u, double *y); void Calculate (double *u, double *y, double time ); void Write (double *u, double *y); void Terminate (double *u, double *y); }; Concurrent Design of Embedded Software 17
Integration Discrete Event Last iteration: Timing Continuous Time / Discrete Time Last iteration: Event interface Target unit test Shesim POOSL implementation 20-sim POOSL template C++ class Motion profiles (12x) lers (6x) Code synthesis Stepwise Partial code generation Template based Simulation feedback I/O drivers template Rotalumis implementation RTAI Linux Target template Target tests Target PC Setup Concurrent Design of Embedded Software 18
Results & Discussion Short integration & testing phase < 2 days, previous case: > week Almost running first time right Minor timing issue with magnet on/off traction delay Concurrent, but separated design Minimal information exchange Refinements on interfaces, data types, timing Required Good partitioning Building blocks approach Working setup Concurrent Design of Embedded Software 19
Results Movie Concurrent Design of Embedded Software 20
Results & Discussion Specs Trade-off Concurrent Design Integration Continuous Discrete Time Event 1 Minimal design interaction Integration Minimal information exchange Refinements on interfaces, data types, timing Designers attitude Focus on own partition, but think across discipline boundaries Possible Improvements Model-based integration tests Physical system model could be used to test the final software Virtual Prototyping Tool support: Automated consistency checks Tool Tool integration Model Model interaction Design Time Model-driven concurrent design process 2 3 Concurrent Design of Embedded Software 21
Conclusions Mechatronics / Cyber Physical Systems Synergistic design approach Close cooperation between disciplines integrated design Integrated design concurrent design efficiency Trade-off between early integration and late integration time Choice is project specific Good partitioning of the mechatronic system Allows concurrent, but partly separated design Case: fully integrated design is not always needed More efficient work flow with still predictable integration Methodology not limited to SW implementation ECS ECS in FPGA realization available Concurrent Design of Embedded Software 22
Ongoing work Embedded System software for our Humanoid Soccer Robot Vision processing Supervisory control Sequence control Path planning Soccer strategy Low level loop control 24 degrees of freedom Concurrent Design of Embedded Software 23