Hardware in the Loop (HIL) Simulation Ken Jackson Vice-President Real-Time.

Post on 28-Jan-2016

237 views 1 download

Transcript of Hardware in the Loop (HIL) Simulation Ken Jackson Vice-President Real-Time.

Hardware in the Loop (HIL) Hardware in the Loop (HIL) SimulationSimulation

Ken Jackson Ken Jackson Vice-President Real-TimeVice-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)

Concurrent Computer Corporation - Company Confidential

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

Spring Force

Hinge Friction

WY

XZ

• Dimensions

• Hardware

• Materials

• Performance

• Mass

Concurrent Computer Corporation - Company Confidential

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

22

0

0

2

2

2

1

lim

Ctt

tdtdtd

dt

d

dt

d

dt

d

dt

d

t

kxFspring

Concurrent Computer Corporation - Company Confidential

t = 0 t = 1 t = 2

• Granularity• Fidelity

1T1 Hz

Frequency - T

Concurrent Computer Corporation - Company Confidential

• Higher Frequency / Finer Granularity• Higher Fidelity / Resolution

010.T100 Hz

Frequency - T

Concurrent Computer Corporation - Company Confidential

Integrating Software Model withHardware

• Hardware in the Loop

• Mate real hardware with the software simulation

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

How are HIL systems used?

M1 Tank

Phalanx

Hard Real-Time HIL Examples

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

• 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-in-

the-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-to-air 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 Examples

Concurrent Computer Corporation - Company Confidential

• Real-Time Operating System

• Real-Time Development Tools

• Real-Time Simulation Environment

• COTS I/O

Hard Real-Time HIL Components

Concurrent Computer Corporation - Company Confidential

Real-Time Operating SystemReal-Time Operating System

Real-Time Technology

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 Development Tools Real-Time Development Tools

Real-Time Technology

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

Concurrent Computer Corporation - Company Confidential

NightStar Tools

Optimizes multi-core environmentsReduces test timeImproves productivityLowers program costsAccelerates time to market

Concurrent Computer Corporation - Company Confidential

Real-Time Simulation Real-Time Simulation Environment Environment

Real-Time Technology

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

Digital InputDigital Input

Analog Input

Analog Input

Input Cycle

Test ScriptTest

Script

Test script Cycle

(Optional)

SimWB Scheduler Frame

Analog Output Device

Analog Output Device

DigitalOutput Device

DigitalOutput Device

Analog Input Device

Analog Input Device

DigitalInput Device

DigitalInput Device

MATLAB/Simulink or Custom Model Cycle

Output Cycle

DigitalOutputDigitalOutput

Analog OutputAnalog Output

Memory Resident RTDB

EU Values +

Meta Data

CVT

Raw InputValues

Raw InputValues

Raw OutputValues

Raw OutputValues

CPU x,y,z …In1 Out1ModelCPU a

CPU b

CPU n CPU x

CPU z

Data LoggerCPU a

Data LoggerCPU a

Data ViewerCPU b

Data ViewerCPU b

HMI

CPU x

HMI

CPU xSync ProcessData

Async Process

Output Data

Gatherer

Output Data

Gatherer

InputData

Gatherer

InputData

Gatherer

Force model inputs

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 multi-processor 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

SimWB in Model-Based Design

SIMulation Workbench can be used in these phases of Model-Based Design

Rapid Prototyping

Production Code Generation

Hardware-in-the-loop Simulation

***

*

Example SimWB Setup

SimWB Toolkit for MATLAB

MATLAB onMATLAB onWindows/LinuxWindows/Linux

Simulink Real-Time Workshop

Optional Toolboxes

Real-Time Host Interface

SimWB on SimWB on Real-Time Linux HostReal-Time Linux Host

Data Viewer

Localhost or Ethernet

Data Recorder

SimWB Toolkit

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 hand-written 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 real-time

• Visualize scheduler info

• Get/Set CVT and ALT values

Human Machine Interface

• Multi-platform Java-based 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 forSimulink 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

Gyros accel

GPS

Air Sensor

s

Stick

INU1 KHz

GPS20 Hz

Air data 1

KHz

Joystick

500 Hz

Aileron1 1 KHz

Aileron 2

1 KHz

Elevator

1 KHz

Rudder

1 KHz

Aileron

Aileron

Elevator

Rudder

Pitch control500 Hz

Lateral control250 Hz

Throttle control250 Hz

Example: Simple Simulink Model With Multi-rate Tasks

Multi-rate Model in Single-tasking Mode

CPU2

CPU1

CPU0

CPU5

CPU4

CPU3

1000

0 us

0 us

2000

0 us

3000

0 us

4000

0 us

5000

0 us

6000

0 us

7000

0 us

8000

0 us

9000

0 us

1000

00 us

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.

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.

Tasks with faster rates have higher priorities

1000

0 us

0 us

2000

0 us

3000

0 us

4000

0 us

5000

0 us

6000

0 us

7000

0 us

8000

0 us

9000

0 us

1000

00 us

Multi-rate Model in Single-tasking Mode – CPU Overruns

CPU1

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.

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.

CPU overrun in single-tasking mode

20000us20000us

Avoid CPU overruns at the expense of unused CPU time and slower simulation speed by decreasing the base rate

Unused CPU timeSafety Margin

Tasks with faster rates have higher priorities

Multi-rate Model in Multi-tasking Mode on a single CPU

CPU1

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.

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.

aa bb cc

Pre-emption by a higher priority task

20000us20000usaa bb cc+ + =

Tasks with faster rates have higher priorities

1000

0 us

0 us

2000

0 us

3000

0 us

4000

0 us

5000

0 us

6000

0 us

7000

0 us

8000

0 us

9000

0 us

1000

00 us

Multi-rate Model in Multi-tasking ModeMultiple CPUs - The SIMulation Workbench Advantage

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.

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.

CPU2

CPU1

CPU0

CPU5

CPU4

CPU3Tasks with faster rates have

higher priorities

1000

0 us

0 us

2000

0 us

3000

0 us

4000

0 us

5000

0 us

6000

0 us

7000

0 us

8000

0 us

9000

0 us

1000

00 us

Multi-rate Model in Multi-tasking ModeCPU Load Balancing - The SIMulation Workbench Advantage

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.

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.

CPU2

CPU1

CPU0

CPU5

CPU4

CPU3

CPU6

Tasks with faster rates have higher prioritiesCPU’s available for executing other Simulink

models, C/C++ user models, and I/O tasks.

1000

0 us

0 us

2000

0 us

3000

0 us

4000

0 us

5000

0 us

6000

0 us

7000

0 us

8000

0 us

9000

0 us

1000

00 us

Actual Screenshot of the RT Viewer for a Multi-rate Simulink Model

Support for Simulink Models ContainingModel 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.

Stereo SubsystemAC Subsystem

Light SubsystemBlinker Subsystem

Body ElectronicsSystem

PowertrainSystem Chassis System

Airbag Deployment System

MATLAB/Simulink Example of a Model Referenced System

Car Model Top LevelCar Model Top Level

Team AModelTeam AModel

Team BModelTeam BModel

Vendor DModel

Vendor DModel

Vendor CModel

Vendor CModel

ECUmodel

ECUmodel

SimWB can generate compliant code for the top level model and automatically include the referenced models.

Concurrent Computer Corporation - Company Confidential

COTS I/OCOTS I/O

Real-Time Technology

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• PMC,PCI or PCIe • RoHS compliant

Inter-system connects

Interrupts

Oscillator,Down to .01 PPM

Accuracy(<1 sec/yr)

GPS option

External clock sync

Concurrent Computer Corporation - Company Confidential

• 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

Distributed Environment

Simulation, Training & Test Systems

Data Acquisition & Control Systems

Questions?

Embedded SystemsEmbedded Systems