© Copyright 2007JMAAB. All rights reserved.
1
CONTROL ALGORITHM MODELING
GUIDELINES USING MATLAB
®
,
Simulink
®
, and Stateflow
®
Version 4.01(English edition)
Japan MBD Automotive Advisory Board
(JMAAB)
31-Mar- 2015
(correct 19-Jun-2015)
© Copyright 2007JMAAB. All rights reserved.
2
■ Copyright
The copyright of this document belongs to JMAAB.
JMAAB provides no guarantees with regard to the contents of this document. JMAAB shall not be
liable for any failures which occur as a result of using this document. Please note that the
information within this document is subject to change or removal without notice.
■ Handling this document
This document may be reproduced only for internal use and non-commercial purposes. In
addition, when quoting from this document, state explicitly that the quote comes from this
document, and include the name of the author, Title etc., in accordance with the requirements for
citation.
Please refer to the JMAAB website for any information regarding this deliverable
(http://jmaab.mathworks.jp/).
For any other inquiries, please contact the JMAAB office (jmaab-office@mathworks.co.jp).
■ Please note:
This document is English edition of “CONTROL ALGORITHM MODELING GUIDELINES USING
MATLAB
®
, Simulink
®
and Stateflow
®
Version 4.0”.
There were differences between Japanese edition and English edition until Version 3.0. However,
they were fixed in Version 4.0. Thus, there may be the case that the even the same rules are
different from the past version.
© Copyright 2007JMAAB. All rights reserved.
3
TABLE OF CONTENTS
CONTROL ALGORITHM MODELING GUIDELINES USING MATLAB
®
, SIMULINK
®
,
AND STATEFLOW
®
1
1. INTRODUCTION 10
1.1. Purpose of these Guidelines 10
1.2. Guideline template 10
1.2.1. ID 10
1.2.2. Title 11
1.2.3. Priority 11
1.2.4. Scope : 11
1.2.5. MATLAB version 11
1.2.6. Prerequisites 12
1.2.7. Description 12
1.2.8. See Also 12
1.2.9. Last Change 12
1.3. Organization of these Guidelines 12
2. NAMING CONVENTIONS 13
2.1. Naming Conventions - Overall summary 13
2.1.1. Rule IDs for characters that can be used in names 13
2.1.2. Rule IDs for character length 13
2.1.3. List of naming rule constraints "character type / character length" 13
2.2. General Rules 13
2.2.1. ar_0001: Usable characters for file names 13
2.2.2. ar_0002: Usable characters for folder names 14
2.2.3. jc_0241: Length restrictions for file names 15
2.2.4. jc_0242: Length restrictions for folder names 15
2.3. Internal model rules 16
2.3.1. jc_0201: Usable characters for Subsystem names 16
2.3.2. jc_0211: Usable characters for Inport block and Outport block 16
2.3.3. jc_0222: Usable characters for signal line and bus names 17
2.3.4. jc_0232: Usable characters for parameter names 17
2.3.5. jc_0231: Usable characters for block names 18
2.3.6. jc_0243: Length restrictions for subsystem names 18
2.3.7. jc_0244: Length restrictions for Inport and Outport names 19
2.3.8. jc_0245: Length restrictions for signal and bus names 19
2.3.9. jc_0246: Length restrictions for parameter names 20
2.3.10. jc_0247: Length restrictions for block names 21
2.4. Notes on other used characters 21
2.4.1. na_0035: Adoption of naming conventions 21
2.4.2. jc_0251: Naming restrictions for signals and parameters. 22
2.4.3. na_0014: Use of local language in Simulink and Stateflow 22
3. MODEL ARCHITECTURE 26
© Copyright 2007JMAAB. All rights reserved.
4
3.1.1. na_0006: Guidelines for mixed use of Simulink and Stateflow 26
3.1.2. na_0007: Guidelines for use of Flowcharts, Truth Tables and State Machines 26
3.1.3. db_0143: Similar block types on the model levels 26
3.1.4. db_0144: Use of Subsystems 28
4. SIMULINK 30
4.1. Diagram appearance 30
4.1.1. na_0004: Simulink model appearance 30
4.1.2. db_0043: Simulink font and font size 31
4.1.3. db_0042: Port block in Simulink models 31
4.1.4. jm_0002: Block resizing 32
4.1.5. db_0142: Position of block names 33
4.1.6. jc_0061: Display of block names 33
4.1.7. db_0140: Display of block parameters 34
4.1.8. db_0032: Simulink signal appearance 37
4.1.9. db_0141: Signal flow in Simulink models 38
4.1.10. jc_0110: Direction of block 39
4.1.11. jc_0111: Direction of Subsystem 40
4.1.12. jc_0653: Guidelines for avoiding algebraic loops between subsystems 40
4.1.13. jc_0171: Maintaining signal flow when using Goto and From blocks 41
4.1.14. jc_0602: Consistency in model element names 42
4.1.15. db_0146: Triggered, enabled, conditional Subsystems 43
4.1.16. jc_0281: Naming of Trigger Port block and Enable Port block 44
4.1.17. jc_0603: Model description 45
4.1.18. jc_0604: Block shading 46
4.2. Signals 47
4.2.1. na_0010: Grouping data flows into signals 47
4.2.2. na_0008: Display of labels on signals 47
4.2.3. na_0009: Entry versus propagation of signal labels 48
4.2.4. jc_0008 : Definition of a Signal labels. 49
4.2.5. jc_0009 :Propagation of signal label 50
4.2.6. na_0005: Port block name visibility in Simulink models 52
4.2.7. jc_0082: Display of Inport and Outport block names 1 53
4.2.8. jc_0083: Display of Inport and Outport block names 2 55
4.2.9. db_0097: Position of labels for signals and busses 57
4.2.10. db_0081: Unconnected signals, block inputs and block outputs 57
4.3. Use of of Blocks 58
4.3.1. na_0003: Simple logical expressions for If condition blocks 58
4.3.2. na_0002: Appropriate implementation of fundamental logical and numerical operations 59
4.3.3. jm_0001: Prohibited Simulink standard blocks inside controllers 61
4.3.4. hd_0001: Prohibited Simulink sinks 63
4.3.5. na_0011: Scope of Goto and From blocks 63
4.3.6. jc_0141: Use of the Switch block 64
4.3.7. jc_0121: Use of the Sum block 65
4.3.8. jc_0610: Operator order for Product block 67
4.3.9. jc_0611: Input signal sign during product block division 67
4.3.10. jc_0131: Use of Relational Operator block 68
4.3.11. jc_0161: Use of Data Store Read/Write/Memory blocks 68
4.3.12. Guideline for using the Logical Operator block 69
4.3.13. jc_0011: Optimization parameters for Boolean data types 70
4.3.14. jc_0629: Fcn block use limits 70
4.3.15. jc_0622: Guideline for using the Fcn block 71
4.3.16. jc_0626: Guideline for using the Lookup Table system block 72
4.3.17. jc_0627: Guideline for using the Discrete-Time Integrator block 73
© Copyright 2007JMAAB. All rights reserved.
5
4.3.18. jc_0628: Guideline for using the Saturation Block 74
4.3.19. jc_0650: Block input/output data type with switching function 75
4.3.20. jc_0630: Number of data ports in Multiport Switch block 76
4.3.21. jc_0631: Input of Multiport Switch block to control port 79
4.3.22. jc_0632: Default case port in Multiport Switch block 79
4.4. Initialization 81
4.4.1. jc_0625: Unification of descriptions of external input values as initial values 81
4.4.2. jc_0640: Detection of undefined initial output 82
4.5. Block Parameters 83
4.5.1. db_0112: Indexing 83
4.5.2. db_0110: Tunable parameters in basic blocks 83
4.5.3. jc_0645: Named constant setting 84
4.5.4. jc_0641: Sample time setting 85
4.5.5. jc_0642: Integer rounding mode setting 85
4.5.6. jc_0643: Fixed-point setting 86
4.5.7. jc_0644: Guideline for type setting 87
4.6. Simulink pattern 89
4.6.1. db_0114: Simulink patterns for If-then-else-if constructs 89
4.6.2. db_0115: Simulink patterns for case constructs 90
4.6.3. db_0116: Simulink patterns for logical constructs with logical blocks 91
4.6.4. db_0117: Simulank patterns for vector signals 91
4.6.5. na_0012: Use of Switch vs. If-Then-Else Action Subsystem 93
4.6.6. na_0028: Use of If-Then-Else Action Subsystem to replace multiple switches 94
4.6.7. jc_0658 :Usage rules for Action Subsystem using conditional control flow 98
4.6.8. jc_0623: Use of Memory block vs. Unit Delay block 101
4.6.9. jc_0624: Guideline for using the Delay block 101
4.6.10. jc_0651: Guideline for use when implementing cast 102
4.6.11. jc_0652: Constant related to timer counter 105
4.6.12. jc_0659: Usage restrictions of signal lines inputted to Merge block 105
4.6.13. jc_0656: Guideline for using the Conditional Control block 107
4.6.14. jc_0657: Retention of output value based on Conditional Control Flow block and Merge
block 108
5. STATEFLOW 112
5.1. Stateflow variable settings 112
5.1.1. db_0123: Stateflow port names 112
5.1.2. jc_0700: Unused data in Stateflow block 112
5.1.3. db_0122: Stateflow and Simulink interface signals and parameters 113
5.1.4. db_0125: Scope of internal signals and local auxiliary variables 114
5.1.5. jc_0701: Usable numbers in first index 115
5.1.6. jc_0702: Stateflow parameters and constants 116
5.1.7. jm_0011: Pointers in Stateflow 117
5.2. Basic appearance of state transition 118
5.2.1. db_0129: Stateflow transition appearance 118
5.2.2. db_0137: States in state machines 119
5.2.3. jc_0711: Division in Stateflow 119
5.2.4. jc_0531: Placement of the default transition 120
5.2.5. jc_0712: Execution timing for default transition path 122
5.2.6. na_0038: Levels in Stateflow charts 123
5.2.7. na_0040: Number of states per container 124
5.2.8. jc_0720: Guideline for using subcharting 125
5.2.9. jc_0721: Guidelines for using parallel states 126