Feedback and Control Systems Activity No. 1 – System Modeling and Simulation Page 1 Name: Taduran, Bryan D. Rating:__________________________ Date Performed: December 07, 2016 __________________ Date Submitted: Feedback and Control Systems SYSTEM MODELING AND SIMULATION Activity No. 1 I. ACTIVITY OBJECTIVES This activity aims to 1. introduce the modeling and simulation tools of MATLAB and LabVIEW to the students; 2. equip the students with the skills and knowledge in using MATLAB and LabVIEW to model and simulate systems; and 3. equip the students with the skill to measure the major performance indicators of a control system, namely: time response parameters, error performance and stability. II. INTENDED LEARNING OUTCOMES At the end of this activity, the student shall be able to 1. create MATLAB and LabVIEW programs that will simulate electrical, mechanical and position control systems; and 2. determine the effects of component values to the system’s time response parameters, error and stability of dynamic systems. III. BACKGROUND INFORMATION One of the steps involved in the design of a control system is to model the system itself from its schematic. The system’s model is very important since it will provide information on the system’s various parameters, such as time response, error and stability information. These parameters will then help the designer to come up with a control system that would make the system perform at its desired state. Thus, modeling and simulation is an important step in the design of control systems. Systems can be modeled as transfer functions using the Laplace transform of the differential equation representing the system, or as state-space models which expresses the system in terms of state and output vectors. Solutions of both models can be highly simplified by the use of computer aided tools, such as MATLAB and LabVIEW. In this activity, MATLAB and LabVIEW are to be used to model and simulate dynamic systems after obtaining their transfer functions. MATLAB has the control system toolbox which can be used to create transfer function s-domain models of dynamic systems and plot and obtain information on the systems step response. In the same manner, LabVIEW has the control design and simulation module which can be used to simulate dynamic systems. This activity will demonstrate how these tools can be used to model and simulate dynamic systems. IV. RESOURCES NEEDED To perform this activity, a computer workstation with MATLAB R2012a or higher and LabVIEW 8.6 or higher installed is required. For MATLAB, the control systems toolbox is required and for LabVIEW, the control design and simulation module. V. LEARNING ACTIVITIES Activity 1.1 – Modeling and simulation of a series RLC electrical network. 1. Consider the simple series RLC circuit shown below. This circuit will be modeled in s- domain and will be simulated using LabVIEW. Let L = 1 H, C = 1 F and R = 1 Ω. For the questions to follow, write the solutions onto separate sheets of paper. Q1.1(a) For this circuit, find the transfer function G( s )=V c (s ) . V (s) 1 G( s )= 2 s + s+1 Q1.1(b) For a step input, find an expression for the output capacitor voltage. V c ( s)= 1 s(s + s+ 1) 2 Q1.1(c) Using this expression, plot the output capacitor voltage and roughly sketch the plot below. Code: >>num=1; >>den=[1 1 1 0]; >>sys=tf(num,den); >> step(sys) 2. MATLAB. The transfer function can be created in MATLAB by creating a row vector matrix containing the coefficients of the numerator and the denominator of the transfer function. For the transfer function of the form where n > m, create a row vector num equal to and a row vector den equal to in the workspace. Then create the object sys which contains the transfer function whose numerator and denominator coefficients in num and den by using the command tf() in the following format >> sys = tf(num,den) In defining numerator and denominator coefficients, the command poly() is also useful. Type in the command help poly() for more information on this function and how can it be used. 3. To plot the step response of the system whose transfer function is sys use the command step()in the following format: >> step(sys) Q1.3 (a) Roughly sketch the plot of the transfer function of the above circuit. Use this graph to determine the time response and error of the system. Code: > num=1; > den=[1 1 1]; > sys=tf(num,den); > step(sys) 4. LabVIEW. Build the front panel (FP) and the block diagram (BD) as shown below, calling this VI act01-01.vi. In the BD, place a Simulation Loop. Right-click on one of the boundaries of the loop and choose Configure Simulation Parameters. Change the Simulation Time’s Final Time to 20. Place a Step Signal, a Transfer Function, a Build Array and the SimTime Waveform functions inside the simulation loop. Configure the transfer function block to contain the transfer function obtained from Q1.1(a) . In the FP, a Waveform Chart will automatically be placed. Configure the Legend on the top right part of the chart and name them as Input and Output as shown. Right click on the chart and choose X Scale >> Properties. In the Display Format tab, choose Type as Floating-point, then click OK. Change the scale of the x- axis of the waveform chart to 0-20. Q1.4(a) Use the VI to plot the step response of the circuit above. Roughly sketch the plot below and label the necessary time response and error information in the plot. The plots obtained in the previous steps must be the same. Q1.4(b) Based on the plots obtained, is the system stable? Why or why not? Since the output waveform is almost converging with the input waveform, the system can be said as stable. Q1.4(d) Discuss the different timing options in the Configure Simulation Parameters of the simulation loop. Changing the timing options in the Configure Simulation Parameters on the simulation loop allows us to see more points and get more information in the waveform graph in the front panel. Q1.4(e) Create a virtual instrument using the control design and simulation module and MathScript node of LabVIEW to simulate the electrical network below. Provide a screenshot of the block diagram and the front panel of the VI on a separate sheet of paper. Plot the step response on the space provided below. CODE: > R=1; > L=5; > C=7; > LC=L*C; > RC=R*C; > num=1; > den=[LC RC 1]; > sys=tf(num,den); > step(sys) CODE: > > > > > > > > R=34; L=66; C=75; LC=L*C; RC=R*C; num=1; den=[LC RC 1]; sys=tf(num,den); > step(sys) Activity 1.2 – Modeling and simulation of mechanical systems. 1. In this part of the activity, the response of the mechanical system such as the one shown below to a step input will be simulated. Q2.1(a) Find the transfer functions G1 ( s)= X1 ( s) and G2 ( s)= X2 ( s) . Fill up F (s) F (s) the spaces provided below. = G1 ( s)= X1 ( s) F (s) G2 ( s)= X2 ( s) = F ( s) Q2.1(b) Compute for the output displacement of the system x2(t) FOR to a step force input and plot them on the space provided. () x1 t : CODE: > > > > num =[1]; den=[1 2 0]; sys=tf(num,den); step(sys); x (t ) 1 and FOR x (t ): 2 CODE: num =[1]; den=[-1 -2 -2]; sys=tf(num,den); step(sys); > > > > 2. Repeat steps 2, 3 and 4 of Activity 1.1 to simulate the mechanical system given. Q2.2(a) Roughly sketch the plot of x1 (t ), x2 (t) as seen in the waveform chart on the space provided. FOR x1 (t ): CODE: > > > > FOR num =[1 1 1]; den=[1 2 2 0 0]; sys=tf(num,den); step(sys); x (t ): 2 CODE: > > > > num =[1 1]; den=[1 2 2 0 0]; sys=tf(num,den); step(sys); and the step input FOR x1 (t )∈ LABVIEW : FOR x2 (t )∈ LABVIEW : Q2.2(b) Interpret the waveforms. How does the position of the masses vary as a step force is applied to the system at step force to the system above?) f (t ) .(Hint: what happens when you apply a Because of the absence of friction, the f(t) is directly proportional to the step force applied and results in the change in position of the masses. According to the system, only the viscous dumper and the spring are the only ones to resist the force. Q2.2(c) Determine what happens when the surface at which the masses moves on has friction which is f =1 N v m for both masses. Plot the new response on a separate sheet of paper and interpret the results. The 2nd mass will move to the right due to the movement of f(t) and the added 1N friction if we consider putting a m of friction on the surface . The spring and the viscous dumper will push the 2nd mass as the f(t) increases. Q2.2(d) Simulate the rotational mechanical system below, plotting the responses (t) and θ (t) 2 with respect to an input step torque. CODE: > > > > num =[1 9]; den=[15 32 95 99 27]; sys=tf(num,den); step(sys); CODE: > > > > num =[1 9]; den=[15 32 95 99 27]; sys=tf(num,den); step(sys); θ 1