Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| learn:courses:real-analog-chapter-9:start [2017/01/10 23:09] – created Martha | learn:courses:real-analog-chapter-9:start [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Real Analog: Chapter 9 ====== | ====== Real Analog: Chapter 9 ====== | ||
| + | [[{}/ | ||
| + | --> | ||
| + | * Lecture Material: | ||
| + | * {{ : | ||
| + | * [[http:// | ||
| + | * Chapter 9 Video: | ||
| + | * [[http:// | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | * {{ : | ||
| + | |||
| + | <-- | ||
| + | |||
| ====== 9. Introduction and Chapter Objectives ====== | ====== 9. Introduction and Chapter Objectives ====== | ||
| In our analysis approach of dynamic systems so far, we have defined variables which describe the energy in the circuit energy storage elements (voltages across capacitors and currents through inductors). We then used KVL and KCL to write differential equations describing the circuit, in terms of those variables. The resulting equations were then combined into a single differential equation governing the parameter in which we were interested (the // | In our analysis approach of dynamic systems so far, we have defined variables which describe the energy in the circuit energy storage elements (voltages across capacitors and currents through inductors). We then used KVL and KCL to write differential equations describing the circuit, in terms of those variables. The resulting equations were then combined into a single differential equation governing the parameter in which we were interested (the // | ||
| Line 71: | Line 88: | ||
| \cdot \\ | \cdot \\ | ||
| - | y_P=c_{P1}x_1+c_{P2}x_2+ \dots + C_{PN}x_N+d_Pu \\ | + | y_P=c_{P1}x_1+c_{P2}x_2+ \dots + c_{PN}x_N+d_Pu \\ |
| (Eq. 9.5)$$ | (Eq. 9.5)$$ | ||
| Line 122: | Line 139: | ||
| x_2 | x_2 | ||
| | | ||
| - | + | ||
| ---- | ---- | ||
| Line 234: | Line 252: | ||
| ==== Example 9.3: Step Response of Series RLC Circuit ==== | ==== Example 9.3: Step Response of Series RLC Circuit ==== | ||
| + | Determine and plot the response of the system of example 9.1 if | ||
| + | $$u(t) = \begin{cases} | ||
| + | 0V, t < 0 \\ | ||
| + | 2V, t \geq 0 \\ | ||
| + | \end{cases}$$ | ||
| + | |||
| + | and the circuit is initially relaxed (i.e. all voltages and currents in the system are initially zero). Also plot the state trajectory for this input. The state equations for the circuit of example 9.1 were previously determined to be: | ||
| + | |||
| + | $$\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} = \begin{bmatrix} | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | x_1 \\ | ||
| + | x_2 \end{bmatrix} + \begin{bmatrix} | ||
| + | 2 \\ | ||
| + | 0 \\ | ||
| + | | ||
| + | |||
| + | While the output equation is: | ||
| + | |||
| + | $$y= \begin{bmatrix} | ||
| + | | ||
| + | | ||
| + | | ||
| + | x_1 \\ | ||
| + | x_2 \end{bmatrix} + 0 \cdot u$$ | ||
| + | |||
| + | Thus, the matrices describing the state space model are: | ||
| + | |||
| + | $$A= \begin{bmatrix} | ||
| + | | ||
| + | 2 & 0 | ||
| + | | ||
| + | | ||
| + | 2 \\ | ||
| + | 0 \end{bmatrix}, | ||
| + | | ||
| + | | ||
| + | |||
| + | To simulate the response of the system we first need to input the state variable model. We begin by defining the $\underline{A}$, | ||
| + | |||
| + | $$ >> A = \begin{bmatrix} | ||
| + | -2 & -2; & 2 & 0 \end{bmatrix}; | ||
| + | >> b = \begin{bmatrix} \\ | ||
| + | 2; & 0 \end{bmatrix}; | ||
| + | >> c = \begin{bmatrix} \\ | ||
| + | 0 & 1 \end{bmatrix}; | ||
| + | >> d = 0; $$ | ||
| + | |||
| + | The >> symbols denote the command prompt at MATLAB’s command window; they are included here to emphasize MATLAB commands. | ||
| + | |||
| + | It is generally desirable to create a model object in MATLAB to represent the system model((This is not entirely necessary, since the step and initial commands will accept the A, b, c, and d matrices directly as arguments. It is, however, encouraged.)). To create a state space system model, the command is **ss**. Arguments to the command are the above matrices; the output is the system model object. To create a model of our system, we type: | ||
| + | |||
| + | $$>> \text{sys = ss(A, b, c, d)};$$ | ||
| + | |||
| + | Our workspace now contains a state space model object of our system named “sys”. | ||
| + | |||
| + | We can simulate the response of this system to the desired input by using MATLAB’s **step** command. The step command assumes that the system is initially relaxed and the input to the system is: | ||
| + | |||
| + | $$u(t) = \begin{cases} | ||
| + | 0, t < 0 \\ | ||
| + | 1, t \geq 0 \\ | ||
| + | \end{cases}$$ | ||
| + | | ||
| + | The input to our system is exactly twice this input, so we can simply scale our output by a factor of two. (This works because the system is linear – don’t try this with a nonlinear system!) The appropriate commands are (note that we have to scale both the output and the states, since we will be plotting the output response and the state trajectory): | ||
| + | |||
| + | $$>> [y,x,t] = step(sys); \\ | ||
| + | >> y = 2*y; \\ | ||
| + | >> x = 2*x; \\$$ | ||
| + | |||
| + | The final step is to plot the responses. Plotting the output response can be accomplished with the following commands: | ||
| + | |||
| + | $$>> \text{figure} \\ | ||
| + | >> \text{plot}(t, | ||
| + | >> \text{title(' | ||
| + | >> \text{xlabel(' | ||
| + | >> \text{ylabel(' | ||
| + | |||
| + | Which results in the figure below: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | We can plot the state trajectory by plotting the second state vector, $x_1(t)$, vs. the first state vector, $x_2(t)$. MATLAB returns the first state vector as the first column of the x matrix, the second state vector as the second column of the x matrix, and so on. Thus, we can plot the state trajectory with the following commands: | ||
| + | |||
| + | $$>> \text{plot}(x(:, | ||
| + | >> \text{grid} \\ | ||
| + | >> \text{xlabel}(' | ||
| + | >> \text{ylabel}(' | ||
| + | >> \text{title(' | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Section Summary ==== | ||
| + | * If you have access to MATLAB’s control system toolbox, | ||
| + | * A state space model object can be created with the **ss** function. Inputs to the function are the A, b, c, and d matrices of the state space model. | ||
| + | * The **step** command can be used to calculate the step response of the system. | ||
| + | * The **initial** command can be used to calculate the natural response of the system. | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Exercises ==== | ||
| + | **1.** | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | **2.** Simulate the response $y(t)$ of the circuit below, if $u(t)$ is a unit step function. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== 9.3: Numerical Simulation of System Responses Using Octave ===== | ||
| + | This chapter provides a brief outline describing the use of some special-purpose Octave commands for simulating the response of linear, time invariant systems (these are systems which are governed by linear differential equations with constant coefficients). | ||
| + | |||
| + | Octave is an open-source software with many of the same capabilities as MATLAB. Unlike MATLAB, however, Octave is available for free. For more information about Octave, see the web site at http:// | ||
| + | |||
| + | This section assumes some knowledge of basic Octave syntax. For those who are not familiar with Octave, a brief overview of the necessary topics is provided in Appendix A.2 of this textbook. | ||
| + | |||
| + | ==== Basic Commands for Simulation of Linear, Time-invariant Systems ==== | ||
| + | Like MATLAB, Octave provides a number of special-purpose commands for simulating the response of linear, time-invariant systems. Among these commands are commands specific to determining the step response and natural response of systems; we will restrict our attention to these commands in this chapter. | ||
| + | |||
| + | To calculate system responses (e.g. to solve the differential equations of interest), we will use only Octave’s **step** and **initial** commands in this chapter. The **step** command calculates a unit step response for the system, while the **initial** command calculates the natural response of a system to some set of initial conditions. We will also use the **ss** command to create state space model objects, to send to the **step** and **initial** commands. Basic syntax for these commands is provided below. | ||
| + | |||
| + | **step**: | ||
| + | |||
| + | The command **[y, | ||
| + | * The command **[y]=step(sys, | ||
| + | * The command **[y, | ||
| + | * **step(sys)** with no left-hand arguments results in a plot of the step response output. | ||
| + | |||
| + | **initial**: | ||
| + | |||
| + | Response of linear system to an initial condition. **[y, | ||
| + | |||
| + | **ss**: | ||
| + | |||
| + | Create a state space model object. **sys = ss(A, b, c, d)** returns an object named **sys** which provides a state space model corresponding to the matrices provided in **A**, **b**, **c**, and **d**. | ||
| + | |||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Example 9.4: Step Response of Series RLC Circuit ==== | ||
| + | Determine and plot the response of the system of example 9.1 if | ||
| + | |||
| + | $$u(t) = \begin{cases} | ||
| + | 0V, t < 0 \\ | ||
| + | 2V, t \geq 0 \\ | ||
| + | \end{cases}$$ | ||
| + | | ||
| + | and the circuit is initially relaxed (i.e. all voltages and currents in the system are initially zero). Also plot the state trajectory for this input. The state equations for the circuit of example 9.1 were previously determined to be: | ||
| + | |||
| + | $$\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} = \begin{bmatrix} | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | x_1 \\ | ||
| + | x_2 \end{bmatrix} + \begin{bmatrix} | ||
| + | 2 \\ | ||
| + | 0 \\ | ||
| + | | ||
| + | |||
| + | While the output equation is: | ||
| + | |||
| + | $$y= \begin{bmatrix} | ||
| + | | ||
| + | | ||
| + | | ||
| + | x_1 \\ | ||
| + | x_2 \end{bmatrix} + 0 \cdot u$$ | ||
| + | |||
| + | Thus, the matrices describing the state space model are: | ||
| + | |||
| + | $$A= \begin{bmatrix} | ||
| + | | ||
| + | 2 & 0 | ||
| + | | ||
| + | | ||
| + | 2 \\ | ||
| + | 0 \end{bmatrix}, | ||
| + | | ||
| + | | ||
| + | |||
| + | To simulate the response of the system we first need to input the state variable model. We begin by defining the $\underline{A}$, | ||
| + | |||
| + | $$ > A = \begin{bmatrix} | ||
| + | -2 & -2; & 2 & 0 \end{bmatrix}; | ||
| + | > b = \begin{bmatrix} \\ | ||
| + | 2; & 0 \end{bmatrix}; | ||
| + | > c = \begin{bmatrix} \\ | ||
| + | 0 & 1 \end{bmatrix}; | ||
| + | > d = 0; $$ | ||
| + | |||
| + | The > symbols denote the command prompt at Octave’s command window; they are included here to emphasize Octave commands. | ||
| + | |||
| + | Unlike MATLAB, Octave __requires__ you to create a model object to represent the system model. To create a state space system model, the command is s**s**. Arguments to the command are the above matrices; the output is the system model object. To create a model of our system, we type: | ||
| + | |||
| + | $$ > \text{sys} = ss(A, b, c, d);$$ | ||
| + | |||
| + | Our workspace now contains a state space model object of our system named “sys”. | ||
| + | |||
| + | We can simulate the response of this system to the desired input by using Octave’s step command. The step command assumes that the system is initially relaxed and the input to the system is: | ||
| + | |||
| + | $$u(t) = \begin{cases} | ||
| + | 0, t < 0 \\ | ||
| + | 1, t \geq 0 \\ | ||
| + | \end{cases}$$. | ||
| + | | ||
| + | The input to our system is exactly twice this input, so we can simply scale our output by a factor of two. (This works because the system is linear – don’t try this with a nonlinear system!) The appropriate commands are (note that we have to scale both the output and the states, since we will be plotting the output response and the state trajectory): | ||
| + | |||
| + | $$ | ||
| + | > [y,t] = \text{step}(sys); | ||
| + | > y = 2*y; \\ | ||
| + | $$ | ||
| + | |||
| + | The final step is to plot the response. Plotting the output response can be accomplished with the following commands: | ||
| + | |||
| + | $$ | ||
| + | > \text{plot}(t, | ||
| + | > \text{title(' | ||
| + | > \text{xlabel(' | ||
| + | > \text{ylabel(' | ||
| + | $$ | ||
| + | |||
| + | which results in the figure below: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | In order to plot the state trajectory using Octave, we must modify our state space model somewhat. Unlike MATLAB, the states themselves are not returned by Octave’s **step** command. However, we can alter our c and d matrices so that the output, y, contains __both__ system states. We will set up our output equations as follows: | ||
| + | |||
| + | $$ \begin{bmatrix} | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | x_1 \\ | ||
| + | x_2 \end{bmatrix} + | ||
| + | | ||
| + | 0 \\ | ||
| + | 0 \\ \end{bmatrix} u$$ | ||
| + | |||
| + | This is implemented in Octave by re-setting the c and d matrices, re-calculating the model object, and re- calculating the system response with the following commands: | ||
| + | |||
| + | $$ | ||
| + | > c = [1 0; 0 1]; \\ | ||
| + | > d = [0; 0]; \\ | ||
| + | > sys = ss(A, | ||
| + | > [y,t] = \text{step}(sys); | ||
| + | > y = 2*y; | ||
| + | $$ | ||
| + | |||
| + | Now, the output $y_1(t)$ is simply the state $x_1(t)$ and the output $y_2(t)$ is the state $x_2(t)$. Octave returns the first state vector as the first row of the y matrix, and the second state vector as the second row of the y matrix. Thus, we can plot the state trajectory with the following commands: | ||
| + | |||
| + | $$ | ||
| + | > \text{plot}(y(1,: | ||
| + | > \text{grid} \\ | ||
| + | > \text{xlabel}(' | ||
| + | > \text{ylabel}(' | ||
| + | > \text{title(' | ||
| + | $$ | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Section Summary ==== | ||
| + | * Octave allows you to simulate linear, time invariant systems with the following commands: | ||
| + | * A state space model object can be created with the **ss** function. Inputs to the function are the A, b, c, and d matrices of the state space model. | ||
| + | * The **step** command can be used to calculate the step response of the system. | ||
| + | * The **initial** command can be used to calculate the natural response of the system. | ||
| + | |||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Exercises ==== | ||
| + | **1.** Simulate the response $y(t)$ of the circuit below, if $u(t)$ is a unit step function. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | **2.** Simulate the response $y(t)$ of the circuit below, if $u(t)$ is a unit step function. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | [[{}/ | ||
| + | [[{}/ | ||

