CONTINUOUS DYNAMICS & SECURITY

66
CONTINUOUS DYNAMICS & SECURITY EEN 417 Fall 2013 8/30/13, Dr. Eric Rozier, V1.0, ECE Thanks to Edward Lee and Sanjit Seshia of UC Berkeley

description

CONTINUOUS DYNAMICS & SECURITY. EEN 417 Fall 2013. 8/30/13, Dr. Eric Rozier , V1.0, ECE Thanks to Edward Lee and Sanjit Seshia of UC Berkeley. Course Progression. Course Progression. Plan for today’s class period. Computer Engineering and Computer Science Continuous Dynamics - PowerPoint PPT Presentation

Transcript of CONTINUOUS DYNAMICS & SECURITY

Page 1: CONTINUOUS DYNAMICS & SECURITY

CONTINUOUS DYNAMICS&SECURITY

EEN 417Fall 2013

8/30/13, Dr. Eric Rozier, V1.0, ECEThanks to Edward Lee and Sanjit Seshia of UC Berkeley

Page 2: CONTINUOUS DYNAMICS & SECURITY

Course Progression

Page 3: CONTINUOUS DYNAMICS & SECURITY

Course Progression

Page 4: CONTINUOUS DYNAMICS & SECURITY

Plan for today’s class period

1. Computer Engineering and Computer Science2. Continuous Dynamics3. Wrap up

Page 5: CONTINUOUS DYNAMICS & SECURITY

COMPUTER ENGINEERING&COMPUTER SCIENCE

Page 6: CONTINUOUS DYNAMICS & SECURITY

Why are we here?

Page 7: CONTINUOUS DYNAMICS & SECURITY

Bloom’s Taxonomy

EvaluationSynthesisAnalysis

ApplicationComprehension

Knowledge

Page 8: CONTINUOUS DYNAMICS & SECURITY

CS and CE

• What are the disciplines?– Computer Engineering?– Computer Science?

Page 9: CONTINUOUS DYNAMICS & SECURITY

What it isn’t

• "What would we like our children- the general public of the future—to learn about computer science in schools? We need to do away with the myth that computer science is about computers. Computer science is no more about computers than astronomy is about telescopes, biology is about microscopes or chemistry is about beakers and test tubes. Science is not about tools, it is about how we use them and what we find out when we do."

-- Ian Parberry

Page 10: CONTINUOUS DYNAMICS & SECURITY

What it isn’t

• A confusion of even longer standing came from the fact that the unprepared included the electronic engineers that were supposed to design, build, and maintain the machines. The job was actually beyond the electronic technology of the day, and, as a result, the question of how to get and keep the physical equipment more or less in working condition became in the early days the all-overriding concern. As a result, the topic became —primarily in the USA— prematurely known as "computer science" —which, actually is like referring to surgery as "knife science"— and it was firmly implanted in people's minds that computing science is about machines and their peripheral equipment.

-- Edsger Dijkstra

Page 11: CONTINUOUS DYNAMICS & SECURITY

What it really is

• Computer science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems. Computer scientists invent algorithmic processes that create, describe, and transform information and formulate suitable abstractions to model complex systems.

• Computer engineering is the process of analyzing, designing, and integrating the hardware and software systems needed for information processing or computation. Computer engineers are saddled with the difficult tasks of modeling, designing, and analyzing cyberphysical systems which solve interdisciplinary problems in a wide variety of domains.

Page 12: CONTINUOUS DYNAMICS & SECURITY

CONTINUOUS DYNAMICS

Page 13: CONTINUOUS DYNAMICS & SECURITY

Modeling, Design, Analysis

•Modeling is the process of gaining a deeper understanding of a system through imitation. Models specify what a system does.

•Design is the structured creation of artifacts. It specifies how a system does what it does. This includes optimization.

•Analysis is the process of gaining a deeper understanding of a system through dissection. It specifies why a system does what it does (or fails to do what a model says it should do).

Page 14: CONTINUOUS DYNAMICS & SECURITY

What is Modeling?

•Developing insight about a system, process, or artifact through imitation.

•A model is the artifact that imitates the system, process, or artifact of interest.

•A mathematical model is model in the form of a set of definitions and mathematical formulas.

Page 15: CONTINUOUS DYNAMICS & SECURITY

What is Model-Based Design?1. Create a mathematical model of all the parts of the

embedded system Physical world Control system Software environment Hardware platform Network Sensors and actuators

2. Construct the implementation from the model Construction may be automated, like a compiler More commonly, portions are automatically constructed

Page 16: CONTINUOUS DYNAMICS & SECURITY

Modeling Techniques in this Course

• Models that are abstractions of system dynamics• (how things change over time)

• Examples: Modeling physical phenomena – ODEs Feedback control systems – time-domain modeling Modeling modal behavior – FSMs, hybrid automata Modeling sensors and actuators – calibration, noise Modeling software – concurrency, real-time models Modeling networks – latencies, error rates, packet loss

Page 17: CONTINUOUS DYNAMICS & SECURITY

Modeling of Continuous Dynamics

•Ordinary differential equations, Laplace transforms, feedback control systems, stability analysis, robustness analysis, …

Page 18: CONTINUOUS DYNAMICS & SECURITY

An Example: Modeling Helicopter Dynamics

Page 19: CONTINUOUS DYNAMICS & SECURITY

Modeling Physical Motion• Six degrees of freedom: Position: x, y, z Orientation: pitch, yaw, roll

Page 20: CONTINUOUS DYNAMICS & SECURITY

Notation

Page 21: CONTINUOUS DYNAMICS & SECURITY

Notation

Page 22: CONTINUOUS DYNAMICS & SECURITY

Newton’s Second Law

Page 23: CONTINUOUS DYNAMICS & SECURITY

Orientation

Page 24: CONTINUOUS DYNAMICS & SECURITY

Angular version of force is torque.For a point mass rotating around a fixed axis:

•Just as force is a push or a pull, a torque is a twist.•Units: newton-meters/radian, Joules/radian

•Note that radians are meters/meter (2p meters of circumference per 1 meter of radius), so as units, are optional.

Ty(t ) = r f (t )

angular momentum, momentum

Page 25: CONTINUOUS DYNAMICS & SECURITY

Rotational Version of Newton’s Second Law

Page 26: CONTINUOUS DYNAMICS & SECURITY

Simple Example

Page 27: CONTINUOUS DYNAMICS & SECURITY

Feedback Control Problem

A helicopter without a tail rotor, like the one below, will spin uncontrollably

due to the torque induced by friction in the rotor shaft.

Control system problem: Apply torque using

the tail rotor to counterbalance the torque of

the top rotor.

Page 28: CONTINUOUS DYNAMICS & SECURITY

Actor Model of Systems

•A system is a function that accepts an input signal and yields an output signal.

•The domain and range of the system function are sets of signals, which themselves are functions.

•Parameters may affect the definition of the function S.

Page 29: CONTINUOUS DYNAMICS & SECURITY

Actor model of the helicopter

•Input is the net torque of the tail rotor and the top rotor. Output is the angular velocity around the y axis.

Parameters of the model are shown in the box. The input and output relation is given by the equation to the right.

Page 30: CONTINUOUS DYNAMICS & SECURITY

Composition of actor models

Page 31: CONTINUOUS DYNAMICS & SECURITY

Actor models with multiple inputs

Page 32: CONTINUOUS DYNAMICS & SECURITY

Proportional controller

desired

angular

velocity

error

signal

net

torque

Note that the angular

velocity appears on both

sides, so this equation is

not trivial to solve.

Page 33: CONTINUOUS DYNAMICS & SECURITY

QuestionsHow do we measure the angular velocity?

Can this controller be implemented in software?

How does the behavior change when it is implemented in software?

Page 34: CONTINUOUS DYNAMICS & SECURITY

Other Modeling Techniques we will talk about State machines

– sequential decision logic Synchronous/reactive concurrent composition

– concurrent computation– composes well with state machines

Dataflow models– exploitable parallelism– well suited to signal processing

Discrete-event models– explicit about time

Time-driven– suitable for periodic, timed actions

Continuous-time models– models of physical dynamics– extended to “hybrid systems” to embrace computation

Page 35: CONTINUOUS DYNAMICS & SECURITY

Discretized ModelA Step Towards Software

•Numerical integration techniques provided sophisticated ways to get from the continuous idealizations to computable algorithms.•Discrete-time signal processing techniques offer the same sophisticated stability analysis as continuous-time methods.

But it’s not accurate for software controllers (fails on correctness)

Page 36: CONTINUOUS DYNAMICS & SECURITY

Hybrid Systems –Union of Continuous & Discrete

A good starting point, but has limitations.E.g. Consider building a hybrid system model for software running under a multitasking real-time OS.

Page 37: CONTINUOUS DYNAMICS & SECURITY

Understanding models can be very challenging

An example, due to Jie Liu, has two controllers sharing a CPU under an RTOS. Under

preemptive multitasking, only one can be made stable (depending on the relative

priorities). Under non-preemptive multitasking, both can be made stable.

Theory for this is lacking, so designers resort to simulation and testing.

Page 38: CONTINUOUS DYNAMICS & SECURITY

Key Concepts in Model-Based Design

Models describe physical dynamics. Specifications are executable models. Models are composed to form designs. Models evolve during design. Deployed code may be (partially) generated from models. Modeling languages have semantics. Modeling languages themselves may be modeled (meta models)

• For embedded systems, this is about Time Concurrency Dynamics

Page 39: CONTINUOUS DYNAMICS & SECURITY

CONTINUOUS DYNAMICS II

Page 40: CONTINUOUS DYNAMICS & SECURITY

PID Controller• Proportional• Integral• Derivative

Page 41: CONTINUOUS DYNAMICS & SECURITY

PID Control

• Proportional control– Output is proportional to current error value

• Integral Control– Output is the sum of instantaneous error value

over time• Derivative Control

– Output is the sum of the slope of the error over time

Page 42: CONTINUOUS DYNAMICS & SECURITY

A simple system with proportional control

• Control is proportional to the error• Consider a marble on a flat and perfectly

leveled tabled.– Any point can be an equilibrium point.– Motion can be described with Newton’s law

• F = ma• x’’ = F/m

– We want to keep the marble at x=0 by applying proportional control F = -kp*x

Page 43: CONTINUOUS DYNAMICS & SECURITY

Proportional Control

• F = -kp*x• Describe the motion of

the marble under this control?

Page 44: CONTINUOUS DYNAMICS & SECURITY

Proportional Control

• F = -kp*x• Describe the motion of

the marble under this control?

• Unstable, oscillates about 0 due to lack of friction in our control equation.

Page 45: CONTINUOUS DYNAMICS & SECURITY

Proportional Control• Error is the difference

between where the object is, and where we want it to be, the set point.

• Set point – can be stationary, an orbit, a proscribed trajectory, etc.

• Objective of this control is to put the marble at x=0 from any initial condition, or if disturbed by a force.

• This intuition is formalized as stability.

Page 46: CONTINUOUS DYNAMICS & SECURITY

Stability

• Asymptotic stability– Error will converge to 0 over time

• Instability– Error will diverge without bound

• Marginal stability– Error will stay within some bound

Page 47: CONTINUOUS DYNAMICS & SECURITY

Proportional Control

• F = -kp*x• -kp -> proportional

control constant• Characterize the

stability of the marble.

Page 48: CONTINUOUS DYNAMICS & SECURITY

Proportional Control

• F = -kp*x• Characterize the

stability of the marble.• Marginally stable

Page 49: CONTINUOUS DYNAMICS & SECURITY

Determining stability

• Given some linear differential equation– 3*y’’ + 4*y’ + 5*y = 0– From calculus we know the solution is the sum of

exponentials:• Y(t) = c1 exp(L1t) + c2(L2t) + …

– Where L1, L2, … are the eigenvalues of the system– Eigenvalues can be complex!

Page 50: CONTINUOUS DYNAMICS & SECURITY

Determining stability

• Study of stability– Stability – all eigenvalues real parts are negative

• Stable with oscillation that dies down, imaginary parts non-zero

• Stable with no oscillation, imaginary parts are zero– Instability -- At least one eigenvalue’s real part is

greater than 0– Marginal stability – all the real parts not greater

than zero, but some equal to zero.

Page 51: CONTINUOUS DYNAMICS & SECURITY

Example system

• Eigenvalue– s=5+6j

• Is the system unstable?

Page 52: CONTINUOUS DYNAMICS & SECURITY

Example system

• Eigenvalue– s=5+6j

• Is the system unstable?• Error y(t)

y(t) = exp((5+6j)t)exp(5*t) * exp(6jt)

• exp(5t)– grows unbounded

• exp(6jt)– = exp(0 + 6jt)– = e^0(cos 6t) + j sin(6t)– = (cos 6t) + j sin(6t)– Oscillates with constant magnitude

• Unstable!

Page 53: CONTINUOUS DYNAMICS & SECURITY

Derivative Control

• Modify our control equation– F = -kp*x

– F = -kp*x - kd*x’

– m*x’’ + kd*x’ + kp*x = 0

– m*s2 + kd*s + kp = 0

– s = (-kd +/- SQRT(kd2 - 4m * kp))/2m

Page 54: CONTINUOUS DYNAMICS & SECURITY

Derivative Control

• Is this system stable?– s = (-kd +/- SQRT(kd

2 - 4m * kp))/2m

• Try some values for kp > 0 and kd > 0– m = 1, kp = 2 and kd = 1

– s1,2 = -1/2 +/- 1.32 j

• System is now stable!

Page 55: CONTINUOUS DYNAMICS & SECURITY

Integral Control

• Systems often have friction, or other changing workloads we can’t model in advance– Cruise control – how many passengers?– Friction – may change due to conditions

• Unmodeled heavy load often results in steady-state error, system will settle near, rather than at the set-point.

Page 56: CONTINUOUS DYNAMICS & SECURITY

Integral Control

• Adds up (integrates) past errors, and then provides a force that is proportional to the cumulative errors.– If the marble gets stuck due to some friction the

error will add up over time, eventually generating a force large enough to overcome friction.

– Heavier car has lower velocity, error adds up and integral control leads to increased throttle.

Page 57: CONTINUOUS DYNAMICS & SECURITY

Integral Control Pitfalls

• Acts on cumulative errors.– Takes some time to reach a large sum– Takes some time to reduce the sum

Page 58: CONTINUOUS DYNAMICS & SECURITY

Integral Control Pitfalls

• Acts on cumulative errors.– Takes some time to reach a large sum– Takes some time to reduce the sum

• Overdose of integral control is a common source of overshooting, oscillations, and instability

Page 59: CONTINUOUS DYNAMICS & SECURITY

Using Integral Control

• Start with zero integral control and use it lightly!

• Check the eigenvalues of the system to make sure all of them are sufficiently negative

Page 60: CONTINUOUS DYNAMICS & SECURITY

Proportional Control

Page 61: CONTINUOUS DYNAMICS & SECURITY

Putting it all together

Page 62: CONTINUOUS DYNAMICS & SECURITY

BIBO Stability

• Bounded-input bounded-output stability– If the output signal is bounded for all bounded

input signals– Input is bounded if there is some real number

A < ∞such that |w(t)| <= A for all t in R.

– Output is bounded if there is some real numberB < ∞

such that |v(t)| <= B for all t in R.

Page 63: CONTINUOUS DYNAMICS & SECURITY

Final thoughts on control• Proportional control

– Output is proportional to current error– Non-zero error required to drive the controller, so pure proportional operates with

steady state error, known as droop• Derivative control

– Output is determined by the slope of the error over time– Slows the rate of change of the controller output– Used to reduce the magnitude of overshoot produced by the integral component, and

improve the combined controller-process stability– Slows the transient response of the controller– Highly sensitive to noise

• Integral control– Proportional to the cumulative instantaneous error– Gives the accumulated offset that should have been corrected previously– Accelerates movement towards the set point, and eliminates residual steady state error– Can cause overshoot, requires loop tuning

Page 64: CONTINUOUS DYNAMICS & SECURITY

Other topics

• Causal systems• Memoryless systems• Linear and time invariance

Page 65: CONTINUOUS DYNAMICS & SECURITY

WRAP UP

Page 66: CONTINUOUS DYNAMICS & SECURITY

For next time

Read Chapter 8 – Memory ArchitecturesAssignment 2: Problems 1, 2, 3, and 4 from Chapter 2.

Due in two weeks (Friday 9/13 at the beginning of class)