modelling, simulation and real-time testing for model ... · developing a motor control algorithm...

30
1 © 2013 The MathWorks, Inc. Modelling, Simulation, and Real-Time Testing for Model-Based Design GianCarlo Pacitti Application Engineer MathWorks

Upload: others

Post on 03-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

1 © 2013 The MathWorks, Inc.

Modelling, Simulation, and Real-Time

Testing for Model-Based Design

GianCarlo Pacitti

Application Engineer

MathWorks

Page 2: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

2

What’s great about simulation?

An example: Simulating a data exchange protocol for a

distributed network of communicating RFID tags

Page 3: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

3

What’s great about simulation?

You can do a lot of tests

You can automate them

Tests are repeatable

Easy to investigate issues

You don’t need physical hardware

Page 4: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

4

Doing simulation keeps getting easier

Ever-increasing range of modelling constructs

Ecosystem

– Physical modelling tools

– Specialist application-specific tools

– Design and analysis tools

– Verification and validation tools

– Parallel computing tools and data analysis in MATLAB

– Model management tools…

Page 5: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

5

Real-Time Testing System Requirements

System Design

Software Design

Implementation

Software

Integration

Development Process

Simulation

Rapid Prototyping

Proof-of-Concept

Production Code Generation

System Integration

and Tuning

Hardware/Software

Integration

Hardware-in-the-Loop Testing

Page 6: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

6

Example applications for these workflows

Developing a proof of concept video processing

algorithm

Developing a motor control algorithm for a new

brushless DC motor

In all cases, simulation is the starting point

Page 7: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

7

The Next Step: Real-Time Testing

Prove the effectiveness of the design in the real world

Test controller against a real plant

Verify interfaces/electrical characteristics

Measure performance

Stimulate a device and acquire data

Black box testing

Page 8: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

8

What’s hard about running on hardware?

It’s complicated!

– Producing a real-time implementation

– Low-level hardware set-up

– Tool-chain configuration

– Multiple environments

– Hardware options

– Debugging issues

?

Page 9: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

9

How can I get to hardware from Simulink?

Data Acquisition Toolbox, Instrument Control Toolbox,

Vehicle Network Toolbox

Run on Target Hardware capability in Simulink

Support Packages for other development boards

Real-Time Windows Target

xPC Target

How do these tools help with the complexity of running

on hardware?

Page 10: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

10

Run Simulink models on low-cost hardware

With just a click, your model

moves from Simulink onto

hardware

Supported target hardware

– Raspberry Pi

– Arduino® Uno and Mega 2560

– LEGO® MINDSTORMS® NXT

– BeagleBoard and more…

Page 11: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

12

Example: Ball tracking on a Raspberry Pi

Page 12: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

13

Run On Target Hardware

– Early stage prototyping/lab experiments

– Low cost hardware

– Relatively limited I/O

– Examples:

EXPO RFID tags

LEGO robot competition

Proof of concept video processing algorithm

Page 13: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

14

EXPO RFID Experiment

ATMEGA 328P from Arduino

RF12 433MHz

Transceiver

CR2032 3V

Lithium battery

Serial communication

between transceiver

and base-station

UDP connection

to database

Raspberry Pi Base-Station Arduino-based Active RFID Tag

Aerial

RFID tags and base-stations programmed using

Run On Target Hardware feature from Simulink

Raspberry Pi

Base-

station

specific

RFID Tag

Page 14: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

15

Support Package Downloads

>> targetinstaller

Growing list of support packages

available for a range of devices

Only requires Simulink

Page 15: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

16

Real-Time Testing using xPC Target

xPC Target enables you to execute Simulink models on a target computer …

… for rapid control prototyping, hardware-in-the-loop (HIL) simulation, and other real-time testing applications.

Page 16: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

17

xPC Target

Hard real-time

Powerful processing capabilities

Reconfigurable and flexible I/O

Extensive data logging, profiling

Applicable across multiple applications/projects

Examples:

– Control system for Bloodhound SSC

– Real-time simulator for Dual Clutch Transmission

– Real-time testing for brushless DC motor control

Page 17: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

18

Brushed DC vs. AC Motor Control

Brushed DC Motor Control : Mechanical Commutation

Brushless DC Motor: Electrical Commutation

Software

Battery Embedded

Controller Inverter

Page 18: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

19

Build better models with real-time testing

How can I use real-time testing to build a better model?

– Characterise a plant

– Optimise a controller

– Verify a system design

Test Identify

Parameters Verify

Page 19: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

20

Real-Time Control System

Motor

Hardware

Controller

C Code

System Model

Workflow Model your system, design your controller, and test in real-time

Controller

C/HDL Code

Controller

Model

Motor

Model

Motor

Hardware

Page 20: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

21

Real-Time Control System

Motor

Hardware

System Model

Model your system using MATLAB and Simulink

Controller

C Code

Controller

Model

Controller

C/HDL Code

Motor

Model

Motor

Hardware

Page 21: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

22

Coast Down Test

Coast down test used to identify:

Rotor inertia (H)

Test Extract

Parameters Verify

Page 22: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

23

Identify Rotor Inertia (H)

Note: J0 and b are known from friction

test. Curve fit equation for ωr to find H.

𝑑𝜔𝑟

𝑑𝑡=

1

𝐻 𝑇𝑒𝑚 − 𝑏𝜔𝑟 − 𝐽0 − 𝑇𝑙𝑜𝑎𝑑

𝐼𝑓 𝑇𝑙𝑜𝑎𝑑 = 0 𝑇𝑒𝑚 = 0

𝑇ℎ𝑒𝑛

𝜔𝑟 = 𝜔𝑟0 + 𝐽0

𝑏 𝑒−

𝑏𝐻𝑡 −

𝐽0

𝑏

Test Extract

Parameters Verify

Page 23: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

24

Validate Coast Down Test Test Extract

Parameters Verify

Page 24: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

25

Real-Time Control System

System Model

Design your controller through simulation

Controller

C Code

Motor

Hardware

Motor

Model

Controller

Model

Controller

C/HDL Code

Motor

Hardware

Page 25: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

26

Demo: Tune Controller using Optimisation

Page 26: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

27

Real-Time Control System

Motor

Hardware

Controller

C Code

System Model

Test and Verify your design

Motor

Hardware

Motor

Model

Controller

Model

Controller

C/HDL Code

Page 27: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

28

Demo: Validated Control Design

Page 28: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

29

Real-Time Testing System Requirements

System Design

Software Design

Implementation

Software

Integration

Development Process

Rapid Prototyping

Proof-of-Concept

System Integration

and Tuning

Hardware/Software

Integration

Hardware-in-the-Loop Testing

Motor Controller

Controller

Motor

Page 29: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

30

In conclusion

Simulation allows you to design and test systems far

more extensively than is possible with physical tests

Real-time testing helps you build better models, and

eliminate bugs in your design before going to the final

hardware

Simulink tools and support packages help manage the

complexity of getting to hardware for real-time testing

Page 30: Modelling, Simulation and Real-Time Testing for Model ... · Developing a motor control algorithm for a new brushless DC motor In all cases, simulation is the starting point . 7 The

31

Questions?