MathWorks UK Conference 2008 Simulink Code of Practice for MBDA

advertisement
MathWorks UK Conference 2008
Simulink Code of Practice for MBDA
Tony Gailor
Head of Simulation and Modelling for the Anti-Armour, Air-Air and Air
Defence sector of MBDA in the UK and France.
Capability Leader for Simulation and Modelling across UK & France
Tyrone Catt
Technical Expert for Simulation and Modelling
Team Leader for Future Projects in the area of Simulation and Modelling
within MBDA.
Ref.: - Page 1 This document and the information contained herein is proprietary information of MBDA and shall not be disclosed or reproduced without the prior authorisation of MBDA.  MBDA 2005.
Agenda
•
•
•
•
Brief History & initial Simulink Code of Practice
Key Principles for establishing a Code of Practice
Mandatory Rules
Summary
Ref.: - Page 2 - 02/05/2008
This document and the information contained herein is proprietary information of MBDA and shall not be disclosed or reproduced without the prior authorisation of MBDA.  MBDA 2005.
A Little bit of history
Stove-piped use of
Simulink
Need for Change
Rapid Development
Projects
Paper based
Methods
The MathWorks –
CoP for MBDA
Improved Methods –
Generic System
Model
Multiple coding of
algorithms
But… No Project
Component-based,
no re-coding
Ref.: - Page 3 - 02/05/2008
This document and the information contained herein is proprietary information of MBDA and shall not be disclosed or reproduced without the prior authorisation of MBDA.  MBDA 2005.
Key Principles for Updated Simulink Code of Practice
Keep Mandatory Rules
to a minimum
Split - Mandatory & Recommended
Flexibility
Allow Tailoring of
Recommended Rules
Ref.: - Page 4 - 02/05/2008
This document and the information contained herein is proprietary information of MBDA and shall not be disclosed or reproduced without the prior authorisation of MBDA.  MBDA 2005.
Automation – Via
MBDA CoP Advisor
The MBDA Code of Practice for Simulink
Mandatory Rules
This document and the information contained herein is proprietary information of MBDA and shall not be disclosed or reproduced without the prior authorisation of MBDA.  MBDA 2005.
Schematic – Rules listed in Priority Order
Topic
Topic
Is the rule tested in MBDA CoP
Advisor? (green = yes, red = no)
Rule…
Rule…
Expansion / clarification / justification
of rule
Ref.: - Page 6 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 1
Available in MBDA CoP Advisor
Diagram
Diagram Layout
Layout
Ensure
Ensure that
that no
no portion
portion of
of aa
signal
signal line
line isis coincident
coincident
(overlaid)
with
a
(overlaid) with a portion
portion of
of
another
another as
as this
this can
can cause
cause
confusion
tracing
signal
confusion tracing signal
paths
paths
This may look neat - but it is confusing on
print outs & on diagrams requires user
manipulation to unravel which signal has come
from/gone to – adding avoidable time and
effort when debugging or reviewing.
Better to use Databuses
Ref.: - Page 7 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 2
Diagram
Diagram Layout
Layout
Tested in MBDA CoP Advisor
Draw
Draw signal
signal lines
lines vertically
vertically and
and
horizontally,
not
heading
off
horizontally, not heading off at
at
many
different
angles
many different angles
Lines running in parallel can be very neatly
drawn side by side round right angled bends.
Avoid lines crossing over as far as possible.
Ref.: - Page 8 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 3
Diagram
Diagram Layout
Layout
Tested in MBDA CoP Advisor
Goto
Goto and
and From
From blocks
blocks -- Never
Never
use
across
module
boundaries
use across module boundaries
Using these block breaks visibility of I/O for
the module, which may result in interfacing
mistakes.
Ref.: - Page 9 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 4
Diagram
Diagram Content
Content
Tested in MBDA CoP Advisor
Avoid
Avoid algebraic
algebraic loops
loops as
as they
they
slow
the
simulation
down
slow the simulation down
significantly.
significantly. Therefore
Therefore set
set the
the
“allow
“allow algebraic
algebraic loop”
loop” flag
flag to
to
“error”.
“error”.
With most single-body systems, it should be
possible to avoid most algebraic loops,
particularly if sensor and actuator dynamics are
modelled.
Ref.: - Page 10 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 5
Diagram
Diagram Content
Content
Tested in MBDA CoP Advisor
Memory
Memory block
block -- Never
Never use
use
with
variable
step
solvers.
with variable step solvers.
If
If the
the system
system isis discrete,
discrete,
use
the
unit
delay
use the unit delay block
block
instead.
instead.
Avoid using to fix algebraic loops.
Ref.: - Page 11 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 6
Tested in MBDA CoP Advisor
Diagram
Diagram Content
Content
Transport
Transport delay
delay and
and
variable
variable transport
transport delay
delay ––
Don’t
Don’t use
use these
these blocks
blocks ifif at
at
all
possible;
Try
to
use
all possible; Try to use
integration
integration step
step dependent
dependent
discrete
time
delays
discrete time delays
instead.
instead.
Any delays in a missile system would
typically be due to processing, and as
such should be modelled using discrete
time delays. This is computationally
much more efficient.
Ref.: - Page 12 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 7
Tested in MBDA CoP Advisor
Diagram
Diagram Content
Content
Derivative
Derivative block
block -- Never
Never
use
use this
this block.
block.
It is numerically inefficient, and should not
be required for modelling most continuous
systems. If a derivative is required in an
algorithm, use a discrete time unit delay to
calculate the derivative.
Ref.: - Page 13 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 8
Diagram
Diagram Content
Content
Set
Set Mux
Mux block
block dimension
dimension
parameters
to
-1,
parameters to -1, to
to force
force
Simulink
to
determine
what
Simulink to determine what the
the
dimensions
dimensions are
are before
before running
running
the
the simulation.
simulation.
Tested in MBDA CoP Advisor
er
d
n
U
iew
v
e
R
However…for cases where the signal dimensions are fixed
regardless of application, then it is strongly recommended to
set the dimensions accordingly. This not only helps the
block/model being misused/misinterpreted by someone else,
but also reduces model initialisation time.
Ref.: - Page 14 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 9
Tested in MBDA CoP Advisor
Diagram
Diagram Content
Content
MATLAB
MATLAB Fcn
Fcn -- Never
Never use
use
this
this block
block
Incompatible with Real-Time Workshop, hence
making use with SME Target impossible (thus
reducing the ability to re-use models).
Generally less efficient than implementing using
native Simulink blocks.
Ref.: - Page 15 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 10
Diagram
Diagram Content
Content
Tested in MBDA CoP Advisor
S-Function
S-Function -- Never
Never use
use
FORTRAN,
Ada,
M
or
nonFORTRAN, Ada, M or noninlined
inlined S-functions
S-functions
Incompatible with Real-Time Workshop, hence
making use with SME Target impossible (thus
reducing the ability to re-use models).
Embedded MATLAB and C S-functions are
permissible.
Ref.: - Page 16 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 11
Module
Module Information
Information
Tested in MBDA CoP Advisor
Indicate
Indicate the
the name,
name, version,
version,
status
and
date
of
the
status and date of the model
model
with
text
in
the
highest
with text in the highest level
level
of
of the
the block
block diagram.
diagram.
This is good for configuration and control.
The Model Info block can be used for this and
can be configured to extract relevant
information from your configuration management
system. E.g. from Dimensions – Highly
Recommended
Ref.: - Page 17 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 12
Module
Module Information
Information
Ensure
Ensure that
that the
the DOC
DOC block
block
employs
an
OpenFcn
of
employs an OpenFcn of the
the
correct
form
to
allow
linking
correct form to allow linking
to
to HTML
HTML inin the
the same
same
directory
as
the
model
directory as the model
Tested in MBDA CoP Advisor
r
e
d
Un w
ie
v
e
R
The steps are:
•Copy a DOC block into your model.
•Right click, and select Block Properties. Select the Callbacks
tab, and then the OpenFcn callback.
•Replace the docblock callback with web(‘htmlfilename.htm’).
If the documentation is stored in a different directory, then
add the path to the filename.
Ref.: - Page 18 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Rule 13
Module
Module Information
Information
Tested in MBDA CoP Advisor
AA defined
defined set
set of
of units
units shall
shall
always
be
used
at
interfaces
always be used at interfaces
between
between modules.
modules. Where
Where nonnonSI
units
are
used,
then
the
SI units are used, then the
relevant
relevant signal
signal and
and port
port names
names
shall
shall include
include units
units inin their
their
names.
names.
Benefit: interfacing mistakes are much less likely to be
made.
For example, an angle-of-attack signal in degrees could
be given the name ‘alpha_deg’, whereas its counterpart
in radians could simply be ‘alpha’.
M file contains set of acceptable units
Ref.: - Page 19 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 1
Zero-Crossing
Zero-Crossing
Not Tested in MBDA CoP Advisor
For
For simulation
simulation efficiency,
efficiency,
turn-off
zero-crossing
turn-off zero-crossing
events
events ifif they
they are
are not
not
required
check
for
selected
required check for selected
solver
solver && which
which blocks
blocks have
have
zero-crossing
zero-crossing turned
turned on
on
Ref.: - Page 20 - 5/2/2008
Each of the following blocks which use zero-crossing, has a tickbox in the mask to facilitate this. Turning off all zero-crossing
detection from the Simulation parameters drop-down menu is not
recommended as other model users may miss that it has been
turned off.
Abs, Backlash, Dead Zone, Hit Crossing, Integrator, MinMax,
Relay, Relational Operator, Saturation, Sign, Step, Subsystem,
Switch
For Details of Zero Crossing in these blocks Click Here
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Blocks which use Zero-Crossing
Block
Number of zero crossings and description
Abs
One: to detect when the input signal crosses zero in either the rising or falling direction.
Backlash
Two: one to detect when the upper threshold is engaged, and one to detect when the lower threshold is
engaged.
Dead Zone
Two: one to detect when the dead zone is entered (the input signal minus the lower limit), and one to
detect when the dead zone is exited (the input signal minus the upper limit).
Hit Crossing
One: to detect when the input crosses the threshold. These zero crossings are not affected by the
Disable zero crossing detection check box in the Simulation Parameters dialog box.
Integrator
If the reset port is present, to detect when a reset occurs. If the output is limited, there are three zero
crossings: one to detect when the upper saturation limit is reached, one to detect when the lower
saturation limit is reached, and one to detect when saturation is left.
MinMax
One: for each element of the output vector, to detect when an input signal is the new minimum or
maximum
Relay
One: if the relay is off, to detect the switch on point. If the relay is on, to detect the switch off point.
Relational
Operator
One: to detect when the output changes.
Saturation
Two: one to detect when the upper limit is reached or left, and one to detect when the lower limit is
reached or left.
Sign
One: to detect when the input crosses through zero.
Step
One: to detect the step time.
Subsystem
For conditionally executed subsystems: one for the enable port if present, and one for the trigger port, if
present.
Ref.: - Page 21 - 5/2/2008
Switch
One: to detect when the switch condition occurs.
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 2
Not Tested in MBDA CoP Advisor
Diagram
Diagram Content
Content
Band-limited
Band-limited white
white noise
noise
block
block -- sample
sample time
time should
should
be
at
least
100
times
be at least 100 times
smaller
smaller than
than the
the smallest
smallest
time
constant
of
interest
time constant of interest
Use this block with caution. The dialog box entry
labelled “Noise Power” is in fact the height of the
power spectral density. Care must be taken to set the
sample time to a suitably small value.
In preference, use the White Noise source block plus
an appropriate first order filter. Reduces risk if
incorrect noise level implemented.
Ref.: - Page 22 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 3
Not Tested in MBDA CoP Advisor
Repeated
Repeated sub-models
sub-models
If
If the
the simulation
simulation model
model contains
contains
several
copies
of
a
sub-model
several copies of a sub-model
this
this should
should be
be made
made into
into aa
'library'
'library' block.
block. This
This block
block isis
then
then copied
copied and
and repeated,
repeated, and
and
all
parameter
information
all parameter information
relating
relating to
to aa particular
particular instance
instance
of
the
library
block
should
of the library block should be
be
contained
contained inin aa mask.
mask.
Warning rather than error (identical in terms of
functional layout not necessarily signals)
Ref.: - Page 23 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 4
Not Tested in MBDA CoP Advisor
Defensive
Defensive Programming
Programming
M-file
M-file name:
name: Never
Never choose
choose
filenames
filenames which
which clash
clash with
with existing
existing
MATLAB
toolbox
filenames.
MATLAB toolbox filenames.
In the event of two identical filenames on the
MATLAB path, MATLAB picks the first one it
finds. This will result in different results
depending on the MATLAB path ordering on any
given machine.
Ref.: - Page 24 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 5
Portability
Portability
Not Tested in MBDA CoP Advisor
Never
Never use
use upper
upper or
or lower
lower case
case
letters
as
the
only
letters as the only
distinguishing
distinguishing feature
feature of
of
different
different m-function
m-function names.
names.
This is to ensure portability between Windows
and UNIX based systems. UNIX does
distinguish between upper and lower case names,
whereas the Windows operating system does
not.
Ref.: - Page 25 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Recommendation 6
Not Tested in MBDA CoP Advisor
Diagram
Diagram Clarity
Clarity
Use
Use grouped
grouped sub-systems.
sub-systems.
Simulink
makes
it
Simulink makes it easy
easy to
to divide
divide
the
the model
model up
up into
into sub-systems
sub-systems
containing
containing related
related parts,
parts, with
with the
the
higher
level
screen
showing
the
higher level screen showing the
sub-systems
sub-systems as
as single
single blocks.
blocks.
Try to avoid the diagram becoming larger than
the maximum window size.
Benefit: aids readability and understanding of
your model by others
Where possible, use atomic sub-systems to
assist autocoding.
Ref.: - Page 26 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Summary
•
Key Benefits
•
•
•
•
Code of Practice is a Living Document
•
•
•
Improvement in Simulink model standard
Improved efficiency during Simulink model exchange
Improved diagram readability improved methods across Organisation
Still learning and updating rules
Balance of improved efficiency vs implementation cost
Important to stick to Key Principles
•
•
•
•
Split into Mandatory and Recommended
Keep Mandatory Rules to a minimum
Flexibility – allow tailoring of Recommended Rules
Automation – use of Model Advisor technology
Ref.: - Page 27 - 5/2/2008
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
MBDA UK Org Design - Page 28
This document and the information contained herein is proprietary information of MBDA UK Limited and shall not be disclosed or reproduced without the prior authorisation of MBDA.
© MBDA UK Limited 2004.
Download