Professional Documents
Culture Documents
Assignments
Appendix A: Position, velocity, and acceleration
Appendix B: Numerical integration
References
MC 516 Systems Engineering II Page 2
Introduction
Response Time
The response time is defined as the time between the presentation of a set
of inputs (stimulus) and the realization of the required output (response).
In real-time systems the constraints on the response time are important.
Distribution
Deadline
Response Time
Deadline
Response Time
FD
If we assume that obstacles are fixed and are always detected at a distance
D from the vehicle, the maximum value that can be assigned to period T is
given by
Example: D = 100m, µ = 0.5, Δt = 250 ms, v =30 m/s, g = 9.8 m/s2
Sampling period T (and all the processing and decision making) must be
less than 20 ms.
CAN interface
Central accelerometer
Vehicle ground
𝜀⋅𝐴
𝐶=
𝑑
18 ms 48 ms
30 ms
50 ms 80 ms
30 ms
Software behavior
Contributes a large part of the execution time variability of a program.
Often dominating the effect of local hardware timing variability.
Example
Introduction
The main complexity is the behavior of the processor itself, along with its
memory system.
IO, networks, sensor, and actuator have less impact. They usually dictate
when a program is executed in response to external stimuli, but do not affect
the instruction-level execution time.
Pipelining and caching
Improve the average case
Span between best case and worst case increases
Worst case typically gets worse
Timing becomes more dependent on the execution history
Memory Access
Different memory technologies different memory access times
RAM technology uses a variety of techniques to take advantage of locality to
improve performance
Burst mode: time to setup up the RAM to deliver 32 or 64 bits has to be
expended only once, subsequent words can be fetched without supplying
the address.
Precise sequence of addresses of memory accesses becomes important
Pipelines
Example
Pipelines
Long Timing Effects (LTE)
Caches
Normally improve average access time to data and instruction
Usually make worst-case access time worse. This occurs for a number of reasons,
including:
Delay before the system determines a cache miss and starts the main memory
access
a whole cache line is loaded from main memory, not just the data requested by
the processor.
Cache lockdown is a feature of some memory systems
Critical code and data (such as high-priority interrupt routines and the data they
access) is loaded into the cache in such way that the cache-lines containing
them are not subsequently re-allocated
Ensures that all subsequent accesses to the code and data are cache hits and
therefore complete quickly
Branch Prediction
Tries to predict which way a particular branch instruction will go, long before the
branch has actually be resolved in the processor pipeline
Above 75% accuracy is possible today
Branch predictors typically have complicated worst-case behavior:
there are examples of cases where executing more iterations of an inner loop
takes less time than iterating fewer iterations
Timing Anomalies
Cases where a local worst case does not entail the global worst case, for example:
a cache hit for a particular instruction causes a longer execution time for a
program than a cache miss.
a miss in a cache might create a better cache state for later code, causing the
overall execution to speed up.
Classic Method
Execute the program many times with different input data, and then
measure the execution time for each test run.
Finding the input that causes the WCET to occur is very difficult in the
general case, and guaranteeing that it has been found is basically
impossible without some form of static analysis.
Nevertheless, measurements are often the only means immediately at the
disposal of a programmer and are useful when the average case timing
behavior of the program is of interest.
Measurement Techniques
Probe effect
Measuring a system might cause the timing to change. This is especially
common when the program is instrumented or extended with
measurement support.
Resolution
Executing code can take a very short time, and the resolution of the timing
system has to be fine enough to accurately capture the variations that
occur. Typically, you want microseconds or better resolution.
Interruptions
The program under measurement might be interrupted by hardware or OS
scheduling intervals. This will lead to intermittent large increases in the
end-to-end execution time of a program, and this effect needs to be
identified and compensated for.
Measurement Techniques
Oscilloscopes, logic analyzers: oscilloscope-based measurements typically
involves toggling a GPIO, logic analyzers needs access to the busses (not
always the case with caches).
Hardware traces: hardware that is built-in, examples Nexus, JTAG.
High resolution timers: code has to be added, timer is started and stopped.
Performance counters: special registers inside the CPU.
Profilers: can use periodic interrupts (which does not provide for very precise
measurements), or instrument the code (creates a probe effect).
OS facilities: need hardware support, OS observes the longest execution
time for a task.
Emulator: special-purpose hardware that behaves like a real processor but
with better debug and inspection capabilities.
Simulator: in practice, very few simulators are guaranteed to be totally
accurate.
MC 516 Systems Engineering II Page 59
Timing by Measurements
Example
IAR Embedded Workbench for Atmel AVR, Simulator
Path-based calculation
Calculating times for different paths in parts of a program
The time for the longest path is combined with the loop bound flow.
Example
Bound-T vs. Profiling
Example
Bound-T vs. Profiling
Assignment 1
Read the paper “S. M. Mahmud, A. Alrabady. A New Decision Making
Algorithm for Airbag Control. IEEE Transactions on Vehicular Technology. Vol.
44, No. 3, August 1995” (see elearning) and implement the described
algorithm in C (IAR Embedded Workbench for Atmel AVR). Of course, you
don’t have to consider real accelerometer values, filtering, etc., focus on the
algorithm itself (sliding window, determination of v and L, comparison with
thresholds, etc.). Don’t use floating point numbers and OO features.
Execute the algorithm in the IAR Simulator to estimate the WCET,
use Bound-T to determine the WCET and discuss and compare both
results. Read the boundt documentation (user guide, Chapter 5: Writing
Analysable Programs) and consider that in your implementation.
Use the Windows XP VMWare Image with pre-installed free evaluation
version of both tools (IAR: 4KB Kickstart version, Bound-T: limited to 1024
instructions)
s 9 m
10 ∆s = 9m v 0.6 m/s
t 15 s
∆t =15m
0
0 10 20 30 40 t [s]
∆t1 =4 s
0
0 10 20 30 40 t [s]
Velocity is the slope of the tangent line through the relevant point on its
distance vs. time graph.
ds
Slope is usually calculated with the derivative of a function: v
dt
a 2
Example: s t
2
a
s v 2t at
2
0.5
0
0 10 20 30 40 t [s]
Area under the curve in the velocity vs. time graph shows the covered
distance (s = vt)
From t = 10s to t = 20s the object covered 0.6 m/s ∙10 m = 6 m
ds
v and therefore s vdt
dt
20s
s vdt 0.6 m/s dt
10s
∆v = 2 m/s
v 2 m/s
2
a 2 m/s 2
∆t = 1 s t 1s
0 1 2 3 4 t [s]
0 1 2 3 4 t [s]
The area under the curve in the acceleration vs. time graph shows the
velocity (v = at)
dv
a
dt
v adt
3
v 2 m / s 2 dt F (3s) F (0s) (2 m/s 2 3 s) (2 m/s 2 0 s) 6 m/s
0
Position
ds
v s vdt
dt
Velocity
(rate of change of position)
d2s dv
a 2
dt
a
dt v adt
Acceleration
(rate of change of velocity)
2 255
191
1 127
63
0 10 20 30 40 t [ms] 0 10 20 30 40 t [ms]
a U(t)
u[mV]
100
50
0 10 20 30 40 t [ms]
u(t)
MC 516 Systems Engineering II Page 74
Appendix B
191 i
n
a i 1
ba
127
63 x
0
n
0 10 20 30 40 t [ms]
a n=8 b
63
0
0 10 20 30 40 t [ms]
a n=8
n 1
f ( xi ) f ( xi 1 )
b
f ( x)dx lim x
n 2
a i 1
ba
x
n
∆x
MC 516 Systems Engineering II Page 76
References
References
R. Bosch GmbH. Automotive Handbook. Wiley. 2007.
P. A. Laplante. Real-Time Systems Design and Analysis: An Engineer’s
Handbook. Third Edition. Wiley. 2004.
J. W. S. Liu. Real-Time Systems. Prentice Hall. 2000.
J. Cooling. Software Engineering for Real-Time Systems. Addison-Wesley.
2003.
IEEE Std 610.12-1990. IEEE Standard Glossary of Software Engineering
Terminology
http://www.euroncap.com
C. Chan. A Treatise on Crash Sensing for Automotive Air Bag System.
IEEE/ASME Transactions on Mechatronics. Vol. 7, No.2, June 2002.
S. M. Mahmud, A. Alrabady. A New Decision Making Algorithm for Airbag
Control. IEEE Transactions on Vehicular Technology. Vol. 44, No. 3, August
1995.
MC 516 Systems Engineering II Page 77
References
References
C. Chan. On the Detection of Vehicular Crashes – System Characteristics
and Architecture. IEEE Transactions on Vehicular Technology. Vol. 51, No. 1,
January 2002.
D. Seal. ARM Architecture Reference Manual. Second Edition. Addison-
Wesley. 2001.
A. Ermedahl, J. Engblohm. Execution Time Analysis for Embedded-Real-
Time-Systems. Handbook of Real-Time and Embedded Systems. Chapman
& Hall/CRC. 2008.
J. S. Wilson. Sensor Technology Handbook. Elsevier 2005.
G. C. Buttazzo. Hard Real-Time Computing Systems. Third Edition. Springer
2011.