Advanced MBSD - Notes
Advanced MBSD - Notes
Marc Herniter
EE - Rose-Hulman Institute of Technology
Zac Chambers
ME - Rose-Hulman Institute of Technology
Course Outline
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Course Outline
Stand-Alone Simulations
Verify logical operation
Give user feel of controls and vehicle operation
Plant and controller on same target
Introduction to CAN
Message IDs
Scaling and Offset
Big Endian and Little Endian
CAN Message Database
Cabling, isolation, and termination
Course Outline
Separate
p
the Plant from the Controller.
Controller on real-time target.
Plant on real-time target.
V&V Using HIL RT Model
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Building a Large System Model
Part 1
1
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Part 1 Outline
3
Powertrain
Battery Model
Almost
Final Model
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Electric Vehicle
a differential.
Drive Train
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
12
Calculated speed of
the vehicle
Road grade in
percent.
Calculated normal
force on the front
tires.
Calculated normal
force on the rear
tires.
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
14
We have set:
the mass of the vehicle
to 1000 kg.
The frontal area to
zero.
The drag coefficient to
0.
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 1 Exercise 1
17
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
20
Icon tab is selected.
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
Parameters tab is selected.
22
Initialization tab is selected.
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
Documentation tab is selected.
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
30
This block calculates the normal force on the frontg and
rear tires. We wont go there.
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Initialization File
33
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
We will onlyy
specify the
vehicle mass.
All other
parameters will
be left at their
default value.
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
We have now created a model of a rearwheel drive vehicle that requires a torque
input
input.
We will test the system with a motor that
outputs a constant torque.
The motor on the next slide was created
with a Constant and a Torque Actuator
(library Simscape / SimDriveline /
Sensors and Actuators.)
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
System Testing
To verify that all of our models work are
the same, we will simulate the models for
200 seconds.
seconds
Calculate the vehicles velocity at 200
seconds and generate a plot of the
vehicles speed versus time.
Remember to remove the limitation on the
number of points a scope can display.
(Continued on next slide)
44
Lecture 1 Exercise 2
System Testing
Vehicle Terminal Velocity
Plot
Pl t off vehicle
hi l speed
d versus time.
ti
Demo___________
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Lecture 1 Exercise 3
Most motors and engines have torque
curves.
Implement a motor that has the following
torque curve:
From 0 to 2000 rpm, the torque is constant at
200 Nm
From 2000 to 7000 rpm, the torque decreases
li
linearly
l to
t zero.
46
Lecture 1 Exercise 3
You will need to sense the motor speed and
convert it to rpm.
You can do this using a 1-D lookup table.
Plot
Pl t the
th vehicle
hi l velocity
l it and
d determine
d t
i the
th
vehicles velocity after 200 seconds.
Demo___________
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Hierarchy
Battery Model
Model Hierarchy
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Motor
Model Hierarchy
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
52
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
53
54
Scope
was here.
SimDriveline
port.
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
57
Conversions
3600 sec 1 mile
Speed
p (mph
p ) = speed
p (m / s )
1
H
Hour
1609
meters
58
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
59
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
61
Double-click here.
Change to 3.
62
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
63
Diagnostic Bus
64
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
66
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
67
Battery Model
We will now create a battery model that
g and
calculates the batteryy terminal voltage
battery state of charge (SOC).
The inputs to the model are the two motor
currents that we will have in the vehicle.
(You can also add an input for the vehicle
hotel loads.))
The outputs of this block are the battery
voltage and a diagnostic bus that contains
battery signals of interest.
68
+
IBAT
VOC
VBAT
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
69
IBAT
VOC
VBAT
C
Currentt iis d
defined
fi d as positive
iti into
i t the
th battery.
b tt
Positive current charges the battery and
increases the battery SOC.
Battery Model
70
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Battery Model
71
72
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Double-click
here.
73
Subsystem name
changed.
74
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
75
In1 and In2 will be the motor and generator currents. The
total battery current will be the sum of these two inputs.
Click on the text In1 and change it to Motor_Current_A.
Click on the text In2 and change it to Generator_Current_A.
76
Next, we would like to form the battery current as the sum of the motor
and generator currents.
Place the sum part (Simulink/Commonly Used Blocks) in your model
and connect the two inputs as shown:
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
77
Double-click
here.
Double-click
D bl li k on the
th Goto
G t partt to
t change
h
the
th label.
l b l
78
Si
Since the
th text
t t A is
i highlighted,
hi hli ht d we can jjustt ttype iin a new ttag ffor th
the
Goto part.
Enter the text, Battery_Current_A and click the OK button.
You may need to change the size of the Goto part to see the label.
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
79
Right-click here.
Battery Model
80
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
81
82
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Battery Constants
83
84
42
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
85
86
43
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Battery SOC
87
Battery SOC
88
44
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
89
Amps
Amp-Seconds
Amp-Hours
(Added or Removed)
Next, divide the Amp-Hours added or removed by the battery AmpHour Rating to calculate the SOC added or removed.
Use the Divide part (Simulink/Math Operations).
The battery Amp-Hour rating is a constant defined in the init file.
90
We could also
do this with a
gain block.
SOC
(Added or
Removed)
Next,
N t we add
dd the
th SOC added
dd d or removed
d to
t the
th b
battery
tt
initial SOC to calculate the batterys current SOC.
Use the Sum part (Simulink/Commonly Used Blocks).
The battery initial SOC is a constant defined in the init file.
45
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
91
92
46
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
93
Battery Diagnostics
94
47
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
95
Double-click here.
Change to 3.
96
48
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
97
98
49
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
99
Lecture 1 Exercise 4
Show your completed Battery and Rear Diff
and Body subsystems.
Run a simulation that shows that your
Battery:
Produces the correct output voltage for a given
input current.
Calculates the correct battery state of charge for
a given
i
iinputt current.
t
Demo___________
50
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 2: Motor Model and
Display Subsystem
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor
Battery
Motor
Motor
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model
M d lO
Outputs (Simulink
(Si li k Si
Signals):
l )
Motor Current
Motor Diagnostics
Motor rpm
Motor Torque
Motor Current
Model
M d lO
Outputs
t t (Si
(SimDriveline):
D i li )
Motor Torque
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor Model
Battery_Voltage
Torque_Request
M t C
Motor_Current
t
Motor_Diagnostics
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
12
The inertia part specifies the inertia for all rotating parts of the motor. We
will define this inertia in the init file. Double-click on the inertia part and
change the value to Motor_Inertia.
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
I Motor =
Motor Motor
VBattery
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor Diagnostics
15
Motor Diagnostics
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
Double-click here.
Change to 3.
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Vehicle Model
19
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
Vehicle System
We now have enough subsystem
components to create a simple vehicle.
We will create the beginning of a series
hybrid electric vehicle by using
The electric motor drive the rear diff.
The electric motor draw power from the
battery.
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
Double-click here.
After making this change, we can easily connect the motor and rear diff.
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
Driver Block
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Driver Block
33
34
Driver Block
The output of the error amplifier
determines the torque.
Depending on the gain and how far off the
speed is, the torque signal can be from
(big number) to +(big number).
We would like to limit the torque signal to
1.
Use the Saturation part located in the
Simulink/Commonly Used Blocks
library.
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
Driver Block
The top-level view of the driver block looks
as shown:
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Display Subsystem
39
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Display Subsystem
41
Display Subsystem
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
Change this to 5.
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Box unchecked.
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Running a Simulation
51
52
Set to 60.
Select ode23tb
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation Diagnostics
53
Set to error.
54
Diagnostics selected.
Set to error.
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
Algebraic Loop
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Algebraic Loop
57
Algebraic Loop
58
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
59
Aglebraic Loop
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
61
62
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
63
Error
64
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
For
For the first time step
step, what is the input to the Divide block?
The Memory block outputs the value from the previous time step.
For the first time step, what is the previous value.
If the block outputs a 0, we get a divide by zero, and the Divide block either outputs
Inf or Nan.
We need to move the Memory block somewhere else to eliminate the algebraic loop.
66
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
67
68
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
69
Lecture 2 Exercise 1
The Simulation Runs!
There appear to be some problems with
our physical model
model.
Demonstrate the operation of your model.
The Speed Approaches 60 mph, but there
are problems in the rpm signal.
Demo___________
Advanced Model-Based-System
Design
Debugging the Model
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
71
72
Vehicle speed
OK.
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Debugging
73
74
If there is no skidding, the tire speeds should be the same as the vehicle
speed.
Run the simulation
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
75
Zoom in here.
76
Tire speed
different than
vehicle speed.
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
77
78
Tire skidding
happens here.
Vehicle cruising
g
at 60 mph here.
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
79
Model Debugging
It looks like the tire skidding occurs when
we have a large change in the driver
torque request.
request
We can fix this by adding a Rate Limiter
to the driver torque request.
(Simulink/Discontinuities)
80
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
81
Things are
worse!
82
What do you
notice about
this?
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Debugging
83
Rate limiter
removed.
84
Scope added.
42
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
85
Tire skidding
h
happens
h
here.
Zoom in on this
section.
86
Traces in nature
are very rarely
straight. Usually
things are curved.
Zoom in some
more.
43
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
87
Simulation point.
Simulation p
point.
Looks like a
straight
t i ht liline
connecting two
simulation points.
Model Debugging
88
What is this?
44
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
89
It looks like Simulink can take a step size as large as 1.2 seconds between
simulation points.
This is a large time step for our simulation. From the previous slides, it looked
like we had a step
p of 0.35 seconds that was too large.
g
Lets try a smaller step size.
Select Simulation and then Configuration Parameters from the Simulink
menus.
Change the Max Step size from Auto to 0.01 (seconds)
90
Changed to 0.01.
45
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
91
Model Debugging
92
46
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
93
Lecture 2 Exercise 2
We would like our vehicle to be able to
accelerate from 0 to 60 mph in 9 seconds.
Determine:
Required motor torque________ (Nm)
Required battery current __________ (A)
The peak motor power __________ (kW)
47
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 2: Drive Cycles and
Advanced Models
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Sch_Cycle =
0
10
15
20
30
40
55
70
80
90
100
120
0
0
30
30
40
40
70
70
30
30
0
0
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Double-click on
the From
Workspace block
and modify as
shown:
Changed to Sch_Cycle.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
Display Modifications
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
Advanced Model-Based-System
Design
Reading Drive Cycles in Excel
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Drive Cycles
17
18
Drive Cycles
Create a directory called Drive_Cycles in
your current working directory.
We will keep all off our drive cycles in this
directory.
Copy the drive cycles that were provided
for this class to this directory
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
Time
(seconds)
Speed
(mph)
Drive Cycles
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Drive Cycles
21
22
name=[pn,fn];
Sch_Cycle = xlsread(name, 'Sch Cycle');
Sch_Brake_on = xlsread(name, 'Sch Brake On');
Sch Gear on = xlsread(name,
Sch_Gear_on
xlsread(name 'Sch
Sch Gear On
On');
);
Sch_Grade = xlsread(name, 'Sch Grade');
Sch_Key_on = xlsread(name, 'Sch Key On');
%Convert the grade from percent to radians.
Sch_Grade(:,2)=atan(Sch_Grade(:,2)/100);
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
if (exist('fn') == 0)|(fn==0)
fn='Drive_Cycles\sch_fu505.xls';
else
fn=['Drive_Cycles\',fn];
end
24
[fn,pn]=uigetfile('Drive_Cycles\sch*.xls','Specify an Excel
Schedule File Name',fn);
name=[pn,fn];
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
Drive Cycles
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
28
0
0
25
25
18
18
46
46
56
56
32
0
0
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
Drive Cycles
If you remember, the Driver block uses the
contents of variable Sch_Cycle as the
drive cycle.
cycle
We can now easily run predefined drive
cycles.
Drive Cycles
30
plot(Sch_Cycle(:,1),Sch_Cycle(:,2));
xlabel('Time(s)');
l b l('Ti ( )')
ylabel('Speed (mph)');
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
Drive Cycles
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Drive Cycles
35
36
The last time point in the drive
cycle will be used as the ending
time for the simulation.
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
Running a Simulation
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 3 Exercise 1
43
Lecture 3 Exercise 1
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Lecture 3 Exercise 1
Part 2:
Create a new init file that is the same as the original
init file except that the drive cycle is read as a .mat file
rather
th th
than an excell fil
file.
Using drive cycle sch_fu505 ten times.xls, compare
the time it takes MATLAB to complete each of your
init files.
Use the tic and toc functions to see how long it haves
to run each script file.
Demo___________
Vehicle Modeling
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
Electric Motor
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Torque Curve
49
50
Torque (Nm)
370
1200
361
1400
319
1600
260
1700
242
2000
190
2200
170
2400
128
2600
120
3000
79
3500
60
4000
51
4500
40
5000
30
6000
10
7000
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
Component Data
We will place this data in an excel file and
read it using the xlsread function.
We will place all component data files in a
directory called Component Data.
52
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
53
We will read this data using the xlsread function in the init file.
Add the following lines to you init file.
54
Motor_Name = 'Fantasy Motor_Data.xls';
Motor_PN = ['Component Data\',Motor_Name];
motor_max_torque = xlsread(Motor_PN,'Max_Torque');
motor_max_torque_rpm_axis =xlsread(Motor_PN,'Max_Torque_rpm_Axis');
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor Model
55
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
57
58
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
59
60
Lecture 3 Exercise 2
The motor model has a problem in that the
effective torque we request changes as the
available torque goes down. The effectively
changes the loop gain of our system and the
motor rpm changes.
We want to modify the model so that the torque
request is always the maximum motor torque
times the driver torque request. If the available
motor torque is less than the torque request
request,
then the available motor torque is used. If the
available motor torque is greater than the torque
request, then the torque requested is used.
Demo___________
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 4: Advanced Models
Vehicle Modeling
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Electric Motor
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Torque Curve
Torque (Nm)
370
1200
361
1400
319
1600
260
1700
242
2000
190
2200
170
2400
128
2600
120
3000
79
3500
60
4000
51
4500
40
5000
30
6000
10
7000
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Component Data
We will place this data in an excel file and
read it using the xlsread function.
We will place all component data files in a
directory called Component Data.
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
We will read this data using the xlsread function in the init file.
Add the following lines to you init file.
10
Motor_Name = 'Fantasy Motor_Data.xls';
Motor_PN = ['Component Data\',Motor_Name];
motor_max_torque = xlsread(Motor_PN,'Max_Torque');
motor_max_torque_rpm_axis =xlsread(Motor_PN,'Max_Torque_rpm_Axis');
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor Model
11
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
16
Lecture 4 Exercise 1
The motor model has a problem in that the
effective torque we request changes as the
available torque goes down. The effectively
changes the loop gain of our system and the
motor rpm changes.
We want to modify the model so that the torque
request is always the maximum motor torque
times the driver torque request. If the available
motor torque is less than the torque request
request,
then the available motor torque is used. If the
available motor torque is greater than the torque
request, then the torque requested is used.
Demo___________
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 4 Exercise 2
17
Motor Efficiency
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Verification
21
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Verification
23
Scope
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
25
Scope
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
27
Scope
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
29
Scope
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
31
Scope
32
Click here.
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
Scope
Change this to 2 to
display 2 plots in the
Scope window.
Scope
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
35
History tab selected.
Scope
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
38
Right-click here!
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
40
Scope
Right-click here.
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Scope
41
Scope
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 4 Exercise 3
45
Demo___________
Model Verification
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
r
p
m
50
94
138
182
226
270
314
358
402
0.86
0.91
0.88
0.85
0.82
0.79
0.76
0.74
0.72
0.69
0.69
500
0.86
0.91
0.88
0.85
0.82
0.79
0.76
0.74
0.72
1000
0.82
0.92
0.91
0.89
0.88
0.86
0.84
0.83
0.81
0.80
1500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
2000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
2500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
3000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
3500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
4000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
4500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
5000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
5500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
6000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
6500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
7000
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
7500
0.78
0.92
0.92
0.91
0.90
0.89
0.87
0.86
0.85
0.84
8000
0.74
0.92
0.92
0.92
0.91
0.90
0.89
0.88
0.87
0.86
8500
0.71
0.92
0.92
0.92
0.91
0.90
0.90
0.89
0.88
0.87
9000
0.68
0.92
0.92
0.92
0.91
0.91
0.90
0.89
0.88
0.88
9500
0.65
0.91
0.92
0.92
0.91
0.91
0.90
0.89
0.89
0.88
10000
0.63
0.91
0.92
0.92
0.91
0.91
0.90
0.89
0.89
0.88
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Worksheet named
Motor_RPM_Axis.
50
Worksheet named
Current_Axis.
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
Worksheet named
Eff_Data.
Excel
52
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Constant block
replaced with 2-D
lookup table.
53
Double-click
D
bl li k on the
h llookup
k table
bl and
d fill
in the parameters as shown:
54
If you
o ran the init file
file, and the data for this
table is loaded into the MATLAB workspace,
we can view the table by clicking the Edit
button.
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
If you select Plot and then Mesh from the menus, you can view a plot of the table.
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
57
This text description is
important!
58
Note that the motor current depends on the efficiency, and the efficiency depends on
the motor current, so we probably have an algebraic loop.
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
59
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
61
Voltage spikes.
Current spikes.
62
Voltage spike.
Current spike.
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
63
Problems
What causes the voltage spike?
Look at the battery model:
+
IBAT
VBAT
Problems
64
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
66
Basic Math
If we divide by a small number, we get a
big number.
When we calculate the current in our
model, we divide in two places.
Divide by battery
voltage here.
Divide by
efficiency here.
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
67
Problems
The only time the battery voltage will become
small is when there is a large current spike.
So the current spike causes the low battery
voltage.
Without the current spike, the battery voltage
would remain high, and would not cause the
current spike.
This sounds like an algebraic loop of reasoning.
68
Problems
Focus on the other division.
Look at this
division.
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
69
70
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Table-Lookup
71
72
So, what happens when the index is outside of the range of the
table?
Im not sure, but you better make sure that you know, or limit the
inputs to be within a specific range defined in the table.
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lookup Tables
73
Problem
74
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
75
Battery current
negative.
76
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
77
78
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
79
Motor Model
We could add much more detail to the
model, and you should as you make it
more realistic
realistic. We could add:
Different regen and motoring efficiencies.
Add separate current limits for regenerative
braking and motoring. These limits are usually
different due to battery limits.
Add a torque map that is based on battery
voltage and motor rpm.
Lecture 4 Exercise 4
80
Demo___________
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
81
Lecture 4 Exercise 5
Battery Model Improvements
Different charge and discharge Demo___________
resistances.
Resistance a function of battery SOC and
temperature.
Batteryy open
p circuit voltage
g is a function of
battery SOC and temperature.
Data contained in file Battery Data.xls.
82
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 5: Engine Modeling
Outline
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
The Need
The Need
Have an on
on-board
board power generation
system using an internal combustion
engine and a generator.
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
The Need
For this module we will develop our own
model of a Diesel engine.
First,
First lets
let s see take a look at the
SimDriveline Diesel engine.
Open a new empty model and place a
Diesel Engine block in your model (library
Simscape / SimDriveline / Vehicle
Components).
The Need
Right-click on the
Diesel Engine
block.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
SimDriveline Engine
What does this
do?
What happens
here?
Lecture 5 Exercise 1
What is the purpose of the switch?
Answers___________
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
SimDriveline Engine
Question
Does an engine produce torque at RPMs
BELOW idle?
Problem
Double-click on the Peak torque lookup table.
Click This
10
SimDriveline Engine
This model has some problems
The model
produces
d
ttorque
below idle and
at zero rpm.
What happens
above 4500 rpm
and below 0
rpm?
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
SimDriveline Engine
11
SimDriveline Model
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Fuel Curve
13
Engine Model
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Fuel Curve
15
Fuel Curve
16
Create a new
model and
add a 2-D
look up table.
Awesome!
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Torque Curve
17
Torque Curve
18
Pretty Cool!
At a given
RPM we
can adjust
the throttle
to get a
desired
torque
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Engine Model
19
Engine Model
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Engine Model
21
Engine Model
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Engine Model
23
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
This line
uncommented.
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
The torque
definitely goes
negative
The output
torque will be
zero for a
throttle slightly
greater than 0.
g
30
Motion actuator
Ramp
Gain
Constant
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
Engine Testing
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
Engine Testing
Fuel consumption goes to
zero at 4500 rpm because
we cut the fuel.
In the fuel consumption
table is 0.4 g/s when the
throttle is 1 and the rpm is
850 or less.
Engine Testing
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
Engine Testing
Next, we will generate the same plot with
the throttle set to 0 rather than 1:
40
Engine Testing
When the throttle is 0, the engine
provides a negative braking torque.
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Engine Testing
41
Engine Testing
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
Lecture 5 Demo 1
Engine demo at full throttle.
Demo___________
Demo___________
Engine Model
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Engine Model
Get rid of the Env block. (We already have
an Env block in our vehicle model. We
onlyy need one.))
Replace the motion actuator, and
associated ramp, constant, and gain block
with an SimDriveline Connection Port.
Replace the constant block used to specify
the throttle with an inport:
46
Engine Model
Env part removed.
Connection port
added here.
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Engine Model
47
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
Lecture 5 Exercise 1
Engine Model Improvements
Add an Engine on signal to the engine model.
Wh the
When
th engine
i is
i on, the
th fuel
f l rate
t and
d th
the
torque are determined by the lookup tables of
the throttle cutoff.
When the engine if off, the fuel rate is zero and
the engine torque is a negative constant equal to
Demo
Demo___________
15 Nm
Nm.
Prove that your design works.
Abrupt step changes in the output torque is not
allowed.
Advanced Model-Based-System
Design
Elementary Control using
Stateflow
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Presentation Outline
53
The Need
54
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
The Need
Lets follow the 505 cycle a few times and
see what happens.
pp
Negative battery
state of charge.
Either we need a
larger battery of we
need a was to put
charge into the
battery.
The Need
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simple Model
57
Vehicle Model
58
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simple Model
59
Controller Subsystem
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Subsystem
61
Control Subsystem
62
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Subsystem
63
Introduction to Stateflow
64
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
Stateflow
From the Stateflow library,
drag in a Chart.
Then double click on it to
open.
Stateflow
66
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
67
Stateflow
Stateflow
68
The first line is the name of the
state. Name it No_Charge.
Note that no spaces are allowed
in the name.
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
69
Stateflow
Add in the Charge
state . Set Simulink
output
t t
charge_current to
15 amps upon
entering the state.
Stateflow
70
Click and hold the left mouse
button here.
This is called a
state transition.
ii
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
71
Stateflow
We need to specify the guard for the
transition. Click the left mouse button on
the transition:
Click here! A
question
i mark
k should
h ld
appear and the
transition should turn
red.
72
Stateflow
Click on the ? To edit the
guard. The ? will be replaced
by a cursor. Enter the text
[SOC< SOC_Charge_On]
Transition selected.
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Stateflow
Stateflow
73
SOC is a Simulink input to the
chart. SOC_Charge_On is
called a parameter and must
be defined in the MATLAB
workspace.
74
Add the guard and transition
to turn off charging when the
state of charge becomes high
enough.
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Stateflow
75
Stateflow
76
Default transition
added here.
Click here to
place the default
transition.
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
77
Stateflow
Next, we need to specify SOC as an input from
Simulink
Select Add, Data, and then Input from
Simulink from the Stateflow menus
Name of the data is
SOC.
SOC specified as a
Simulink input.
Stateflow
78
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Stateflow
79
Stateflow
80
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Stateflow
81
Stateflow
82
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
83
Stateflow
When you close the chart, you will see the
Simulink inputs and outputs that we
specified
specified.
Clock.
Output.
Input.
Stateflow
84
42
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Stateflow
85
Connect the charge_current to
the Generator_Current port.
Stateflow
86
43
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
87
88
Lecture 5 Demo 2
Demo of Stateflow controller charging the
battery.
Demo___________
44
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 6: Creating a Genset and
Building a Formal Controller
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Complete Model
Complete Model
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
7
Changed.
Changed.
Changed.
Changed.
Model Connections
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Connections
10
Vehicle System
Bus Changes
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
18
Run a simulation
and plot the engine
speed and M/G
current.
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
Battery Current
Mostly
M
l P
Positive.
ii
SOC Increasing.
RPM constant at
~1860.
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
Controller Modifications
30
Rate Limiter
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
Run a simulation first for the AVL drive cycle, then the FU505.
Plot both the Engine rpm and the M/G current.
32
Zoom in here.
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
Engine is up to speed,
but the generator is
using
gp
power,, not
generating power.
The generator is not
charging the battery.
Here, the g
generator is
charging the battery.
Engine appears to be
up to speed here.
Lecture 6 Exercise 1
Demo___________
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
Zoom in here.
36
Negative current
speeds up
engine while off.
Controlled start.
Generator current
charges battery.
Controlled stop.
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
Lecture 6 Demo 1
38
Demo___________
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 7: Multi
Multi-Loop
Loop Control
Post Processing
2
Results from previous model.
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Line added.
Line added.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Start engine.
Line added.
Controller Modifications
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
9
Enlargements of various
parts are shown on the
next two slides.
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
Charging Current
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Saturation Block
13
Component Settings
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
Constant charging
current.
Oscillation in
throttle control.
Constant engine
rpm.
Current Control
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
Changed to 0.1.
(Just guessing.)
18
Oscillation
reduced.
What is going on
here?
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
Current Control
We have reduced the oscillations in the
throttle signal a little bit. We will call it good
for now and fix a few other problems first.
first
If the problem still persists, we will address
it later.
We will zoom in on the spike in the throttle
signal that occurs when we first start the
engine and commence charging.
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
Line added.
Line added. Disable the
feedback when we want
to stop charging
charging.
24
Modified.
Modified.
Modified.
Modified.
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
Big spike.
This cant be
good.
Zoom in.
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
Lots of
problems!
Current Control
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
Current Control
We will modify the control to do the following.
For engine speeds below 800 rpm, the engine is
off.
When the engine speed hits 800 rpm, turn on
the engine.
Apply a constant throttle to speed up the engine.
We will determine this constant experimentally.
We will need to add Engine
Engine_On
On and
Throttle_Offset Signals to the Stateflow chart.
Modify the Stateflow chart as shown:
30
(1) Initialize Values.
(4) We do not have an
idle circuit yet.
However, with no
external throttle
applied the speed will
applied,
return to the idle speed.
Turn off the engine
once it is just slightly
above the idle speed.
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Modifications
31
Controller Modifications
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
Zoom in here
Step change in
throttle. May want to
slow this down. Step
changes break things.
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
(1) Because the throttle is
too big, the engine speed
is larger than needed, so
the generator applies a
negative torque to slow it
down. The result is a small
amount of charging. Note
th t th
that
the engine
i speed
d lloop
is closed here.
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller
41
Controller
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
44
Looks
Good!
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Engine
Turn On
This used to be a
step.
This used to be a
step.
46
Engine
Turn Off
This used to be a
step.
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
This is where we
specify using an
accelerator or not.
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Sample Time
In the Init File, define a variable
Click here.
50
Sample Time
Specify sample
time here.
Enter variable
Sample_Time here,
which we define in
the init file as 0.1
seconds.
seconds
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
Sample Time
52
Lecture 7 Demo 1
Demo of System running the FU505 drive
cycle five times
Demo___________
Demo of model running the Consumer
Reports drive cycle
Demo___________
Demo of model running the Trip EPA
Combined drive cycle.
Demo___________
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
53
54
Voltage
S ik
Spike
Voltage
g
Spike
Consumer
Reports
y
City
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
Lecture 7 Exercise 1
In the consumer reports drive cycle, we noticed
large voltage spikes. The spikes we observed in
the previous Consumer Reports slide are
reduced because we used a large sample time
and since the spikes were so fast.
The next slide sets the Sample_Time to 0.01,
and we see huge voltage spikes.
Figure out the reason for the battery voltage
spikes and update the model to prevent the
problem, and show the drive cycle with the
Demo___________
problem eliminated.
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
57
150,000 V
Voltage
Spike
Consumer
p
Reports
City
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 8: Post Processing
Post Processing
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Post Processing
Post Processing
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Post Processing
Post Processing
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Post Processing
Post Processing
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Display_and_Logging Subsystem
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
Distance_Miles
The Distance_Miles signal will be saved
as an array:
Notice that we are using
the Sample_Time variable
to reduce the size of the
array.
The format is specified as
y A 1-dimensional
an array.
array will be created that
contains only the data for
the specified signal.
To Workspace
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Post Processing
15
Battery_SOC
Battery_Voltage_V
Battery_Current_A
Engine_Fuel_Consumed_g
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
Constants
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
Constants
Remember that our battery model was a
voltage source (referred to as the open
circuit voltage) in series with a resistor:
RSeries
+
IBAT
VOC
VBAT
Constants
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Constants
21
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
Note that if, at the end of a simulation, the battery final SOC
is less that the battery initial SOC, electrical energy will have
been removed from the battery.
In our calculation
calculation, this will result in a negative value for the
Electrical_Energy_BTU.
Since this energy was removed from the battery and used to
move the vehicle, we need to add this amount of energy to
the actual amount of fuel consumed by the vehicle.
Since energy removed from the battery is calculated as
negative energy
energy, we have to subtract this amount of energy
from the fuel consumed energy so that the two actually
add.(This is done later when we calculate the total energy
consumed.)
Fuel Energy
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Total Energy
29
RFG Consumed
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MPGGE
31
32
MPGGE
Step 4 Fuel Energy BTU
Fuel_Energy_BTU = Fuel_Consumed_Gallons*
133393 1102
133393.1102
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Vehicle_Post_File.m File
Vehicle_Post_File.m File
33
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Msgbox
35
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation Results
37
Demo___________
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Battery Model
39
RSeries
+
IBAT
VOC
VBAT
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
42
The measured V-I curve for the FU505 drive cycle is:
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
Polyfit
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Demo___________
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 9: Improving Simulation Speed
Brake Models
Simulation Speed
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation Speed
Simulation Speed
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation speed
Simulation runs
very slow here,
even in accelerator
mode.
Driver torque
q
appears to be zero,
as it should be. We
will zoom in here.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
7
Vehicle speed is
zero
Simulation Speed
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation Speed
Simulation Speed
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Simulation Speed
11
Solution 1
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Solution 1
13
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
Solution 2
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
Brake Models
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Brake Models
23
Brake Models
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Braking Methods
25
Braking Methods
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
SimDriveline motion
sensor used to
measure rotational
velocity.
1-D Lookup
table.
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
Torque actuator
applies braking torque
to the shaft.
Maximum available
braking torque.
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Brake Testing
41
Brake Testing
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
44
Brake Testing
For an Initial condition of -1000 rad/sec, the plot
of the speed is shown below:
We see that the speed
decreases (in absolute
value) and eventually the
shaft locks at 0.
Demo___________
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
Brake Testing
For an Initial condition of +1000 rad/sec, the plot
of the speed is shown below:
We see that the speed
decreases and eventually
the shaft locks at 0.
Demo___________
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
Method 2
This model uses a friction clutch to apply
torque in the form of friction between the
rotating shaft (input port of the brake) and
an immovable object (in this case the
housing).
The housing can be thought of an in
infinite inertia. It takes in infinite amount of
toque to make it spin.
The properties of the friction clutch are
shown on the next slide.
48
Brake Method 2
The applied torque is
equal to the normal
force times the times
the radius of the
friction surface times
the number of friction
surfaces. In our case
the peak torque we
can apply is 6000 Nm,
the same as in
method 1.
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Clutch Model
49
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
52
Brake Testing
For an Initial condition of -1000 rad/sec, the plot
of the speed is shown below:
We see that the speed
decreases (in absolute
value) and eventually the
shaft locks at 0.
Demo___________
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
53
Brakes
The two models appear to behave in a
similar fashion.
We will use the clutch model in the
vehicle.
Dont ask why..
54
Brake Testing
For an Initial condition of +1000 rad/sec, the plot
of the speed is shown below:
We see that the speed
decreases and eventually
the shaft locks at 0.
Demo___________
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 9:
Brakes Part 2: Brake Controller
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
The brakes are connected to the rear halfshafts (the shafts between the rear
differential and the wheels
wheels.
We will start with model Lectue9_Model3
that we modified in Lecture 9 and
improved the simulation speed.
Save this mode as Lecture10_Model1.
Add the mechanical brakes as shown:
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Inport 1.
Inports
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Inports
Place a single Inport in your drawing:
Inport 1
added here.
Inport 1 not
added here.
Inports
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Inports
Inports
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
Inports
Select Duplicate Inport and connect the
port as shown:
12
Inports
When we go top-level block diagram, we will see
that the Rear Diff and Body subsystem only has
a single Brake_Request input:
Single Simulink
input.
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Driver Model
13
Driver Model
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
Driver Model
We will use saturation blocks to split the signal in
half. The Driver_Accel_Request is the positive
portions of the driver torque request signal.
16
Driver Model
The Driver_Brake_Request signal is the negative
portions of the driver torque request signal.
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Driver Signals
17
Note that:
A positive value in the Driver_Brake_Request
means slow down the vehicle.
A positive value in the Driver_Accel_Request
means speed up the vehicle.
Driver Block
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Brake Controller
19
Brake Controller
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
Brake Controller
We will add a new subsystem to the
Controller called
Acceleration and Braking
Acceleration_and_Braking
The input to this subsystem will be the
Vehicle_System_Daignostic bus.
The Outputs of the system will be:
Motor_Torque_Request
_
q _ q
((responsible
p
for
acceleration and regen braking).
Brake_Request (foundation brake signal)
22
Added subsystem.
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Acceleration Signal
25
Acceleration Signal
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Braking Method
27
Braking Method
28
This method:
Allows us to use 100% regenerative braking
for light braking requests.(No foundation
brakes.)
Uses both the foundation and regen brakes
for safety through the use of both braking
systems at the same time.
Creates a dead spot in the brake pedal with
no braking regen braking is disabled (whill wil
happen quite frequently. Need to fix this.)
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Braking Method
29
Braking Method
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Braking Method
31
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
Lecture 10 Demo 1
Demo___________
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Braking Results
35
Braking Results
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
More foundation
braking.
Braking Problem
38
What is this.
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
Lecture 10 Exercise 1
What is the hash that you are seeing in
the previous slide?
What is the cause of the problem?
Determine a way to fix the problem and
demo the Consumer Reposts City drive
cycle showing that the problem has been
eliminated.
Demo___________
40
Lecture 10 Exercise 2
In Lecture 8 we calculated the fuel efficiency of a
model that used only regen braking to slow the
vehicle.
In this lecture, we have now added foundation
brakes, which can only reduce the efficiency of
our vehicle.
Compare the efficiency of your vehicle from
lecture 8 to the efficiency of this vehicle using of
the FU505 and Consumer Reports City drive
cycles.
Demo___________
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 11:
Partitioning the System
High-Level Control
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Driver Block
10
Note that the only reason the driver block needs the
Vehicle_System_Diagnostiocs is because the feedback
system that tracks a drive cycle needs to know the vehicle
speed In a future lecture
speed.
lecture, the driver block will have only
outputs unless we implement a cruise control.
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Modifications
11
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Vehicle_Plant Chaqnges
15
Vehicle_Plant
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
Battery Model
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
19
Electric Motor
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
More Changes
21
Plant Model
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Top Level
23
Top Level
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Top Level
25
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
Enlargements of each
portion of this subsystem
are shown ion the next
few slides.
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
System Test
31
System Test
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
System Test
34
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
System Test
Pick the method you would like to use and
run a simulation and vetrify that it
produces the same results for the FU505
as in lecture 10.
Lecture 11 Demo 1
Demo___________
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Manual Controls
37
Driver Block
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Driver Block
39
Slider Gain
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
Slider Gain
Driver Block
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
43
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Modifications
45
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
47
Test Drive
48
S
Sett up your windows
i d
as shown
h
nextt and
dd
drive
i
the vehicle and verify the logic of the accel and
brake pedals:
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Lecture 11 Demo 2
Demo___________
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model
Model-Based-System
Based System
Design
Lecture 12:
System Initialization
Shifting Logic
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
System Initialization
We now have a vehicle that we can drive
with manual accelerator and brake pedals.
With most vehicles, you cannot just hump
press the accelerator p
pedal and
in and p
drive away. The following usually occurs
You turn the key to start the vehicle.
The vehicle goes through a component check.
The vehicle systems are enabled
enabled.
You must then shift the vehicle out of park into
forward or reverse.
System Initialization
We will add a parallel Stateflow chart to go
through the vehicle startup and shifting
procedures.
This Stateflow chart will enable the
charge-control Stateflow chart that
g
g
charging
g g
controls the engine-generator
system.
We will start with model
Lecture12_Model0, which will be passed
out in class.
class
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
System Initialization
First, we will add a switch to the driver block that
simulates the key switch of a conventional
vehicle.
hi l
Our vehicle does not have a starter, so all we
need is an off
off-on
on switch
switch.
We will use a manual switch to switch the signal
between 0 and 1
1.
We will add this to the Driver_Controlls bus, and
this signal will go directly to the controller
controller.
We will Name the signal Vehicle_Key.
Driver Subsystem
Controller
Next
Next, we will add a second Stateflow chart
chart.
The only inputs to this chart will be the
Vehicle Key signal and a clock
Vehicle_Key
clock, which is the
same clock as used for the charge controller.
This chart has a single output, which is the
Vehicle_Ready signal.
The value of this signal
g
is initialized to zero and
will remain zero until we check the status of the
battery, motor, generator, and engine.
We will also add a variable called State for
debugging purposes.
Add a Stateflow chart as shown:
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Modifications
Controller
The contents of the chart only check to see the
status of the Vehicle_Key switch.
Note that,
that for the moment
moment, the vehicle_Key
vehicle Key
switch only tells the vehicle to turn on. It is not
capable
p
of turning
g the vehicle off.
(We will implement this later because we need
to do a controlled shut-down procedure.)
The beginning of the Startup_and_Shifting chart
are shown next:
Controller
There is an error in this
diagram. Something was left
out. You may find it later
Controller
The Charge_Controller
Charge Controller Stateflow chart must also
be modified.
We want to specify that the engine and
generator not be enabled until until the
Startup_and_Shifting
p_
_
g chart check out all of the
components and signals that the vehicle is
ready.
We will need to add the Vehicle_Ready signal as
an input to this chart.
10
Controller
Modify the Charge_Controller
Charge Controller chart as shown:
11
Charge_Controller
We will add an exit condition to the
initialization state of the Charge-Controller
Stateflow chart that will not allow the
vehicle to enter the normal
charge/discharge cycle until the vheicle is
ready.
Note that this modification does not
graceful shutdown.
address the issue of a g
12
Charge Controller
This state transition guard
added.
13
Battery Model
Next we will add a startup handshake for the battery and
some operational details.
The battery has a control signal that must be sent to it and a
status signal that it sends to indicate its state.
The battery has an internal contactor. When the contactor is
open, the battery voltage is zero and the pack is
disconnected from the system.
When the contactor is closed
closed, the battery is connected to
the system (motor and generator in our case) and the output
voltage is that indicated by our model.
14
Battery Model
Connect Command Input signal received by
the battery
1 Close the contactor.
0 Open Contactor.
0 Unavailable
1 Idle
2 Disconnected (Contactor Open)
3 Precharging
g g
4 Connected (Contactor Closed).
15
Battery Model
16
Battery Model
The Startup_and_Shifting Controller must be
modified as follows:
After Vehicle_Key = 1, the controller must issue the
connect command.
Before proceeding to the next state
state, the controller
waits for the Pack state to Equal 4.
If the pack state does not go to 4, do not proceed and
do not allow the driver to use the vehicle. (Indicate an
error and hold in an error state.)
If the pack state changes to 4
4, allow the controller to
proceed to the next state.
17
Lecture12 Exercise 1
D
Demonstrate
t t the
th operation
ti off the
th Vehicle
V hi l
Key Switch and the Battery Connect
command.
d Sh
Show the
th ffollowing:
ll i
Startup_and_Shifting chart as it walks through
th startup
the
t t procedure.
d
The battery voltage showing the operation of
the contactor
contactor.
The battery status signal showing the various
states.
states
Show a plot similar to the one shown on the
Demo___________
___________
next two slides
slides.
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
18
Lecture12 Exercise 1
19
Pack
P
k state
t t stays
t
att
2.
Contactor never
closes.
State goes to 4
indicating an error.
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
20
21
Next
Next, we need to add the handshake and status
signals for the Motor and generator models.
The Motor and Generator models have a control
signal that must be sent to it and a status signal that
it sends to indicate its state.
Enable Command Received by Motor or Generator
1 Enable Component.
p
0 Disable Component.
22
Controller Modifications
The start-up sequence must be modified:
After the battery has passed its start-up test
the enable command should be sent to the
motor. The controller then waits to receive
th status
the
t t off the
th motor.
t
If the status is 1, proceed to the generator check.
If the status does not change to 1 after 1
1.5
5
seconds, enter an error state and hold.
23
Controller Modifications
The start-up sequence must be modified:
After the motor has passed its start-up test the
enable command should be sent to the
generator. The controller then waits to
receive
i th
the status
t t off the
th generator.
t
If the status is 1, set Vehicle_Ready to 1 and go to
the Park State (for now do nothing in this state
except set Vehicle_Ready to 1).
If the status does not change to 1 after 1.5
seconds, enter an error state and hold.
24
25
Lecture12 Exercise 2
D
Demonstrate
t t the
th operation
ti off the
th Vehicle
V hi l Key
K
Switch, Battery Connect, Motor Enable, and
G
Generator
t Enable
E bl C
Commands.
d Sh
Show th
the
following:
Startup_and_Shifting
S
d Shif i chart
h as iit walks
lk through
h
h the
h
startup procedure.
The
Th status
t t signals
i
l showing
h i th
the various
i
states
t t off
each component.
Show a plot similar to the one shown on the next
Demo___________
two slides.
Plots are shown on the next two slides
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture12 Exercise 2
26
Lecture12 Exercise 2
27
Lecture 12 Exercise 3
We now wish to add shifting logic to our model
model.
We will need to add three pushbuttons for forward,
reverse and park
reverse,
park. These switches go in the Driver
block.
Park When the driver p
presses this p
push-button, it
indicates that the driver wants to have the transmission
enter the park state. In this state, the accelerator pedal
input is ignored.
ignored
Forward - When the driver presses this push-button, it
indicates that the driver wants the vehicle to move
forward when the accelerator pedal is pressed.
Reverse - When the driver presses this push-button, it
indicates that the driver wants the vehicle to move
backwards when the accelerator pedal is pressed.
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
28
Lecture 12 Exercise 3
We also need some dashboard indicator lights for
the driver.
Park LED This LED is illuminated when the vehicle is in
Park.
Forward LED This LED is illuminated when the vehicle
is in Forward.
Reverse LED This LED is illuminated when the vehicle
is in Reverse.
Error LED This LED illuminates to alert the driver if
there is a problem
problem.
Vehicle Ready LED This light illuminates when the
vehicle has passed all component checks.
29
Lecture 12 Exercise 3
Note that the controller determines when
we are in park, forward or reverse.
We will place these indicators in a new
y
within the Vehicle_Plant called
subsystem
Dashboard.
30
Lecture 12 Exercise 3
31
32
All logic for the accelerator pedal, brake pedal and pushbuttons resides in the controller
controller. The controller emits signals for
the traction motor torque and foundation brakes. The driver
block just contains the driver input sensors.
At vehicle startup, after checking that the status of each
component is correct, the vehicle should enter the park state.
To shift out of park into either forward or reverse
reverse, the following
sequence must occur:
The driver must depress the brake pedal by 50% or more.
The driver can then press the forward or reverse buttons.
When the button is pressed, the appropriate indicator light is illuminated
and the vehicle shifts into either forward or reverse.
If the vehicle is in park and the brake pedal is depressed less than 50%
and the forward or reverse buttons are pressed, nothing happens and
the vehicle remains in Park.
Forward State
33
Reverse State
34
35
Lecture12 Exercise 3
D
Demo off everything
thi working.
ki
I will try to brake your model.
Demo___________
4/22/2009
Introduction to Model-Based
Systems Design
Lecture HIL1:
Introduction to Hardware-in-theLoop
HIL
4/22/2009
HIL
Remember that our goal is to design and
implement a controller for real and
complicated physical system.
system
Controller
Interface
Plant
HIL
4/22/2009
HIL
HIL
4/22/2009
HIL
HIL
4/22/2009
HIL
HIL simulations allow us to test the control
algorithm on the hardware that will be
used to implement the controller
controller.
The benefit is that we can test the
controller using a model of the plant so
that there is no danger of personal injury
or physical damage to the plant.
10
HIL
We will be using the test platform below:
Controller
Interface
Controller deployed on an
MPC5554 computer.
4/22/2009
11
HIL
Once controller testing is complete and the
controller passes all tests and satisfied all
requirements we just plug the controller
requirements,
into the physical plant.
If the models are accurate and the
interface is the same, the controller should
be able to control the physical plant as
well as it controlled the model off the plant.
12
HIL
Completed System:
Controller
Interface
Controller deployed on an
MPC5554 computer.
Physical Plant
4/22/2009
HIL
13
HIL
14
4/22/2009
HIL
15
HIL
16
4/22/2009
HIL
17
HIL
18
4/22/2009
Stand-Alone Model
19
Model Modifications
20
Slider deleted.
Slider deleted.
10
4/22/2009
Top-Level Modifications
21
Top-Level Modifications
22
11
4/22/2009
23
Top-Level Model
Your top-level Model should be as shown:
Controller Modifications
24
12
4/22/2009
Controller Modifications
25
Controller Modifications
26
13
4/22/2009
27
28
14
4/22/2009
Model Modifications
29
Model Modifications
30
Solver
selected.
Fixed Step solver
selected because we
will be running in realtime on a target.
15
4/22/2009
Model Modifications
31
32
16
4/22/2009
33
34
Build was
successful.
17
4/22/2009
35
W
We will
ill need
d tto point
i t tto this
thi file
fil when
h we
set up our LabVIEW front panel.
36
18
4/22/2009
37
38
19
4/22/2009
39
40
20
4/22/2009
41
42
21
4/22/2009
43
44
22
4/22/2009
45
46
Target Selected.
The IP address of this target is
192.168.1.107. We will need
thi address
this
dd
iin order
d tto run our
model on this target.
23
4/22/2009
47
48
24
4/22/2009
49
50
25
4/22/2009
51
52
26
4/22/2009
LabVIEW
53
54
27
4/22/2009
55
Right-click here.
Left-click here to
select this control.
control
Hover here.
Motor-Controller Shell
56
28
4/22/2009
57
58
29
4/22/2009
59
Entire control
selected.
60
30
4/22/2009
61
62
Select the
Display Format
tab.
31
4/22/2009
63
Click here to
select the
Advanced
editing mode.
64
32
4/22/2009
65
66
33
4/22/2009
67
68
34
4/22/2009
69
Right-click here.
Left-click here to
select this control.
control
Hover here.
70
35
4/22/2009
71
72
36
4/22/2009
Motor-Generator Shell
73
74
37
4/22/2009
75
76
Maximum
specified as 1.
38
4/22/2009
77
Front Panel
Click on the control and use the
handlebars to resize the fill slide:
78
Hover here.
39
4/22/2009
79
80
40
4/22/2009
81
Motor-Generator Shell
82
41
4/22/2009
83
Thicker line
selected.
84
X-Axis selected.
Select the
Scales tab.
Time range
specified as 0 to
20.
42
4/22/2009
85
Range specified
as 0 to 8.
We are done
with the
changes for
the chart..
Click the OK
button when
done.
86
43
4/22/2009
Motor-Generator Shell
87
88
We are now
ready to connect
our front panel to
the Simulink
model compiled
into a DLL.
From the
LabVIEW menus,
select Tools and
then SIT
Connection
Manager:
44
4/22/2009
89
90
Model
selected.
45
4/22/2009
91
92
46
4/22/2009
93
94
47
4/22/2009
95
96
Simulink Model
We would like to connect this to the
constant block in the top level of our
Simulink model
model. The model is shown
below as a reminder:
48
4/22/2009
97
We want to connect
to this constant (One
Bulb).
98
49
4/22/2009
99
100
50
4/22/2009
101
102
Click here.
51
4/22/2009
103
Encoder Mapping
Expand the Plant subsystem and then the Encoder
subsystem until you see the gain with the output
port labeled as Plant_RPM. If you recall, we
labeled the signal out of the gain block in the
Encoder as Plant_RPM.
Output port of the
encoder gain block
selected.
104
52
4/22/2009
105
Controls added by
the SIT Connection
Manager.
Block Diagram
106
53
4/22/2009
107
108
Click here.
54
4/22/2009
109
110
55
4/22/2009
111
Running the VI
The model will continue to download:
112
56
4/22/2009
113
114
57
4/22/2009
115
Demo
116
Demo___________
58
4/22/2009
Exercise 1
117
Demo___________
Exercise 2
118
Create the front panel shown below. The controls created earlier are
unchanged. Added items are listed in the following few slides.
59
4/22/2009
119
Exercise 2
120
Exercise 2
60
4/22/2009
121
Exercise 2
122
Exercise 2
Decoration.
Decoration.
Decoration.
61
4/22/2009
123
Exercise 2
Demo___________
62
8/28/2009
Advanced Model-Based-System
Design
Lecture 14:
Real-Time Vehicle Model
Models
8/28/2009
Foreshadowing
Models
8/28/2009
Driver Block
8/28/2009
Display_and_Logging
8/28/2009
10
8/28/2009
11
Solver
12
8/28/2009
Lecture14 Exercise 1
13
14
Demo___________
Lecture14 Exercise 1
CPU Utilization_______ %
8/28/2009
15
Lecture 14 Exercise 2
We notice that the generator current
bounces all around, independent of the
step size and integration methods
methods.
To get a better idea of the system
behavior, add the graphs to the front panel
as shown next:
16
Demo___________
Lecture14 Exercise 2
CPU Utilization_______ %
8/28/2009
Model Problems
17
Model Problems
18
8/28/2009
Lecture 14 Exercise 3
19
Demo___________
CPU Utilization_______ %
Model Problems
20
10
8/28/2009
Model Problems
21
New
Tire Model
22
11
8/28/2009
23
24
12
8/28/2009
Lecture 14 Exercise 4a
25
Lecture 14 Exercise 4b
26
13
8/28/2009
27
Model Debugging
28
14
8/28/2009
29
Lecture 14 Exercise 5
Modify the control algorithm as follows:
Under normal conditions, the generator will charge the battery at
50 A.
If the battery SOC goes below a value of 0.58, a new algorithm
kicks in where the battery charges at the motor current plus 20%
with some averaging. (What should happen if regen braking
kicks in and the motor current flips?)
The minimum charging current in this mode is 50 A.
This method continues until the battery is charged back up to
0.7.
Once the battery is charged to 0.7,
0 7 the normal charging
algorithm kicks back in.
Demo___________
CPU Utilization_______ %
30
Lecture 14 Exercise 6
15
Advanced Model-Based-System
Design
Lecture 15:
Number Systems
Outline
Binary
Hexadecimal
M tl b Functions
Matlab
F
ti
Unsigned Integers
Signed Integers
Floating Point Numbers
Number Systems
There are two kinds of engineers in this
world
Those who know binary and those who dont.
That was a joke.
If you dont know binary, you probably didnt
get it.
Base 10
Most of us are familiar with base 10
number systems.
Valid digits are 0 through 9 (Hey! There
are 10 values!)
The base is also referred to as the radix.
An example is:
Radix = 10
Binary
Binary uses a radix of 2.
Valid values of a digit are 0 and 1.
) (
) (
) (
) (
10110 = 1 2 4 + 0 23 + 1 2 2 + 1 21 + 0 20
Radix = 2
10110 = (1 16 ) + (0 8) + (1 4 ) + (1 2 ) + 0 = 22
Binary
10110
0s place
16s place
8s place
2s place
4s place
Binary
Synonyms
1 = logic 1 = high = True
0 = logic 0 = low = False
Terminology
Hexadecimal Radix = 16
Hex
Decimal
Binary
Hex
Decimal
0000
1000
0001
1001
0010
1010
10
0011
1011
11
0100
1100
12
0101
1101
13
0110
1110
14
0111
1111
15
Hexadecimal
10
11
Hexadecimal
1011
{ 0110
{ 1101
{ 0111
{ 0011
{
B
6
D
7
3
) (
) (
) (
) (
12
13
Matlab
14
Hexadecimal Numbers
15
16
17
Signed Integers
18
19
20
10
21
) (
) (
) (
) (
10110 = 1 2 4 + 0 23 + 1 2 2 + 1 21 + 0 20
= 16 + 6
= 10
22
2s complement Numbers
) (
) (
) (
) (
00110 = 0 2 4 + 0 23 + 1 2 2 + 1 21 + 0 20
= 0+6
= 6
With 2s complement
If the most significant bit is a 1, the number is
negative
negative.
If the most significant bit is a 0, the number
will be positive.
11
2s complement Numbers
23
127
2s complement
24
12
25
26
13
27
28
14
29
d .dddd 10 p
= ddddd .0 10 p 4
0.ddddd 10 p +1
Decimal point.
30
Binary Point
Binary numbers can have a fractional part
just like decimal numbers:
) (
) (
) (
) (
101.11 = 1 2 2 + 0 21 + 1 20 + 1 2 1 + 1 2 2
101.11 = (1 4 ) + (0 2 ) + (1 1) + (1 1 2 ) + (1 1 4 ) = 5.75
Binary point.
15
31
= bbbbb.0 2 p 4
b.bbbb 2 p
Binary point.
0.bbbbb 2 p +1
32
(
(
)
)
s
Value = ( 1) 2 e 126 (0. f ) ; denormalised , e = 0, f > 0
exceptional value
16
33
1 10111101 10100000000000000000000
s
e
f
s = 1 we have
h
a negative
ti number.
b
e = 10111101=18910
e 127
189 127
) = (262 )
(2 ) = (2
f = 10100000000000000000000
1.ff = 1.10100000000000000000000
= (1 20 ) + (1 21 ) + (0 22 ) + (1 23 ) + (0 24 ) + (0 25 ) + ....
= 1.625
34
Our number is
-1.62510 + 262
= -7.493989779944505
7 493989779944505 x 1018 (decimal)
(d i l)
17
35
(
(
)
)
s
Value = ( 1) 2e 1022 (0. f ) ; denormalised , e = 0, f > 0
exceptional value
36
Low Limit
High Limit
Exponent
Bias
Precision
Single
2-12610-38
21283x1038
127
2-2310-7
Double
2-10222x10-308
210242x10308
1023
2-5210-16
18
37
The
Th ffollowing
ll i operations
ti
resultlt iin a N
NaN:
N
+
0
0/0
/
Questions?
19
Advanced Model-Based-System
Design
Lecture 16:
Introduction to MotoTron ECUs
and MotoHawk
Outline
Physical Connections
Creating a MotoTron MotoHawk Project
Flashing LED Project (Digital Output)
Changing CAN Speed
Motor Speed Controller
Analog Input
Digital Output
Using MotoTune
MotoHawk Probes
MotoHawk Calibration
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Harness ground
connection
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
ECU555-80
Plug these in to the ECU.
They only fit one way.
ECU555-80
80-Pin Connectors
ECU555-80 Connections
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
CAN Hub
10
On/Key switch. This
switch passes 12V to the
ECUP input of the ECU.
This is an old style
switch.
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
11
CAN Hub
Development cable CAN
connection
12
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
Can Connections
14
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
15
Can Connections
120 terminator.
120 Terminator
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
17
Non-terminated side
of CAN cable
connected here.
Terminated side of CAN cable connected here. (Or nonterminated cable with terminator plugged into hub.)
18
Plug in MotoHawk
dongle here.
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Complete Setup
19
20
Run Matlab.
Change to your working directory.
At th
the M
Matlab
tl b promptt enter
t the
th command
d
motohawk_project('Motor_Control_MH1')
This will:
Create a directory called Motor_Control_MH1
Change to that directory
directory.
Create support sub directories.
Create a model file called Motor_Control_MH1.mdl
Open the model named Motor_Control_MH1.mdl
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
21
Directory Structure
Support directories.
New directory.
22
Title block.
Target definition.
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
Title Block
Revision number
number. This number will
increment every time we build this model
(automatically generate code).
24
Selected ECU
Double-click on
this block to
change the ECU.
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
25
We will be using a
ECU555-80 target for this
example. If you have a
different target, specify it
here.
here
MotoHawk Blocks
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
27
Red wire in
development
harness.
28
Key switch.
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
Solver option
selected.
30
Discrete solver
selected
selected.
Simulink will pick
our step size.
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
31
MotoHawk target
selected.
Real-Time Workshop
option selected.
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
Foreground Process
We are now ready to create our controller.
Our first controller will just turn on and off
the LEDs.
LEDs
These LEDs tell us that the ECU is alive.
Double-click on
the foreground
block to open it.
34
Default foreground
process.
We will not use this
stuff.
Delete the controller
and plant
plant.
Your foreground
subsystem should
look as shown on the
next slide.
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
36
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
Pulse Generator
Compare To Constant
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
39
Compare To Constant
Change to 0.5.
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
41
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
FUELP
43
The TACH output
uses pin B12.
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
45
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Digital Output
47
In the
Simulink
model,
doubleclick on the
Discrete
Output
block and
change the
Resource
to TACH:
Digital Output
48
Change
the
Resource
of the
other
digital
output
block to
FUELP:
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
51
52
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
53
Boolean output
data type selected.
Data Types
54
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
56
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
57
58
Wiring
The next thing we need
to do is wire up our
circuit.
The LED circuit is
shown to the right.
We have already
identified the wires for
the TACH and FUELP
Signals.
We need to find a 5V
reference.
XDRP (A23)
Wire No. 23
Purple/Yellow
5V
D2
D1
LED
LED
R2
R1
100
LED1
TACH (B12)
Wire Number 43
Orange
100
LED2
FUELP (B11)
Wire Number 44
Gray
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Wiring
59
Wiring
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Wiring
61
We need to make
connections as shown.
y
Connections
Physical
are Shown on the next
slide.
Wiring
62
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Project Build
63
Revision 000.
Project Build
64
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
66
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Project Build
67
This is the file we will
download to the ECU.
Project Build
68
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
69
Project Build
When we switch back to our model, we
notice that the revision number in the
header has been incremented.
incremented
Revision 001.
MotoTune
70
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
71
MotoServer
Before we download our model, we will
check the CAN port settings in
MotoServer
MotoServer.
The MotoServer icon
should be
located in your windows tray.
MotoServer icon.
MotorServer
72
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotorServer
73
MotoServer
74
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
75
Port selected.
76
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
77
Click here.
78
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
79
CAN Bus 1.
80
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
81
82
Port is selected.
Click the OK button. We
are ready to go.
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
83
MotoTune
We now have the ports set correctly and
can program our ECU!
In the MotoTune window select File and
then Program, or select the program
button:
84
MotoTune
Select the most
recent .srz file for
your model (or the
.srz
srz file you want to
download to your
ECU).
42
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
85
MotoTune
File selected. Click
the Open button.
86
MotoTune
If you are successful, you will see the
series of dialog boxes below:
If you do not see this
box, you may need to
turn on your key switch
and/or turn on your 12 V
power supply.
43
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune
87
Build Process
88
44
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
89
90
Double-click on this
block to change its
parameters.
45
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
91
92
46
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
93
94
47
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
95
96
48
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
97
98
Port selected.
49
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
99
Baud rate
changed.
100
50
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
101
102
51
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
103
104
52
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
105
Lecture 16 Demo 1
106
Demo___________
53
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 17:
MotoTron MotoHawk Projects
Outline
1
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
2
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Foreground Subsystem
3
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
Analog Inputs
4
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
10
5
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
11
Analog Inputs
12
Double-click on this
block to open it.
6
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
13
Analog Inputs
Change this to AN4M.
14
Analog Inputs
Modify the three Analog Input Blocks as shown.
Changed to AN4M.
Changed to AN5M.
Changed to AN6M.
7
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
15
Analog Inputs
16
8
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
17
Analog Inputs
18
9
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Inputs
19
Analog Inputs
20
10
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Analog Input
21
MotoHawk Probes
22
11
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoHawk Probes
23
PWM Output
24
12
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
PWM Output
25
PWM Output
26
13
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
PWM Outputs
27
PWM Output
28
14
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
29
PWM Output
Specify the Resource as
EST1.
S
Specify
if th
the minimum
i i
ffrequency
as 1000. (If you are not using
MotoHawk 084 Beta 9 or
higher, you will get a different
dialog box here.)
PWM Output
30
15
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
PWM Output
31
PWM Output
32
16
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
33
PWM Frequency
34
PWM Frequency
Frequency
value
specified
here.
17
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
35
PWM Frequency
The frequency input needs a uint32 data
type.
We could do this with a data type
conversion block.
Instead we will do it with the Signal Data
Types tab in the constant block:
36
PWM Frequency
Select the Signal Data Types tab and
select the uint32 data type:
Uint32 specified.
Click the OK
b tt when
button
h
done.
18
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
37
38
19
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoHawk Override
39
MotoHawk Override
40
20
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoHawk Override
41
42
21
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Model Build
43
If:
you did not receive any errors after using the
ctrl-d
ctrl
d command, and
Your data types match the ones shown
Wiring Connections
44
22
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
PWM Connection
45
POT Connection
46
23
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
RPM Connection
47
Voltage Connection
48
24
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
49
Circuit Diagram
A complete circuit diagram for our
connections is shown below.
XDRP (A23)
Wire No. 23
Purple/Yellow
5V
PWM
5V
RPM
Voltage
D2
D1
LED
LED
LED1
TACH (B12)
Wire Number 43
Orange
R3
10k
R2
R1
100
100
LED2
FUELP (B11)
Wire Number 44
Gray
PWM
EST1 (B2)
Wire Number 34
Green/Black
GND
POT
XDRG (A22)
Wire Number 22
Black/Orange
AN4M (A6)
Wire Number 6
Light Blue/White
RPM
VOLTAGE
AN5M (A7)
Wire Number 7
White/Yellow
Wiring Connections
AN6M (A8)
Wire Number 8
Brown/White
50
25
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune
51
MotoTune Display
52
26
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Display
53
Cli
Click
k th
the Next
N t button
b tt twice
t i and
d then
th click
li k
the Finish button.
You should have the screen shown next:
54
27
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
55
MotoTune
Click on the plus sign(s) next to
Motor_Control_MH2 to expand the tree.
56
MotoTune Display
This is the override
we p
placed in our
model.
28
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Display
57
MotoTune Display
58
29
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Display
59
Probe name.
Real-time value.
MotoTune Display
60
30
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Display
61
MotoTune Display
62
31
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
63
MotoTune Display
64
MotoTune Display
Option selected.
32
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
65
MotoTune Display
The model is running on our ECU.
If you rotate the pot, you should see the
value on the Desired
Desired_Voltage
Voltage probe
change between 0 and 1.
66
MotoTune Override
Right now, the override is set to PassThrough.
From the model
model, the value we specified is
0, so the motor will be off.
33
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Override
67
After selecting the cell,
options are now available.
Select Override and press
the enter key.
68
MotoTune Override
Enter a value here.
When you press the enter
key, the output of the
override block will be
changed to the value you
enter.
34
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Override
69
MotoTune Display
70
35
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 17 Demo 1
71
Demo___________
Controller Implementation
72
36
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Implementation
73
74
Added subsystem.
Double-click on the
subsystem to open it.
ports as shown next.
Add p
37
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Subsystem
75
Controller
76
38
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller
77
Controller
78
39
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
79
Controller
We will start with the proportional feedback
method we developed in model
Motor_Control_Sim1.mdl.
The controller portion of the model is shown
below.
Controller.
80
40
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoHawk Controller
81
MotoHawk Controller
82
41
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
83
MotoHawk Controller
Gain changed to 1
P d t bl
Product
block
k added.
dd d
84
Calibration Block
Name changed to
Proportional_Gain
Do not forget the quotes. No
spaces allowed.
42
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Calibrations
85
MotoTune
86
43
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor-Generator Operation
87
Lecture 17 Demo 2
88
Demo___________
44
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor-Generator Operation
89
Motor-Generator Operation
90
45
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
91
92
Block added.
46
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
93
94
Period changed
to 1 ms.
47
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
95
FGND RTI
We see that our foreground subsystem is
triggered by the FGND RTI. Since we
changed this value to 1 ms
ms, our controller
will now execute every 1 ms.
This block generates a trigger at
the rate specified by the FGND
RTI block.
Motor-Generator Operation
96
48
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Calibration
97
MotoTune Calibration
98
49
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Calibration
99
MotoTune Calibration
100
50
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
MotoTune Calibration
101
Calibrations
102
51
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor-Generator Operation
103
Proportional Feedback
104
52
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Proportional Feedback
105
Proportional Gain
106
53
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Motor-Generator System
107
Lecture 17 Demo 3
108
Demo___________
54
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Further Investigations
109
Integral Control
110
55
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Integral Control
111
Integral Control
112
56
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Integral Control
Proportional Gain.
113
Error Signal.
Integrator.
114
Integrator output.
Equal to the
previous value
value, plus
the added area of
the rectangle just
calculated.
Integrator output from
the previous time step.
57
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
115
Integral gain.
Initially the gain is
set to zero.
zero We will
change the gain
with the calibration
block.
Model Build
116
58
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
117
System Behavior
118
The Integral
g g
gain
Drives the error signal to zero.
Causes over and undershoot.
Larger values of integral gain cause more over and
undershoot, but drive the error to zero faster.
59
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 17 Demo 4
119
Demo___________
Calibration Problem
120
60
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
121
Calibration Problem
A step change like the one we see in our
motor-generator system could easily break
a shaft
shaft.
The reason for this problem is where we
placed the gain block for our integrator.
122
Calibration Problem
Output to sum
bl k E
block:
Even
though the
integrator
holds it value,
this signal will
have step
changes
because the
gain has step
changes.
61
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Calibration Problem
123
Calibration Problem
124
62
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Controller Improvements
125
Generator Model
126
63
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Generator Model
127
128
64
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
129
130
Generator output
voltage is now the
feedback variable.
The speed signal is
not being used.
65
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
131
132
66
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Lecture 17 Demo 5
133
Demo___________
67
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
Advanced Model-Based-System
Design
Lecture 18:
CAN Communication
Outline
Vector CANdb++
Sent by ECU1
CAN ID x123 (hex)
CAN Standard 11-bit ID
DLC 6 bytes in length
Signals
SW1 values -1 to 1
SW2 values -3 to 3
SW3 values -5 to 5
SW3 values -7 to 7
SW1
Sine Wave 1
g
is a signal
with values
from -1 to +1.
Send as an
unsigned 8-bit
code.
Unsigned
g
Codes
n := 8
Xmax := 2 1
Xmax = 255
Xmin := 0
X is
i the
th binary
bi
value
l off th
the code
d iin th
the fifield.
ld W
We are
assuming a unsigned codes from 0 to 2n-1.
Ymax and Ymin are the values of the data signal being
sent via CAN.
Ymax := 1
factor := 1
Ymin := 1
offset := 0
Initial Guesses
Given
Ymax
Ymin
factor
offset = 1
SW2
Sine Wave 2
g
is a signal
with values
from -3 to +3.
Send as a
signed 8-bit
code.
n1
Xmax = 127
Xmin := 2
n1
Xmin = 128
10
Ymax and Ymin are the values of the data signal being
sent via CAN.
Ymax := 3
Ymin := 3
factor := 1
offset := 0
Initial Guesses
Given
Ymax
Ymin
factor
offset = 0.0117647
11
SW2
Sine Wave 3
is a signal
with values
from -5 to +5.
Send as an
unsigned 16bit code.
Use little
endian (Intel)
format.
Ymax and Ymin are the values of the data signal being
sent via CAN.
Ymax := 5
factor := 1
12
Ymin := 5
offset := 0
Initial Guesses
Given
Ymax
a
factor Xmax
a + offset
Ymin
factor
offset = 5
13
SW4
Sine Wave 4 is a
signal with
values from -7 to
+7.
Send as a
signed 16-bit
code.
Use big endian
(Motorola)
format.
n1
Xmax = 32767
Xmin := 2
n 1
Xmin = 32768
Ymax and Ymin are the values of the data signal being
sent via CAN.
Ymax := 7
14
Ymin := 7
factor := 1
offset := 0
Initial Guesses
Given
Ymax
Ymin
factor
offset = 0.0001068
15
16
17
18
19
ECU1_Message1.m
20
10
21
ECU1_message1
The message will be
sent at a 50 Hz rate.
Information for
documentation.
22
ECU1_message1
We will be using an11-bit ID.
This is a 6-byte
message.
11
23
ECU_Message1
Here is where the signals
contained in the message
are defined
defined.
ECU1_message1 SW1
24
Same as in CANdb+.
12
25
ECU1_message1 SW1
26
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
13
27
ECU1_message1 SW2
28
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
14
29
ECU1_message1 SW3
Location of the least significant
bit of this signal is 40.
30
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
35
33
32
Least
SW3 is27
31 significant
30 bit of
29signal28
bit 40.
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
15
31
ECU1_message1 SW4
Location of the least significant
bit of this signal is 16.
32
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
16
33
ECU1_Message2
Sent by ECU1
CAN ID x601 (hex)
CAN Standard 11-bit ID
DLC 6 bytes in length
Signals
Potentiometer Value 0 to 1023.
Sine Wave Period = 5.0 s, Amplitude = 5V
Shark Tooth Waveform (Ramp) -100 to 100.
Time 0 to 3600 seconds.
Potentiometer
34
17
35
Signal with
values from -5
to +5.
Send as an
unsigned 14bit code.
tt e
Use little
endian (Intel)
format.
36
18
SharkTooth
37
Signal with
values from 100 to +100.
Send as an
unsigned 12bit code.
tt e
Use little
endian (Intel)
format.
38
19
Time
39
Signal with
values from 0
to 3600.
Send as an
unsigned 12bit code.
tt e
Use little
endian (Intel)
format.
40
20
41
42
21
43
ECU1_Message2.m
44
ECU1_message2
The message will be
sent at a 50 Hz rate.
Information for
documentation.
22
45
ECU1_message2
We will be using an11-bit ID.
This is a 6-byte
message.
ECU_Message2
46
23
47
ECU1_message2 Sinewave
Location of the least significant
bit of signal Sinewave is 50.
48
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
43
42
41
40
39
38
37
36
35
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
24
49
ECU1_message2 Time
Location of the least significant
bit of the signal.
50
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
43
42
41
40
39
38
37
36
35
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
25
51
Sent by ECU2
CAN ID x708 (hex)
CAN Standard 11-bit ID
DLC 3 bytes in length
Signals
Temperature 0 to 100
Fred -3150 to -3120
LED3 0 to 1
Pulsewidth 0 to 100
Temperature
52
Signal with
values from 0
to 100.
Send as an
unsigned 7-bit
code.
tt e
Use little
endian (Intel)
format.
26
53
Fred
54
Signal values
from -3150 to
-3120.
Send as an
unsigned 5-bit
code.
tt e
Use little
endian (Intel)
format.
27
55
LED3
56
Signal value 0 or 1.
Send over CAN as an unsigned 1-bit code.
Factor is 1.
1
Use little endian (Intel) format.
28
Pulsewidth
57
Signal values
from 0 to 100.
Send as an
unsigned 10-bit
code.
Use little
endian
e
d a ((Intel)
te )
format.
58
29
59
60
30
61
ECU2_Message1.m
62
ECU2_Message1
The message will be
sent at a 50 Hz rate.
Information for
documentation.
31
63
ECU2_Message1
We will be using an11-bit ID.
This is a 3-byte
message.
ECU2_Message1
64
32
65
ECU2_Message1 Fred
Location of the least significant
bit of signal Fred is 63.
66
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
36
35
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
33
67
ECU2_Message1 LED3
Location of the least significant
bit of signal LED3 is 52.
68
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
36
35
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
34
69
Sent by ECU2
CAN ID x124 (hex)
CAN Standard 11-bit ID
DLC 1 byte in length
Signals
Cooling_Fan 0 to 1
Cooling_Fan
70
Signal value 0 or 1.
Send over CAN as an unsigned 1-bit code.
Factor is 1.
1
Use little endian (Intel) format.
35
71
72
36
73
74
37
75
76
ECU1 Slides
ECU2 Group skip ahead to slides
l b l d with
labeled
ith h
header
d ECU2
ECU2.
(Approximately slide number 116)
38
ECU1
77
ECU1
78
39
ECU1
79
ECU1
80
40
ECU1
81
ECU1
82
41
83
ECU1
Copy all of the CAN files to the CAN
directory.
By default
default, the MotoHawk CAN blocks will
look in this directory for the m-files.
84
ECU1
Next, open the foreground subsystem.
Delete the controller and plant models.
Place
Pl
4 Si
Sine W
Wave parts
t iin thi
this subsystem
b
t
(library Simulink/Sources).
Sine wave properties:
Amplitude: 1
Period: 1 sec
42
ECU1
85
Time based chosen. We cannot
use a sample based sine wave
inside a triggered subsystem.
ECU1
86
43
87
ECU1
We want to send the values of the sine
waves over the CAN bus.
Place a part called Send CAN Messages
in your model. (Library MotoHawk/CAN
Blocks.)
Double-click on the part and change the
settings as shown:
ECU1
88
We created this m-file earlier.
The name of the file was
ECU1_Message1.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
44
ECU1
89
ECU1
90
45
ECU1
91
ECU1
92
46
93
ECU1
As a reminder, the potentiometer used
analog input AN4M.
Do not scale the value
value. (We are
transmitting the raw value in the range of 0
to 1023.)
94
ECU1
For the sine wave, use the same part as
we used for the first 4 sine waves and set
the amplitude to 5 and period to 5:
Amplitude 5.
Period 5
5.
47
95
ECU1
For our ramp, we will use a part called
Signal Generator. (Located in library
Simulink/Sources.))
Sawtooth chosen.
Note that we have chosen
that the time reference for
this block should be an
external signal.
We will need to provide a
signal for this block that
corresponds to time.
Amplitude set to 100, Frequency set to
0.2 Hz (corresponding to a period of 5
seconds.)
ECU1
96
48
ECU1
97
ECU1
98
49
ECU1
99
We created this m-file earlier.
The name of the file was
ECU1_Message2.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
ECU1
100
50
ECU1
101
ECU1
102
51
103
ECU1
ECU1 will be receiving two can messages.
We need to add a CAN receive block for
each message we are receiving
receiving.
Place a part called Read CAN Message in
your model. (Library MotoHawk/CAN
Blocks.)
Double
Double-click
click on the block and change the
settings as shown:
ECU1
104
We created this m-file earlier.
The name of the file was
ECU2_Message1.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
52
ECU1
105
ECU1
106
53
107
ECU1
LED3:
Convert to a Boolean type and turn on and off an LED
in the motor-generator system.
Use digital output part with pin TACH
TACH. (Same as in
our previous motor control exercise. Should already
be wired up correctly.)
Pulsewidth:
The received signal has values from 0 to 100.
Convert to values from 0 to 4096.
Convert to type int16 and send out a PWM signal
using the PWM output block with pin EST1.
(Same as in our previous motor control exercise.
Should already be wired up correctly.)
108
ECU1
The next few slides show the connections.
MotoHawk probe.
MotoHawk probe.
MotoHawk_dout.
Pin: TACH
Data Type Conversion.
54
109
ECU1
Motohawk_pwm.
Pin: EST1
MotoHawk probe.
ECU1
110
55
111
ECU1
The second CAN message that ECU1 will
receive is ECU2_message2.
This message has one signal called
Cooling_Fan.
We will display this signal with a probe.
Place a part called Read CAN Message in
your model. (Library MotoHawk/CAN
Blocks.)
Double-click on the block and change the
settings as shown:
ECU1
112
We created this m-file earlier.
The name of the file was
ECU2_Message2.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
56
ECU1
113
ECU1
114
57
115
ECU1
We are now done building the model.
Use the techniques covered previously to:
Check for consistency in data types:
Select Format, Port/Signal Displays, and then
Port Data Types to display data types.
Type ctrl-D to evaluate your model for errors.
116
ECU2 Slides
ECU1 Group skip ahead to slides
l b l d with
labeled
ith h
header
d ECU1/ECU2
ECU1/ECU2.
(Approximately slide number 166)
58
ECU2
117
ECU2
118
59
ECU2
119
ECU2
120
60
121
ECU2
122
ECU2
Baud rate set to 500 kbaud.
61
ECU2
123
ECU2
124
62
125
ECU2
Copy all of the CAN files to the CAN
directory.
By default
default, the MotoHawk CAN blocks will
look in this directory for the m-files.
ECU2
126
63
127
ECU2
ECU2 will be receiving two can messages.
We need to add a CAN receive block for
each message we are receiving
receiving.
Place a part called Read CAN Message in
your model. (Library MotoHawk/CAN
Blocks.)
Double
Double-click
click on the block and change the
settings as shown:
ECU2
128
We created this m-file earlier.
The name of the file was
ECU1_Message1.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
64
ECU2
129
ECU2
130
65
131
ECU2
The second CAN message that ECU2
receives is ECU1_Message2.
Place a part called Read CAN Message in
your model. (Library MotoHawk/CAN
Blocks.)
Double-click on the block and change the
settings as shown:
ECU2
132
We created this m-file earlier.
The name of the file was
ECU1_Message2.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
66
ECU2
133
ECU2
134
67
135
ECU2
The next few slides show the connections.
Gain block. Scale the
signal to 0 to 4096. Gain
= 4096/1023.
Data Type
Conversion.
MotoHawk probe.
MotoHawk_pwm.
Pin: EST1
ECU2
136
68
ECU2
137
ECU2
138
69
139
ECU2
As a reminder, the potentiometer used
analog input AN4M.
140
ECU2
The three other signals in this message
use overrides to set the values.
To p
protect against
g
the user making
g an
error when setting an override, we will add
saturation blocks to limit the signals.
70
141
ECU2
We want to send the values of the signals
just created over the CAN bus.
Place a part called Send CAN Messages
in your model. (Library MotoHawk/CAN
Blocks.)
Double-click on the part and change the
settings as shown:
ECU2
142
We created this m-file earlier.
The name of the file was
ECU2_Message1.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
71
ECU2
143
ECU2
144
72
ECU2
145
ECU2
146
73
147
ECU2
We want to send the value of the
Cooling_Fan signal just created over the
CAN bus
bus.
Place a part called Send CAN Messages
in your model. (Library MotoHawk/CAN
Blocks.)
Double-click on the part and change the
settings as shown:
ECU2
148
We created this m-file earlier.
The name of the file was
ECU2_Message2.m.
We placed this file in the
subdirectory named CAN.
This m-file contains the signal
definitions for this message.
74
ECU2
149
ECU2
150
75
ECU2
151
ECU2
152
76
153
ECU2
Once ECU2 has been programmed with
the new model, we need to change (or
add) a port for PCM
PCM-2
2 (City ID 12)
12).
We used a procedure earlier to
change/verify the properties of the
MotoServer ports.
We will repeat a similar procedure here.
ECU2 - MotoServer
154
77
ECU2 - MotorServer
155
ECU2 - MotorServer
156
78
157
ECU2 - MotoServer
If PCM-2 port settings are not:
Kavaser CAN
Access 4
Baud Rate 500000
158
ECU2 - MotorServer
If you need to change the port settings,
select PCM-2 and click the Modify button.
Port selected.
79
159
ECU2 - MotorServer
Change the settings as shown:
160
ECU2 - MotoServer
If your port settings are correct, skip to
slide 166.
If your window does not have a port
named PCM-2, you must do the following:
Click the Edit Names button
Click here.
80
161
ECU2 - MotoServer
Click this Add
button.
162
ECU2 - MotoServer
Fill in the dialog box as shown and click
the Finish button.
Name is PCM-2.
CityID is 12.
CAN Bus 1.
81
163
ECU2 - MotoServer
PCM-2 should be added to the CAN Bus
Mappings.
164
ECU2 - MotoServer
Click this Add
button.
82
165
ECU2 - MotoServer
The port should
be added with
the proper
settings
settings.
Port is enabled.
Click the OK button. We
are ready to go.
166
83
167
168
Quick check:
Signals SW1
through SW4
should be
changing
h
i
continuously.
84
169
Testing
Next, we will change values of the
overrides on PC2/ECU2 and we should
see the probe values change on
PC1/ECU1.
Test each override for several values
within each signals range.
I will show the display for both PCs on the
same slide. You will have the displays
shown on two different PC screens.
Testing
170
This value
should follow a
change in the
indicated
override. Valid
range is 0 to 1.
85
Testing
Testing
171
This value should
follow a change in
the indicated
override. Valid
range is -3150 to
-3120.
172
Note a significant
amount of error?
For a temperature
range of 0 to 100
degrees, we only
used 7 bits. One
q
to
bit is equal
0.79 degrees.
86
Testing
173
174
87
175
176
88
177
178
89
179
180
90
181
182
91
CAN_CAN Project
183
184
92
185
93
Advanced Model
Model-Based
Based
Systems Design
Lecture 19:
Hardware In The loop Simulations
(HIL)
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
HIL
Up to this point we have:
Learned several levels of simulations: PC
and Real-Time.
Learned several software packages:
MATLAB, Simulink, MotoHawk, LabVIEW
Used many platforms: PC, LabVIEW RT, PXI
Used several different hardware targets: PXI,
MPC555.
HIL
It is now time to put it all together and perform Hardwarein-the-loop (HIL) simulations.
We will start with the full vehicle model developed in
Lecture 14 exercise 6 and split the model so that:
The controller runs in the MPC555 target.
The plant runs on the PXI target.
HIL
This is a test of the controller:
Hardware - It is running on the target we will use in
the final implementation.
p
Speed - It is running in real time.
Wiring Interface - It is connected to the plant and
driver controls using the same interface that will be
used in the final implementation.
This tests both the wiring
g as well as the effect of network
latency as control messages are sent through the CAN bus.
HIL
HIL
We will be using the test platform below:
Controller
d l
deployed
d on an
MPC555
computer.
Same p
physical
y
interface as
in the actual system.
(Wiring for analog signals
in our example.)
National Instruments
PXI real-time
computer running a
model
d l off th
the plant.
l t
HIL Simulations
10
11
12
Hardware Shell
We will now create a top-level shell for
our controller that:
Initializes the MPC555 and MotoTune
Reads and scales the inputs
p
and p
provides the
outputs
Passes the information to a subsystem that
contains the controller.
13
Hardware Shell
The basic idea is that our interface to the
hardware will not change that much.
Given the same interface, we can make
significant changes to our control method.
All off these
th
changes
h
will
ill b
be iimplemented
l
t d iin th
the
controller subsystem.
The
Th hardware
h d
shell
h ll will
ill remain
i relatively
l ti l
unchanged. (Occasionally, a new control
method will require new inputs or outputs.
outputs In this
case, we will need to modify the hardware shell.)
14
15
CAN
Outputs
Analog inputs
and outputs.
Controller outputs
p
extracted with a
bus selector and
passed to analog
and CAN output
blocks.
CAN
Inputs
16
17
18
19
20
21
HIL Simulations
Plant Model
Since we already implemented the entire
model in real-time to run on a PXI target in
the previous lecture, we will reuse some of
the work we did in that model.
This Model was resaved as
Lecture19_Model0.
Open the model and resave it as
Vehicle Plant mdl
Vehicle_Plant.mdl.
22
Plant Model
Delete the Controller subsystem and NI_Driver
subsystem.
Leave the NI_Display_and_Loging subsystem in
the model as we will display most of the same
signals in the LabVIEW front panel as we did in
lecture 14.
The inputs that came from the controller are now
connected to In ports and the plant outputs that
went to the controller are now connected to Out
ports.
We will associate these with CAN signal inputs and
outputs using the Simulation interface toolkit.
Copyright (c) 2013 by Zac Chambers and Marc E. Herniter.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/.
23
Plant Model
24
NI_Display_and_Logging
The NI_Display_and_Logging subsusyem
was slightly modified because we needed
to remove the driver signals.
25
26
27
28
29
Select Hardware
I/O.
30
31
32
33
34
Lecture 19 Exercise 1
Demonstrate a working HIL system with the
controller logic unchanged. You will need to:
Use MotoTune to debug and display many of the
controller input and output signals.
Define some m-files
m files for the missing CAN signals
signals.
Wire the driver control board to your ECU.
Debug
g a lot of wrong
g connections and signal
g
associations.
Lecture 19 Exercise 2
You will notice that the charging current oscillates
wildly when the vehicle starts charging.
This is because the feedback signals and generator
torque engine throttle command signals for the
proportional feedback loop come over the CAN bus
bus.
CAN messages are periodic and are sent at a slower
rate than needed to make the loop stable
stable.
35
36
Lecture 19 Exercise 2a
37
Lecture 19 Exercise 2b
Demo___________
38
Lecture 19 Exercise 3