Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT LAB MANAUAL #07 DC Motor Speed Modeling in MATLAB and Simulink Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Physical setup and system equations: A common actuator in control systems is the DC motor. It directly provides rotary motion and, coupled with wheels or drums and cables, can provide transitional motion. The electric circuit of the armature and the free body diagram of the rotor are shown in the following figure: For this example, we will assume the following values for the physical parameters. * moment of inertia of the rotor (J) = 0.01 kg.m^2/s^2 * damping ratio of the mechanical system (b) = 0.1 Nms * electromotive force constant (K=Ke=Kt) = 0.01 Nm/Amp * electric resistance (R) = 1 ohm * electric inductance (L) = 0.5 H * input (V): Source Voltage * output (theta): position of shaft The motor torque, T, is related to the armature current, i, by a constant factor Kt. The back emf, e, is related to the rotational velocity by the following equations: In SI units (which we will use), Kt (armature constant) is equal to Ke (motor constant). From the figure above we can write the following equations based on Newton's law combined with Kirchhoff's law: Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Transfer Function: Using Laplace Transforms, the above modeling equations can be expressed in terms of s. By eliminating I(s) we can get the following open-loop transfer function, where the rotational speed is the output and the voltage is the input. MATLAB representation of Transfer Function: We can represent the above transfer function into MATLAB by defining the numerator and denominator matrices as follows: J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; motor=tf(num,den); step(motor,0:0.1:3); title ('Step Response for the Open Loop System'); Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Step Response 0.1 0.09 0.08 0.07 Amplitude 0.06 0.05 0.04 0.03 0.02 0.01 0 0 0.5 1 1.5 2 2.5 3 Time (sec) DC Motor Speed Modeling in Simulink: The motor torque, T, is related to the armature current, i, by a constant factor Kt. The back emf, e, is related to the rotational velocity by the following equations: In SI units (which we will use), Kt (armature constant) is equal to Ke (motor constant). Building the Model : This system will be modeled by summing the torques acting on the rotor inertia and integrating the acceleration to give the velocity. Also, Kirchhoff’s laws will be applied to the armature circuit. Open Simulink and open a new model window. Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT First, we will model the integrals of the rotational acceleration and of the rate of change of armature current. Insert an Integrator block (from the linear block library) and draw lines to and from its input and output terminals. Label the input line "d2/dt2(theta)" and the output line "d/dt (theta)" as shown below. To add such a label, double click in the empty space just above the line. Insert another Integrator block above the previous one and draw lines to and from its input and output terminals. Label the input line "d/dt(i)" and the output line "i". Next, we will start to model both Newton's law and Kirchoff's law. These laws applied to the motor system give the following equations: Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT The angular acceleration is equal to 1/J multiplied by the sum of two terms (one pos., one neg.). Similarly, the derivative of current is equal to 1/L multiplied by the sum of three terms (one pos., two neg.). Insert two Gain blocks, (from the Linear block library) one attached to each of the integrators. Edit the gain block corresponding to angular acceleration by double-clicking it and changing its value to "1/J". Change the label of this Gain block to "inertia" by clicking on the word "Gain" underneath the block. Similarly, edit the other Gain's value to "1/L" and it's label to Inductance. Insert two Sum blocks (from the Linear block library), one attached by a line to each of the Gain blocks. Edit the signs of the Sum block corresponding to rotation to "+-" since one term is positive and one is negative. Edit the signs of the other Sum block to "-+-" to represent the signs of the terms in Kirchoff's equation. Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Now, we will add in the torques which is represented in Newton's equation. First, we will add in the damping torque. Insert a gain block below the inertia block, select it by single-clicking on it, and select Flip from the Format menu (or type Ctrl-F) to flip it left-to-right. Set the gain value to "b" and rename this block to "damping". Tap a line (hold Ctrl while drawing) off the rotational integrator's output and connect it to the input of the damping gain block. Draw a line from the damping gain output to the negative input of the rotational Sum block. Next, we will add in the torque from the armature. Insert a gain block attached to the positive input of the rotational Sum block with a line. Edit its value to "K" to represent the motor constant and Label it "Kt". Continue drawing the line leading from the current integrator and connect it to the Kt gain block. Now, we will add in the voltage terms which are represented in Kirchoff's equation. First, we will add in the voltage drop across the coil resistance. Insert a gain block above the inductance block, and flip it left-to-right. Set the gain value to "R" and rename this block to "Resistance". Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Tap a line (hold Ctrl while drawing) off the current integrator's output and connect it to the input of the resistance gain block. Draw a line from the resistance gain output to the upper negative input of the current equation Sum block. Next, we will add in the back emf from the motor. Insert a gain block attached to the other negative input of the current Sum block with a line. Edit it's value to "K" to represent the motor constant and Label it "Ke". Tap a line off the rotational integrator output and connect it to the Ke gain block. The third voltage term in the Kirchhoff’s equation is the control input, V. We will apply a step input. Insert a Step block (from the Sources block library) and connect it with a line to the positive input of the current Sum block. To view the output speed, insert a Scope (from the Sinks block library) connected to the output of the rotational integrator. To provide a appropriate unit step input at t=0, double-click the Step block and set the Step Time to "0". Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Open-loop response: To simulate this system, first, an appropriate simulation time must be set. Select Parameters from the Simulation menu and enter "3" in the Stop Time field. 3 seconds is long enough to view the open-loop response. The physical parameters must now be set. Run the following commands at the MATLAB prompt: J=0.01; b=0.1; K=0.01; R=1; L=0.5; Run the simulation (Ctrl-t or Start on the Simulation menu). When the simulation is finished, double-click on the scope and hit its autoscale button. You should see the following output. Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Extracting a Linear Model into MATLAB A linear model of the system (in state space or transfer function form) can be extracted from a Simulink model into MATLAB. This is done through the use of In and Out Connection blocks and the MATLAB function linmod. First, replace the Step Block and Scope Block with an In Connection Block and an Out Connection Block, respectively (these blocks can be found in the Connections block library). This defines the input and output of the system for the extraction process. Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT MATLAB will extract the linear model from the saved model file, not from the open model window. At the MATLAB prompt, enter the following commands: [A,B,C,D]=linmod ('motormodel') [num,den]=ss2tf(A,B,C,D) You should see the following output, providing both state-space and transfer function models of the system. A = -10.0000 -0.0200 1.0000 -2.0000 B = 0 2 C = 1 0 D = 0 num = 0 0.0000 2.0000 1.0000 12.0000 20.0200 den = To verify the model extraction, we will generate an open-loop step response of the extracted transfer function in MATLAB. Enter the following command in MATLAB. step(num,den); You should see the following plot which is equivalent to the Scope's output. Control Engineering Lab Instructor: Engr. Romana UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING COMPUTER ENGINEERING DEPARTMENT Step Response 0.1 0.09 0.08 0.07 Amplitude 0.06 0.05 0.04 0.03 0.02 0.01 0 0 0.5 1 1.5 2 2.5 3 Time (sec) LAB TASK: Read the entire manual carefully implements each step one by one in Simulink and complete the Model. Save the model as”motorspeed.mdl” and execute it to verify the Results. Control Engineering Lab Instructor: Engr. Romana