Hardware in the Loop (HIL) Simulation Ken Jackson Vice-President Real-Time Agenda • • • • • • • • Why Simulation? Software Modeling Frequencies - ΔT Integration: Software with Hardware (I/O) HIL Examples HIL Components RTOS & RT-Tools Simulation Executive (SimWB) Why Simulation? • Industry is constantly developing products • Those products require designing & testing • Software modeling & Simulation lower development cost and improve time to market Concurrent Computer Corporation - Company Confidential Design Issues Hinge Friction • Dimensions • Hardware • Materials • Performance • Mass Y W Spring Force X Concurrent Computer Corporation - Company Confidential Z Software Modeling Rather than building and testing repeatedly, the door and its components can be modeled in software. This way, design parameters can be changed quickly and easily while running repeated tests d t dt d d d 2 2 dt dt dt lim d dt tdt 0 1 2 0t t C2 2 Concurrent Computer Corporation - Company Confidential Fspring kx Frequency - T • Granularity • Fidelity 1 Hz t=0 T 1 t=1 Concurrent Computer Corporation - Company Confidential t=2 Frequency - T • Higher Frequency / Finer Granularity • Higher Fidelity / Resolution 100 Hz T .010 Concurrent Computer Corporation - Company Confidential Integrating Software Model with Hardware • Hardware in the Loop • Mate real hardware with the software simulation Concurrent Computer Corporation - Company Confidential Hard Real-Time HIL Applications Aerospace FADEC Design/Test High Lift Simulation Missile Design/Test Aircraft Design/Test Guidance Design/Test Weapons Design/Test Defense Radar &Telemetry Non-Aerospace Design/Test Controller Design/Test Weapons Design/Test Automotive Powertrain Control Design/Test Chassis Control Design/Test Suspension Control Design/Test Braking Control Design/Test FlexRay Design/Test M1 Tank Hard Real-Time HIL Examples M1 Tank How are HIL systems used? Phalanx Hard Real-Time HIL Examples • Ford – PCM (Powertrain Control Module) Testing in the Virtual Powertrain and Control System (VPACS) HIL Laboratory for current and future vehicles (MATLAB/Simulink) – Testing/developing ECU code for controllers, gas, diesel etc. with lots of I/O in systems Hard Real-Time HIL Examples • Johns Hopkins – Hardware-in-the-Loop (HIL) missile testing for the US Department Of Defense (DOD) • RedHawk used in classified HIL application • Draper Labs – Graphics processing in the simulation environment – Trident Controls Development – HILS • Sikorsky – Selected for Blackhawk helicopter engineering simulation – Utilizes Concurrent RedHawk Linux and NightStar tools Hard Real-Time HIL Examples • Common Missile HIL – Classified DAC application • B1B bomber - Weapons control systems – Mission critical EMUX performance required Hard Real-Time HIL Examples • Collins submarine - Simulation/test of Sonar arrays • Tomahawk missile program – Real-Time Hardware-in-the- Loop (HIL) testing Hard Real-Time HIL Examples • Joint Standoff Weapon (JSOW) – Real-Time Hardware In the Loop (HIL) Testing • Small Diameter Bomb (SDB) – Real-Time Hardware-inthe-Loop (HIL) Testing Hard Real-Time HIL Examples • Airbus– HIL simulation A400M, A320, A340, and A350 programs – HIL Test stands for HLSS in Bremen (SIMulation Workbench) Hard Real-Time HIL Examples • MBDA – A world-leading missile systems company with products from armor piercing land weapons to air-toair missiles use HIL simulators Hard Real-Time HIL Examples • MHI Nagasaki (Mitsubishi Heavy Industries) – HIL simulator for new G-RX6 torpedo – High-performance homing system generates sound waves & analyzes returns for multiple target discrimination & location, destroyers, subs, decoys Hard Real-Time HIL Components • Real-Time Operating System • Real-Time Development Tools • Real-Time Simulation Environment • COTS I/O Concurrent Computer Corporation - Company Confidential Real-Time Technology Real-Time Operating System Concurrent Computer Corporation - Company Confidential Real-Time Operating Systems Desirable Real-Time features: – Guaranteed hard real-time response – Advanced shielding features • Easy-to-use API and GUI • Processor, interrupt and local timer – NUMA Performance Optimization – UIO User-level Driver Support – Real-Time Scheduler – Optimized graphics I/O – Lockless kernel trace – User-level preemption control – High Resolution timers – Single-kernel solution Concurrent Computer Corporation - Company Confidential RedHawk Advantages • RedHawk Linux provides the following market strengths and differentiators over proprietary embedded OS products and other Linux distributions: – RedHawk is an true Linux distribution (not micro-kernel) – RedHawk Linux is optimized for multi-core platforms (SMP) – RedHawk is fully compatible with the Red Hat user environment – NightStar tools provide superior functionality over competing tool sets especially in multi-core applications – RedHawk Architect GUI tool will provide a single, easy-to-use tool for building an embedded solution – RedHawk will easily address the needs of applications that have both soft and hard real-time requirements. – Extensive Concurrent experience in supporting Linux and Linux applications Concurrent Computer Corporation - Company Confidential Real-Time Technology Real-Time Development Tools Concurrent Computer Corporation - Company Confidential Development Tools Desirable Real-Time features: • Minimally-intrusive multi-system, multi-process debugging via a single interface • Hot patched event points including breakpoints, patchpoints, monitorpoints, watchpoints, and tracepoints • Application speed execution • View of Linux kernel activity and user space • Complete view of application threads running across available CPU cores • Automatic insertion of trace points NightStar Tools Optimizes multi-core environments Reduces test time Improves productivity Lowers program costs Accelerates time to market Concurrent Computer Corporation - Company Confidential Real-Time Technology Real-Time Simulation Environment Concurrent Computer Corporation - Company Confidential Simulation Environment Desirable Real-Time features: – Support both hand-written and autocoded models concurrently – Run multiple models at multiple rates concurrently while sharing interdependent data – Trace both types of models simultaneously – Simple I/O to Model interface – Real-Time Scheduler – Easy to use GUIs – Data logging and playback – Real-time viewer with easy to use display tool – Powerful COTS systems and I/O Simulation Cycle SimWB Scheduler Frame Input Cycle Analog Input CPU a Test script Cycle (Optional) Test Script CPU n Digital Input CPU b MATLAB/Simulink or Custom Model Cycle Output Cycle In1 Data Raw Input Values Output Data Gatherer EU Values + Meta Data CVT HMI Sync Process Async Process Out1 Memory Resident RTDB Analog Input Device Digital Input Device Model CPU x,y,z … CPU x Data Logger CPU a Analog Output CPU x Digital Output CPU z Analog Output Device Raw Output Values Input Data Gatherer Data Viewer CPU b Digital Output Device SIMulation Workbench SIMulation Workbench Overview • A framework which enables the cyclic execution of simulation models in real-time. • Connect the inputs and outputs of the models with external hardware and interact with the model signals and parameters via program and operator interfaces in real-time. • SimWB is based on Concurrent's Frequency Based Scheduler (FBS) and fully supports multiprocessor architectures. Why use SimWB? • Leverage Simulink and other tools for rapid prototyping and HIL simulations • Ability to change/tune input, output, and parameters in real-time • Capture, store, and visualize simulation data • Leverage RedHawk real-time features including CPU shielding and scheduling on multiprocessor platforms More – Why use SimWB? • • • • • COTS hardware Thousands of I/O points Multi-Core support Multiple models on different cores Run multi-rate Simulink model as threads on different cores • Support for – 32 and 64 Bit MATLAB®/Simulink® Support – 32 and 64 Bit real-time Linux environment support (SimWB32 & SimWB64) SIMulation Workbench Features • Platform independent Control Panel (Java based graphical user interface) • User access control for resources • Data logger viewer tool (DL Viewer) • Execute multi-rate Simulink models on different cores • Change CPU affinity of multi-rate Simulink models at run-time for improved CPU load balancing • Simulink Model Referencing support • ASAM support Modelling & Simulation Complete Integration & Test System-Level Integration & Test Subsystem Integration & Test Implementation Subsystem Design System Level Specification Define Requirements SimWB in Model-Based Design Integration & Test * Rapid Prototyping Hardware-in-the-loop Simulation * * Production Code Generation * SIMulation Workbench can be used in these phases of Model-Based Design Example SimWB Setup SimWB Toolkit for MATLAB MATLAB on Windows/Linux Real-Time Workshop Simulink Optional Toolboxes SimWB Toolkit Real-Time Host Interface Localhost or Ethernet Data Recorder SimWB on Real-Time Linux Host RTDB I/O HMI Data Viewer SimWB Core Modules • • • • • • • • Model Ingest Real-time Data Base (RTDB) Scripting Language (Swm) I/O Support Data Recorder Playback Real-Time Viewer (RT Viewer) Data-Logger Viewer (DL Viewer) User Model Ingest • Import a handwritten model into the SimWB framework • Compile code and create the executable • Transparently map to the Real-Time Database (RTDB) and hook into the real-time scheduler Simulink Model Ingest • Use SimWB menu in Simulink to access the SimWB Toolkit GUI • Automatically create RTDB for Simulink model • Automatically generate SimWB compliant code using RTW (Simulink Coder in R2011b) • No need for hardware dependent S functions Real-Time Database (RTDB) • Memory resident • Map RTDB variables to physical hardware channels • Engineering unit conversion • GUI panels for convenient remapping of model parameters and I/O points • Simulink model parameters (Gain, Constant, Look-up table, etc..) are created at runtime and mapped in the RTDB RTDB I/O Mapping Scripting Language • • • • Test management capabilities Provides the environment to control a test run Integrated environment to edit/compile test scripts Extensive API to modify the RTDB in real-time and control I/O devices (timing, pause/resume, etc.) • Python, C, or Swm language capable – Synchronous (runs as part of the scheduling loop) – Asynchronous (via network client API) • Automatically generate HTML test reports. Embedded Editor Data Logger • All simulation data points can be recorded individually and independently of the Simulink modeling environment. There is no impact on the model runtime. • Hardware and engineering unit values, as well as run-time flags and time stamps are recorded. • Depending on the performance required, data logging can be run on the real-time simulation host or on a separate networked server. Test Session Playback • Provides the mechanism to take logged data and write it back into the RTDB. • The playback mechanism is synchronized via RedHawk’s Frequency-Based Scheduler. • Replay simulation data as it occurred for analyzing and tuning. • Test scripts can run simultaneously during playback giving the operator the ability to experiment with a portion of the simulation and tune the results. Advanced Playback Support DL Viewer • Visualize SimWB RTDB values that have been logged using the SimWB data logger. • Save and export to Excel and MATLAB MAT files. RT Viewer • Visualize SimWB RTDB values in realtime • Visualize scheduler info • Get/Set CVT and ALT values Human Machine Interface • Multi-platform Javabased HMI • Display RTDB items in real-time • Show real-time plots • Display logged data • Display test scheduling information • Lots of built in widgets for creating photo-realistic HMIs Multi-Screen Photo-realistic HMI Display’s Multi-rate Multi-core Support for Simulink Models • Run multi-rate Simulink model as threads on different cores. • Visualize model statistics including multi-rate thread statistics at runtime. • Modify CPU affinity of different threads for improved CPU load balancing. Hard Real-time System With Multi-rate Tasks Example: A Fly-by-wire Avionics model Sensors Conditioning Gyros accel INU 1 KHz GPS GPS 20 Hz Air Sensors Air data 1 KHz Stick Joystick 500 Hz Control Laws Pitch control 500 Hz Lateral control 250 Hz Throttle control 250 Hz Actuating Actuators Aileron1 1 KHz Aileron Aileron 2 1 KHz Aileron Elevator 1 KHz Elevator Rudder 1 KHz Rudder Example: Simple Simulink Model With Multi-rate Tasks Multi-rate Model in Single-tasking Mode CPU0 CPU1 CPU2 CPU3 Tasks with faster rates have higher priorities CPU4 CPU5 Real-Time execution of a single-tasking system requires a base sample rate that is long enough to execute one step through the entire model. Assuming each sub-rate in the model requires less than 1500us for execution, one step through the entire model requires 6000us which is still less than the base rate of 10000us. Thus, single-tasking mode works in this example but can result in inefficient use of available CPU time. Multi-rate Model in Single-tasking Mode – CPU Overruns CPU1 CPU overrun in single-tasking mode 20000us Safety Margin Tasks with faster rates have higher priorities Unused CPU time Avoid CPU overruns at the expense of unused CPU time and slower simulation speed by decreasing the base rate Real-Time execution of a single-tasking system results in CPU overruns if it takes longer than the base rate to execute one step through the entire model. Assume the Discrete 3 sub-rate requires 20000us for execution. To continue execution in single-tasking mode, the base rate has to be decreased to be greater than 20000us+1500*3us or the execution will result in CPU overrun. Multi-rate Model in Multi-tasking Mode on a single CPU CPU1 a b c Pre-emption by a higher priority task a + b + c = Tasks with faster rates have higher priorities 20000us When running multiple tasks on the same CPU, the higher priority tasks preempt the lower priority tasks. No CPU over run occurs, if all the tasks are completed before they are run again. Occasional CPU overruns can occur due to changing task execution times and context switching times resulting in CPU idle times not being enough to complete the preempted tasks. Multi-rate Model in Multi-tasking Mode Multiple CPUs - The SIMulation Workbench Advantage CPU0 CPU1 CPU2 CPU3 Tasks with faster rates have higher priorities CPU4 CPU5 With SimWB multi-rate multi-tasking support, tasks with different rates are run in their own thread and these tasks can be run on different CPU’s thereby preventing overruns. Multi-rate Model in Multi-tasking Mode CPU Load Balancing - The SIMulation Workbench Advantage CPU0 CPU1 CPU2 CPU3 CPU4 CPU’s available for executing other Simulink models, C/C++ user models, and I/O tasks. Tasks with faster rates have higher priorities CPU5 CPU6 With SimWB not only can we run different tasks on different CPU’s but we can also visualize the task execution time for different tasks and reassign the tasks to run on different CPU’s for improved CPU load balancing. Actual Screenshot of the RT Viewer for a Multi-rate Simulink Model Support for Simulink Models Containing Model References • Model reference lets you break up the hierarchy into separate models. • These models can be simulated and built stand alone, which means teams can independently develop components in parallel. • Teams deal with fewer blocks in their models. • Simulate and unit test component models. • Incremental update diagrams and code generation saves time. • SimWB now supports code generation for a Simulink model containing model references. MATLAB/Simulink Example of a Model Referenced System Light Subsystem Stereo Subsystem Blinker Subsystem AC Subsystem Airbag Deployment System Car Model Top Level Team A Model Body Electronics System Powertrain System Team B Model ECU model Chassis System Vendor D Model Vendor C Model SimWB can generate compliant code for the top level model and automatically include the referenced models. Real-Time Technology COTS I/O Concurrent Computer Corporation - Company Confidential COTS I/O Support • • • • • • • • • • • Analog Input and Output Digital Input and Output AFDX / ARINC 664 ARINC 429 CANbus MIL-STD-1553 RVDT/LVDT Resolver Counter/Timer FlexRay Reflective Memory • • • • • • • • Serial I/O Relays Resistor simulator Arbitrary waveform generator ScramNet GT 200 reflective memory Square wave generators DDS wave synthesizer CCUR PWM 1012 RCIM Features RCIM • • • • • • • • 8 interrupt-generating real-time clocks 12 edge-triggered input external interrupt lines 12 output external interrupt lines 12 inter-CPU interrupts Can sync to external time sources GPS synchronization option Inter-system connects PMC,PCI or PCIe External clock sync RoHS compliant Oscillator, Down to .01 PPM Accuracy (<1 sec/yr) Interrupts GPS option Distributed Environment • • • • • • Use the RCIM to synchronize the distributed systems Can sync to external time sources GPS synchronization option Use 10g Enet or Firewire to pass data packets Data can be synchronous or asynchronous Configuration only limited by timing contraints Concurrent Computer Corporation - Company Confidential Questions? Simulation, Training & Test Systems Embedded Systems Data Acquisition & Control Systems