Professional Documents
Culture Documents
Simulink Formation: Version 0.1 - by MARTIN Cezar
Simulink Formation: Version 0.1 - by MARTIN Cezar
Click on the block and change the name of the constant to the one declared in the .m file.
At the top of the model, use these blocks to change calibrations or configurations of time.
-Conv_BoolToEvent is used when we have a boolean that does NOT need to take into account the
change from 0 to 1 of the input.
-Conv_Bool ToEvent_RisingEdge is used when we have a boolean that NEEDS to take into account the
change from 0 to 1 of the input.
Modelling
Here we have an example of a modelling configuration that is commonly found in functions. The
purpose of this structure is to allow the user to have a simple structure that is easy to read. In our
example, the first switch has a particular structure used for the signal port:
RSA Timer
This block detects the rising of the INIT port to 1. Afterwards, the following will happen :
1.The output “Timer” will be set with “Duration” value and start Decrementing by SampleTime.
When INIT falls back to 0, the block will be reset to Initial State(delay_out= 0 , Timer= 0). This can be
observed in the previous screenshots. One thing to note here is the fact that the block parameters can
be modified to change the Initial State.In the following example, we have configured the block to have
the output TIMEOUT=1 and INIT= 1.
When we have a true value applied to both SET and RESET, the output is set to either true or false:
NOTE:
1.When fixed data types is given for input ("dly"), the sample time's data type in the mask should be set
as "Uint8".
2.The input "dly" should be set such that it is a multiple of sample time "Ts". Eg. If "dly" is 1 then allowed
sample time (Ts) are 0.1,0.2,0.02, etc.,
Detect Increase:
If the input is strictly greater than its previous value, then output TRUE, otherwise output FALSE. Initial
condition of the output is false.
NOTE:
The check for the initial condidtion can be inhibited by unchecking the checkbox
"Compare the Input with Initial Value".
In the BCM library we also have access to the detectChange block that can display both the changes
from one state to another and vice-versa.
*_CF Configuration Parameter Allows to activate/deactivate an Activity Chart (typ. in EEPORM) All
*_TP Calibration Parameter Calibration parameter for tunning (typ. in Flash ROM) All
*_S Saved Variable for input Variable that needs to be saved (in EEPROM for example) All
*_S_OUT Saved Variable for output Variable that needs to be saved (in EEPROM for example) All
*_T_CONF
*_TOP TOP SubSystem The highest level of the hierarchy of a project SubSystem
TT_* Truth Table Gives the values of the outputs as a function of the inputs Truth Table
SubSystem
TB_* Test Bench Describes interactions between the model and the environment .mdl
Z_* Test Bench Variable Variable used in the Test Bench for simulation purposes. All
Lowercase letter is not permitted for the inputs, outputs, constants, enumerated types
parameters.
The naming rules in capitals letters is due to Statemate naming rules which allow only capital
letters. It’s to have the same naming rules between Statemate and Matlab to avoid problem in
the data-dictionary.
The maximum letters permitted for a parameters is 31 characters (It’s a model Based-Design
rules)
Choose the Right Words for a Parameter, Subsystem, Stateflow, State in StateFlow
The name of a function must contain one or two action verbs and one or two objects
(complements). The label must represent the task performed by the underlying function. Thus
verbs like “manage”, “supervise” should be avoided because they are too vague.
This rule also forces the author to construct the specification by identifying the missions and
objectives of the function.
Respect Name Uniqueness for Each Parameter, SubSystem, StateFlow, State in Stateflow
In general, do not use names that are too similar for two different states, parameters, etc.
In particular …
Do not define local variables with the same name in one model to avoid problem.
Similarly …
Do not name two subsystem or state in StateFlow identically, especially if they perform two
different functions, even though Simulink allows it. This is to avoid interpretation errors.
Notably…
Use different names for a parallel StateFlow State.
Use the Positive Form for all Parameters, SubSystems, StateFlow Names
Use variable, state and chart names that satisfy positive logic. For instance use
“ALL_THE_DOORS_ARE_CLOSED” instead of “NO_DOOR_IS_NOT_OPEN”.
Avoid abbreviations. All the names should be as clear as possible, and should be meaningful to
the layman.
All the names used inside the top of the model should be independent of any project. These
names should not include any physical or implementation information. They should be as
The names of the external activities should be representative of what they represent (either
physically, e.g., the CAN; or abstractly, e.g., an input produced by another Simulink model or a
Statemate Model or an output fed to another Simulink or Statemate model).
Flow names should be as clear and explicit as possible and must not burden with useless
information, given that name sizes are limited to 31 characters.
For names to hold maximum information it is recommended to follow the following scheme for
internal or CAN inputs: R_ACTION_BY_SOURCE (Example:: R_WIPING_BY_DRIVER). “R” stands
for “Request”.
R_action1_by_A1
R_action1_by_driver
A1
R_action3_by_A3
A3
R_action2_by_driver
A2
R_action2_by_A2
For Example: Data such as vehicle or engine speed or the state of the engine, it is useless to add
any prefix or suffix.
Variable names should not hold negative forms inside them. For example,
'DRIVER_DOOR_NOT_OPEN' should be replaced by 'DRIVER_DOOR_CLOSED'.
NAMEOFTHEMODEL_NAMEOFTHECONSTANT_CST or
INITIALOFTHEMODEL_NAMEOFTHECONST_CST
Declare constants of the model in the function InitFct for each model.
In the file NameOfTheModel_Constant.m, you find only the constant
“NAMEOFTHEMODEL_SAMPLE_TIME_CST” if in this model there is the use of timing calibration.
3
2
5
4
Some specifies about the architecture EE C1A (double APC and VehicleState C1A etc …) making diversity
with our transversal models.
To resolve this problem and keep our transversal models, an addition of an interface envelop is probably
needed.
The modification is to take into account the diversity and manage the 2 inputs data for the same
information (In this case it’s alimentation) and switch on the correct data depend on the architecture EE.
In this example :
VOL_ALARM_ZERO_CST means that we have both the Timeout output and the Init Input = 0.
1. Model explorer :
2. In the window that pops up, at the highest level of our function ( here VolumetricAlarm )
Enum types:
When working inside a function , one variable might hold more than 2 values, as such we will need
to use a ENUM type class to define the values/functionality of the variable. In the following
example , we will see how this works for the variable RES_STATUS_S.
When using one of the enum values, we will need to declare the constant as
TYP_”variablename”.”value”. In this example, the model checks to see if RES_STATUS_S is in the
Remote engine start value.
Step size: the size of which the solver takes samples for.
Event signal : Specifies an event that causes the transition to be taken, provided the condition. If
used without a convert block, it is used for stateflow . If a converter block is used, used for Simulink
type checks.
Delay block: Sample and hold with one sample period delay. (This block applies a delay to the
signal)
In the example we can see that the added delay to the signal is = to 0.01.
Pass through input 1 when input 2 satisfies the selected criterion; otherwise, pass through input 3.
The inputs are numbered top to bottom (or left to right). The first and third input ports are data
ports, and the second input port is the control port.
This example illustrates the case in which input 2 satisfies the criteria and therefore input 1 passes
to the output.
Similarly, the same case goes for when input 2 does not satisfy the criteria and input 3 will pass to
the output.
Pass through the input signals corresponding to the value of the first input. The inputs are
numbered top to bottom (or left to right). The first input port is the control port. The other input
ports are data ports. The number of data ports are customizable.
In the example, because the control port is set to 1, the output will have the value set at the input
port 1.
For this, we have to use a counter that counts how much time our signal has stayed in the true state.
To do this we have to plan out the logic by using the signal output and adding 1 to it every time-step
in which the signal is true. After 60ms the output will display the value 1.
MXAM:
The MES Model examiner(MXAM) automatically checks the model using guideline checks of
MATLAB Simulink/ Stateflow compliant to ISO 26262(functional safety standard for the automotive
industry). To use this tool for our model (and use the correct guidelines/rules ) we have to right click
our model at the topmost level-> Body functions-> Start MXAM drive.