RTS Introduction Terminology Real-Time System Design Issues Example RTS Common Misconceptions Brief History CMPE-443 Real-Time System Design (Spring 2009) 1 Terminology CMPE-443 Real-Time System Design (Spring 2009) 2 System CMPE-443 Real-Time System Design (Spring 2009) 3 Real-Time Definitions Deadlines come from the underlying physical phenomena of the system under control. For example, in animated displays, images must be updated at approximately 30 frames/second to provide continuous CMPE-443 Real-Time System Design (Spring motion 2009) 4 Events and Determinism CMPE-443 Real-Time System Design (Spring 2009) 5 Determinism CMPE-443 Real-Time System Design (Spring 2009) 6 CPU Utilization CMPE-443 Real-Time System Design (Spring 2009) 7 Real-Time System Design Issues CMPE-443 Real-Time System Design (Spring 2009) 8 Example Real-Time Systems CMPE-443 Real-Time System Design (Spring 2009) 9 Single-input single-output PID controller PID (Proportional, Integral and Derivative). The analog sensor reading y(t) gives the measured state of the plant at time t. Let e(t)=r(t)-y(t) denote the difference between the desired state r(t) and the measured state y(t) at time t. Reference input r(t) uk rk Control-law computation A/D D/A yk A/D u(t) y(t) Sensor Plant CMPE-443 Real-Time System Design (Spring 2009) Actuator 10 PID Controller The output u(t) of the controller depends on three terms: a term that is proportional to e(t), to the integral of e(t) and to the derivative of e(t). In the sampled data version, the inputs to the control-law computation are the sampled values yk and rk, k=0,1,2,.., which analog-to-digital converters produce by sampling and digitizing y(t) and r(t) periodically every T units of time. ek=rk-yk is the k-th sample value of e(t). There are many ways to discretize the derivative and integral of e(t). For example, we can approximate derivative of e(t) for (k-1)T<=t<=kT by (ek-ek-1)/T and use the right rectangular rule of numerical integration to transform a continuous integral into a b discrete form: f ( x)dx f (b)(b a) a CMPE-443 Real-Time System Design (Spring 2009) 11 PID Controller a,b,c are some constants; they are chosen at the design time. During the k-th sampling period, the RTS computes the output of the controller according to this expression. Different discretization methods may lead to different expressions for uk, but they all are simple to compute (10-20 machine instructions). kT k 0 i 1 u k ek (ek ek 1 ) / T e(t )dt ek (ek ek 1 ) / T ei T k 1 u k 1 ek 1 (ek 1 ek 2 ) / T ei T i 1 uk uk 1 aek 2 bek 1 cek CMPE-443 Real-Time System Design (Spring 2009) 12 Controller algorithm Set timer to interrupt periodically with period T; At each timer interrupt, do Do analog-to-digital conversion to get y Compute control output u Make digital-to-analog conversion and output u End do CMPE-443 Real-Time System Design (Spring 2009) 13 Time sampling The length T of time between any two consecutive instants at which y(t) and r(t) are sampled is called the sampling period. T is a key design choice. The behavior of the resultant digital controller critically depends on this parameter. Ideally, we want the sampled data version behave like the analog version. This can be done by making T small. However, this will lead to more frequent control-law computation and higher processor-time demand. The operator may issue a command at any time, say at t. The consequent change in the reference input is read and reacted to by the digital controller at the next sampling instant. This instant can be as late as t+T. Thus, sampling introduces a delay in a system response. The operator will feel the system sluggish when the delay exceeds a tenth of a second. Therefore, the sampling period should be under this limit. The second factor is the dynamic behavior of the plant (considered earlier). It is recommended to use sampling frequency twice as highest possible frequency occurring in the system to be able to reproduce such signals (Nyquist-Kotelnikov theorem). CMPE-443 Real-Time System Design (Spring 2009) 14 Common Misconceptions CMPE-443 Real-Time System Design (Spring 2009) 15 Brief History http://en.wikipedia.org/wiki/Whirlwind_(computer) http://en.wikipedia.org/wiki/Semi_Automatic_Ground_Environment http://en.wikipedia.org/wiki/Sabre_Airline_Reservations_System CMPE-443 Real-Time System Design (Spring 2009) 16