Chapter 1 Differential equations represented as block diagrams 1.1 Introduction The basic mathematical model form of a dynamic system is the differential equation since applying physical principles results in one of more differential equation describing the system. A given differential equation can be represented conveniently in two alternative forms: • Block diagrams: A (mathematical) block diagram gives a graphical representation of a mathematical model, and therefore gives good information of the structure of the model, e.g. how subsystems are connected. With block diagrams you can build simulators in graphical simulation tools as SIMULINK and LabVIEW Simulation Module. • State-space models: State-space models are just a structured way to write the differential equations for a system: All the time-derivatives are of first order, and they appear on the left-hand side of the differential equations. Various tools for analysis and design and simulaton of dynamic systems and control systems assume state-space models. In the following the block diagram representation is explained. State-space models are not relevant for the Project part of the course Control with 1 2 Finn Haugen: SCE1106 Control with Implementation Implementation. 1.2 1.2.1 Mathematical block diagrams Commonly used blocks in block diagrams Figure 1.1 shows the most frequently used blocks, which we can call the elementary blocks, that we can use for drawing block diagrams. Name: Symbol: Function: y0 Integrator u=y y t y(t) = y 0 + u(t)dt 0 u1 Sum (incl. subtraction ) (No sign means plus .) u2 y y = u1 + u2 – u3 u3 u1 Multiplication MULT y y = u1u2 u2 u1 Division Gain Time delay y DIV u2 u u K y y y = u1/u2 y = Ku y(t) = Ku Figure 1.1: Elementary blocks for drawing block diagrams Other blocks than the elementary blocks shown in Figure 1.1 must be used to represent non-linear functions. Figure 1.2 shows a few such blocks. You can define the function and the appearance of a block yourself. Finn Haugen: SCE1106 Control with Implementation Saturation Rate limiter Dead zone Relay u y u y u y u y u1 Switch Control signal, c 3 y u2 Figure 1.2: Blocks for non-linear functions 1.2.2 How to draw a block diagram A systematic way of drawing the block diagram of a given differential equation is as follows: 1. Write the differential equations so that the variable of the highest time-derivative order appears alone on the left part of the equations. 2. For first order differential equations (first order time-derivatives): Draw one integrator for the each of the variables that appear with its time-derivative in the model, so that the time-derivative is at the integrator input and the variable itself is at the integrator output. These variables, at the integrator outputs, are denoted state-variables, because their values at any instant of time represent the state of the system. The general names of the state-variables are x1 , x2 etc. The initial values of the state-variables are the initial outputs of the integrator. For second order differential equations (second order time-derivatives): Draw two integrators (from left to right) and connect them in series. The second order time-derivative is then the input to the leftmost integrator. (The variables at the integrator outputs are state-variables.) Finn Haugen: SCE1106 Control with Implementation 4 You will probably not see third or higher order differential equations, but if you do, the above procedure is naturally extended. 3. Connect the integrators together according to the differential equation using proper blocks, cf. Figures 1.1 and 1.2. The following example demonstrates the above procedure. Example 1.1 Block diagram of mass-spring-damper system Figure 1.3 shows a mass-spring-damper-system. y is position. F is applied K [N/m] F [N] m D [N/(m/s)] 0 y [m] Figure 1.3: Mass-spring-damper force. D is damping constant. K is spring constant. It is assumed that the damping force Fd is proportional to the velocity, and that the spring force Fs is proportional to the position of the mass. The spring force is assumed to be zero when y is zero. Force balance (Newtons 2. Law) yields1 mÿ(t) = F (t) − Fd (t) − Fs (t) = F (t) − Dẏ(t) − Ky(t) (1.1) which is a second order differential equation. We isolate ÿ at the left side: ÿ(t) = 1 [F (t) − Dẏ(t) − Ky(t)] m (1.2) Then we draw two integrators and connect them in series. ÿ is the input to the first (leftmost) integrator. Finally, we complete the block diagram according to the model. The resulting block diagram is shown in Figure 1.4. The state-variables x1 and x2 are defined as y and ẏ, respectively. [End of Example 1.1] 1 Double-dot is used for second order time-derivative: ÿ(t) ≡ d2 y(t)/dt2 5 Finn Haugen: SCE1106 Control with Implementation my = F - Dy - Ky F Sum m x DIV ÷ y(0) y(0) y y y x1 x2 Integrator Integrator Dy MULT D Ky MULT K Figure 1.4: Block diagram of (1.2) 1.2.3 Simulators based on block diagram models LabVIEW, SIMULINK, and Scicos are examples of simulation tools for block diagram models.2 Figure 1.5 shows the block diagram of the mass-spring-damper system in LabVIEW, and Figure 1.6 shows the front panel (the user interface) of the simulator. The front panel contains adjustable elements (controls), and indicators displaying resulting values and plots. Figure 1.7 shows a SIMULINK block diagram of the mass-spring-damper system. The simulated force u and the response in the position y due to a step in the force will be shown in respective scopes. Since the responses are the same as shown in Figure 1.6, the scopes are not depicted here. 2 Tutorials are available at http://techteach.no. Finn Haugen: SCE1106 Control with Implementation 6 Figure 1.5: The block diagram of the mass-spring-damper system simulator in LabVIEW Figure 1.6: The front panel of the mass-spring-damper system simulator in LabVIEW Finn Haugen: SCE1106 Control with Implementation Figure 1.7: SIMULINK block diagram of the mass-spring-damper system 7