·
Cursos Gerais ·
Laboratório de Sistemas de Controle
Send your question to AI and receive an answer instantly
Recommended for you
1
Controle de Velocidade de Fita Magnetica com Motor CC - Projeto de Controlador e Observador de Estados
Laboratório de Sistemas de Controle
UFAM
3
Laboratório de Sistemas de Controle - Análise do Comportamento Dinâmico de Sistemas de 1a Ordem
Laboratório de Sistemas de Controle
UFAM
3
Projeto Final Sistemas de Controle
Laboratório de Sistemas de Controle
UFAM
22
LAB02 - Análise do Comportamento Dinâmico de Sistemas de Primeira Ordem
Laboratório de Sistemas de Controle
UFAM
5
Projeto de Sistema de Controle no Domínio do Tempo - Engenharia Elétrica
Laboratório de Sistemas de Controle
UFAM
2
Lista de Exercícios: Representação em Frequência
Laboratório de Sistemas de Controle
IFBA
17
Análise e Simulação da Série de Fourier em Sinais Periódicos
Laboratório de Sistemas de Controle
IFBA
5
Análise de Sistemas em Frequência: Defasagem e Escalonamento
Laboratório de Sistemas de Controle
IFBA
10
Exercício 2 - Registro de Atividades
Laboratório de Sistemas de Controle
IFBA
16
Construção Termometro - Paper e Calculo de Erro
Laboratório de Sistemas de Controle
UFABC
Preview text
STUDENT WORKBOOK SRV02 Base Unit Experiment For MatlabSimulink Users Standardized for ABET Evaluation Criteria Developed by Jacob Apkarian PhD Quanser Michel Lévis MASc Quanser Hakan Gurocak PhD Washington State University Solutions for teaching and research Made in Canada With the SRV02 Base Unit you can select from 10 addon modules to create experiments of varying complexity across a wide range of topics disciplines and courses All of the experimentsworkstations are compatible with MATLABSimulink To request a demonstration or a quote please email infoquansercom 2011 Quanser Inc All rights reserved MATLAB and Simulink are registered trademarks of The MathWorks Inc SRV02 Base Unit Flexible Link Inverted Pendulum Ball and Beam MultiDOF Torsion 2 DOF Inverted Pendulum 2 DOF Robot Flexible Joint GyroStable Platform Double Inverted Pendulum 2 DOF Ball Balancer CAPTIVATE MOTIVATE GRADUATE INFOQUANSERCOM 19059403575 QUANSERCOM Student Workbook SRV02 Base Unit Experiment for MatlabSimulink Users Ten modules to teach controls from the basic to advanced level ABET Inc is the recognized accreditor for college and university programs in applied science computing engineering and technology Among the most respected accreditation organizations in the US ABET has provided leadership and quality assurance in higher education for over 75 years SRV02 educational solutions are powered by Course material complies with c 2011 Quanser Inc All rights reserved Quanser Inc 119 Spy Court Markham Ontario L3R 5H6 Canada infoquansercom Phone 19059403575 Fax 19059403576 Printed in Markham Ontario For more information on the solutions Quanser Inc offers please visit the web site at httpwwwquansercom This document and the software described in it are provided subject to a license agreement Neither the software nor this document may be used or copied except as specified under the terms of that license agreement All rights are reserved and no part may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopying recording or otherwise without the prior written permission of Quanser Inc ACKNOWLEDGEMENTS Quanser Inc would like to thank Dr Hakan Gurocak Washington State University Vancouver USA for rewriting this manual to include embedded outcomes assessment SRV02 Workbook Student Version ii CONTENTS Preface v 1 SRV02 Modeling 1 11 Background 2 111 Modeling Using FirstPrinciples 2 112 Modeling Using Experiments 5 12 PreLab Questions 8 13 Lab Experiments 9 131 Frequency Response Experiment 9 132 Bump Test Experiment 12 133 Model Validation Experiment 13 134 Results 14 14 System Requirements 15 141 Overview of Files 15 142 Configuring the SRV02 and the Lab Files 15 15 Lab Report 17 151 Template for Content 17 152 Tips for Report Format 18 2 SRV02 Position Control 19 21 Background 20 211 Desired Position Control Response 20 212 PV Controller Design 23 213 PIV Controller 24 22 PreLab Questions 26 23 Lab Experiments 27 231 Step Response Using PV Controller 27 232 Ramp Response Using PV Controller 30 233 Ramp Response with No SteadyState Error 32 234 Results 33 24 System Requirements 34 241 Overview of Files 34 242 Setup for Position Control Simulations 34 243 Setup for Position Control Implementation 35 25 Lab Report 36 251 Template for Content Step Response Experiment 37 252 Template for Content Ramp Response with PV 38 253 Template for Content Ramp Response with No SteadyState Error 39 254 Tips for Report Format 40 3 SRV02 Speed Control 41 31 Background 42 311 Desired Response 42 312 PI Control Design 43 313 Lead Control Design 45 314 Sensor Noise 50 SRV02 Workbook Student Version v 10 32 PreLab Questions 51 33 Lab Experiments 52 331 Step Response with PI Control 52 332 Step Response with LEAD Control 55 333 Results 56 34 System Requirements 58 341 Overview of Files 58 342 Setup for Speed Control Simulation 58 343 Setup for Speed Control Implementation 59 35 Lab Report 60 351 Template for Content PI Control Experiments 61 352 Template for Content Lead Control Experiments 62 353 Tips for Report Format 63 A SRV02 QUARC Integration 65 A1 Applying Voltage to SRV02 Motor 66 A11 Making the Simulink Model 66 A12 Compiling the Model 68 A13 Running QUARC Code 69 A2 Reading Position using Potentiometer 71 A21 Reading the Potentiometer Voltage 71 A22 Measuring Position 72 A3 Measuring Speed using Tachometer 75 A4 Measuring Position using Encoder 77 A5 Saving Data 79 SRV02 Workbook Student Version iv PREFACE Every laboratory chapter in this manual is organized into four sections Background section provides all the necessary theoretical background for the experiments You should read this section first to prepare for the PreLab questions and for the actual lab experiments PreLab Questions section provides targetted questions for preliminary calculations that need to be done prior to the lab experiments You should go through these questions and try to answer them using the background materials and the references given at the end of the manual Lab Experiments section provides you with stepbystep instructions to conduct the lab experiments and to record the collected data System Requirements section describes all the details of how to configure the hardware and software to conduct the experiments It is assumed that the hardware and software configuration have been completed by the instructor or the teaching assistant prior to the lab sessions If not you can configure the systems by following the instructions given in this section When you write your lab report you should use the specific template for content given at the end of each laboratory chapter A section on Tips for Report Format is also provided at the end of each laboratory chapter SRV02 Workbook Student Version v 10 vi LABORATORY 1 SRV02 MODELING The objective of this experiment is to find a transfer function that describes the rotary motion of the SRV02 load shaft The dynamic model is derived analytically from classical mechanics principles and using experimental methods Topics Covered Deriving the dynamics equation and transfer function for the SRV02 servo plant using the firstprinciples Obtaining the SRV02 transfer function using a frequency response experiment Obtaining the SRV02 transfer function using a bump test Tuning the obtained transfer function and validating it with the actual system response Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 11 Background The angular speed of the SRV02 load shaft with respect to the input motor voltage can be described by the following firstorder transfer function Ωls Vms K τs 1 111 where Ωls is the Laplace transform of the load shaft speed ωlt Vms is the Laplace transform of motor input voltage vmt K is the steadystate gain τ is the time constant and s is the Laplace operator The SRV02 transfer function model is derived analytically in Section 111 and its K and τ parameters are evaluated These are known as the nominal model parameter values The model parameters can also be found experimentally Sections 1121 and 1122 describe how to use the frequency response and bumptest methods to find K and τ These methods are useful when the dynamics of a system are not known for example in a more complex system After the lab experiments the experimental model parameters are compared with the nominal values 111 Modeling Using FirstPrinciples 1111 Electrical Equations The DC motor armature circuit schematic and gear train is illustrated in Figure 11 As specified in 6 recall that Rm is the motor resistance Lm is the inductance and km is the backemf constant Figure 11 SRV02 DC motor armature circuit and gear train The backemf electromotive voltage ebt depends on the speed of the motor shaft ωm and the backemf constant of the motor km It opposes the current flow The back emf voltage is given by ebt kmωmt 112 Using Kirchoffs Voltage Law we can write the following equation Vmt RmImt Lm dImt dt kmωmt 0 113 Since the motor inductance Lm is much less than its resistance it can be ignored Then the equation becomes Vmt RmImt kmωmt 0 114 SRV02 Workbook Student Version 2 Solving for Imt the motor current can be found as Imt Vmt kmωmt Rm 115 1112 Mechanical Equations In this section the equation of motion describing the speed of the load shaft ωl with respect to the applied motor torque τm is developed Since the SRV02 is a one degreeoffreedom rotary system Newtons Second Law of Motion can be written as J α τ 116 where J is the moment of inertia of the body about its center of mass α is the angular acceleration of the system and τ is the sum of the torques being applied to the body As illustrated in Figure 11 the SRV02 gear train along with the viscous friction acting on the motor shaft Bm and the load shaft Bl are considered The load equation of motion is Jl dωlt dt Blωlt τlt 117 where Jl is the moment of inertia of the load and τl is the total torque applied on the load The load inertia includes the inertia from the gear train and from any external loads attached eg disc or bar The motor shaft equation is expressed as Jm dωmt dt Bmωmt τmlt τmt 118 where Jm is the motor shaft moment of inertia and τml is the resulting torque acting on the motor shaft from the load torque The torque at the load shaft from an applied motor torque can be written as τlt ηgKgτmlt 119 where Kg is the gear ratio and ηg is the gearbox efficiency The planetary gearbox that is directly mounted on the SRV02 motor see 6 for more details is represented by the N1 and N2 gears in Figure 11 and has a gear ratio of Kgi N2 N1 1110 This is the internal gear box ratio The motor gear N3 and the load gear N4 are directly meshed together and are visible from the outside These gears comprise the external gear box which has an associated gear ratio of Kge N4 N3 1111 The gear ratio of the SRV02 gear train is then given by Kg KgeKgi 1112 Thus the torque seen at the motor shaft through the gears can be expressed as τmlt τlt ηgKg 1113 Intuitively the motor shaft must rotate Kg times for the output shaft to rotate one revolution θmt Kgθlt 1114 SRV02 Workbook Student Version v 10 We can find the relationship between the angular speed of the motor shaft ωm and the angular speed of the load shaft ωl by taking the time derivative ωmt Kgωlt 1115 To find the differential equation that describes the motion of the load shaft with respect to an applied motor torque substitute 1113 1115 and 117 into 118 to get the following JmKg dωlt dt BmKgωlt Jl dωlt dt Blωlt ηgKg τmt 1116 Collecting the coefficients in terms of the load shaft velocity and acceleration gives ηgK2 gJm Jldωlt dt ηgK2 gBm Blωlt ηgKgτmt 1117 Defining the following terms Jeq ηgK2 gJm Jl 1118 Beq ηgK2 gBm Bl 1119 simplifies the equation as Jeq dωlt dt Beqωlt ηgKgτmt 1120 1113 Combining the Electrical and Mechanical Equations In this section the electrical equation derived in Section 1111 and the mechanical equation found in Section 1112 are brought together to get an expression that represents the load shaft speed in terms of the applied motor voltage The motor torque is proportional to the voltage applied and is described as τmt ηmktImt 1121 where kt is the currenttorque constant NmA ηm is the motor efficiency and Im is the armature current See 6 for more details on the SRV02 motor specifications We can express the motor torque with respect to the input voltage Vmt and load shaft speed ωlt by substituting the motor armature current given by equation 115 in Section 1111 into the currenttorque relationship given in equation 1121 τmt ηmkt Vmt kmωmt Rm 1122 To express this in terms of Vm and ωl insert the motorload shaft speed equation 1115 into 1121 to get τmt ηmkt Vmt kmKgωlt Rm 1123 If we substitute 1123 into 1120 we get Jeq d dtwlt Beqwlt ηgKgηmkt Vmt kmKgωlt Rm 1124 After collecting the terms the equation becomes d dtwlt Jeq kmηgK2 gηmkt Rm Beq ωlt ηgKgηmktVmt Rm 1125 SRV02 Workbook Student Version 4 This equation can be rewritten as d dtwlt Jeq Beqvωlt Am Vmt 1126 where the equivalent damping term is given by Beqv ηgK2 gηmktkm BeqRm Rm 1127 and the actuator gain equals Am ηgKgηmkt Rm 1128 112 Modeling Using Experiments In Section 111 you learned how the system model can be derived from the firstprinciples A linear model of a system can also be determined purely experimentally The main idea is to experimentally observe how a system reacts to different inputs and change structure and parameters of a model until a reasonable fit is obtained The inputs can be chosen in many different ways and there are a large variety of methods In Sections 1121 and 1122 two methods of modeling the SRV02 are outlined 1 frequency response and 2 bump test 1121 Frequency Response In Figure 12 the response of a typical firstorder timeinvariant system to a sine wave input is shown As it can be seen from the figure the input signal u is a sine wave with a fixed amplitude and frequency The resulting output y is also a sinusoid with the same frequency but with a different amplitude By varying the frequency of the input sine wave and observing the resulting outputs a Bode plot of the system can be obtained as shown in Figure 13 Figure 12 Typical frequency response The Bode plot can then be used to find the steadystate gain ie the DC gain and the time constant of the system The cuttoff frequency ωc shown in Figure 13 is defined as the frequency where the gain is 3 dB less than the maximum gain ie the DC gain When working in the linear nondecibel range the 3 dB frequency is defined as the frequency where the gain is 1 2 or about 0707 of the maximum gain The cutoff frequency is also known as the bandwidth of the system which represents how fast the system responds to a given input SRV02 Workbook Student Version v 10 Figure 13 Magnitude Bode plot The magnitude of the frequency response of the SRV02 plant transfer function given in equation 111 is defined as Gw v w Ωlw jVmw j 1129 where ω is the frequency of the motor input voltage signal Vm We know that the transfer function of the system has the generic firstorder system form given in Equation 111 By substituting s j w in this equation we can find the frequency response of the system as ΩlwjVmwj Kτω j 1 1130 Then the magnitude of it equals GwIvw K1 τ2 w2 1131 Lets call the frequency response model parameters Kef and τef to differentiate them from the nominal model parameters K and τ used previously The steadystate gain or the DC gain ie gain at zero frequency of the model is Kef GwIv 0 1132 1122 Bump Test The bump test is a simple test based on the step response of a stable system A step input is given to the system and its response is recorded As an example consider a system given by the following transfer function YsUs Kτ s 1 1133 The step response shown in Figure 14 is generated using this transfer function with K 5 radVs and τ 005 s The step input begins at time t0 The input signal has a minimum value of umin and a maximum value of umax The resulting output signal is initially at y0 Once the step is applied the output tries to follow it and eventually settles at its steadystate value yss From the output and input signals the steadystate gain is K ΔyΔu 1134 Figure 14 Input and output signal used in the bump test method where y yss y0 and u umax umin In order to find the model time constant τ we can first calculate where the output is supposed to be at the time constant from yt1 0632yss y0 1135 Then we can read the time t1 that corresponds to yt1 from the response data in Figure 14 From the figure we can see that the time t1 is equal to t1 t0 τ 1136 From this the model time constant can be found as τ t1 t0 1137 Going back to the SRV02 system a step input voltage with a time delay t0 can be expressed as follows in the Laplace domain Vms Av es t0 s 1138 where Av is the amplitude of the step and t0 is the step time ie the delay If we substitute this input into the system transfer function given in Equation 111 we get Ωls KAv es t0 τ s 1 s 1139 We can then find the SRV02 load speed step response wlt by taking inverse Laplace of this equation Here we need to be careful with the time delay t0 and note that the initial condition is ωl0 ωlt0 ωlt K Av 1 e tt0 τ ωl t0 1140 SRV02 Workbook Student Version v 10 12 PreLab Questions Before you start the lab experiments given in Section 13 you should study the background materials provided in Section 11 and work through the questions in this Section 1 In Section 1113 we obtained an equation 1126 that described the dynamic behavior of the load shaft speed as a function of the motor input voltage Starting from this equation find the transfer function Ωls Vms 2 Express the steadystate gain K and the time constant τ of the process model Equation 111 in terms of the Jeq Beqv and Am parameters 3 Calculate the Beqv and Am model parameters using the system specifications given in 6 The parameters are to be calculated based on an SRV02ET in the highgear configuration 4 Calculate the moment of inertia about the motor shaft Note that Jm Jtach Jmrotor where Jtach and Jmrotor are the moment of inertia of the tachometer and the rotor of the SRV02 DC motor respectively Use the specifications given in 6 5 The load attached to the motor shaft includes a 24tooth gear two 72tooth gears and a single 120tooth gear along with any other external load that is attached to the load shaft Thus for the gear moment of inertia Jg and the external load moment of inertia Jlext the load inertia is Jl Jg Jlext Using the specifications given in 6 find the total moment of inertia Jg from the gears Hint Use the definition of moment of inertia for a disc Jdisc mr2 2 6 Assuming the disc load is attached to the load shaft calculate the inertia of the disc load Jextl and the total load moment of inertia Jl 7 Evaluate the equivalent moment of inertia Jeq 8 Calculate the steadystate model gain K and time constant τ These are the nominal model parameters and will be used to compare with parameters that are later found experimentally 9 Referring to Section 1121 find the time constant τ of the frequency response model given in Equation 1131 Evaluate the magnitude of the transfer function at the cuttoff frequency ωc 10 Referring to Section 1122 find the steadystate gain of the step response and compare it with Equation 1134 Hint The the steadystate value of the load shaft speed can be defined as ωlss lim t ωlt 11 Evaluate the step response given in equation 1140 at t t0 τ and compare it with Equation 1134 SRV02 Workbook Student Version 8 13 Lab Experiments The main goal of this laboratory is to find a transfer function model that describes the rotary motion of the SRV02 load shaft as a function of the input voltage We can obtain this transfer function experimentally using one of the following two methods Frequency response or Bump test In this laboratory first you will conduct two experiments exploring how these methods can be applied to a real system Then you will conduct a third experiment to fine tune the parameters of the transfer functions you obtained and to validate them Experimental Setup The q srv02 mdl Simulink diagram shown in Figure 15 will be used to conduct the experiments The SRV02 ET subsystem contains QUARCblocks that interface with the DC motor and sensors of the SRV02 system as discussed in Reference 4 The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary to simulate the SRV02 system Thus both the measured and simulated load shaft speed can be monitored simultaneously given an input voltage Figure 15 q srv02 mdl Simulink diagram used to model SRV02 IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 142 to configure the lab files first 131 Frequency Response Experiment As explained in 1121 earlier the frequency response of a linear system can be obtained by providing a sine wave input signal to it and recording the resulting output sine wave from it In this experiment the input signal is the motor voltage and the output is the motor speed SRV02 Workbook Student Version v 10 In this method we keep the amplitude of the input sine wave constant but vary its frequency At each frequency setting we record the amplitude of the output sine wave The ratio of the output and input amplitudes at a given frequency can then be used to create a Bode magnitude plot Then the transfer function for the system can be extracted from this Bode plot 1311 Steadystate gain First we need to find the steadystate gain of the system This requires running the system with a constant input voltage To create a 2V constant input voltage follow these steps 1 In the Simulinkdiagram doubleclick on the Signal Generator block and ensure the following parameters are set Wave form sine Amplitude 10 Frequency 00 Units Hertz 2 Set the Amplitude V slider gain to 0 3 Set the Offset V block to 20 V 4 Open the load shaft speed scope w l rads and the motor input voltage scope V m V 5 Click on QUARC Build to compile the Simulink diagram 6 Select QUARC Start to run the controller The SRV02 unit should begin rotating in one direction The scopes should be reading something similar to Figures 16 and 17 Note that in the w l rads scope the yellow trace is the measured speed while the purple trace is the simulated speed generated by the SRV02 Model block Figure 16 Constant input motor voltage Figure 17 Load shaft speed re sponse to a constant input 7 Measure the speed of the load shaft and enter the measurement in Table 11 below under the f 0 Hz row The measurement can be done directly from the scope Alternatively you can use Matlabcommands to find the maximum load speed using the saved wl variable When the controller is stopped the w l rads scope saves the last 5 seconds of response data to the Matlabworkspace in the wl parameter It has the following structure wl1 is the time vector wl2 is the measured speed and wl3 is the simulated speed 8 Calculate the steadystate gain both in linear and decibel dB units as explained in 1121 Enter the resulting numerical value in the f 0 Hz row of Table 11 Also enter its nondecibel value in Table 12 in Section 134 SRV02 Workbook Student Version 10 1312 Gain at varying frequencies In this part of the experiment we will send an input sine wave at a certain frequency to the system and record the amplitude of the output signal We will then increment the frequency and repeat the same observation To create the input sine wave 1 Set the Offset V block to 0 V 2 Set the Amplitude V slider gain to 20 V 3 The SRV02 unit should begin rotating smoothly back and forth and the scopes should be reading a response similar to Figures 18 and 19 Figure 18 Input motor voltage scope Figure 19 Load shaft speed sine wave response 4 Measure the maximum positive speed of the load shaft at f 10 Hz input and enter it in Table 11 below As before this measurement can be done directly from the scope or preferably you can use Matlabcommands to find the maximum load speed using the saved wl variable 5 Calculate the gain of the system in both linear and dB units and enter the results in Table 11 6 Now increase the frequency to f 20 Hz by adjusting the frequency parameter in the Signal Generator block Measure the maximum load speed and calculate the gain Repeat this step for each of the frequency settings in Table 11 7 Using the Matlabplot command and the data collected in Table 11 generate a Bode magnitude plot Make sure the amplitude and frequency scales are in decibels When making the Bode plot ignore the f 0 Hz entry as the logarithm of 0 is not defined 8 Calculate the time constant τef using the obtained Bode plot by finding the cutoff frequency Label the Bode plot with the 3 dB gain and the cutoff frequency Enter the resulting time constant in Table 12 Hint Use the ginput command to obtain values from the Matlabfigure 9 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 10 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session SRV02 Workbook Student Version v 10 f Hz Amplitude V Maximum Load Speed rads GainGω radsV GainGω radsV dB 00 20 10 20 20 20 30 20 40 20 50 20 60 20 70 20 80 20 Table 11 Collected frequency response data 132 Bump Test Experiment In this method a step input is given to the SRV02 and the corresponding load shaft response is recorded Using the saved response the model parameters can then be found as discussed in Section 1122 To create the step input 1 Doubleclick on the Signal Generator block and ensure the following parameters are set Wave form square Amplitude 10 Frequency 04 Units Hertz 2 Set the Amplitude V slider gain to 15 V 3 Set the Offset V block to 20 V 4 Open the load shaft speed scope w l rads and the motor input voltage cope V m V 5 Click on QUARC Build to compile the Simulink diagram 6 Select QUARC Start to run the controller The gears on the SRV02 should be rotating in the same direction and alternating between low and high speeds The response in the scopes should be similar to Figures 110 and 111 Figure 110 Square input motor voltage Figure 111 Load shaft speed step response 7 Plot the response in Matlab Recall that the maximum load speed is saved in the Matlabworkspace under the wl variable SRV02 Workbook Student Version 12 8 Find the steadystate gain using the measured step response and enter it in Table 12 Hint Use the Matlabginput command to measure points off the plot 9 Find the time constant from the obtained response and enter the result in Table 12 10 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 11 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 133 Model Validation Experiment In this experiment you will adjust the model parameters you found in the previous experiments to tune the transfer function Our goal is to match the simulated system response with the parameters you found as closely as possible to the response of the actual system To create a step input 1 Doubleclick on the Signal Generator block and ensure the following parameters are set Wave form square Amplitude 10 Frequency 04 Units Hertz 2 Set the Amplitude V slider gain to 10 V 3 Set the Offset V block to 15 V 4 Open the load shaft speed scope w l rads and the motor input voltage scope V m V 5 Click on QUARC Build to compile the Simulinkdiagram 6 Select QUARC Start to run the controller The gears on the SRV02 should be rotating in the same direction and alternating between low and high speeds and the scopes should be as shown in figures 112 and 113 Recall that the yellow trace is the measured load shaft rate and the purple trace is the simulated trace By default the steadystate gain and the time constant of the transfer function used in simulation are set to K 1 radsV and τ 01s These model parameters do not accurately represent the system Figure 112 Input square volt age Figure 113 Speed step re sponse Simulation done with default model parameters K 1 and τ 01 7 Enter the command K 125 in the MatlabCommand Window SRV02 Workbook Student Version v 10 8 Update the parameters used by the Transfer Function block in the simulation by selecting the Edit Update Diagram item in the q srv02 mdl Simulinkdiagram and observe how the simulation changes 9 Enter the command tau 02 in the MatlabCommand Window 10 Update the simulation again by selecting the Edit Update Diagram and observe how the simulation changes 11 Vary the gain and time constant model parameters How do the gain and the time constant affect the system response 12 Enter the nominal values K and τ that were found in Section 12 in the MatlabCommand Window Update the parameters and examine how well the simulated response matches the measured one 13 If the calculations were done properly then the model should represent the actual system quite well However there are always some differences between each servo unit and as a result the model can always be tuned to match the system better Try varying the model parameters until the simulated trace matches the measured response better Enter these tuned values under the Model Validation section of Table 12 14 Provide two reasons why the nominal model does not represent the SRV02 with better accuracy 15 Create a Matlabfigure that shows the measured and simulated response of each method the nominal model the frequency response model and the bumptest model Enter the nominal values K and τ in the MatlabCommand Window update the parameters and examine the response Repeat for the frequency response parameters Kef and τef along with the bump test variables Keb and τeb 16 Explain how well the nominal model the frequency response model and the bumptest model represent the SRV02 system 17 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 18 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 134 Results Fill out Table 12 below with your results Section Description Symbol Value Unit 12 Nominal Values OpenLoop SteadyState Gain K OpenLoop Time Constant τ 131 Frequency Response Exp OpenLoop SteadyState Gain Kef OpenLoop Time Constant τef 132 Bump Test Exp OpenLoop SteadyState Gain Keb OpenLoop Time Constant τeb 133 Model Validation OpenLoop SteadyState Gain Kev OpenLoop Time Constant τev Table 12 Summary of results for the SRV02 Modeling laboratory SRV02 Workbook Student Version 14 14 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARC compatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 141 Overview of Files Table 13 Files supplied with the SRV02 Modeling laboratory File Name Description 01 SRV02 Modeling Student Manualpdf This laboratory guide contains prelab and inlab exer cises demonstrating how to model the Quanser SRV02 rotary plant The inlab exercises are explained using the QUARC software setup srv02 exp01 mdlm The main Matlabscript that sets the SRV02 motor and sensor parameters Run this file only to setup the lab oratory config srv02m Returns the configurationbased SRV02 model specifica tions Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP calc conversion constantsm Returns various conversions factors q srv02 mdlmdl Simulinkfile that implements the openloop controller for the SRV02 system using QUARC 142 Configuring the SRV02 and the Lab Files Before beginning the lab exercises the SRV02 device the q srv02 mdl Simulinkdiagram and the setup srv02 exp02m script must be configured Follow these steps to get the system ready for this lab 1 Set up the SRV02 in the highgear configuration and with the disc load as described in Reference 5 2 Load the Matlabsoftware 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 modeling files eg q srv02 mdlmdl 4 Doubleclick on the q srv02 mdlmdl file to open the Simulinkdiagram shown in Figure 15 5 Configure DAQ Doubleclick on the HIL Initialize block in the Simulinkdiagram and ensure it is configured for the DAQ device that is installed in your system For instance the block shown in Figure 15 is setup for the Quanser Q8 hardwareintheloop board See 1 for more information on configuring the HIL Initialize block SRV02 Workbook Student Version v 10 6 Configure Sensor The speed of the load shaft can be measured using various sensors Set the Spd Src Source block in q srv02 mdl as shown in Figure 15 as follows 1 to use tachometer 2 to use the encoder 7 It is recommended that the tachometer sensor be used to perform this laboratory However for users who do not have a tachometer with their servo eg SRV02 or SRV02E options they may choose to use the encoder with a highpass filter to get a velocity measurement 8 Go to the Current Directory window and doubleclick on the setup srv02 exp01 mdlm file to open the setup script for the q srv02 mdl Simulinkmodel 9 Configure setup script The beginning of the setup script is shown below Ensure the script is setup to match the configuration of your actual SRV02 device For example the script given below is setup for an SRV02ET plant in the highgear configuration mounted with a disc load and it is actuated using the Quanser VoltPAQ device with a motor cable gain of 1 See 6 for more information on SRV02 plant options and corresponding accessories Finally make sure MODELING TYPE is set to MANUAL SRV02 Configuration External Gear Configuration set to HIGH or LOW EXTGEARCONFIG HIGH Encoder Type set to E or EHR ENCODERTYPE E Is SRV02 equipped with Tachometer ie option T set to YES or NO TACHOPTION YES Type of Load set to NONE DISC or BAR LOADTYPE DISC Amplifier Gain set VoltPAQ amplifier gain to 1 KAMP 1 Power Amplifier Type set to VoltPAQ UPM1503 UPM2405 or Q3 AMPTYPE VoltPAQ DigitaltoAnalog Maximum Voltage V VMAXDAC 10 Lab Configuration Type of Controller set it to AUTO MANUAL MODELINGTYPE AUTO MODELINGTYPE MANUAL 10 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the MatlabCommand Window These are default model parameters and do not accurately represent the SRV02 system Calculated SRV02 model parameter K 1 radsV tau 01 s SRV02 Workbook Student Version 16 15 Lab Report When you prepare your lab report you can follow the outline given in Section 151 to build the content of your report Also in Section 152 you can find some basic tips for the format of your report 151 Template for Content I PROCEDURE I1 Frequency Response Experiment 1 Briefly describe the main goal of this experiment and the procedure Briefly describe the experimental procedure Section 1311 Steadystate gain Briefly describe the experimental procedure Section 1312 Gain at varying frequencies I2 Bump Test Experiment 1 Briefly describe the main goal of this experiment and the experimental procedure Section 132 I3 Model Validation Experiment 1 Briefly describe the main goal of this experiment and the experimental procedure Section 133 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Bode plot from step 7 in Section 1312 Gain at varying frequencies 2 Response plot from step 7 in Section 132 Bump Test Experiment 3 Response plot from step 15 in Section 133 Model Validation Experiment 4 Provide data collected in this laboratory from Table 11 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Frequency Response Experiment 1 Step 8 in Section 1311 Steadystate gain 2 Step 8 in Section 1312 Gain at varying frequencies III2 Bump Test Experiment 1 Steps 8 and 9 in Section 132 SRV02 Workbook Student Version v 10 IV CONCLUSIONS Interpret your results to arrive at logical conclusions 1 Steps 11 14 and 16 in Section 133 152 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version 18 LABORATORY 2 SRV02 POSITION CONTROL The objective of this laboratory is to develop feedback systems that control the position of the rotary servo load shaft Using the proportionalintegralderivative PID family controllers are designed to meet a set of specifications Topics Covered Design of a proportionalvelocity PV controller for position control of the servo load shaft to meet certain timedomain requirements Actuator saturation Design of a proportionalvelocityintegral PIV controller to track a ramp reference signal Simulation of the PV and PIV controllers using the developed model of the plant to ensure the specifications are met without any actuator saturation Implementation of the controllers on the Quanser SRV02 device to evaluate their performance Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 21 Background 211 Desired Position Control Response The block diagram shown in Figure 21 is a general unity feedback system with compensator controller Cs and a transfer function representing the plant Ps The measured output Ys is supposed to track the reference signal Rs and the tracking has to match to certain desired specifications Figure 21 Unity feedback system The output of this system can be written as Y s Cs Ps Rs Y s 211 By solving for Y s we can find the closedloop transfer function Y s Rs Cs Ps 1 Cs Ps 212 Recall in Laboratory SRV02 Modelling Section 1 the SRV02 voltagetospeed transfer function was derived To find the voltagetoposition transfer function we can put an integrator 1s in series with the speed transfer function effectively integrating the speed output to get position Then the resulting openloop voltagetoload gear position transfer function becomes Ps K s τs 1 213 As you can see from this equation the plant is a second order system In fact when a second order system is placed in series with a proportional compensator in the feedback loop as in Figure 21 the resulting closedloop transfer function can be expressed as Y s Rs ω2 n s2 2ζ ωn s ω2n 214 where ωn is the natural frequency and ζ is the damping ratio This is called the standard secondorder transfer function Its response proporeties depend on the values of ωn and ζ 2111 Peak Time and Overshoot Consider a secondorder system as shown in Equation 214 subjected to a step input given by Rs R0 s 215 with a step amplitude of R0 15 The system response to this input is shown in Figure 22 where the red trace is the response output yt and the blue trace is the step input rt The maximum value of the response is denoted by the variable ymax and it occurs at a time tmax For a response similar to Figure 22 the percent overshoot is found using PO 100 ymax R0 R0 216 SRV02 Workbook Student Version 20 Figure 22 Standard secondorder step response From the initial step time t0 the time it takes for the response to reach its maximum value is tp tmax t0 217 This is called the peak time of the system In a secondorder system the amount of overshoot depends solely on the damping ratio parameter and it can be calculated using the equation PO 100 e π ζ 1ζ2 218 The peak time depends on both the damping ratio and natural frequency of the system and it can be derived as tp π ωn 1 ζ2 219 Generally speaking the damping ratio affects the shape of the response while the natural frequency affects the speed of the response 2112 Steady State Error Steadystate error is illustrated in the ramp response given in Figure 23 and is denoted by the variable ess It is the difference between the reference input and output signals after the system response has settled Thus for a time t when the system is in steadystate the steadystate error equals ess rsst ysst 2110 where rsst is the value of the steadystate input and ysst is the steadystate value of the output We can find the error transfer function Es in Figure 21 in terms of the reference Rs the plant Ps and the compensator Cs The Laplace transform of the error is Es Rs Y s 2111 Solving for Y s from equation 213 and substituting it in equation 2111 yields Es Rs 1 Cs Ps 2112 SRV02 Workbook Student Version v 10 Figure 23 Steadystate error in ramp response We can find the the steadystate error of this system using the finalvalue theorem ess lim s0 s Es 2113 In this equation we need to substitute the transfer function for Es from 2112 The Es transfer function requires Rs Cs and Ps For simplicity let Cs1 as a compensator The Ps and Rs were given by equations 213 and 215 respectively Then the error becomes Es R0 s 1 K s τs1 2114 Applying the finalvalue theorem gives ess R0 lim s0 τ s 1 s τ s2 s K 2115 When evaluated the resulting steadystate error due to a step response is ess 0 2116 Based on this zero steadystate error for a step input we can conclude that the SRV02 is a Type 1 system 2113 SRV02 Position Control Specifications The desired timedomain specifications for controlling the position of the SRV02 load shaft are ess 0 2117 tp 020 s 2118 and PO 50 2119 Thus when tracking the load shaft reference the transient response should have a peak time less than or equal to 020 seconds an overshoot less than or equal to 5 and the steadystate response should have no error SRV02 Workbook Student Version 22 212 PV Controller Design 2121 Closed Loop Transfer Function The proportionalvelocity PV compensator to control the position of the SRV02 has the following structure Vmt kp θdt θlt kv d dt θlt 2120 where kp is the proportional control gain kv is the velocity control gain θdt is the setpoint or reference load shaft angle θlt is the measured load shaft angle and Vmt is the SRV02 motor input voltage The block diagram of the PV control is given in Figure 24 We need to find the closedloop transfer function ΘlsΘds for the closedloop Figure 24 Block diagram of SRV02 PV position control position control of the SRV02 Taking the Laplace transform of equation 2120 gives Vms kp Θds Θls kv s Θls 2121 From the Plant block in Figure 24 and equation 213 we can write Θls Vms K s τ s 1 2122 Substituting equation 2121 into 2122 and solving for ΘlsΘds gives the SRV02 position closedloop transfer function as Θls Θds K kp τ s2 1 K kv s K kp 2123 2122 Controller Gain Limits In control design a factor to be considered is saturation This is a nonlinear element and is represented by a saturation block as shown in Figure 25 In a system like the SRV02 the computer calculates a numeric control voltage value This value is then converted into a voltage Vdact by the digitaltoanalog converter of the data acquisition device in the computer The voltage is then amplified by a power amplifier by a factor of Ka If the amplified voltage Vampt is greater than the maximum output voltage of the amplifier or the input voltage limits of the motor whichever is smaller then it is saturated limited at Vmax Therefore the input voltage Vmt is the effective voltage being applied to the SRV02 motor The limitations of the actuator must be taken into account when designing a controller For instance the voltage entering the SRV02 motor should never exceed Vmax 100 V 2124 SRV02 Workbook Student Version v 10 Figure 25 Actuator saturation 2123 Ramp Steady State Error Using PV Control From our previous steadystate analysis we found that the closedloop SRV02 system is a Type 1 system In this section we will investigate the steadystate error due to a ramp input when using PV controller Given the following ramp setpoint input Rs R0 s2 2125 we can find the error transfer function by substituting the SRV02 closedloop transfer function in equation 2123 into the formula given in 2111 Using the variables of the SRV02 this formula can be rewritten as Es ΘdsΘls After rearranging the terms we find Es Θds s τ s 1 K kv τ s2 s K kp K kv s 2126 Substituting the input ramp transfer function 2125 into the Θds variable gives Es R0 τ s 1 K kv s τ s2 s K kp K kv s 2127 213 PIV Controller Adding an integral control can help eliminate any steadystate error We will add an integral signal middle branch in Figure 26 to have a proportionalintegralvelocity PIV algorithm to control the position of the SRV02 The motor voltage will be generated by the PIV according to Vmt kp θdd θlt ki θdt θlt dt kv d dt θlt 2128 where ki is the integral gain We need to find the closedloop transfer function ΘlsΘds for the closedloop position control of the SRV02 Taking the Laplace transform of equation 2128 gives Vms kp ki s Θds Θls kv s Θls 2129 From the Plant block in Figure 26 and equation 213 we can write Θls Vms K τ s 1 s 2130 Substituting equation 2129 into 2130 and solving for ΘlsΘds gives the SRV02 position closedloop transfer function as Θls Θds K kp s ki s3 τ 1 K kv s2 K kp s K ki 2131 SRV02 Workbook Student Version 24 Figure 26 Block diagram of PIV SRV02 position control 2131 Ramp SteadyState Error using PIV Controller To find the steadystate error of the SRV02 for a ramp input under the control of the PIV substitute the closedloop transfer function from equation 2131 into equation 2111 Es Θds s2 τ s 1 K kv s3 τ s2 K kp s K ki K kv s2 2132 Then substituting the reference ramp transfer function 2125 into the Θds variable gives Es R0 τ s 1 K kv s3 τ s2 K kp s K ki K kv s2 2133 2132 Integral Gain Design It takes a certain amount of time for the output response to track the ramp reference with zero steadystate error This is called the settling time and it is determined by the value used for the integral gain In steadystate the ramp response error is constant Therefore to design an integral gain the velocity compensation the V signal can be neglected Thus we have a PI controller left as Vmt kp θdt θlt ki θdt θlt dt 2134 When in steadystate the expression can be simplified to Vmt kp ess ki ti 0 ess dt 2135 where the variable ti is the integration time SRV02 Workbook Student Version v 10 22 PreLab Questions Before you start the lab experiments given in Section 23 you should study the background materials provided in Section 21 and work through the questions in this Section 1 Calculate the maximum overshoot of the response in radians given a step setpoint of 45 degrees and the overshoot specification given in Section 2113 Hint By substituting ymax θtp and step setpoint R0 θdt into equation 216 we can obtain θtp θdt 1 P O 100 Recall that the desired response specifications include 5 overshoot 2 The SRV02 closedloop transfer function was derived in equation 2123 in Section 2121 Find the control gains kp and kv in terms of ωn and ζ Hint Remember the standard second order system equation 3 Calculate the minimum damping ratio and natural frequency required to meet the specifications given in Section 2113 4 Based on the nominal SRV02 model parameters K and τ found in Laboratory 1 SRV02 Modeling calculate the control gains needed to satisfy the timedomain response requirements given in Section 2113 5 In the PV controlled system for a reference step of π4 ie 45 degree step starting from Θlt 0 position calculate the maximum proportional gain that would lead to providing the maximum voltage to the motor Ignore the velocity control kv 0 Can the desired specifications be obtained based on this maximum available gain and what you calculated in question 4 6 For the PV controlled closedloop system find the steadystate error and evaluate it numerically given a ramp with a slope of R0 336 rads Use the control gains found in question 4 7 What should be the integral gain ki so that when the SRV02 is supplied with the maximum voltage of Vmax 10 V it can eliminate the steadystate error calculated in question 6 in 1 second Hint Start from equation 2135 and use ti 1 Vmt 10 the kp you found in question 4 and ess found in question 6 Remember that ess is constant SRV02 Workbook Student Version 26 23 Lab Experiments The main goal of this laboratory is to explore position control of the SRV02 load shaft using PV and PIV controllers In this laboratory you will conduct three experiments 1 Step response with PV controller 2 Ramp response with PV controller and 3 Ramp response with no steadystate error You will need to design the third experiment yourself In each experiment you will first simulate the closedloop response of the system Then you will implement the controller using the SRV02 hardware and software to compare the real response to the simulated one 231 Step Response Using PV Controller 2311 Simulation First you will simulate the closedloop response of the SRV02 with a PV controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated Then you will explore the effect of using a highpass filter instead of a direct derivative to create the velocity signal V in the controller Experimental Setup The s srv02 pos Simulinkdiagram shown in Figure 27 will be used to simulate the closedloop position control response with the PV and PIV controllers The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary The PIV Control subsystem contains the PIV controller detailed in Section 213 When the integral gain is set to zero it essentially becomes a PV controller Figure 27 Simulink model used to simulate the SRV02 closedloop position response IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 242 to configure the lab files first Closedloop Response with the PV Controller SRV02 Workbook Student Version v 10 1 Enter the proportional and velocity control gains found in PreLab question 4 in Matlabas kp and kv 2 To generate a step reference ensure the SRV02 Signal Generator is set to the following Signal type square Amplitude 1 Frequency 04 Hz 3 In the Simulinkdiagram set the Amplitude rad gain block to π8rad to generate a step with an amplitude of 45 degrees ie square wave goes between π8 which results in a step amplitude of π4 4 Inside the PIV Control subsystem set the Manual Switch to the upward position so the Derivative block is used 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to figures 28 and 29 Note that in the theta l rad scope the yellow trace is the setpoint position while the purple trace is the simulated position generated by the SRV02 Model block This simulation is called the Ideal PV response as it uses the PV compensator with the derivative block Figure 28 Ideal PV position re sponse Figure 29 Ideal PV motor input voltage 7 Generate a Matlabfigure showing the Ideal PV position response and the ideal input voltage After each simulation run each scope automatically saves their response to a variable in the Matlabworkspace That is the theta l rad scope saves its response to the variable called data pos and the Vm V scope saves its data to the data vm variable The data pos variable has the following structure data pos1 is the time vector data pos2 is the setpoint and data pos3 is the simulated angle For the data vm variable data vm1 is the time and data vm2 is the simulated input voltage 8 Measure the steadystate error the percent overshoot and the peak time of the simulated response Does the response satisfy the specifications given in Section 2113 Hint Use the Matlabginput command to take measurements off the figure Using a Highpass Filter Instead of Direct Derivative 9 When implementing a controller on actual hardware it is generally not advised to take the direct derivative of a measured signal Any noise or spikes in the signal becomes amplified and gets multiplied by a gain and fed into the motor which may lead to damage To remove any highfrequency noise components in the velocity signal a lowpass filter is placed in series with the derivative ie taking the highpass filter of the measured signal However as with a controller the filter must also be tuned properly In addition the filter has some adverse affects Go in the PIV Control block and set the Manual Switch block to the down position to enable the highpass filter 10 Start the simulation The response in the scopes should still be similar to figures 28 and 29 This simulation is called the Filtered PV response as it uses the PV controller with the highpass filter block SRV02 Workbook Student Version 28 11 Generate a Matlabfigure showing the Filtered PV position and input voltage responses 12 Measure the steadystate error peak time and percent overshoot Are the specifications still satisfied without saturating the actuator Recall that the peak time and percent overshoot should not exceed the values given in Section 2113 Discuss the changes from the ideal response Hint The different in the response is minor Make sure you use ginput to take precise measurements 2312 Implementing Step Response using PV Controller In this experiment we will control the angular position of the SRV02 load shaft ie the disc load using the PV controller Measurements will then be taken to ensure that the specifications are satisfied Experimental Setup The q srv02 pos Simulinkdiagram shown in Figure 210 is used to implement the position control experiments The SRV02ET subsystem contains QUARC blocks that interface with the DC motor and sensors of the SRV02 system as discussed in Section A The PIV Control subsystem implements the PIV controller detailed in Section 213 except a highpass filter is used to obtain the velocity signal as opposed to taking the direct derivative Figure 210 Simulink model used with QUARC to run the PV and PIV position controllers on the SRV02 IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 243 to configure the lab files first 1 Run the setup srv02 exp02 posm script 2 Enter the proportional and velocity control gains found in PreLab question 4 3 Set Signal Type in the SRV02 Signal Generator to square to generate a step reference 4 Set the Amplitude rad gain block to π8 to generate a step with an amplitude of 45 degrees 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Click on QUARC Build to compile the Simulinkdiagram 7 Select QUARC Start to begin running the controller The scopes should display responses similar to figures 211 and 212 Note that in the theta l rad scope the yellow trace is the setpoint position while the purple trace is the measured position SRV02 Workbook Student Version v 10 Figure 211 Measured PV step response Figure 212 PV control input voltage 8 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the PV position response and its input voltage As in the s srv02 pos Simulink diagram when the controller is stopped each scope automatically saves their response to a variable in the Matlabworkspace Thus the theta l rad scope saves its response to the data pos variable and the Vm V scope saves its data to the data vm variable 9 Measure the steadystate error the percent overshoot and the peak time of the SRV02 load gear Does the response satisfy the specifications given in Section 2113 10 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 11 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 232 Ramp Response Using PV Controller 2321 Simulation In this simulation the goal is to verify that the system with the PV controller can meet the zero steadystate error specification without saturating the motor As in the Step Response experiment in Section 231 in this experiment you need to use the s srv02 pos Simulinkdiagram shown in Figure 27 in Section 2311 again 1 Enter the proportional and velocity control gains found in PreLab question 4 2 Set the SRV02 Signal Generator parameters to the following to generate a triangular reference which corre sponds to a ramp input Signal Type triangle Amplitude 1 Frequency 08 Hz 3 Setting the frequency to 08 Hz will generate an increasing and decreasing ramp signal with the same slope used in the PreLab question 6 The slope is calculated from the Triangular Waveform amplitude Amp and frequency f using the expression R0 4 Amp f 2336 4 In the Simulinkdiagram set the Amplitude rad gain block to π3 SRV02 Workbook Student Version 30 5 Inside the PIV Control subsystem set the Manual Switch to the down position so that the HighPass Filter block is used 6 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 7 Start the simulation The scopes should display responses similar to figures 213 and 214 Figure 213 Ramp response us ing PV Figure 214 Input voltage of ramp tracking using PV 8 Generate a Matlabfigure showing the Ramp PV position response and its corresponding input voltage trace 9 Measure the steadystate error Compare the simulation measurement with the steadystate error calculated in PreLab question 6 2322 Implementing Ramp Response Using PV In this experiment we will control the angular position of the SRV02 load shaft ie the disc load using a PV controller The goal is to examine how well the system can track a triangular ramp position input Measurements will then be taken to ensure that the specifications are satisfied As in the Step Response experiment in Section 231 in this experiment you also need to use the q srv02 pos Simulinkdiagram shown in Figure 210 to implement the position control experiments 1 Run the setup srv02 exp02 posm script 2 Enter the proportional and velocity control gains found in PreLab question 4 3 Set the SRV02 Signal Generator parameters to the following to generate a triangular reference ie ramp reference Signal Type triangle Amplitude 1 Frequency 08 Hz 4 In the Simulinkdiagra set the Amplitude rad gain block to π3 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Click on QUARC Build to compile the Simulinkdiagram 7 Select QUARC Start to run the controller The scopes should display responses similar to figures 215 and 216 8 Generate a Matlabfigure showing the Ramp PV position response and its corresponding input voltage trace 9 Measure the steadystate error and compare it with the steadystate error calculated in PreLab question 6 SRV02 Workbook Student Version v 10 Figure 215 Measured SRV02 PV ramp response Figure 216 Input voltage of PV ramp response 233 Ramp Response with No SteadyState Error Design an experiment to see if the steadystate error can be eliminated when tracking a ramp input First simulate the response then implement it using the SRV02 system 1 How can the PV controller be modified to eliminate the steadystate error in the ramp response State your hypothesis and describe the anticipated causeandeffect leading to the expected result Hint Look through Section 2 2 List the independent and dependent variables of your proposed controller Explain their relationship 3 Your proposed control like the PV compensator are modelbased controllers This means that the control gains generated are based on mathematical representation of the system Given this list the assumptions you are making in this control design State the reasons for your assumptions 4 Give a brief general overview of the steps involved in your experimental procedure for two cases 1 Simula tion and 2 Implementation 5 For each case generate a Matlabfigure showing the position response of the system and its corresponding input voltage 6 In each case measure the steadystate error 7 For each case comment on whether the steadystate specification given in Section 2113 was satisfied without saturating the actuator 8 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 9 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session SRV02 Workbook Student Version 32 234 Results Fill out Table 21 below with your answers to the PreLab questions and your results from the lab experiments Section Ques tion Description Symbol Value Unit Question 4 PreLab Model Parameters OpenLoop SteadyState Gain K OpenLoop Time Constant τ Question 4 PreLab PV Gain Design Proportional gain kp Velocity gain kv Question 5 PreLab Control Gain Limits Maximum proportional gain kpmax Question 6 PreLab Ramp SteadyState Error Steadystate error using PV ess Question 7 PreLab Integral Gain Design Integral gain ki 2311 Step Response Simulation Peak time tp Percent overshoot PO Steadystate error ess 2311 Filtered Step Response Using PV Peak time tp Percent overshoot PO Steadystate error ess 2312 Step Response Implementation Peak time tp Percent overshoot PO Steadystate error ess 2321 Ramp Response Simulation with PV Steadystate error ess 2322 Ramp Response Implementation with PV Steadystate error ess 233 Ramp Response Simulation with with no steadystate error Steadystate error ess 233 Ramp Response Implementation with with no steadystate error Steadystate error ess Table 21 Summary of results for the SRV02 Position Control laboratory SRV02 Workbook Student Version v 10 24 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARC compatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 241 Overview of Files Table 22 Files supplied with the SRV02 Position Control laboratory File Name Description 02 SRV02 Position Control Stu dent Manualpdf This laboratory guide contains prelab questions and lab experiments demonstrating how to design and imple ment a position controller on the Quanser SRV02 rotary plant using QUARC setup srv02 exp02 posm The main Matlabscript that sets the SRV02 motor and sensor parameters as well as its configuration dependent model parameters Run this file only to setup the laboratory config srv02m Returns the configurationbased SRV02 model spec ifications Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP d model paramm Calculates the SRV02 model parameters K and tau based on the device specifications Rm kt km Kg eta g Beq Jeq and eta m calc conversion constantsm Returns various conversions factors s srv02 posmdl Simulink file that simulates a closedloop PIV controller for the SRV02 system q srv02 posmdl Simulink file that implements a closedloop PIV position controller on the SRV02 system using QUARC 242 Setup for Position Control Simulations Follow these steps to configure the lab properly 1 Load the Matlabsoftware 2 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 position controller files eg q srv02 posmdl 3 Doubleclick on the s srv02 posmdl file to open the Simulinkdiagram shown in Figure 27 4 Doubleclick on the setup srv02 exp02 spdm file to open the setup script for the position control Simulink models SRV02 Workbook Student Version 34 5 Configure setup script The controllers will be run on an SRV02 in the highgear configuration with the disc load In order to simulate the SRV02 properly make sure the script is setup to match this configuration ie the EXT GEAR CONFIG should be set to HIGH and the LOAD TYPE should be set to DISC Also ensure the ENCODER TYPE TACH OPTION K CABLE AMP TYPE and VMAX DAC parameters are set according to the SRV02 system that is to be used in the laboratory 6 Finally make sure CONTROL TYPE is set to MANUAL 7 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the Matlab Command Window The model parameters and specifications are loaded but the PIV gains are all set to zero they need to be changed SRV02 model parameters K 153 radsV tau 00254 s Specifications tp 02 s PO 5 Calculated PV control gains kp 0 Vrad kv 0 Vsrad Integral control gain for triangle tracking ki 0 Vrads 243 Setup for Position Control Implementation Before beginning the lab experiments on the SRV02 device the q srv02 pos Simulinkdiagram and the setup srv02 exp02 posm script must be configured Follow these steps to get the system ready for this lab 1 Setup the SRV02 in the highgear configuration and with the disc load as described in Reference 6 2 Load the Matlabsoftware 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 position control files eg q srv02 posmdl 4 Doubleclick on the q srv02 posmdl file to open the Position Control Simulinkdiagram shown in Figure 27 5 Configure DAQ Doubleclick on the HIL Initialize block in the SRV02ET subsystem which is located inside the SRV02ET Position subsystem and ensure it is configured for the DAQ device that is installed in your system See Section A for more information on configuring the HIL Initialize block 6 Configure Sensor The position of the load shaft can be measured using various sensors Set the Pos Src Source block in q srv02 pos as shown in Figure 27 as follows 1 to use the potentiometer 2 to use to the encoder Note that when using the potentiometer there will be a discontinuity 7 Configure setup script Set the parameters in the setup srv02 exp02 posm script according to your system setup See Section 242 for more details SRV02 Workbook Student Version v 10 25 Lab Report This laboratory contains three experiments namely 1 step response 2 ramp response with PV controller and 3 ramp response with no steadystate error When you are writing your lab report follow the outline corresponding to the experiment you conducted to build the content of your report Also in Section 254 you can find some basic tips for the format of your report SRV02 Workbook Student Version 36 251 Template for Content Step Response Exper iment I PROCEDURE 1 Closedloop response with the PV controller Briefly describe the main goal of the simulation Briefly describe the simulation procedure Section 2311 2 Step response with PV controller using highpass filter Briefly describe the main goal of this simulation Briefly describe the simulation procedure Section 2311 3 Implementing Step Response using PV Controller Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 2312 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 7 in Section 2311 Simulated step response 2 Response plot from step 11 in Section 2311 Filtered PV response 3 Response plot from step 8 in Section 2312 Step response of implemented PV controller 4 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 8 in Section 2311 Step response with PV controller 2 Step 12 in Section 2311 Step response with PV controller using highpass filter 3 Step 9 in Section 2312 Step response with PV controller IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 8 in Section 2311 Step response simulation with PV controller 2 Step 12 in Section 2311 Step response simulation with PV controller using Highpass filter 3 Step 9 in Section 2312 Step response with the implemented PV controller SRV02 Workbook Student Version v 10 252 Template for Content Ramp Response with PV I PROCEDURE 1 Ramp response with PV controller Briefly describe the main goal of this simulation Briefly describe the procedure Section 2321 2 Implementing Ramp Response Using PV Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 2322 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 8 in Section 2321 Simulated PV controller with ramp input 2 Response plot from step 8 in Section 2322 Ramp response of implemented PV controller 3 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 9 in Section 2321 Simulated PV controller with ramp input 2 Step 9 in Section 2322 Ramp response of implemented PV controller IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 9 in Section 2322 Ramp response with the implemented PV controller SRV02 Workbook Student Version 38 253 Template for Content Ramp Response with No SteadyState Error I PROCEDURE 1 State the hypothesis of your experiment and describe the anticipated causeandeffect leading to the expected result Step 1 in Section 233 2 List the independent and dependent variables for the controller Explain their relationship Step 2 in Section 233 3 List the assumptions you made in this experiment State the reasons for your assumptions Step 3 in Section 233 4 Briefly list the steps of your experimental procedure for two cases 1 Simulation and 2 Implementation Step 4 in Section 233 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 5 in Section 233 Simulated controller with ramp input 2 Response plot from step 5 in Section 233 Implemented controller with ramp input 3 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 6 in Section 233 Simulated controller with ramp input 2 Step 6 in Section 233 Implemented controller with ramp input IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 7 in Section 233 for both simulated and implemented controllers SRV02 Workbook Student Version v 10 254 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version 40 LABORATORY 3 SRV02 SPEED CONTROL The objective of this laboratory is to develop feedback systems that control the speed of the rotary servo load shaft A proportionalintegral PI controller and a lead compensator are designed to regulate the shaft speed according to a set of specifications Topics Covered Design of a proportionalintegral PI controller that regulates the angular speed of the servo load shaft Design of a lead compensator Simulation of the PI and lead controllers using the plant model to ensure the specifications are met without any actuator saturation Implemention of the controllers on the Quanser SRV02 device to evaluate their performance Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 31 Background 311 Desired Response 3111 SRV02 Speed Control Specifications The timedomain requirements for controlling the speed of the SRV02 load shaft are ess 0 311 tp 005 s and 312 PO 5 313 Thus when tracking the load shaft reference the transient response should have a peak time less than or equal to 005 seconds an overshoot less than or equal to 5 and zero steadystate error In addition to the above timebased specifications the following frequencydomain requirements are to be met when designing the Lead Compensator PM 750 deg 314 and ωg 750 rads 315 The phase margin mainly affects the shape of the response Having a higher phase margin implies that the system is more stable and the corresponding time response will have less overshoot The overshoot will not go beyond 5 with a phase margin of at least 750 degrees The crossover frequency is the frequency where the gain of the Bode plot is 1 or 0 dB This parameter mainly affects the speed of the response thus having a larger ωg decreases the peak time With a crossover frequency of 750 radians the resulting peak time will be less than or equal to 005 seconds 3112 Overshoot In this laboratory we will use the following step setpoint input ωdt 25 rads t t0 75 rads t t0 316 where t0 is the time the step is applied Initially the SRV02 should be running at 25 rads and after the step time it should jump up to 75 rads From the standard definition of overshoot in step response we can calculate the maximum overshoot of the response in radians ωtp ωdt0 ωdt ωdt0 1 PO 100 317 SRV02 Workbook Student Version 42 with the given values the maximum overshoot of the response is ωtp 775 rads 318 The closedloop speed response should therefore not exceed the value given in Equation 318 3113 Steady State Error Consider the speed control system with unity feedback shown in Figure 31 Let the compensator be Cs 1 Figure 31 Unity feedback loop We can find the steadystate error using the final value theorem ess lim s0 s Es 319 where Es Rs 1 Cs Ps 3110 The voltagetospeed transfer function for the SRV02 was found in Section 1 as Ps K τ s 1 3111 Substituting Rs R0 s and Cs 1 gives Es R0 s 1 K τ s1 3112 Applying the finalvalue theorem to the system gives ess R0 lim s0 τ s 1 τ s 1 K 3113 When evaluated the resulting steadystate error due to a step response is ess R0 1 K 3114 312 PI Control Design 3121 Closed Loop Transfer Function The proportionalintegral PI compensator used to control the velocity of the SRV02 has the following structure Vmt kp bsp ωdt ωlt ki ωdt ωlt dt 3115 SRV02 Workbook Student Version v 10 Figure 32 Block diagram of SRV02 PI speed control where kp is the proportional control gain ki is the integral control gain ωdt is the setpoint or reference angular speed for the load shaft ωlt is the measured load shaft angular speed bsp is the setpoint weight and Vmt is the voltage applied to the SRV02 motor The block diagram of the PI control is given in Figure 32 We can take Laplace transform of the controller given in Equation 3115 Vms kp bsp Ωds Ωls ki Ωds Ωls s 3116 To find the closedloop speed transfer function ΩlsΩds we can use the process transfer function from Equation 3111 and solve for ΩlsΩds as Ωls Ωds K kp s bsp ki s2 τ 1 K kp s K ki 3117 3122 Finding PI Gains to Satisfy Specifications In this section we will first calculate the minimum damping ratio and natural frequency required to meet the speci fications given in Section 3111 Then using these values we will calculate the necessary control gains kp and ki to achieve the desired performance with a PI controller The minimum damping ratio and natural frequency needed to satisfy a given percent overshoot and peak time are ζ ln PO 100 1 ln P O 100 2 π2 3118 and ωn π tp 1 ζ2 3119 Substituting the percent overshoot specifications given in 313 into Equation 3118 gives the required damping ratio ζ 0690 3120 Then by substituting this damping ratio and the desired peak time given in 312 into Equation 3119 the minimum natural frequency is found as ωn 867 rads 3121 Now lets look at how we can calculate the gains When the setpoint weight is zero ie bsp 0 the closedloop SRV02 speed transfer function has the structure of a standard secondorder system We can find expressions for the control gains kp and ki by equating the characteristic equation denominator of the SRV02 closedloop transfer function to the standard characteristic equation s2 2 ζ ωn s ω2 n SRV02 Workbook Student Version 44 The denominator of the transfer function can be restructured into the following s2 1 K kp s τ K ki τ 3122 equating the coefficients of this equation to the coefficients of the standard characteristic equation gives K ki τ ω2 n 3123 and 1 K kp τ 2 ζ ωn 3124 Then the proportional gain kp can be found as kp 1 2 ζ ωn τ K 3125 and the integral gain ki is ki ω2 n τ K 3126 313 Lead Control Design Alternatively a lead or lag compensator can be designed to control the speed of the servo The lag compensator is actually an approximation of a PI control and this at first may seem like the more viable option However due to the saturation limits of the actuator the lag compensator cannot achieve the desired zero steadystate error specification Instead a lead compensator with an integrator as shown in Figure 33 will be designed Figure 33 Closedloop SRV02 speed control with lead compensator To obtain zero steadystate error an integrator is placed in series with the plant This system is denoted by the transfer function Pis Ps s 3127 where Ps is the plant transfer function in Equation 3111 The phase margin and crossover frequency specifications listed in equations 314 and 315 of Section 3111 can then be satisfied using a proportional gain Kc and the lead transfer function Gleads 1 a T s 1 T s 3128 The a and T parameters change the location of the pole and the zero of the lead compensator which changes the gain and phase margins of the system The design process involves examining the stability margins of the loop transfer function Ls Cs Ps where the compensator is given by Cs Kc 1 a T s 1 T s s 3129 SRV02 Workbook Student Version v 10 3131 Finding Lead Compensator Parameters The Lead compensator is an approximation of a proportionalderivative PD control A PD controller can be used to add damping to reduce the overshoot in the transient of a step response and effectively making the system more stable In other words it increases the phase margin In this particular case the lead compensator is designed for the following system Lps Kc Ps s 3130 The proportional gain Kc is designed to attain a certain crossover frequency Increasing the gain crossover frequency essentially increases the bandwidth of the system which decreases the peak time in the transient response ie makes the response faster However as will be shown adding a gain Kc 1 makes the system less stable The phase margin of the Lps system is therefore lower than the phase margin of the Pis system and this translates to having a large overshoot in the response The lead compensator is used to dampen the overshoot and increase the overall stability of the system ie increase its phase margin The frequency response of the lead compensator given in 3128 is Glead ω j 1 a T ωj 1 T ω j 3131 and its corresponding magnitude and phase equations are Gleadω j T 2 ω2 a2 1 1 T 2 ω2 3132 and ϕG arctana Tω arctanT ω 3133 The Bode plot of the lead compensator is shown in Figure 34 Figure 34 Bode of lead compensator 3132 Lead Compensator Design using MATLAB In this section we will use Matlabto design a lead compensator that will satisfy the frequencybased specifications given in Section 3111 1 Bode plot of the openloop uncompensated system Pis must first be found To generate the Bode plot of Pis enter the following commands in Matlab NOTE If your system has not been set up yet then you SRV02 Workbook Student Version 46 need to first run the the setup srv02 exp03 spdm script This script will store the model parameter K and tau in the Matlabworkspace These parameters are used with the commands tf and series to create the Pis transfer function The margin command generates a Bode plot of the system and it lists the gain and phase stability margins as well as the phase and gain crossover frequencies Plant transfer function P tfKtau 1 Integrator transfer function I tf11 0 Plant with Integrator transfer function Pi seriesPI Bode of Pis figure1 marginPi set 1namePis The entire Lead compensator design is given in the d leadm script file Run this script after running the setup srv02 exp03 spdm script when CONTROL TYPE AUTO to generate a collection of Bode diagrams including the Bode of Pis given in Figure 35 Figure 35 Bode of Pis system 2 Find how much more gain is required such that the gain crossover frequency is 500 rads use the ginput Matlabcommand As mentioned before the lead compensator adds gain to the system and will increases the phase as well Therefore gain Kc is not to be designed to meet the specified 750 rads fully As given in Figure 35 the crossover frequency of the uncompensated system is 153 rads To move the crossover frequency to 500 rads a gain of Kc 345 dB 3134 or Kc 531 Vrad 3135 in the linear range is required The Bode plot of the loop transfer function Lps from Section 313 is given in Figure 36 This initial estimate of the gain was found using the ginput command The gain was then adjusted according to the crossover frequency calculated in the generated Bode plot of the Lps system The commands used to generate the Bode plot are given in the d leadm script SRV02 Workbook Student Version v 10 Figure 36 Bode of Lps system 3 Gain needed for specified phase margin must be found next so that the lead compensator can achieve the specified phase margin of 75 degrees Also to ensure the desired specifications are reached well add another 5 degrees to the maximum phase of the lead To attain the necessary phase margin the maximum phase of the lead can be calculated using ϕm PMdes PMmeas 5 3136 Given that the desired phase margin in Equation 314 and the phase margin of Lps is PMmeas 215 deg 3137 the maximum lead phase has to be about ϕm 418 deg 3138 or ϕm 0728 rad 3139 The lead compensator as explained in Section 3131 has two parameters a and T To attain the maximum phase ϕm shown in Figure 34 the Lead compensator has to add 20 log10a of gain This is determined using the equation a 1 sinϕm 1 sinϕm 3140 The gain needed is found by inserting the max phase into this equation to get a 496 3141 which is 20 log 10a 139 dB 3142 4 The frequency at which the lead maximum phase occurs must be placed at the new gain crossover fre quency ωgnew This is the crossover frequency after the lead compensator is applied As illustrated in Figure 34 ωm occurs halfway between 0 dB and 20 log10a ie at 10 log10a So the new gain crossover frequency in the Lps system will be the frequency where the gain is 10 log10a From Figure 36 it is found that the frequency where the 10 log10a gain in the Lps system occurs is at about 809 rads Thus the maximum phase of the lead will be set to ωm 809 rads 3143 SRV02 Workbook Student Version 48 As illustrated earlier in Figure 34 in Section 3131 the maximum phase occurs at the maximum phase fre quency ωm Parameter T given by T 1 ωm a 3144 is used to attain a certain maximum phase frequency This changes where the Lead compensator breakpoint frequencies 1a T and 1T shown in Figure 34 occur The slope of the lead compensator gain changes at these frequencies We can find the parameter T by substituting ωm 809 and the lead gain value from Equation 3141 into Equation 3144 T 000556 srad 3145 Therefore the lead breakpoint frequencies are 1 a T 361 rads 3146 and 1 T 1809 rads 3147 5 Bode plot of the lead compensator Cleads defined in 3128 can be generated using the d leadm script Figure 37 Bode of lead compensator Cleads 6 Bode plot of the loop transfer function Ls as described in 3130 can be generated using the d leadm script The phase margin of Ls is 681 degrees and is below the desired phase margin of 750 degrees as specified in Section 311 7 Check response by simulating the system to make sure that the timedomain specifications are met Keep in mind that the goal of the lead design is the same as the PI control the response should meet the desired steadystate error peak time and percentage overshoot specifications given in Section 311 Thus if the crossover frequency andor phase margin specifications are not quite satisfied the response should be simu lated to verify if the timedomain requirements are satisfied If so then the design is complete If not then the lead design needs to be revisited You will work on this later in the laboratory as described in Section 3321 SRV02 Workbook Student Version v 10 Figure 38 Bode of loop transfer function Ls 314 Sensor Noise When using analog sensors such as a tachometer there is often some inherent noise in the measured signal The peaktopeak noise of the measured SRV02 load gear signal can be calculated using eω 1 100 Kn ωl 3148 where Kn is the peaktopeak ripple rating of the sensor and ωl is the speed of SRV02 load gear The rated peak topeak noise of the SRV02 tachometer is given in Appendix B of Reference 6 as Kn 7 3149 Based on this specification the peaktopeak noise when the load shaft runs at 75 rads will be eω 0525 rads 3150 Thus the signal will oscillate 02625 rads about the 75 rads setpoint or approximately between 724 rads and 776 rads Then taking the noise into account what would be the maximum peak in the speed response that is to be expected Equation 317 was used to find the peak value of the load gear response for a given percent overshoot To take into account the noise in the signal this formula is modified as follows ωtp ωdt0 ωdt ωdt0 1 PO 100 1 2eω 3151 Given a reference signal that goes between 25 rads to 75 rads as described in Section 3111 and the peakto peak ripple estimate in Equation 3150 the peak speed of the load gear including the noise can be found as ωtp 801 rads 3152 Using PO 100 ωtp ωdt ωdt ωdt0 3153 the new maximum percent overshoot for a 50 rads step is PO 102 3154 SRV02 Workbook Student Version 50 32 PreLab Questions 1 Based on the steadystate error result of a step response from Equation what type of system is the SRV02 when performing speed control Type 0 1 or 2 and why 2 The nominal SRV02 model parameters K and τ found in SRV02 Modeling Laboratory Section 1 should be about 153 radsV and 00254 sec respectively Calculate the PI control gains needed to satisfy the timedomain response requirements 3 Find the frequency response magnitude Piω of the transfer function Pis given in Equation 3127 4 Calculate the DC gain of Pis given in Equation 3127 Hint The DC gain is the gain when the frequency is zero ie ω 0 rads However because of its integrator Pis has a singularity at zero frequency Therefore the DC gain is not technically defined for this system Instead approximate the DC gain by using ω 1 rads Make sure the DC gain estimate is evaluated numerically in dB using the nominal model parameters K 153 and τ 00254 or use what you found for K and τ in Section 1 5 The gain crossover frequency ωg is the frequency at which the gain of the system is 1 or 0 dB Express the crossover frequency symbolically in terms of the SRV02 model parameters K and τ Then evaluate the expression using the nominal SRV02 model parameters K 153 and τ 00254 or use what you found for K and τ in Section 1 SRV02 Workbook Student Version v 10 33 Lab Experiments The main goal of this laboratory is to explore closedloop speed control of the SRV02 load shaft In this laboratory you will conduct two experiments 1 Step response with PI control and 2 Step response with Lead control In each of the experiments you will first simulate the closedloop response of the system Then you will implement the controller using the SRV02 hardware and software to compare the real response to the simulated one 331 Step Response with PI Control 3311 Simulation First you will simulate the closedloop speed response of the SRV02 with a PI controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated Then you will explore the effect of the setpoint weight Experimental Setup The s srv02 spd Simulinkdiagram shown in Figure 39 is used to simulate the closedloop speed response of the SRV02 when using either the PI or Lead controls The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary to simulate the system The PI compensator subsystem contains the PI control detailed in Section 312 and the Lead Compensator block has the compensator described in Section 313 Figure 39 Simulink diagram used to simulate the closedloop SRV02 speed response IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 342 to configure the lab files first 1 Enter the proportional and integral control gains found in Section 3122 as kp and ki in Matlab 2 The speed reference signal is to be a 04 Hz square wave that goes between 25 rads and 75 rads ie between 239 rpm and 716 rpm Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 SRV02 Workbook Student Version 52 Frequency 04 Hz 3 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads block to 50 rads 4 Set the Manual Switch to the upward position to activate the PI control 5 Open the load shaft position scope w l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to figures 310 and 311 Note that in the w l rad scope the yellow trace is the setpoint position while the purple trace is the simulated speed generated by the SRV02 Model block Figure 310 Simulated PI speed response Figure 311 Simulated PI motor input voltage 7 Generate a Matlabfigure showing the simulated PI speed response and its input voltage After each simula tion run each scope automatically saves their response to a variable in the Matlab workspace The w l rad scope saves its response to the variable called data spd and the Vm V scope saves its data to the data vm variable The data spd variable has the following structure data spd1 is the time vector data spd2 is the setpoint and data spd3 is the simulated angular speed For the data vm variable data vm1 is the time and data vm2 is the simulated input voltage 8 Measure the steadystate error the percent overshoot and the peak time of the simulated response Does the response satisfy the specifications given in Section 3111 3312 Implementing PI Speed Control Experimental Setup The q srv02 spd Simulinkdiagram shown in Figure 312 is used to perform the speed control exercises in this laboratory The SRV02ET Speed subsystem contains QUARCblocks that interface with the DC motor and sensors of the SRV02 system as discussed in Section A The PI control subsystem implements the PI control detailed in Section 312 and the Lead Compensator block implements the lead control described in Section 313 SRV02 Workbook Student Version v 10 Figure 312 Simulink model used with QUARC to run the PI and lead speed controllers on the SRV02 1 Run the setup srv02 exp03 spdm script 2 Enter the proportional and integral control gains found in Section 32 as kp and ki in Matlab 3 To generate a square reference speed signal set the SRV02 Signal Generator block parameters to the follow ing Signal type square Amplitude 1 Frequency 04 Hz 4 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 5 Open the load shaft speed scope w l rads and the motor input voltage scope Vm V 6 Set the Manual Switch to the upward position to activate the PI control 7 Click on QUARC Build to compile the Simulinkdiagram 8 Select QUARC Start to run the controller The scopes should be displaying responses similar to figures Figure 313 and Figure 314 Note that in the w l rads scope the yellow trace is the setpoint position while the purple trace is the measured position Figure 313 Measured PI speed step response Figure 314 PI motor input volt age SRV02 Workbook Student Version 54 9 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the PI speed response and its input voltage As in the s srv02 spd Simulinkdiagram when the controller is stopped each scope automatically saves their response to a variable in the Matlabworkspace Thus the theta l rad scope saves its response to the data spd variable and the Vm V scope saves its data to the data vm variable 10 Due to the noise in the measured speed signal it is difficult to obtain an accurate measurement of the speci fications In the Speed Control Simulinkmode set the Amplitude rad block to 0 rads and the Offset rad block to 75 rads in order to generate a constant speed reference of 75 rads Generate a Matlabfigure showing the noise in the signal 11 Measure the peaktopeak ripple found in the speed signal eωmeas and compare it with the estimate in Section 314 Then find the steadystate error by comparing the average of the measured signal with the desired speed Is the steadystate error specification satisfied 12 Measure the percent overshoot and the peak time of the SRV02 load gear step response Taking into account the noise in the signal does the response satisfy the specifications given in Section 3111 13 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 14 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 332 Step Response with LEAD Control 3321 Simulation You will simulate the closedloop speed response of the SRV02 with a Lead controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated As in the step response with PI control experiment in Section 3311 in this experiment you need to use the s srv02 spd Simulinkdiagram shown in Figure 312 again 1 Enter the Lead control parameters found in Section 3132 These are denoted as Kc a and T in Matlab 2 Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 Frequency 04 Hz 3 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 4 To engage the lead control set the Manual Switch to the downward position 5 Open the load shaft position scope w l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to Figures 310 and 311 7 Verify if the timedomain specifications in Section 3111 are satisfied and that the motor is not being saturated To calculate the steadystate error peak time and percent overshoot use the simulated response data stored in the data spd variable 8 If the specifications are not satisfied go back in the lead compensator design You may have to for example add more maximum phase in order to increase the phase margin If the specifications are met move on to the next step 9 Generate a Matlabfigure showing the Simulated Lead speed response and its input voltage SRV02 Workbook Student Version v 10 3322 Implementing LEAD Speed Control In this section the speed of the SRV02 is controlled using the lead compensator Measurements will be taken to see if the specifications are satisfied 1 Run the setup srv02 exp03 spdm script 2 Enter the Kc a and T lead parameters found in Section 3132 in Matlab 3 Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 Frequency 04 Hz 4 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 5 To engage the lead compensator set the Manual Switch in the Speed Control Simulink diagram to the downward position 6 Open the load shaft speed scope w l rads and the motor input voltage scope Vm V 7 Click on QUARC Build to compile the Simulinkdiagram 8 Select QUARC Start to run the controller The scopes should be displaying responses similar to figures 313 and 314 9 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the lead speed response and its input voltage 10 Measure the steadystate error the percent overshoot and the peak time of the SRV02 load gear For the steadystate error it may be beneficial to give a constant reference and take its average as done in Section 3312 Does the response satisfy the specifications given in Section 3111 11 Using both your simulation and implementation results comment on any differences between the PI and lead controls 12 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 13 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 333 Results Fill out Table 31 below with your answers to the PreLab questions and your results from the lab experiments SRV02 Workbook Student Version 56 Section Ques tion Description Symbol Value Unit Question 2 PreLab PI Gains Proportional Gain kp Integral Gain ki OpenLoop Time Constant τ OpenLoop Steadystate Gain K Question 4 PreLab DC Gain Estimate DC Gain Estimate of Pis Pi1 Question 5 PreLab Gain Crossover Frequency Gain crossover frequency ωg Section 3311 InLab PI Step Response Simulation Peak time tp Percent overshoot PO Steadystate error ess Section 3312 InLab PI Speed Control Implementa tion Measured peaktopeak ripple eωmeas Steadystate error ess Peak time tp Percent overshoot PO Section 3321 InLab Step Response Simulation with Lead Control Peak time tp Percent overshoot PO Steadystate error ess Section 3322 InLab Lead Speed Control Imple mentation Peak time tp Percentage overshoot PO Steadystate error ess Table 31 Summary of results for the Speed Control laboratory SRV02 Workbook Student Version v 10 34 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARCcompatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 341 Overview of Files Table 32 Files supplied with the SRV02 Speed Control laboratory File Name Description 03 SRV02 Speed Control Stu dent Manualpdf This laboratory guide contains prelab questions and lab experiments demonstrating how to design and implement a speed controller on the Quanser SRV02 rotary plant us ing QUARC setup srv02 exp03 spdm The main Matlab script that sets the SRV02 motor and sensor parameters as well as its configurationdependent model parameters Run this file only to setup the labora tory config srv02m Returns the configurationbased SRV02 model specifica tions Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP d model paramm Calculates the SRV02 model parameters K and tau based on the device specifications Rm kt km Kg eta g Beq Jeq and eta m calc conversion constantsm Returns various conversions factors s srv02 spdmdl Simulink file that simulates the closedloop SRV02 speed control using either the PI control or the lead compensator q srv02 spdmdl Simulink file that runs the PI or Lead speed control on the actual SRV02 system using QUARC 342 Setup for Speed Control Simulation Follow these steps to configure the Matlabsetup script and the Simulinkdiagram for the Speed Control simulation laboratory 1 Load the Matlabsoftware 2 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 speed controller files eg s srv02 spdmdl 3 Doubleclick on the s srv02 spdmdl file to open the SRV02 Speed Control Simulation Simulink diagram shown in Figure 39 SRV02 Workbook Student Version 58 4 Doubleclick on the setup srv02 exp03 spdm file to open the setup script for the position control Simulink models 5 Configure setup script The controllers will be run on an SRV02 in the highgear configuration with the disc load as in Section 1 In order to simulate the SRV02 properly make sure the script is setup to match this configuration eg the EXT GEAR CONFIG should be set to HIGH and the LOAD TYPE should be set to DISC Also ensure the ENCODER TYPE TACH OPTION K AMP AMP TYPE and VMAX DAC parameters are set according to the SRV02 system that is to be used in the laboratory Finally make sure CONTROL TYPE is set to MANUAL 6 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the Matlab Command Window The correct model parameters are loaded but the control gains and related parameters loaded are default values that need to be changed That is the PI control gains are all set to zero the lead compensator parameters a and T are both set to 1 and the compensator proportional gain Kc is set to zero SRV02 model parameters K 153 radsV tau 00254 s PI control gains kp 0 Vrad ki 0 Vrads Lead compensator parameters Kc 0 Vrads 1aT 1 rads 1T 1 rads 343 Setup for Speed Control Implementation Before beginning the inlab exercises on the SRV02 device the q srv02 spd Simulinkdiagram and the setup srv02 exp03 spdm script must be configured Follow these steps to get the system ready for this lab 1 Setup the SRV02 in the highgear configuration and with the disc load as described in Reference 6 2 Load the Matlab software 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 speed control files eg q srv02 spdmdl 4 Doubleclick on the q srv02 spdmdl file to open the Speed Control Simulink diagram shown in Figure 312 5 Configure DAQ Doubleclick on the HIL Initialize block in the SRV02ET subsystem which is located inside the SRV02ET Speed subsystem and ensure it is configured for the DAQ device that is installed in your system See Section A for more information on configuring the HIL Initialize block 6 Configure Sensor To perform the speed control experiment the angular rate of the load shaft should be measured using the tachometer This has already been set in the Spd Src Source block inside the SRV02ET Speed subsystem 7 Configure setup script Set the parameters in the setup srv02 exp03 spdm script according to your system setup See Section 342 for more details SRV02 Workbook Student Version v 10 35 Lab Report This laboratory contains two experiments namely 1 step response with PI control and 2 step response with lead control When you are writing your report follow the outline corresponding to the experiment you conducted to build the content of your report Also in Section 353 you can find some basic tips for the format of your report SRV02 Workbook Student Version 60 351 Template for Content PI Control Experiments I PROCEDURE I1 Step Response with PI Control 1 Simulation Briefly describe the main goal of this simulation Briefly describe the procedure Section 3311 2 Implementation Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 3312 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 7 in Section 3311 Step response simulation with PI Control 2 Response plot from step 9 in Section 3312 Step response implementation with PI Control 3 Signal noise plot from step 10 in Section 3312 Step response implementation with PI Control 4 Provide data collected in this laboratory from Table 31 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Step Response with PI Control 1 Step 8 in Section 3311 Step response simulation with PI Control 2 Step 11 in Section 3312 Step response implementation with PI Control 3 Step 12 in Section 3312 Step response implementation with PI Control IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 8 in Section 3311 Step response simulation with PI Control 2 Step 11 in Section 3312 Step response implementation with PI Control 3 Step 12 in Section 3312 Step response implementation with PI Control SRV02 Workbook Student Version v 10 352 Template for Content Lead Control Experi ments I PROCEDURE I1 Step Reponse with Lead Control 1 Simulation Briefly describe the main goal of this simulation Briefly describe the procedure Section 3321 2 Implementation Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 3322 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 9 in Section 3321 Step response simulation with Lead Control 2 Response plot from step 9 in Section 3322 Step response implementation with Lead Control 3 Provide data collected in this laboratory from Table 31 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Step Response with Lead Control 1 Step 7 in Section 3321 Step response simulation with Lead Control 2 Step 10 in Section 3322 Step response implementation with Lead Control IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 7 in Section 3321 Step response simulation with Lead Control 2 Step 10 in Section 3322 Step response implementation with Lead Control 3 Step 11 in Section 3322 Step response implementation with Lead Control SRV02 Workbook Student Version 62 353 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version v 10 64 Appendix A SRV02 QUARC INTEGRATION In this section we explain how to send command voltages to the QuanserSRV02 and measure the position and speed of its load shaft in realtime using your computer System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in 1 You have a QUARCcompatible dataacquisition DAQ card installed in your PC For a listing of compliant DAQ cards see 5 SRV02 and amplifier are connected to your DAQ board as described in 6 Prerequisites The user should be familiar with the following System hardware Data acquisition card eg Q2USB in 2 Amplifier eg VoltPAQ in 4 Main components of the SRV02 ie DC motor and sensors such as the potentiometer 6 Basics of Simulink SRV02 Workbook Student Version v 10 A1 Applying Voltage to SRV02 Motor Here are the basic steps to apply a voltage to the SRV02 motor using QUARC 1 Make a Simulinkmodel that interacts with your installed dataacquisition device using blocks from the QUARC Targets library This is explained in Section A11 2 From the Simulinkmodel build realtime code as shown in Section A12 and 3 Execute the code as explained in Section A13 A11 Making the Simulink Model In this section we will make a Simulinkmodel as shown in Figure A1 using QUARCblocks to feed a sinusoidal voltage to the SRV02 dc motor The blocks from the QUARC Targets library are used to interact with a data acquisition board eg Quanser Q2USB or Q8USB device Figure A1 Simulink model used with QUARC to apply voltage to SRV02 Follow these steps to make the Simulinkdiagram 1 Load the Matlabsoftware 2 Create a new Simulinkdiagram To do this go to File New Model item in the menu bar 3 Open the Simulink Library Browser window by clicking on the View Library Browser item in the Simulink menu bar or clicking on the Simulink icon 4 Expand the QUARC Targets item and go to the Data Acquisition Generic Configuration folder as shown in Figure A2 5 Clickanddrag the HIL Initialize block from the library window into the blank Simulinkmodel This block is used to configure your dataacquisition device eg the Quanser Q2USB or Q8USB hardwareintheloop HIL boards 6 In the Library Browser go to the Data Acquisition Generic Immediate IO category This contains various blocks used to interact with actuators and sensors 7 Clickanddrag the HIL Write Analog block from the library into the Simulinkdiagram This block is used to output a voltage from an Analog Output channel ie digitaltoanalog DA channel on the dataacquisition device SRV02 Workbook Student Version 66 Figure A2 QUARC Targets in SimulinkLibrary Browser 8 Add the Signal Generator block found in the Simulink Source folder and the Slider Gain block from the Simulink Math Operations category into the Simulinkmodel Connect the blocks as shown in A1 9 Doubleclick on the HIL Initialize block In the Board type field select the board that is installed in your PC For example if you have a Quanser Q2USB board then select q2 usb If more than one of the same board is installed eg two Q2USB devices ensure the Board number field is set correctly eg if two boards are used then choose either 0 or 1 10 Go to the Analog Output pane shown in Figure A3 Make sure the Analog output channels field includes 0 This will ensure 0 V is output from Analog Output channel 0 when the QUARC controller is stopped For more information click on the Help button Otherwise click on the OK button and proceed Note If you are using a NI DAQ device make sure you enter 0 in the Analog Output channel box The analog output channels for the NI boards are not selected by default 11 Doubleclick on the HIL Write Analog block Make sure Board name is set to HIL1 ie points to the HIL Initialize block Set Channels to 0 default setting Recall that as instructed in Reference 6 the dc motor is connected to Analog Output Channel 0 on the hardwareintheloop board Therefore Channels should be set to 0 Set Sample time to 1 default setting This implies that the sampling interval is inherited from the previous block 12 Click on the OK button to save and close the HIL Write Analog block properties 13 Save the Simulinkmode by selecting the File Save item in the menu bar or clicking on the Save icon SRV02 Workbook Student Version v 10 Figure A3 Configuring Analog Output channel on DAQ device A12 Compiling the Model The Simulinkmodel we made in Section A1 can now be used by QUARC to generate code When you execute this code a voltage is sent to the SRV02 Follow these steps to generate code from a Simulinkdiagram 1 In the Simulinkdiagram made in Section A1 go to the QUARC Set default options item to set the correct RealTime Workshop parameters and setup the Simulinkmodel for external use as opposed to the simulation mode 2 To view the compiler options shown in Figure A4 go to QUARC Options in the Simulinkmodel tool bar 3 RealTime Workshop pane System target file is set to Target Language Compiler file quarc windowstlc Make command is set to make rtw and the Template makefile is set to quarc default tmf file 4 Solver pane Stop time is set to inf in order for the code to be executed continuously until it is stopped manually by the user Alternatively the Stop time parameter can be set to the desired duration code will cease executing when the stop time value is reached Type parameter is set to Fixedstep When compiling realtime code the solver must be fixedstep as opposed to variable step which can be used in simulations Solver is set to discrete There are no continuous blocks inside the designed Simulink model therefore having a discrete solver is fine However if an Integrator block or another continuous system were be added then the Solver field would have to be changed to an integration method such as ode1 Euler Fixedstep size field sets the sampling interval or sampling time of the controller By default this is set to 0002 seconds which is a sampling rate of 500 Hz SRV02 Workbook Student Version 68 Figure A4 Default QUARC solver settings 5 Click on the OK button to close the Configuration Parameters window 6 Select the QUARC Build item Various lines in the MatlabCommand Window should be displayed as the model is being compiled 7 Once done compiling a QUARC Windows executable file along with a folder containing various C and Matlabfiles are generated Note that once the executable is created the folder is no longer needed If you like you can remove the executable and associated code folder may be removed from the current directory by clicking on QUARC Clean item See 5 for more information about configuring QUARC A13 Running QUARC Code Once the Simulinkmodel has been compiled the code can be executed and the voltage set in the Simulinkmodel can be sent to the SRV02 motor Here are the steps to follow 1 Power ON your power amplifier eg Quanser VoltPAQ 2 To begin executing the code click on the QUARC Start item in the Simulinkmodel The SRV02 external gears on the SRV02 should begin rotating backandforth This command actually does two things it connects to the target and then executes the code Alternatively users may decide to go through these steps individually Option 1 In the Simulinkmodel tool bar click on the Connect to target icon and then click on the Run icon These buttons are shown in Figure A5 Option 2 Select the Simulation Connect to target item from the menu bar and the select Simulation Start RealTime Code item 3 Doubleclick on the Signal Generator block to open its parameter window 4 Set the Frequency field to 05 Hz and click on the OK button Notice how the parameter change effects the SRV02 immediately the gears on the SRV02 begin to switch backandforth slowly SRV02 Workbook Student Version v 10 Figure A5 Simulinkmodel toolbar connect to target and compilation 5 Vary the value of the Slider Gain block between 0 and 2 Examine how the angular rate of the SRV02 gears change proportionally with the amplitude of the sine wave 6 Select the QUARC Stop item to stop the code execution or click on the Stop button in the Simulinkmodel tool bar 7 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 70 A2 Reading Position using Potentiometer In this section the Simulinkmodel previously designed in Section A1 is modified to obtain readings from the potentiometer sensor A21 Reading the Potentiometer Voltage Follow the procedure below to design the Simulinkdiagram as shown in Figure A6 to read the potentiometer voltage Figure A6 Simulinkmodel used with QUARC to read potentiometer 1 From the Generic Timebases category in the SimulinkLibrary Browser clickanddrag the HIL Read Analog Timebase block into the Simulinkdiagram created previously in Section A1 This block will be used to read a voltage from an Analog Input channel ie analogtodigital AD on the dataacquisition device Note Using a Timebase type block causes the running model to be triggered by the hardware timer on the dataacquisition board as opposed to the system clock This increases performance of the controller by reducing jitter and allowing for greater sampling rates If you want to use system clock instead some DAQ cards do not support hardwarebased timing see 5 for details then use blocks from the Immediate IO category instead 2 Recall that as instructed in 6 the potentiometer is connected to Analog Input 0 on the DAQ board Therefore the default setting of 0 in the block is fine 3 Add a Scope block from the Simulink Sinks folder in the Library Browser and connect it to the output of the HIL Read Analog Timebase block as shown in Figure A6 4 Set the Frequency parameter in the Signal Generator block to 10 Hz and the Slider Gain block to 1 5 Doubleclick on the Scope block to open the scope 6 Save the Simulinkmodel if you want to save the model as a different file go to Save As 7 Power ON the power amplifier 8 Go to QUARC Build to compile the code 9 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the Scope should display the potentiometer readings similar to Figure A7 Notice that the readings shown are the voltage output of the potentiometer and not an angular measurement in degrees or radians SRV02 Workbook Student Version v 10 Figure A7 Reading raw voltage from the SRV02 potentiometer Note If the SRV02 gears are rotating but the scope is not plotting any data then you must reconfigure the RTW Signal Triggering properties inside the Simulinkdiagram See the Signal Triggering section under QUARC Basics in 5 for more information 10 Vary the sine wave frequency between 01 and 2 Hz and the Slider Gain value between 0 and 2 Notice how the controller is updated in realtime and the measurement in the scope changes with the new parameters Note The potentiometer has an electrical range of 352 degrees across 5 V 6 As a result the poten tiometer outputs a discontinous voltage signal as seen in Figure A8 Then a disadvantage is that you cannot surpass the 180 degree range when controlling the position or take the derivative of this sensor to control velocity Figure A8 Potentiometer reading when encountering its discontinuity 11 Stop the code by clicking on QUARC Stop A22 Measuring Position The Simulinkmodel will now be modified to read the load angle from the potentiometer and the voltage commanded to the motor as shown in Figure A9 SRV02 Workbook Student Version 72 Figure A9 Simulinkmodel used with QUARC to send voltage to the SRV02 and read its load shaft angle using potentiometer Modify the Simulinkdiagram built in the previous section following these steps 1 Label the Scope block that is presently connected to the HIL Read Analog Timebase block to theta l deg This will display the angular measurement of the load gear in degrees 2 Add a Scope block from the Simulink Sinks folder in the Library Browser and connect it to the output of the Slider Gain block as shown in Figure A9 above Label the Scope block Vm V which stands for the input motor voltage 3 From the Simulink Math Operations category in the Library Browser add two Gain blocks into the Simulinkmodel 4 Connect the gain blocks as illustrated in Figure A9 One gain block between the Amplifier PreCompensation and HIL Write Analog blocks and label it Motor Calibration VV Another gain block between the HIL Read Analog Timebase and theta l Scope blocks and denote it Potentiometer Calibration degV 5 Recompile the Simulinkmodel ie click on QUARC Build 6 Click on QUARC Start to run the code 7 Open the Vm V and theta l deg scopes 8 In the Signal Generator set the Frequency parameter to 025 Hz 9 Set the Slider Gain block to 1 10 Currently when the voltage goes positive the load gear rotates in the clockwise direction However the desired convention is for the load gear to rotate in the counterclockwise direction when the voltage goes positive Thus set the Motor Calibration VV block to 1 11 As described in 6 the potentiometer outputs between 5 V when it rotated 352 degrees Enter the value 35210 in the Potentiometer Calibration degVblock 12 In the theta l deg scope click on the Autoscale icon so the yaxis range is increased and the full signal can be viewed 13 Set the Slider Gain block to 0 14 Rotate the load gear manually and examine the corresponding response in the theta l deg scope Confirm that indeed the correct measurement is being taken 15 Position the load gear such that 0 is read in the theta l deg scope SRV02 Workbook Student Version v 10 16 Set the Slider Gain block to 1 17 Examine the relationship between the input voltage and load position When the input voltage increases in the positive direction the potentiometer angle decreases Add a negative sign to the Potentiometer Calibration degV block so the entered value becomes 35210 Now the angular position of the load gear displayed in the theta l deg scope reads increasingly positive when the commanded motor input voltage ie signal in the Vm V scope is positive Note The theoretical model assumes that the velocity increases when the voltage is positive The feedback control design is based on the model Therefore it is imperative that the actual system follows the same conventions as the model that will be developed Figure A10 Sinusoidal input voltage Figure A11 Load gear position reading using potentiometer 18 Select the QUARC Stop item to stop the code from running 19 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 74 A3 Measuring Speed using Tachometer In this section we will modify the Simulinkdiagram designed in Section A2 to include the readings from the tachometer Before continuing please ensure that the SRV02 unit being used has a tachometer ie SRV02T option Figure A12 Simulinkmodel used with QUARC to send voltage to SRV02 and read the potentiometer and tachome ter sensors Using the Simulinkdiagram built in Section A2 go through this procedure to add the tachometer functionality 1 Doubleclick on the HIL Read Analog Timebase block to open its properties 2 As detailed in 6 the tachometer is connected to Analog Input 1 on the hardwareintheloop board To add a channel set the Analog channels field to 01 and click on the OK button 3 Add a Scope block and a Gain block from Library Browser into the Simulinkmodel 4 Connect the Scope and Gain blocks as depicted in Figure A12 above Connect the Gain block to the output of Channel 1 from the HIL Read Analog Timebase block and label it Tachometer Calibration krpmV Connect the output of this gain block to the input of the Scope block and label the scope w l rpm The speed of the load gear is denoted by the ωl This scope will display the measured speed of the load gear in thousand revolutions per minute 5 Set the Signal Generator Frequency parameter to 10 Hz and the Slider Gain block to 1 6 Open the Vm V and the w l krpm scopes 7 Power ON the amplifier 8 Go to QUARC Build to compile the code 9 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the w l rpmV scope should display the tachometer readings Since the Tachometer Calibration krpmV gain has not been configured yet the scope is displaying the tachometer output voltage which is proportional to the speed of the load shaft SRV02 Workbook Student Version v 10 10 The backemf constant of the tachometer sensor is 15 mVrpm However the measurement is taken directly from the motor itself see 6 Thus to read the velocity of the gear the tachometer calibration gain must be divided by the gear ratio Enter 1 15 70 in the Tachometer Calibration krpmV gain block when using the SRV02 in the highgear configuration or 1 15 14 if using the lowgear configuration Note The measurement will be very small Click on the Autoscale icon in the scope to zoom up on the signal Alternatively the yrange of the scope can be set manually To do this rightclick on the yaxis select Axes Properties from the dropdown menu and set the desired yrange values 11 Examine the relationship between the input voltage and load speed When the input voltage increases in the positive direction the tachometer velocity decreases Similar to the potentiometer the speed of the load shaft should go positive when the input voltage is positive To fix this add a negative sign to the Tachometer Calibration krpmV block so the entered value becomes 1 15 70 or 1 15 14 for lowgear The input voltage and load velocity scopes should read as shown in Figure A13 and Figure A14 Note If you want the measurement to be in RPM instead of kRPM enter 1000 15 70 gear or 1000 15 14 for lowgear Figure A13 Sinusoidal input voltage Figure A14 High gear velocity reading using tachometer 12 Select the QUARC Stop item to stop the code from running 13 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 76 A4 Measuring Position using Encoder The Simulinkdiagram designed previously is modified to include an encoder measurement as illustrated in Figure A15 below Before continuing please ensure that the SRV02 unit being used has an encoder ie SRV02E option Figure A15 Simulinkmodel used with QUARC to send voltage to SRV02 and reads the potentiometer tachometer and encoder sensors Using the Simulinkmodel designed in either Section A2 or A3 follow this procedure to add encoder functionality 1 From the QUARC Targets Data Acquisition Generic Immediate IO category in the Library Browser add a HIL Read Encoder block 2 Recall that as instructed in 6 the encoder is connected to Encoder Input 0 on the data acquisition board The HIL Read Encoder block is already configured for to read channel 0 and the default encoder configurations in the HIL Initialize block are fine but keep in mind that these can be changed 3 Add a Gain block and a Scope block from the Math Operations and Sinks folders in the Library Browser respectively into the Simulinkmodel 4 Connect the scope and gain blocks as depicted in Figure A15 Connect the HIL Read Timebase block output e0 to a Gain block and label it Encoder Calibration degcount Connect the output of this gain block to the input of the Scope block and label the scope enc theta l deg This scope will display the measured angular position of the load gear in degrees 5 Set the Frequency parameter in the Signal Generator block to 10 Hz and the Slider Gain block to 1 6 Open the Vm V and enc theta l deg scopes 7 Save the Simulinkmodel you may want to save the model as a different file 8 Power ON the power amplifier 9 Go to QUARC Build to compile the code SRV02 Workbook Student Version v 10 10 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the enc theta l deg should display the encoder readings Since the Encoder Calibration degcount gain has not been configured yet the scope is displaying the number of counts from the encoder output which is proportional to the position of the load shaft Note The measurement will be very large Click on the Autoscale icon in the scope to zoom out and view the entire signal Alternatively the yrange of the scope can be set manually To do this rightclick on the yaxis select Axes Properties from the dropdown menu and set the desired yrange values 11 As discussed in 6 the encoder outputs 4096 counts for every full revolution To measure the load gear angle set the Encoder Calibration degcount gain block to 360 4096 degrees per count 12 The measurement will be very small Click on the Autoscale icon in the scope to zoom up on the signal or adjust the range of the yaxis manually The input voltage and position scopes should appear similarly as shown in Figure A16 and Figure A17 Note that no further calibration is needed since the encoder position increases when the input voltage goes positive Figure A16 Sinusoidal input voltage Figure A17 Position reading us ing encoder 13 Select the QUARC Stop item to stop the code from running 14 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 78 A5 Saving Data The scopes in the Simulinkmodel can be configured to save variables in the Matlabworkspace For instance to configure the load gear position scope theta l deg in the Simulinkmodel from Section A2 perform the following 1 Open the theta l deg scope 2 Click on Parameters icon and select the Data History tab as shown in Figure A18 Select the Save data to workspace check box Set the Variable name field to a desired variable eg theta l Set Format to Array Figure A18 Adjusting scope parameters to save data Note By default the Limit data points to last box is set to 5000 This means that only the last 5000 points of data will be saved in the variable Thus given that the controller runs at 500 Hz this implies that the last 10 seconds of data shown in the theta l deg scope will be captured 3 Click on the OK button 4 Save the Simulinkmodel 5 Select QUARC Build to rebuild the model 6 Click on QUARC Run 7 Run the controller for a few seconds and stop QUARC 8 When the controller is stopped the variable theta l is saved to the workspace The variable is a twodimensional array with a maximum of 5000 elements The first vector is the running time and the second vector is the po sition of the load gear You can plot the data into a Matlab figure using a script like t theta l1 th l theta l2 plottth lr You can then add Matlabcommands such as xlabel ylabel and title to desribe the data and units you are plotting Note If the controller has not run for the full 10 seconds then it will have tfTs number of elements where tf is the duration of the controller and Ts is the sampling interval For instance if you ran QUARC for 4 seconds then there will be 40002 2000 elements SRV02 Workbook Student Version v 10 Figure A19 Plotting saved data 9 Running the script generates a Matlab figure as shown in Figure A19 Note Use the Matlabcommand ginput to measure points directly from the Matlab figure There are many different ways to save data for offline analysis eg saving data to a Matlab MAT file Go to 5 in the QUARC Basics Data Collection category for more information SRV02 Workbook Student Version 80 BIBLIOGRAPHY 1 Quanser Inc QUARC Installation Guide 2009 2 Quanser Inc Q2USB Users Manual 2010 3 Quanser Inc VoltPAQ Users Manual 2010 4 Quanser Inc QUARC User Manual 2011 5 Quanser Inc SRV02 User Manual 2011 SRV02 Workbook Student Version v 10 USER MANUAL SRV02 Rotary Servo Base Unit Set Up and Configuration Developed by Jacob Apkarian PhD Quanser Michel Lévis MASc Quanser Hakan Gurocak PhD Washington State University CAPTIVATE MOTIVATE GRADUATE Solutions for teaching and research Made in Canada INFOQUANSERCOM 19059403575 QUANSERCOM Ten modules to teach controls from the basic to advanced level SRV02 Base Unit Flexible Link Inverted Pendulum Ball and Beam MultiDOF Torsion 2 DOF Inverted Pendulum 2 DOF Robot Flexible Joint GyroStable Platform Double Inverted Pendulum 2 DOF Ball Balancer With the SRV02 Base Unit you can select from 10 addon modules to create experiments of varying complexity across a wide range of topics disciplines and courses All of the experimentsworkstations are compatible with LabVIEW and MATLABSimulink To request a demonstration or a quote please email infoquansercom 2011 Quanser Inc All rights reserved LabVIEW is a trademark of National Instruments MATLAB and Simulink are registered trademarks of The MathWorks Inc Quanser educational solutions are powered by
Send your question to AI and receive an answer instantly
Recommended for you
1
Controle de Velocidade de Fita Magnetica com Motor CC - Projeto de Controlador e Observador de Estados
Laboratório de Sistemas de Controle
UFAM
3
Laboratório de Sistemas de Controle - Análise do Comportamento Dinâmico de Sistemas de 1a Ordem
Laboratório de Sistemas de Controle
UFAM
3
Projeto Final Sistemas de Controle
Laboratório de Sistemas de Controle
UFAM
22
LAB02 - Análise do Comportamento Dinâmico de Sistemas de Primeira Ordem
Laboratório de Sistemas de Controle
UFAM
5
Projeto de Sistema de Controle no Domínio do Tempo - Engenharia Elétrica
Laboratório de Sistemas de Controle
UFAM
2
Lista de Exercícios: Representação em Frequência
Laboratório de Sistemas de Controle
IFBA
17
Análise e Simulação da Série de Fourier em Sinais Periódicos
Laboratório de Sistemas de Controle
IFBA
5
Análise de Sistemas em Frequência: Defasagem e Escalonamento
Laboratório de Sistemas de Controle
IFBA
10
Exercício 2 - Registro de Atividades
Laboratório de Sistemas de Controle
IFBA
16
Construção Termometro - Paper e Calculo de Erro
Laboratório de Sistemas de Controle
UFABC
Preview text
STUDENT WORKBOOK SRV02 Base Unit Experiment For MatlabSimulink Users Standardized for ABET Evaluation Criteria Developed by Jacob Apkarian PhD Quanser Michel Lévis MASc Quanser Hakan Gurocak PhD Washington State University Solutions for teaching and research Made in Canada With the SRV02 Base Unit you can select from 10 addon modules to create experiments of varying complexity across a wide range of topics disciplines and courses All of the experimentsworkstations are compatible with MATLABSimulink To request a demonstration or a quote please email infoquansercom 2011 Quanser Inc All rights reserved MATLAB and Simulink are registered trademarks of The MathWorks Inc SRV02 Base Unit Flexible Link Inverted Pendulum Ball and Beam MultiDOF Torsion 2 DOF Inverted Pendulum 2 DOF Robot Flexible Joint GyroStable Platform Double Inverted Pendulum 2 DOF Ball Balancer CAPTIVATE MOTIVATE GRADUATE INFOQUANSERCOM 19059403575 QUANSERCOM Student Workbook SRV02 Base Unit Experiment for MatlabSimulink Users Ten modules to teach controls from the basic to advanced level ABET Inc is the recognized accreditor for college and university programs in applied science computing engineering and technology Among the most respected accreditation organizations in the US ABET has provided leadership and quality assurance in higher education for over 75 years SRV02 educational solutions are powered by Course material complies with c 2011 Quanser Inc All rights reserved Quanser Inc 119 Spy Court Markham Ontario L3R 5H6 Canada infoquansercom Phone 19059403575 Fax 19059403576 Printed in Markham Ontario For more information on the solutions Quanser Inc offers please visit the web site at httpwwwquansercom This document and the software described in it are provided subject to a license agreement Neither the software nor this document may be used or copied except as specified under the terms of that license agreement All rights are reserved and no part may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopying recording or otherwise without the prior written permission of Quanser Inc ACKNOWLEDGEMENTS Quanser Inc would like to thank Dr Hakan Gurocak Washington State University Vancouver USA for rewriting this manual to include embedded outcomes assessment SRV02 Workbook Student Version ii CONTENTS Preface v 1 SRV02 Modeling 1 11 Background 2 111 Modeling Using FirstPrinciples 2 112 Modeling Using Experiments 5 12 PreLab Questions 8 13 Lab Experiments 9 131 Frequency Response Experiment 9 132 Bump Test Experiment 12 133 Model Validation Experiment 13 134 Results 14 14 System Requirements 15 141 Overview of Files 15 142 Configuring the SRV02 and the Lab Files 15 15 Lab Report 17 151 Template for Content 17 152 Tips for Report Format 18 2 SRV02 Position Control 19 21 Background 20 211 Desired Position Control Response 20 212 PV Controller Design 23 213 PIV Controller 24 22 PreLab Questions 26 23 Lab Experiments 27 231 Step Response Using PV Controller 27 232 Ramp Response Using PV Controller 30 233 Ramp Response with No SteadyState Error 32 234 Results 33 24 System Requirements 34 241 Overview of Files 34 242 Setup for Position Control Simulations 34 243 Setup for Position Control Implementation 35 25 Lab Report 36 251 Template for Content Step Response Experiment 37 252 Template for Content Ramp Response with PV 38 253 Template for Content Ramp Response with No SteadyState Error 39 254 Tips for Report Format 40 3 SRV02 Speed Control 41 31 Background 42 311 Desired Response 42 312 PI Control Design 43 313 Lead Control Design 45 314 Sensor Noise 50 SRV02 Workbook Student Version v 10 32 PreLab Questions 51 33 Lab Experiments 52 331 Step Response with PI Control 52 332 Step Response with LEAD Control 55 333 Results 56 34 System Requirements 58 341 Overview of Files 58 342 Setup for Speed Control Simulation 58 343 Setup for Speed Control Implementation 59 35 Lab Report 60 351 Template for Content PI Control Experiments 61 352 Template for Content Lead Control Experiments 62 353 Tips for Report Format 63 A SRV02 QUARC Integration 65 A1 Applying Voltage to SRV02 Motor 66 A11 Making the Simulink Model 66 A12 Compiling the Model 68 A13 Running QUARC Code 69 A2 Reading Position using Potentiometer 71 A21 Reading the Potentiometer Voltage 71 A22 Measuring Position 72 A3 Measuring Speed using Tachometer 75 A4 Measuring Position using Encoder 77 A5 Saving Data 79 SRV02 Workbook Student Version iv PREFACE Every laboratory chapter in this manual is organized into four sections Background section provides all the necessary theoretical background for the experiments You should read this section first to prepare for the PreLab questions and for the actual lab experiments PreLab Questions section provides targetted questions for preliminary calculations that need to be done prior to the lab experiments You should go through these questions and try to answer them using the background materials and the references given at the end of the manual Lab Experiments section provides you with stepbystep instructions to conduct the lab experiments and to record the collected data System Requirements section describes all the details of how to configure the hardware and software to conduct the experiments It is assumed that the hardware and software configuration have been completed by the instructor or the teaching assistant prior to the lab sessions If not you can configure the systems by following the instructions given in this section When you write your lab report you should use the specific template for content given at the end of each laboratory chapter A section on Tips for Report Format is also provided at the end of each laboratory chapter SRV02 Workbook Student Version v 10 vi LABORATORY 1 SRV02 MODELING The objective of this experiment is to find a transfer function that describes the rotary motion of the SRV02 load shaft The dynamic model is derived analytically from classical mechanics principles and using experimental methods Topics Covered Deriving the dynamics equation and transfer function for the SRV02 servo plant using the firstprinciples Obtaining the SRV02 transfer function using a frequency response experiment Obtaining the SRV02 transfer function using a bump test Tuning the obtained transfer function and validating it with the actual system response Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 11 Background The angular speed of the SRV02 load shaft with respect to the input motor voltage can be described by the following firstorder transfer function Ωls Vms K τs 1 111 where Ωls is the Laplace transform of the load shaft speed ωlt Vms is the Laplace transform of motor input voltage vmt K is the steadystate gain τ is the time constant and s is the Laplace operator The SRV02 transfer function model is derived analytically in Section 111 and its K and τ parameters are evaluated These are known as the nominal model parameter values The model parameters can also be found experimentally Sections 1121 and 1122 describe how to use the frequency response and bumptest methods to find K and τ These methods are useful when the dynamics of a system are not known for example in a more complex system After the lab experiments the experimental model parameters are compared with the nominal values 111 Modeling Using FirstPrinciples 1111 Electrical Equations The DC motor armature circuit schematic and gear train is illustrated in Figure 11 As specified in 6 recall that Rm is the motor resistance Lm is the inductance and km is the backemf constant Figure 11 SRV02 DC motor armature circuit and gear train The backemf electromotive voltage ebt depends on the speed of the motor shaft ωm and the backemf constant of the motor km It opposes the current flow The back emf voltage is given by ebt kmωmt 112 Using Kirchoffs Voltage Law we can write the following equation Vmt RmImt Lm dImt dt kmωmt 0 113 Since the motor inductance Lm is much less than its resistance it can be ignored Then the equation becomes Vmt RmImt kmωmt 0 114 SRV02 Workbook Student Version 2 Solving for Imt the motor current can be found as Imt Vmt kmωmt Rm 115 1112 Mechanical Equations In this section the equation of motion describing the speed of the load shaft ωl with respect to the applied motor torque τm is developed Since the SRV02 is a one degreeoffreedom rotary system Newtons Second Law of Motion can be written as J α τ 116 where J is the moment of inertia of the body about its center of mass α is the angular acceleration of the system and τ is the sum of the torques being applied to the body As illustrated in Figure 11 the SRV02 gear train along with the viscous friction acting on the motor shaft Bm and the load shaft Bl are considered The load equation of motion is Jl dωlt dt Blωlt τlt 117 where Jl is the moment of inertia of the load and τl is the total torque applied on the load The load inertia includes the inertia from the gear train and from any external loads attached eg disc or bar The motor shaft equation is expressed as Jm dωmt dt Bmωmt τmlt τmt 118 where Jm is the motor shaft moment of inertia and τml is the resulting torque acting on the motor shaft from the load torque The torque at the load shaft from an applied motor torque can be written as τlt ηgKgτmlt 119 where Kg is the gear ratio and ηg is the gearbox efficiency The planetary gearbox that is directly mounted on the SRV02 motor see 6 for more details is represented by the N1 and N2 gears in Figure 11 and has a gear ratio of Kgi N2 N1 1110 This is the internal gear box ratio The motor gear N3 and the load gear N4 are directly meshed together and are visible from the outside These gears comprise the external gear box which has an associated gear ratio of Kge N4 N3 1111 The gear ratio of the SRV02 gear train is then given by Kg KgeKgi 1112 Thus the torque seen at the motor shaft through the gears can be expressed as τmlt τlt ηgKg 1113 Intuitively the motor shaft must rotate Kg times for the output shaft to rotate one revolution θmt Kgθlt 1114 SRV02 Workbook Student Version v 10 We can find the relationship between the angular speed of the motor shaft ωm and the angular speed of the load shaft ωl by taking the time derivative ωmt Kgωlt 1115 To find the differential equation that describes the motion of the load shaft with respect to an applied motor torque substitute 1113 1115 and 117 into 118 to get the following JmKg dωlt dt BmKgωlt Jl dωlt dt Blωlt ηgKg τmt 1116 Collecting the coefficients in terms of the load shaft velocity and acceleration gives ηgK2 gJm Jldωlt dt ηgK2 gBm Blωlt ηgKgτmt 1117 Defining the following terms Jeq ηgK2 gJm Jl 1118 Beq ηgK2 gBm Bl 1119 simplifies the equation as Jeq dωlt dt Beqωlt ηgKgτmt 1120 1113 Combining the Electrical and Mechanical Equations In this section the electrical equation derived in Section 1111 and the mechanical equation found in Section 1112 are brought together to get an expression that represents the load shaft speed in terms of the applied motor voltage The motor torque is proportional to the voltage applied and is described as τmt ηmktImt 1121 where kt is the currenttorque constant NmA ηm is the motor efficiency and Im is the armature current See 6 for more details on the SRV02 motor specifications We can express the motor torque with respect to the input voltage Vmt and load shaft speed ωlt by substituting the motor armature current given by equation 115 in Section 1111 into the currenttorque relationship given in equation 1121 τmt ηmkt Vmt kmωmt Rm 1122 To express this in terms of Vm and ωl insert the motorload shaft speed equation 1115 into 1121 to get τmt ηmkt Vmt kmKgωlt Rm 1123 If we substitute 1123 into 1120 we get Jeq d dtwlt Beqwlt ηgKgηmkt Vmt kmKgωlt Rm 1124 After collecting the terms the equation becomes d dtwlt Jeq kmηgK2 gηmkt Rm Beq ωlt ηgKgηmktVmt Rm 1125 SRV02 Workbook Student Version 4 This equation can be rewritten as d dtwlt Jeq Beqvωlt Am Vmt 1126 where the equivalent damping term is given by Beqv ηgK2 gηmktkm BeqRm Rm 1127 and the actuator gain equals Am ηgKgηmkt Rm 1128 112 Modeling Using Experiments In Section 111 you learned how the system model can be derived from the firstprinciples A linear model of a system can also be determined purely experimentally The main idea is to experimentally observe how a system reacts to different inputs and change structure and parameters of a model until a reasonable fit is obtained The inputs can be chosen in many different ways and there are a large variety of methods In Sections 1121 and 1122 two methods of modeling the SRV02 are outlined 1 frequency response and 2 bump test 1121 Frequency Response In Figure 12 the response of a typical firstorder timeinvariant system to a sine wave input is shown As it can be seen from the figure the input signal u is a sine wave with a fixed amplitude and frequency The resulting output y is also a sinusoid with the same frequency but with a different amplitude By varying the frequency of the input sine wave and observing the resulting outputs a Bode plot of the system can be obtained as shown in Figure 13 Figure 12 Typical frequency response The Bode plot can then be used to find the steadystate gain ie the DC gain and the time constant of the system The cuttoff frequency ωc shown in Figure 13 is defined as the frequency where the gain is 3 dB less than the maximum gain ie the DC gain When working in the linear nondecibel range the 3 dB frequency is defined as the frequency where the gain is 1 2 or about 0707 of the maximum gain The cutoff frequency is also known as the bandwidth of the system which represents how fast the system responds to a given input SRV02 Workbook Student Version v 10 Figure 13 Magnitude Bode plot The magnitude of the frequency response of the SRV02 plant transfer function given in equation 111 is defined as Gw v w Ωlw jVmw j 1129 where ω is the frequency of the motor input voltage signal Vm We know that the transfer function of the system has the generic firstorder system form given in Equation 111 By substituting s j w in this equation we can find the frequency response of the system as ΩlwjVmwj Kτω j 1 1130 Then the magnitude of it equals GwIvw K1 τ2 w2 1131 Lets call the frequency response model parameters Kef and τef to differentiate them from the nominal model parameters K and τ used previously The steadystate gain or the DC gain ie gain at zero frequency of the model is Kef GwIv 0 1132 1122 Bump Test The bump test is a simple test based on the step response of a stable system A step input is given to the system and its response is recorded As an example consider a system given by the following transfer function YsUs Kτ s 1 1133 The step response shown in Figure 14 is generated using this transfer function with K 5 radVs and τ 005 s The step input begins at time t0 The input signal has a minimum value of umin and a maximum value of umax The resulting output signal is initially at y0 Once the step is applied the output tries to follow it and eventually settles at its steadystate value yss From the output and input signals the steadystate gain is K ΔyΔu 1134 Figure 14 Input and output signal used in the bump test method where y yss y0 and u umax umin In order to find the model time constant τ we can first calculate where the output is supposed to be at the time constant from yt1 0632yss y0 1135 Then we can read the time t1 that corresponds to yt1 from the response data in Figure 14 From the figure we can see that the time t1 is equal to t1 t0 τ 1136 From this the model time constant can be found as τ t1 t0 1137 Going back to the SRV02 system a step input voltage with a time delay t0 can be expressed as follows in the Laplace domain Vms Av es t0 s 1138 where Av is the amplitude of the step and t0 is the step time ie the delay If we substitute this input into the system transfer function given in Equation 111 we get Ωls KAv es t0 τ s 1 s 1139 We can then find the SRV02 load speed step response wlt by taking inverse Laplace of this equation Here we need to be careful with the time delay t0 and note that the initial condition is ωl0 ωlt0 ωlt K Av 1 e tt0 τ ωl t0 1140 SRV02 Workbook Student Version v 10 12 PreLab Questions Before you start the lab experiments given in Section 13 you should study the background materials provided in Section 11 and work through the questions in this Section 1 In Section 1113 we obtained an equation 1126 that described the dynamic behavior of the load shaft speed as a function of the motor input voltage Starting from this equation find the transfer function Ωls Vms 2 Express the steadystate gain K and the time constant τ of the process model Equation 111 in terms of the Jeq Beqv and Am parameters 3 Calculate the Beqv and Am model parameters using the system specifications given in 6 The parameters are to be calculated based on an SRV02ET in the highgear configuration 4 Calculate the moment of inertia about the motor shaft Note that Jm Jtach Jmrotor where Jtach and Jmrotor are the moment of inertia of the tachometer and the rotor of the SRV02 DC motor respectively Use the specifications given in 6 5 The load attached to the motor shaft includes a 24tooth gear two 72tooth gears and a single 120tooth gear along with any other external load that is attached to the load shaft Thus for the gear moment of inertia Jg and the external load moment of inertia Jlext the load inertia is Jl Jg Jlext Using the specifications given in 6 find the total moment of inertia Jg from the gears Hint Use the definition of moment of inertia for a disc Jdisc mr2 2 6 Assuming the disc load is attached to the load shaft calculate the inertia of the disc load Jextl and the total load moment of inertia Jl 7 Evaluate the equivalent moment of inertia Jeq 8 Calculate the steadystate model gain K and time constant τ These are the nominal model parameters and will be used to compare with parameters that are later found experimentally 9 Referring to Section 1121 find the time constant τ of the frequency response model given in Equation 1131 Evaluate the magnitude of the transfer function at the cuttoff frequency ωc 10 Referring to Section 1122 find the steadystate gain of the step response and compare it with Equation 1134 Hint The the steadystate value of the load shaft speed can be defined as ωlss lim t ωlt 11 Evaluate the step response given in equation 1140 at t t0 τ and compare it with Equation 1134 SRV02 Workbook Student Version 8 13 Lab Experiments The main goal of this laboratory is to find a transfer function model that describes the rotary motion of the SRV02 load shaft as a function of the input voltage We can obtain this transfer function experimentally using one of the following two methods Frequency response or Bump test In this laboratory first you will conduct two experiments exploring how these methods can be applied to a real system Then you will conduct a third experiment to fine tune the parameters of the transfer functions you obtained and to validate them Experimental Setup The q srv02 mdl Simulink diagram shown in Figure 15 will be used to conduct the experiments The SRV02 ET subsystem contains QUARCblocks that interface with the DC motor and sensors of the SRV02 system as discussed in Reference 4 The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary to simulate the SRV02 system Thus both the measured and simulated load shaft speed can be monitored simultaneously given an input voltage Figure 15 q srv02 mdl Simulink diagram used to model SRV02 IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 142 to configure the lab files first 131 Frequency Response Experiment As explained in 1121 earlier the frequency response of a linear system can be obtained by providing a sine wave input signal to it and recording the resulting output sine wave from it In this experiment the input signal is the motor voltage and the output is the motor speed SRV02 Workbook Student Version v 10 In this method we keep the amplitude of the input sine wave constant but vary its frequency At each frequency setting we record the amplitude of the output sine wave The ratio of the output and input amplitudes at a given frequency can then be used to create a Bode magnitude plot Then the transfer function for the system can be extracted from this Bode plot 1311 Steadystate gain First we need to find the steadystate gain of the system This requires running the system with a constant input voltage To create a 2V constant input voltage follow these steps 1 In the Simulinkdiagram doubleclick on the Signal Generator block and ensure the following parameters are set Wave form sine Amplitude 10 Frequency 00 Units Hertz 2 Set the Amplitude V slider gain to 0 3 Set the Offset V block to 20 V 4 Open the load shaft speed scope w l rads and the motor input voltage scope V m V 5 Click on QUARC Build to compile the Simulink diagram 6 Select QUARC Start to run the controller The SRV02 unit should begin rotating in one direction The scopes should be reading something similar to Figures 16 and 17 Note that in the w l rads scope the yellow trace is the measured speed while the purple trace is the simulated speed generated by the SRV02 Model block Figure 16 Constant input motor voltage Figure 17 Load shaft speed re sponse to a constant input 7 Measure the speed of the load shaft and enter the measurement in Table 11 below under the f 0 Hz row The measurement can be done directly from the scope Alternatively you can use Matlabcommands to find the maximum load speed using the saved wl variable When the controller is stopped the w l rads scope saves the last 5 seconds of response data to the Matlabworkspace in the wl parameter It has the following structure wl1 is the time vector wl2 is the measured speed and wl3 is the simulated speed 8 Calculate the steadystate gain both in linear and decibel dB units as explained in 1121 Enter the resulting numerical value in the f 0 Hz row of Table 11 Also enter its nondecibel value in Table 12 in Section 134 SRV02 Workbook Student Version 10 1312 Gain at varying frequencies In this part of the experiment we will send an input sine wave at a certain frequency to the system and record the amplitude of the output signal We will then increment the frequency and repeat the same observation To create the input sine wave 1 Set the Offset V block to 0 V 2 Set the Amplitude V slider gain to 20 V 3 The SRV02 unit should begin rotating smoothly back and forth and the scopes should be reading a response similar to Figures 18 and 19 Figure 18 Input motor voltage scope Figure 19 Load shaft speed sine wave response 4 Measure the maximum positive speed of the load shaft at f 10 Hz input and enter it in Table 11 below As before this measurement can be done directly from the scope or preferably you can use Matlabcommands to find the maximum load speed using the saved wl variable 5 Calculate the gain of the system in both linear and dB units and enter the results in Table 11 6 Now increase the frequency to f 20 Hz by adjusting the frequency parameter in the Signal Generator block Measure the maximum load speed and calculate the gain Repeat this step for each of the frequency settings in Table 11 7 Using the Matlabplot command and the data collected in Table 11 generate a Bode magnitude plot Make sure the amplitude and frequency scales are in decibels When making the Bode plot ignore the f 0 Hz entry as the logarithm of 0 is not defined 8 Calculate the time constant τef using the obtained Bode plot by finding the cutoff frequency Label the Bode plot with the 3 dB gain and the cutoff frequency Enter the resulting time constant in Table 12 Hint Use the ginput command to obtain values from the Matlabfigure 9 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 10 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session SRV02 Workbook Student Version v 10 f Hz Amplitude V Maximum Load Speed rads GainGω radsV GainGω radsV dB 00 20 10 20 20 20 30 20 40 20 50 20 60 20 70 20 80 20 Table 11 Collected frequency response data 132 Bump Test Experiment In this method a step input is given to the SRV02 and the corresponding load shaft response is recorded Using the saved response the model parameters can then be found as discussed in Section 1122 To create the step input 1 Doubleclick on the Signal Generator block and ensure the following parameters are set Wave form square Amplitude 10 Frequency 04 Units Hertz 2 Set the Amplitude V slider gain to 15 V 3 Set the Offset V block to 20 V 4 Open the load shaft speed scope w l rads and the motor input voltage cope V m V 5 Click on QUARC Build to compile the Simulink diagram 6 Select QUARC Start to run the controller The gears on the SRV02 should be rotating in the same direction and alternating between low and high speeds The response in the scopes should be similar to Figures 110 and 111 Figure 110 Square input motor voltage Figure 111 Load shaft speed step response 7 Plot the response in Matlab Recall that the maximum load speed is saved in the Matlabworkspace under the wl variable SRV02 Workbook Student Version 12 8 Find the steadystate gain using the measured step response and enter it in Table 12 Hint Use the Matlabginput command to measure points off the plot 9 Find the time constant from the obtained response and enter the result in Table 12 10 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 11 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 133 Model Validation Experiment In this experiment you will adjust the model parameters you found in the previous experiments to tune the transfer function Our goal is to match the simulated system response with the parameters you found as closely as possible to the response of the actual system To create a step input 1 Doubleclick on the Signal Generator block and ensure the following parameters are set Wave form square Amplitude 10 Frequency 04 Units Hertz 2 Set the Amplitude V slider gain to 10 V 3 Set the Offset V block to 15 V 4 Open the load shaft speed scope w l rads and the motor input voltage scope V m V 5 Click on QUARC Build to compile the Simulinkdiagram 6 Select QUARC Start to run the controller The gears on the SRV02 should be rotating in the same direction and alternating between low and high speeds and the scopes should be as shown in figures 112 and 113 Recall that the yellow trace is the measured load shaft rate and the purple trace is the simulated trace By default the steadystate gain and the time constant of the transfer function used in simulation are set to K 1 radsV and τ 01s These model parameters do not accurately represent the system Figure 112 Input square volt age Figure 113 Speed step re sponse Simulation done with default model parameters K 1 and τ 01 7 Enter the command K 125 in the MatlabCommand Window SRV02 Workbook Student Version v 10 8 Update the parameters used by the Transfer Function block in the simulation by selecting the Edit Update Diagram item in the q srv02 mdl Simulinkdiagram and observe how the simulation changes 9 Enter the command tau 02 in the MatlabCommand Window 10 Update the simulation again by selecting the Edit Update Diagram and observe how the simulation changes 11 Vary the gain and time constant model parameters How do the gain and the time constant affect the system response 12 Enter the nominal values K and τ that were found in Section 12 in the MatlabCommand Window Update the parameters and examine how well the simulated response matches the measured one 13 If the calculations were done properly then the model should represent the actual system quite well However there are always some differences between each servo unit and as a result the model can always be tuned to match the system better Try varying the model parameters until the simulated trace matches the measured response better Enter these tuned values under the Model Validation section of Table 12 14 Provide two reasons why the nominal model does not represent the SRV02 with better accuracy 15 Create a Matlabfigure that shows the measured and simulated response of each method the nominal model the frequency response model and the bumptest model Enter the nominal values K and τ in the MatlabCommand Window update the parameters and examine the response Repeat for the frequency response parameters Kef and τef along with the bump test variables Keb and τeb 16 Explain how well the nominal model the frequency response model and the bumptest model represent the SRV02 system 17 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 18 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 134 Results Fill out Table 12 below with your results Section Description Symbol Value Unit 12 Nominal Values OpenLoop SteadyState Gain K OpenLoop Time Constant τ 131 Frequency Response Exp OpenLoop SteadyState Gain Kef OpenLoop Time Constant τef 132 Bump Test Exp OpenLoop SteadyState Gain Keb OpenLoop Time Constant τeb 133 Model Validation OpenLoop SteadyState Gain Kev OpenLoop Time Constant τev Table 12 Summary of results for the SRV02 Modeling laboratory SRV02 Workbook Student Version 14 14 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARC compatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 141 Overview of Files Table 13 Files supplied with the SRV02 Modeling laboratory File Name Description 01 SRV02 Modeling Student Manualpdf This laboratory guide contains prelab and inlab exer cises demonstrating how to model the Quanser SRV02 rotary plant The inlab exercises are explained using the QUARC software setup srv02 exp01 mdlm The main Matlabscript that sets the SRV02 motor and sensor parameters Run this file only to setup the lab oratory config srv02m Returns the configurationbased SRV02 model specifica tions Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP calc conversion constantsm Returns various conversions factors q srv02 mdlmdl Simulinkfile that implements the openloop controller for the SRV02 system using QUARC 142 Configuring the SRV02 and the Lab Files Before beginning the lab exercises the SRV02 device the q srv02 mdl Simulinkdiagram and the setup srv02 exp02m script must be configured Follow these steps to get the system ready for this lab 1 Set up the SRV02 in the highgear configuration and with the disc load as described in Reference 5 2 Load the Matlabsoftware 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 modeling files eg q srv02 mdlmdl 4 Doubleclick on the q srv02 mdlmdl file to open the Simulinkdiagram shown in Figure 15 5 Configure DAQ Doubleclick on the HIL Initialize block in the Simulinkdiagram and ensure it is configured for the DAQ device that is installed in your system For instance the block shown in Figure 15 is setup for the Quanser Q8 hardwareintheloop board See 1 for more information on configuring the HIL Initialize block SRV02 Workbook Student Version v 10 6 Configure Sensor The speed of the load shaft can be measured using various sensors Set the Spd Src Source block in q srv02 mdl as shown in Figure 15 as follows 1 to use tachometer 2 to use the encoder 7 It is recommended that the tachometer sensor be used to perform this laboratory However for users who do not have a tachometer with their servo eg SRV02 or SRV02E options they may choose to use the encoder with a highpass filter to get a velocity measurement 8 Go to the Current Directory window and doubleclick on the setup srv02 exp01 mdlm file to open the setup script for the q srv02 mdl Simulinkmodel 9 Configure setup script The beginning of the setup script is shown below Ensure the script is setup to match the configuration of your actual SRV02 device For example the script given below is setup for an SRV02ET plant in the highgear configuration mounted with a disc load and it is actuated using the Quanser VoltPAQ device with a motor cable gain of 1 See 6 for more information on SRV02 plant options and corresponding accessories Finally make sure MODELING TYPE is set to MANUAL SRV02 Configuration External Gear Configuration set to HIGH or LOW EXTGEARCONFIG HIGH Encoder Type set to E or EHR ENCODERTYPE E Is SRV02 equipped with Tachometer ie option T set to YES or NO TACHOPTION YES Type of Load set to NONE DISC or BAR LOADTYPE DISC Amplifier Gain set VoltPAQ amplifier gain to 1 KAMP 1 Power Amplifier Type set to VoltPAQ UPM1503 UPM2405 or Q3 AMPTYPE VoltPAQ DigitaltoAnalog Maximum Voltage V VMAXDAC 10 Lab Configuration Type of Controller set it to AUTO MANUAL MODELINGTYPE AUTO MODELINGTYPE MANUAL 10 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the MatlabCommand Window These are default model parameters and do not accurately represent the SRV02 system Calculated SRV02 model parameter K 1 radsV tau 01 s SRV02 Workbook Student Version 16 15 Lab Report When you prepare your lab report you can follow the outline given in Section 151 to build the content of your report Also in Section 152 you can find some basic tips for the format of your report 151 Template for Content I PROCEDURE I1 Frequency Response Experiment 1 Briefly describe the main goal of this experiment and the procedure Briefly describe the experimental procedure Section 1311 Steadystate gain Briefly describe the experimental procedure Section 1312 Gain at varying frequencies I2 Bump Test Experiment 1 Briefly describe the main goal of this experiment and the experimental procedure Section 132 I3 Model Validation Experiment 1 Briefly describe the main goal of this experiment and the experimental procedure Section 133 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Bode plot from step 7 in Section 1312 Gain at varying frequencies 2 Response plot from step 7 in Section 132 Bump Test Experiment 3 Response plot from step 15 in Section 133 Model Validation Experiment 4 Provide data collected in this laboratory from Table 11 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Frequency Response Experiment 1 Step 8 in Section 1311 Steadystate gain 2 Step 8 in Section 1312 Gain at varying frequencies III2 Bump Test Experiment 1 Steps 8 and 9 in Section 132 SRV02 Workbook Student Version v 10 IV CONCLUSIONS Interpret your results to arrive at logical conclusions 1 Steps 11 14 and 16 in Section 133 152 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version 18 LABORATORY 2 SRV02 POSITION CONTROL The objective of this laboratory is to develop feedback systems that control the position of the rotary servo load shaft Using the proportionalintegralderivative PID family controllers are designed to meet a set of specifications Topics Covered Design of a proportionalvelocity PV controller for position control of the servo load shaft to meet certain timedomain requirements Actuator saturation Design of a proportionalvelocityintegral PIV controller to track a ramp reference signal Simulation of the PV and PIV controllers using the developed model of the plant to ensure the specifications are met without any actuator saturation Implementation of the controllers on the Quanser SRV02 device to evaluate their performance Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 21 Background 211 Desired Position Control Response The block diagram shown in Figure 21 is a general unity feedback system with compensator controller Cs and a transfer function representing the plant Ps The measured output Ys is supposed to track the reference signal Rs and the tracking has to match to certain desired specifications Figure 21 Unity feedback system The output of this system can be written as Y s Cs Ps Rs Y s 211 By solving for Y s we can find the closedloop transfer function Y s Rs Cs Ps 1 Cs Ps 212 Recall in Laboratory SRV02 Modelling Section 1 the SRV02 voltagetospeed transfer function was derived To find the voltagetoposition transfer function we can put an integrator 1s in series with the speed transfer function effectively integrating the speed output to get position Then the resulting openloop voltagetoload gear position transfer function becomes Ps K s τs 1 213 As you can see from this equation the plant is a second order system In fact when a second order system is placed in series with a proportional compensator in the feedback loop as in Figure 21 the resulting closedloop transfer function can be expressed as Y s Rs ω2 n s2 2ζ ωn s ω2n 214 where ωn is the natural frequency and ζ is the damping ratio This is called the standard secondorder transfer function Its response proporeties depend on the values of ωn and ζ 2111 Peak Time and Overshoot Consider a secondorder system as shown in Equation 214 subjected to a step input given by Rs R0 s 215 with a step amplitude of R0 15 The system response to this input is shown in Figure 22 where the red trace is the response output yt and the blue trace is the step input rt The maximum value of the response is denoted by the variable ymax and it occurs at a time tmax For a response similar to Figure 22 the percent overshoot is found using PO 100 ymax R0 R0 216 SRV02 Workbook Student Version 20 Figure 22 Standard secondorder step response From the initial step time t0 the time it takes for the response to reach its maximum value is tp tmax t0 217 This is called the peak time of the system In a secondorder system the amount of overshoot depends solely on the damping ratio parameter and it can be calculated using the equation PO 100 e π ζ 1ζ2 218 The peak time depends on both the damping ratio and natural frequency of the system and it can be derived as tp π ωn 1 ζ2 219 Generally speaking the damping ratio affects the shape of the response while the natural frequency affects the speed of the response 2112 Steady State Error Steadystate error is illustrated in the ramp response given in Figure 23 and is denoted by the variable ess It is the difference between the reference input and output signals after the system response has settled Thus for a time t when the system is in steadystate the steadystate error equals ess rsst ysst 2110 where rsst is the value of the steadystate input and ysst is the steadystate value of the output We can find the error transfer function Es in Figure 21 in terms of the reference Rs the plant Ps and the compensator Cs The Laplace transform of the error is Es Rs Y s 2111 Solving for Y s from equation 213 and substituting it in equation 2111 yields Es Rs 1 Cs Ps 2112 SRV02 Workbook Student Version v 10 Figure 23 Steadystate error in ramp response We can find the the steadystate error of this system using the finalvalue theorem ess lim s0 s Es 2113 In this equation we need to substitute the transfer function for Es from 2112 The Es transfer function requires Rs Cs and Ps For simplicity let Cs1 as a compensator The Ps and Rs were given by equations 213 and 215 respectively Then the error becomes Es R0 s 1 K s τs1 2114 Applying the finalvalue theorem gives ess R0 lim s0 τ s 1 s τ s2 s K 2115 When evaluated the resulting steadystate error due to a step response is ess 0 2116 Based on this zero steadystate error for a step input we can conclude that the SRV02 is a Type 1 system 2113 SRV02 Position Control Specifications The desired timedomain specifications for controlling the position of the SRV02 load shaft are ess 0 2117 tp 020 s 2118 and PO 50 2119 Thus when tracking the load shaft reference the transient response should have a peak time less than or equal to 020 seconds an overshoot less than or equal to 5 and the steadystate response should have no error SRV02 Workbook Student Version 22 212 PV Controller Design 2121 Closed Loop Transfer Function The proportionalvelocity PV compensator to control the position of the SRV02 has the following structure Vmt kp θdt θlt kv d dt θlt 2120 where kp is the proportional control gain kv is the velocity control gain θdt is the setpoint or reference load shaft angle θlt is the measured load shaft angle and Vmt is the SRV02 motor input voltage The block diagram of the PV control is given in Figure 24 We need to find the closedloop transfer function ΘlsΘds for the closedloop Figure 24 Block diagram of SRV02 PV position control position control of the SRV02 Taking the Laplace transform of equation 2120 gives Vms kp Θds Θls kv s Θls 2121 From the Plant block in Figure 24 and equation 213 we can write Θls Vms K s τ s 1 2122 Substituting equation 2121 into 2122 and solving for ΘlsΘds gives the SRV02 position closedloop transfer function as Θls Θds K kp τ s2 1 K kv s K kp 2123 2122 Controller Gain Limits In control design a factor to be considered is saturation This is a nonlinear element and is represented by a saturation block as shown in Figure 25 In a system like the SRV02 the computer calculates a numeric control voltage value This value is then converted into a voltage Vdact by the digitaltoanalog converter of the data acquisition device in the computer The voltage is then amplified by a power amplifier by a factor of Ka If the amplified voltage Vampt is greater than the maximum output voltage of the amplifier or the input voltage limits of the motor whichever is smaller then it is saturated limited at Vmax Therefore the input voltage Vmt is the effective voltage being applied to the SRV02 motor The limitations of the actuator must be taken into account when designing a controller For instance the voltage entering the SRV02 motor should never exceed Vmax 100 V 2124 SRV02 Workbook Student Version v 10 Figure 25 Actuator saturation 2123 Ramp Steady State Error Using PV Control From our previous steadystate analysis we found that the closedloop SRV02 system is a Type 1 system In this section we will investigate the steadystate error due to a ramp input when using PV controller Given the following ramp setpoint input Rs R0 s2 2125 we can find the error transfer function by substituting the SRV02 closedloop transfer function in equation 2123 into the formula given in 2111 Using the variables of the SRV02 this formula can be rewritten as Es ΘdsΘls After rearranging the terms we find Es Θds s τ s 1 K kv τ s2 s K kp K kv s 2126 Substituting the input ramp transfer function 2125 into the Θds variable gives Es R0 τ s 1 K kv s τ s2 s K kp K kv s 2127 213 PIV Controller Adding an integral control can help eliminate any steadystate error We will add an integral signal middle branch in Figure 26 to have a proportionalintegralvelocity PIV algorithm to control the position of the SRV02 The motor voltage will be generated by the PIV according to Vmt kp θdd θlt ki θdt θlt dt kv d dt θlt 2128 where ki is the integral gain We need to find the closedloop transfer function ΘlsΘds for the closedloop position control of the SRV02 Taking the Laplace transform of equation 2128 gives Vms kp ki s Θds Θls kv s Θls 2129 From the Plant block in Figure 26 and equation 213 we can write Θls Vms K τ s 1 s 2130 Substituting equation 2129 into 2130 and solving for ΘlsΘds gives the SRV02 position closedloop transfer function as Θls Θds K kp s ki s3 τ 1 K kv s2 K kp s K ki 2131 SRV02 Workbook Student Version 24 Figure 26 Block diagram of PIV SRV02 position control 2131 Ramp SteadyState Error using PIV Controller To find the steadystate error of the SRV02 for a ramp input under the control of the PIV substitute the closedloop transfer function from equation 2131 into equation 2111 Es Θds s2 τ s 1 K kv s3 τ s2 K kp s K ki K kv s2 2132 Then substituting the reference ramp transfer function 2125 into the Θds variable gives Es R0 τ s 1 K kv s3 τ s2 K kp s K ki K kv s2 2133 2132 Integral Gain Design It takes a certain amount of time for the output response to track the ramp reference with zero steadystate error This is called the settling time and it is determined by the value used for the integral gain In steadystate the ramp response error is constant Therefore to design an integral gain the velocity compensation the V signal can be neglected Thus we have a PI controller left as Vmt kp θdt θlt ki θdt θlt dt 2134 When in steadystate the expression can be simplified to Vmt kp ess ki ti 0 ess dt 2135 where the variable ti is the integration time SRV02 Workbook Student Version v 10 22 PreLab Questions Before you start the lab experiments given in Section 23 you should study the background materials provided in Section 21 and work through the questions in this Section 1 Calculate the maximum overshoot of the response in radians given a step setpoint of 45 degrees and the overshoot specification given in Section 2113 Hint By substituting ymax θtp and step setpoint R0 θdt into equation 216 we can obtain θtp θdt 1 P O 100 Recall that the desired response specifications include 5 overshoot 2 The SRV02 closedloop transfer function was derived in equation 2123 in Section 2121 Find the control gains kp and kv in terms of ωn and ζ Hint Remember the standard second order system equation 3 Calculate the minimum damping ratio and natural frequency required to meet the specifications given in Section 2113 4 Based on the nominal SRV02 model parameters K and τ found in Laboratory 1 SRV02 Modeling calculate the control gains needed to satisfy the timedomain response requirements given in Section 2113 5 In the PV controlled system for a reference step of π4 ie 45 degree step starting from Θlt 0 position calculate the maximum proportional gain that would lead to providing the maximum voltage to the motor Ignore the velocity control kv 0 Can the desired specifications be obtained based on this maximum available gain and what you calculated in question 4 6 For the PV controlled closedloop system find the steadystate error and evaluate it numerically given a ramp with a slope of R0 336 rads Use the control gains found in question 4 7 What should be the integral gain ki so that when the SRV02 is supplied with the maximum voltage of Vmax 10 V it can eliminate the steadystate error calculated in question 6 in 1 second Hint Start from equation 2135 and use ti 1 Vmt 10 the kp you found in question 4 and ess found in question 6 Remember that ess is constant SRV02 Workbook Student Version 26 23 Lab Experiments The main goal of this laboratory is to explore position control of the SRV02 load shaft using PV and PIV controllers In this laboratory you will conduct three experiments 1 Step response with PV controller 2 Ramp response with PV controller and 3 Ramp response with no steadystate error You will need to design the third experiment yourself In each experiment you will first simulate the closedloop response of the system Then you will implement the controller using the SRV02 hardware and software to compare the real response to the simulated one 231 Step Response Using PV Controller 2311 Simulation First you will simulate the closedloop response of the SRV02 with a PV controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated Then you will explore the effect of using a highpass filter instead of a direct derivative to create the velocity signal V in the controller Experimental Setup The s srv02 pos Simulinkdiagram shown in Figure 27 will be used to simulate the closedloop position control response with the PV and PIV controllers The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary The PIV Control subsystem contains the PIV controller detailed in Section 213 When the integral gain is set to zero it essentially becomes a PV controller Figure 27 Simulink model used to simulate the SRV02 closedloop position response IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 242 to configure the lab files first Closedloop Response with the PV Controller SRV02 Workbook Student Version v 10 1 Enter the proportional and velocity control gains found in PreLab question 4 in Matlabas kp and kv 2 To generate a step reference ensure the SRV02 Signal Generator is set to the following Signal type square Amplitude 1 Frequency 04 Hz 3 In the Simulinkdiagram set the Amplitude rad gain block to π8rad to generate a step with an amplitude of 45 degrees ie square wave goes between π8 which results in a step amplitude of π4 4 Inside the PIV Control subsystem set the Manual Switch to the upward position so the Derivative block is used 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to figures 28 and 29 Note that in the theta l rad scope the yellow trace is the setpoint position while the purple trace is the simulated position generated by the SRV02 Model block This simulation is called the Ideal PV response as it uses the PV compensator with the derivative block Figure 28 Ideal PV position re sponse Figure 29 Ideal PV motor input voltage 7 Generate a Matlabfigure showing the Ideal PV position response and the ideal input voltage After each simulation run each scope automatically saves their response to a variable in the Matlabworkspace That is the theta l rad scope saves its response to the variable called data pos and the Vm V scope saves its data to the data vm variable The data pos variable has the following structure data pos1 is the time vector data pos2 is the setpoint and data pos3 is the simulated angle For the data vm variable data vm1 is the time and data vm2 is the simulated input voltage 8 Measure the steadystate error the percent overshoot and the peak time of the simulated response Does the response satisfy the specifications given in Section 2113 Hint Use the Matlabginput command to take measurements off the figure Using a Highpass Filter Instead of Direct Derivative 9 When implementing a controller on actual hardware it is generally not advised to take the direct derivative of a measured signal Any noise or spikes in the signal becomes amplified and gets multiplied by a gain and fed into the motor which may lead to damage To remove any highfrequency noise components in the velocity signal a lowpass filter is placed in series with the derivative ie taking the highpass filter of the measured signal However as with a controller the filter must also be tuned properly In addition the filter has some adverse affects Go in the PIV Control block and set the Manual Switch block to the down position to enable the highpass filter 10 Start the simulation The response in the scopes should still be similar to figures 28 and 29 This simulation is called the Filtered PV response as it uses the PV controller with the highpass filter block SRV02 Workbook Student Version 28 11 Generate a Matlabfigure showing the Filtered PV position and input voltage responses 12 Measure the steadystate error peak time and percent overshoot Are the specifications still satisfied without saturating the actuator Recall that the peak time and percent overshoot should not exceed the values given in Section 2113 Discuss the changes from the ideal response Hint The different in the response is minor Make sure you use ginput to take precise measurements 2312 Implementing Step Response using PV Controller In this experiment we will control the angular position of the SRV02 load shaft ie the disc load using the PV controller Measurements will then be taken to ensure that the specifications are satisfied Experimental Setup The q srv02 pos Simulinkdiagram shown in Figure 210 is used to implement the position control experiments The SRV02ET subsystem contains QUARC blocks that interface with the DC motor and sensors of the SRV02 system as discussed in Section A The PIV Control subsystem implements the PIV controller detailed in Section 213 except a highpass filter is used to obtain the velocity signal as opposed to taking the direct derivative Figure 210 Simulink model used with QUARC to run the PV and PIV position controllers on the SRV02 IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 243 to configure the lab files first 1 Run the setup srv02 exp02 posm script 2 Enter the proportional and velocity control gains found in PreLab question 4 3 Set Signal Type in the SRV02 Signal Generator to square to generate a step reference 4 Set the Amplitude rad gain block to π8 to generate a step with an amplitude of 45 degrees 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Click on QUARC Build to compile the Simulinkdiagram 7 Select QUARC Start to begin running the controller The scopes should display responses similar to figures 211 and 212 Note that in the theta l rad scope the yellow trace is the setpoint position while the purple trace is the measured position SRV02 Workbook Student Version v 10 Figure 211 Measured PV step response Figure 212 PV control input voltage 8 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the PV position response and its input voltage As in the s srv02 pos Simulink diagram when the controller is stopped each scope automatically saves their response to a variable in the Matlabworkspace Thus the theta l rad scope saves its response to the data pos variable and the Vm V scope saves its data to the data vm variable 9 Measure the steadystate error the percent overshoot and the peak time of the SRV02 load gear Does the response satisfy the specifications given in Section 2113 10 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 11 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 232 Ramp Response Using PV Controller 2321 Simulation In this simulation the goal is to verify that the system with the PV controller can meet the zero steadystate error specification without saturating the motor As in the Step Response experiment in Section 231 in this experiment you need to use the s srv02 pos Simulinkdiagram shown in Figure 27 in Section 2311 again 1 Enter the proportional and velocity control gains found in PreLab question 4 2 Set the SRV02 Signal Generator parameters to the following to generate a triangular reference which corre sponds to a ramp input Signal Type triangle Amplitude 1 Frequency 08 Hz 3 Setting the frequency to 08 Hz will generate an increasing and decreasing ramp signal with the same slope used in the PreLab question 6 The slope is calculated from the Triangular Waveform amplitude Amp and frequency f using the expression R0 4 Amp f 2336 4 In the Simulinkdiagram set the Amplitude rad gain block to π3 SRV02 Workbook Student Version 30 5 Inside the PIV Control subsystem set the Manual Switch to the down position so that the HighPass Filter block is used 6 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 7 Start the simulation The scopes should display responses similar to figures 213 and 214 Figure 213 Ramp response us ing PV Figure 214 Input voltage of ramp tracking using PV 8 Generate a Matlabfigure showing the Ramp PV position response and its corresponding input voltage trace 9 Measure the steadystate error Compare the simulation measurement with the steadystate error calculated in PreLab question 6 2322 Implementing Ramp Response Using PV In this experiment we will control the angular position of the SRV02 load shaft ie the disc load using a PV controller The goal is to examine how well the system can track a triangular ramp position input Measurements will then be taken to ensure that the specifications are satisfied As in the Step Response experiment in Section 231 in this experiment you also need to use the q srv02 pos Simulinkdiagram shown in Figure 210 to implement the position control experiments 1 Run the setup srv02 exp02 posm script 2 Enter the proportional and velocity control gains found in PreLab question 4 3 Set the SRV02 Signal Generator parameters to the following to generate a triangular reference ie ramp reference Signal Type triangle Amplitude 1 Frequency 08 Hz 4 In the Simulinkdiagra set the Amplitude rad gain block to π3 5 Open the load shaft position scope theta l rad and the motor input voltage scope Vm V 6 Click on QUARC Build to compile the Simulinkdiagram 7 Select QUARC Start to run the controller The scopes should display responses similar to figures 215 and 216 8 Generate a Matlabfigure showing the Ramp PV position response and its corresponding input voltage trace 9 Measure the steadystate error and compare it with the steadystate error calculated in PreLab question 6 SRV02 Workbook Student Version v 10 Figure 215 Measured SRV02 PV ramp response Figure 216 Input voltage of PV ramp response 233 Ramp Response with No SteadyState Error Design an experiment to see if the steadystate error can be eliminated when tracking a ramp input First simulate the response then implement it using the SRV02 system 1 How can the PV controller be modified to eliminate the steadystate error in the ramp response State your hypothesis and describe the anticipated causeandeffect leading to the expected result Hint Look through Section 2 2 List the independent and dependent variables of your proposed controller Explain their relationship 3 Your proposed control like the PV compensator are modelbased controllers This means that the control gains generated are based on mathematical representation of the system Given this list the assumptions you are making in this control design State the reasons for your assumptions 4 Give a brief general overview of the steps involved in your experimental procedure for two cases 1 Simula tion and 2 Implementation 5 For each case generate a Matlabfigure showing the position response of the system and its corresponding input voltage 6 In each case measure the steadystate error 7 For each case comment on whether the steadystate specification given in Section 2113 was satisfied without saturating the actuator 8 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 9 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session SRV02 Workbook Student Version 32 234 Results Fill out Table 21 below with your answers to the PreLab questions and your results from the lab experiments Section Ques tion Description Symbol Value Unit Question 4 PreLab Model Parameters OpenLoop SteadyState Gain K OpenLoop Time Constant τ Question 4 PreLab PV Gain Design Proportional gain kp Velocity gain kv Question 5 PreLab Control Gain Limits Maximum proportional gain kpmax Question 6 PreLab Ramp SteadyState Error Steadystate error using PV ess Question 7 PreLab Integral Gain Design Integral gain ki 2311 Step Response Simulation Peak time tp Percent overshoot PO Steadystate error ess 2311 Filtered Step Response Using PV Peak time tp Percent overshoot PO Steadystate error ess 2312 Step Response Implementation Peak time tp Percent overshoot PO Steadystate error ess 2321 Ramp Response Simulation with PV Steadystate error ess 2322 Ramp Response Implementation with PV Steadystate error ess 233 Ramp Response Simulation with with no steadystate error Steadystate error ess 233 Ramp Response Implementation with with no steadystate error Steadystate error ess Table 21 Summary of results for the SRV02 Position Control laboratory SRV02 Workbook Student Version v 10 24 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARC compatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 241 Overview of Files Table 22 Files supplied with the SRV02 Position Control laboratory File Name Description 02 SRV02 Position Control Stu dent Manualpdf This laboratory guide contains prelab questions and lab experiments demonstrating how to design and imple ment a position controller on the Quanser SRV02 rotary plant using QUARC setup srv02 exp02 posm The main Matlabscript that sets the SRV02 motor and sensor parameters as well as its configuration dependent model parameters Run this file only to setup the laboratory config srv02m Returns the configurationbased SRV02 model spec ifications Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP d model paramm Calculates the SRV02 model parameters K and tau based on the device specifications Rm kt km Kg eta g Beq Jeq and eta m calc conversion constantsm Returns various conversions factors s srv02 posmdl Simulink file that simulates a closedloop PIV controller for the SRV02 system q srv02 posmdl Simulink file that implements a closedloop PIV position controller on the SRV02 system using QUARC 242 Setup for Position Control Simulations Follow these steps to configure the lab properly 1 Load the Matlabsoftware 2 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 position controller files eg q srv02 posmdl 3 Doubleclick on the s srv02 posmdl file to open the Simulinkdiagram shown in Figure 27 4 Doubleclick on the setup srv02 exp02 spdm file to open the setup script for the position control Simulink models SRV02 Workbook Student Version 34 5 Configure setup script The controllers will be run on an SRV02 in the highgear configuration with the disc load In order to simulate the SRV02 properly make sure the script is setup to match this configuration ie the EXT GEAR CONFIG should be set to HIGH and the LOAD TYPE should be set to DISC Also ensure the ENCODER TYPE TACH OPTION K CABLE AMP TYPE and VMAX DAC parameters are set according to the SRV02 system that is to be used in the laboratory 6 Finally make sure CONTROL TYPE is set to MANUAL 7 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the Matlab Command Window The model parameters and specifications are loaded but the PIV gains are all set to zero they need to be changed SRV02 model parameters K 153 radsV tau 00254 s Specifications tp 02 s PO 5 Calculated PV control gains kp 0 Vrad kv 0 Vsrad Integral control gain for triangle tracking ki 0 Vrads 243 Setup for Position Control Implementation Before beginning the lab experiments on the SRV02 device the q srv02 pos Simulinkdiagram and the setup srv02 exp02 posm script must be configured Follow these steps to get the system ready for this lab 1 Setup the SRV02 in the highgear configuration and with the disc load as described in Reference 6 2 Load the Matlabsoftware 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 position control files eg q srv02 posmdl 4 Doubleclick on the q srv02 posmdl file to open the Position Control Simulinkdiagram shown in Figure 27 5 Configure DAQ Doubleclick on the HIL Initialize block in the SRV02ET subsystem which is located inside the SRV02ET Position subsystem and ensure it is configured for the DAQ device that is installed in your system See Section A for more information on configuring the HIL Initialize block 6 Configure Sensor The position of the load shaft can be measured using various sensors Set the Pos Src Source block in q srv02 pos as shown in Figure 27 as follows 1 to use the potentiometer 2 to use to the encoder Note that when using the potentiometer there will be a discontinuity 7 Configure setup script Set the parameters in the setup srv02 exp02 posm script according to your system setup See Section 242 for more details SRV02 Workbook Student Version v 10 25 Lab Report This laboratory contains three experiments namely 1 step response 2 ramp response with PV controller and 3 ramp response with no steadystate error When you are writing your lab report follow the outline corresponding to the experiment you conducted to build the content of your report Also in Section 254 you can find some basic tips for the format of your report SRV02 Workbook Student Version 36 251 Template for Content Step Response Exper iment I PROCEDURE 1 Closedloop response with the PV controller Briefly describe the main goal of the simulation Briefly describe the simulation procedure Section 2311 2 Step response with PV controller using highpass filter Briefly describe the main goal of this simulation Briefly describe the simulation procedure Section 2311 3 Implementing Step Response using PV Controller Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 2312 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 7 in Section 2311 Simulated step response 2 Response plot from step 11 in Section 2311 Filtered PV response 3 Response plot from step 8 in Section 2312 Step response of implemented PV controller 4 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 8 in Section 2311 Step response with PV controller 2 Step 12 in Section 2311 Step response with PV controller using highpass filter 3 Step 9 in Section 2312 Step response with PV controller IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 8 in Section 2311 Step response simulation with PV controller 2 Step 12 in Section 2311 Step response simulation with PV controller using Highpass filter 3 Step 9 in Section 2312 Step response with the implemented PV controller SRV02 Workbook Student Version v 10 252 Template for Content Ramp Response with PV I PROCEDURE 1 Ramp response with PV controller Briefly describe the main goal of this simulation Briefly describe the procedure Section 2321 2 Implementing Ramp Response Using PV Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 2322 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 8 in Section 2321 Simulated PV controller with ramp input 2 Response plot from step 8 in Section 2322 Ramp response of implemented PV controller 3 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 9 in Section 2321 Simulated PV controller with ramp input 2 Step 9 in Section 2322 Ramp response of implemented PV controller IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 9 in Section 2322 Ramp response with the implemented PV controller SRV02 Workbook Student Version 38 253 Template for Content Ramp Response with No SteadyState Error I PROCEDURE 1 State the hypothesis of your experiment and describe the anticipated causeandeffect leading to the expected result Step 1 in Section 233 2 List the independent and dependent variables for the controller Explain their relationship Step 2 in Section 233 3 List the assumptions you made in this experiment State the reasons for your assumptions Step 3 in Section 233 4 Briefly list the steps of your experimental procedure for two cases 1 Simulation and 2 Implementation Step 4 in Section 233 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 5 in Section 233 Simulated controller with ramp input 2 Response plot from step 5 in Section 233 Implemented controller with ramp input 3 Provide applicable data collected in this laboratory from Table 21 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following 1 Step 6 in Section 233 Simulated controller with ramp input 2 Step 6 in Section 233 Implemented controller with ramp input IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 7 in Section 233 for both simulated and implemented controllers SRV02 Workbook Student Version v 10 254 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version 40 LABORATORY 3 SRV02 SPEED CONTROL The objective of this laboratory is to develop feedback systems that control the speed of the rotary servo load shaft A proportionalintegral PI controller and a lead compensator are designed to regulate the shaft speed according to a set of specifications Topics Covered Design of a proportionalintegral PI controller that regulates the angular speed of the servo load shaft Design of a lead compensator Simulation of the PI and lead controllers using the plant model to ensure the specifications are met without any actuator saturation Implemention of the controllers on the Quanser SRV02 device to evaluate their performance Prerequisites In order to successfully carry out this laboratory the user should be familiar with the following Data acquisition device eg Q2USB the power amplifier eg VoltPAQX1 and the main components of the SRV02 eg actuator sensors as described in References 2 4 and 6 respectively Wiring and operating procedure of the SRV02 plant with the amplifier and dataaquisition DAQ device as discussed in Reference 6 Transfer function fundamentals eg obtaining a transfer function from a differential equation Laboratory described in Appendix A to get familiar with using QUARCwith the SRV02 SRV02 Workbook Student Version v 10 31 Background 311 Desired Response 3111 SRV02 Speed Control Specifications The timedomain requirements for controlling the speed of the SRV02 load shaft are ess 0 311 tp 005 s and 312 PO 5 313 Thus when tracking the load shaft reference the transient response should have a peak time less than or equal to 005 seconds an overshoot less than or equal to 5 and zero steadystate error In addition to the above timebased specifications the following frequencydomain requirements are to be met when designing the Lead Compensator PM 750 deg 314 and ωg 750 rads 315 The phase margin mainly affects the shape of the response Having a higher phase margin implies that the system is more stable and the corresponding time response will have less overshoot The overshoot will not go beyond 5 with a phase margin of at least 750 degrees The crossover frequency is the frequency where the gain of the Bode plot is 1 or 0 dB This parameter mainly affects the speed of the response thus having a larger ωg decreases the peak time With a crossover frequency of 750 radians the resulting peak time will be less than or equal to 005 seconds 3112 Overshoot In this laboratory we will use the following step setpoint input ωdt 25 rads t t0 75 rads t t0 316 where t0 is the time the step is applied Initially the SRV02 should be running at 25 rads and after the step time it should jump up to 75 rads From the standard definition of overshoot in step response we can calculate the maximum overshoot of the response in radians ωtp ωdt0 ωdt ωdt0 1 PO 100 317 SRV02 Workbook Student Version 42 with the given values the maximum overshoot of the response is ωtp 775 rads 318 The closedloop speed response should therefore not exceed the value given in Equation 318 3113 Steady State Error Consider the speed control system with unity feedback shown in Figure 31 Let the compensator be Cs 1 Figure 31 Unity feedback loop We can find the steadystate error using the final value theorem ess lim s0 s Es 319 where Es Rs 1 Cs Ps 3110 The voltagetospeed transfer function for the SRV02 was found in Section 1 as Ps K τ s 1 3111 Substituting Rs R0 s and Cs 1 gives Es R0 s 1 K τ s1 3112 Applying the finalvalue theorem to the system gives ess R0 lim s0 τ s 1 τ s 1 K 3113 When evaluated the resulting steadystate error due to a step response is ess R0 1 K 3114 312 PI Control Design 3121 Closed Loop Transfer Function The proportionalintegral PI compensator used to control the velocity of the SRV02 has the following structure Vmt kp bsp ωdt ωlt ki ωdt ωlt dt 3115 SRV02 Workbook Student Version v 10 Figure 32 Block diagram of SRV02 PI speed control where kp is the proportional control gain ki is the integral control gain ωdt is the setpoint or reference angular speed for the load shaft ωlt is the measured load shaft angular speed bsp is the setpoint weight and Vmt is the voltage applied to the SRV02 motor The block diagram of the PI control is given in Figure 32 We can take Laplace transform of the controller given in Equation 3115 Vms kp bsp Ωds Ωls ki Ωds Ωls s 3116 To find the closedloop speed transfer function ΩlsΩds we can use the process transfer function from Equation 3111 and solve for ΩlsΩds as Ωls Ωds K kp s bsp ki s2 τ 1 K kp s K ki 3117 3122 Finding PI Gains to Satisfy Specifications In this section we will first calculate the minimum damping ratio and natural frequency required to meet the speci fications given in Section 3111 Then using these values we will calculate the necessary control gains kp and ki to achieve the desired performance with a PI controller The minimum damping ratio and natural frequency needed to satisfy a given percent overshoot and peak time are ζ ln PO 100 1 ln P O 100 2 π2 3118 and ωn π tp 1 ζ2 3119 Substituting the percent overshoot specifications given in 313 into Equation 3118 gives the required damping ratio ζ 0690 3120 Then by substituting this damping ratio and the desired peak time given in 312 into Equation 3119 the minimum natural frequency is found as ωn 867 rads 3121 Now lets look at how we can calculate the gains When the setpoint weight is zero ie bsp 0 the closedloop SRV02 speed transfer function has the structure of a standard secondorder system We can find expressions for the control gains kp and ki by equating the characteristic equation denominator of the SRV02 closedloop transfer function to the standard characteristic equation s2 2 ζ ωn s ω2 n SRV02 Workbook Student Version 44 The denominator of the transfer function can be restructured into the following s2 1 K kp s τ K ki τ 3122 equating the coefficients of this equation to the coefficients of the standard characteristic equation gives K ki τ ω2 n 3123 and 1 K kp τ 2 ζ ωn 3124 Then the proportional gain kp can be found as kp 1 2 ζ ωn τ K 3125 and the integral gain ki is ki ω2 n τ K 3126 313 Lead Control Design Alternatively a lead or lag compensator can be designed to control the speed of the servo The lag compensator is actually an approximation of a PI control and this at first may seem like the more viable option However due to the saturation limits of the actuator the lag compensator cannot achieve the desired zero steadystate error specification Instead a lead compensator with an integrator as shown in Figure 33 will be designed Figure 33 Closedloop SRV02 speed control with lead compensator To obtain zero steadystate error an integrator is placed in series with the plant This system is denoted by the transfer function Pis Ps s 3127 where Ps is the plant transfer function in Equation 3111 The phase margin and crossover frequency specifications listed in equations 314 and 315 of Section 3111 can then be satisfied using a proportional gain Kc and the lead transfer function Gleads 1 a T s 1 T s 3128 The a and T parameters change the location of the pole and the zero of the lead compensator which changes the gain and phase margins of the system The design process involves examining the stability margins of the loop transfer function Ls Cs Ps where the compensator is given by Cs Kc 1 a T s 1 T s s 3129 SRV02 Workbook Student Version v 10 3131 Finding Lead Compensator Parameters The Lead compensator is an approximation of a proportionalderivative PD control A PD controller can be used to add damping to reduce the overshoot in the transient of a step response and effectively making the system more stable In other words it increases the phase margin In this particular case the lead compensator is designed for the following system Lps Kc Ps s 3130 The proportional gain Kc is designed to attain a certain crossover frequency Increasing the gain crossover frequency essentially increases the bandwidth of the system which decreases the peak time in the transient response ie makes the response faster However as will be shown adding a gain Kc 1 makes the system less stable The phase margin of the Lps system is therefore lower than the phase margin of the Pis system and this translates to having a large overshoot in the response The lead compensator is used to dampen the overshoot and increase the overall stability of the system ie increase its phase margin The frequency response of the lead compensator given in 3128 is Glead ω j 1 a T ωj 1 T ω j 3131 and its corresponding magnitude and phase equations are Gleadω j T 2 ω2 a2 1 1 T 2 ω2 3132 and ϕG arctana Tω arctanT ω 3133 The Bode plot of the lead compensator is shown in Figure 34 Figure 34 Bode of lead compensator 3132 Lead Compensator Design using MATLAB In this section we will use Matlabto design a lead compensator that will satisfy the frequencybased specifications given in Section 3111 1 Bode plot of the openloop uncompensated system Pis must first be found To generate the Bode plot of Pis enter the following commands in Matlab NOTE If your system has not been set up yet then you SRV02 Workbook Student Version 46 need to first run the the setup srv02 exp03 spdm script This script will store the model parameter K and tau in the Matlabworkspace These parameters are used with the commands tf and series to create the Pis transfer function The margin command generates a Bode plot of the system and it lists the gain and phase stability margins as well as the phase and gain crossover frequencies Plant transfer function P tfKtau 1 Integrator transfer function I tf11 0 Plant with Integrator transfer function Pi seriesPI Bode of Pis figure1 marginPi set 1namePis The entire Lead compensator design is given in the d leadm script file Run this script after running the setup srv02 exp03 spdm script when CONTROL TYPE AUTO to generate a collection of Bode diagrams including the Bode of Pis given in Figure 35 Figure 35 Bode of Pis system 2 Find how much more gain is required such that the gain crossover frequency is 500 rads use the ginput Matlabcommand As mentioned before the lead compensator adds gain to the system and will increases the phase as well Therefore gain Kc is not to be designed to meet the specified 750 rads fully As given in Figure 35 the crossover frequency of the uncompensated system is 153 rads To move the crossover frequency to 500 rads a gain of Kc 345 dB 3134 or Kc 531 Vrad 3135 in the linear range is required The Bode plot of the loop transfer function Lps from Section 313 is given in Figure 36 This initial estimate of the gain was found using the ginput command The gain was then adjusted according to the crossover frequency calculated in the generated Bode plot of the Lps system The commands used to generate the Bode plot are given in the d leadm script SRV02 Workbook Student Version v 10 Figure 36 Bode of Lps system 3 Gain needed for specified phase margin must be found next so that the lead compensator can achieve the specified phase margin of 75 degrees Also to ensure the desired specifications are reached well add another 5 degrees to the maximum phase of the lead To attain the necessary phase margin the maximum phase of the lead can be calculated using ϕm PMdes PMmeas 5 3136 Given that the desired phase margin in Equation 314 and the phase margin of Lps is PMmeas 215 deg 3137 the maximum lead phase has to be about ϕm 418 deg 3138 or ϕm 0728 rad 3139 The lead compensator as explained in Section 3131 has two parameters a and T To attain the maximum phase ϕm shown in Figure 34 the Lead compensator has to add 20 log10a of gain This is determined using the equation a 1 sinϕm 1 sinϕm 3140 The gain needed is found by inserting the max phase into this equation to get a 496 3141 which is 20 log 10a 139 dB 3142 4 The frequency at which the lead maximum phase occurs must be placed at the new gain crossover fre quency ωgnew This is the crossover frequency after the lead compensator is applied As illustrated in Figure 34 ωm occurs halfway between 0 dB and 20 log10a ie at 10 log10a So the new gain crossover frequency in the Lps system will be the frequency where the gain is 10 log10a From Figure 36 it is found that the frequency where the 10 log10a gain in the Lps system occurs is at about 809 rads Thus the maximum phase of the lead will be set to ωm 809 rads 3143 SRV02 Workbook Student Version 48 As illustrated earlier in Figure 34 in Section 3131 the maximum phase occurs at the maximum phase fre quency ωm Parameter T given by T 1 ωm a 3144 is used to attain a certain maximum phase frequency This changes where the Lead compensator breakpoint frequencies 1a T and 1T shown in Figure 34 occur The slope of the lead compensator gain changes at these frequencies We can find the parameter T by substituting ωm 809 and the lead gain value from Equation 3141 into Equation 3144 T 000556 srad 3145 Therefore the lead breakpoint frequencies are 1 a T 361 rads 3146 and 1 T 1809 rads 3147 5 Bode plot of the lead compensator Cleads defined in 3128 can be generated using the d leadm script Figure 37 Bode of lead compensator Cleads 6 Bode plot of the loop transfer function Ls as described in 3130 can be generated using the d leadm script The phase margin of Ls is 681 degrees and is below the desired phase margin of 750 degrees as specified in Section 311 7 Check response by simulating the system to make sure that the timedomain specifications are met Keep in mind that the goal of the lead design is the same as the PI control the response should meet the desired steadystate error peak time and percentage overshoot specifications given in Section 311 Thus if the crossover frequency andor phase margin specifications are not quite satisfied the response should be simu lated to verify if the timedomain requirements are satisfied If so then the design is complete If not then the lead design needs to be revisited You will work on this later in the laboratory as described in Section 3321 SRV02 Workbook Student Version v 10 Figure 38 Bode of loop transfer function Ls 314 Sensor Noise When using analog sensors such as a tachometer there is often some inherent noise in the measured signal The peaktopeak noise of the measured SRV02 load gear signal can be calculated using eω 1 100 Kn ωl 3148 where Kn is the peaktopeak ripple rating of the sensor and ωl is the speed of SRV02 load gear The rated peak topeak noise of the SRV02 tachometer is given in Appendix B of Reference 6 as Kn 7 3149 Based on this specification the peaktopeak noise when the load shaft runs at 75 rads will be eω 0525 rads 3150 Thus the signal will oscillate 02625 rads about the 75 rads setpoint or approximately between 724 rads and 776 rads Then taking the noise into account what would be the maximum peak in the speed response that is to be expected Equation 317 was used to find the peak value of the load gear response for a given percent overshoot To take into account the noise in the signal this formula is modified as follows ωtp ωdt0 ωdt ωdt0 1 PO 100 1 2eω 3151 Given a reference signal that goes between 25 rads to 75 rads as described in Section 3111 and the peakto peak ripple estimate in Equation 3150 the peak speed of the load gear including the noise can be found as ωtp 801 rads 3152 Using PO 100 ωtp ωdt ωdt ωdt0 3153 the new maximum percent overshoot for a 50 rads step is PO 102 3154 SRV02 Workbook Student Version 50 32 PreLab Questions 1 Based on the steadystate error result of a step response from Equation what type of system is the SRV02 when performing speed control Type 0 1 or 2 and why 2 The nominal SRV02 model parameters K and τ found in SRV02 Modeling Laboratory Section 1 should be about 153 radsV and 00254 sec respectively Calculate the PI control gains needed to satisfy the timedomain response requirements 3 Find the frequency response magnitude Piω of the transfer function Pis given in Equation 3127 4 Calculate the DC gain of Pis given in Equation 3127 Hint The DC gain is the gain when the frequency is zero ie ω 0 rads However because of its integrator Pis has a singularity at zero frequency Therefore the DC gain is not technically defined for this system Instead approximate the DC gain by using ω 1 rads Make sure the DC gain estimate is evaluated numerically in dB using the nominal model parameters K 153 and τ 00254 or use what you found for K and τ in Section 1 5 The gain crossover frequency ωg is the frequency at which the gain of the system is 1 or 0 dB Express the crossover frequency symbolically in terms of the SRV02 model parameters K and τ Then evaluate the expression using the nominal SRV02 model parameters K 153 and τ 00254 or use what you found for K and τ in Section 1 SRV02 Workbook Student Version v 10 33 Lab Experiments The main goal of this laboratory is to explore closedloop speed control of the SRV02 load shaft In this laboratory you will conduct two experiments 1 Step response with PI control and 2 Step response with Lead control In each of the experiments you will first simulate the closedloop response of the system Then you will implement the controller using the SRV02 hardware and software to compare the real response to the simulated one 331 Step Response with PI Control 3311 Simulation First you will simulate the closedloop speed response of the SRV02 with a PI controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated Then you will explore the effect of the setpoint weight Experimental Setup The s srv02 spd Simulinkdiagram shown in Figure 39 is used to simulate the closedloop speed response of the SRV02 when using either the PI or Lead controls The SRV02 Model uses a Transfer Fcn block from the Simulinklibrary to simulate the system The PI compensator subsystem contains the PI control detailed in Section 312 and the Lead Compensator block has the compensator described in Section 313 Figure 39 Simulink diagram used to simulate the closedloop SRV02 speed response IMPORTANT Before you can conduct these experiments you need to make sure that the lab files are configured according to your SRV02 setup If they have not been configured already then you need to go to Section 342 to configure the lab files first 1 Enter the proportional and integral control gains found in Section 3122 as kp and ki in Matlab 2 The speed reference signal is to be a 04 Hz square wave that goes between 25 rads and 75 rads ie between 239 rpm and 716 rpm Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 SRV02 Workbook Student Version 52 Frequency 04 Hz 3 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads block to 50 rads 4 Set the Manual Switch to the upward position to activate the PI control 5 Open the load shaft position scope w l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to figures 310 and 311 Note that in the w l rad scope the yellow trace is the setpoint position while the purple trace is the simulated speed generated by the SRV02 Model block Figure 310 Simulated PI speed response Figure 311 Simulated PI motor input voltage 7 Generate a Matlabfigure showing the simulated PI speed response and its input voltage After each simula tion run each scope automatically saves their response to a variable in the Matlab workspace The w l rad scope saves its response to the variable called data spd and the Vm V scope saves its data to the data vm variable The data spd variable has the following structure data spd1 is the time vector data spd2 is the setpoint and data spd3 is the simulated angular speed For the data vm variable data vm1 is the time and data vm2 is the simulated input voltage 8 Measure the steadystate error the percent overshoot and the peak time of the simulated response Does the response satisfy the specifications given in Section 3111 3312 Implementing PI Speed Control Experimental Setup The q srv02 spd Simulinkdiagram shown in Figure 312 is used to perform the speed control exercises in this laboratory The SRV02ET Speed subsystem contains QUARCblocks that interface with the DC motor and sensors of the SRV02 system as discussed in Section A The PI control subsystem implements the PI control detailed in Section 312 and the Lead Compensator block implements the lead control described in Section 313 SRV02 Workbook Student Version v 10 Figure 312 Simulink model used with QUARC to run the PI and lead speed controllers on the SRV02 1 Run the setup srv02 exp03 spdm script 2 Enter the proportional and integral control gains found in Section 32 as kp and ki in Matlab 3 To generate a square reference speed signal set the SRV02 Signal Generator block parameters to the follow ing Signal type square Amplitude 1 Frequency 04 Hz 4 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 5 Open the load shaft speed scope w l rads and the motor input voltage scope Vm V 6 Set the Manual Switch to the upward position to activate the PI control 7 Click on QUARC Build to compile the Simulinkdiagram 8 Select QUARC Start to run the controller The scopes should be displaying responses similar to figures Figure 313 and Figure 314 Note that in the w l rads scope the yellow trace is the setpoint position while the purple trace is the measured position Figure 313 Measured PI speed step response Figure 314 PI motor input volt age SRV02 Workbook Student Version 54 9 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the PI speed response and its input voltage As in the s srv02 spd Simulinkdiagram when the controller is stopped each scope automatically saves their response to a variable in the Matlabworkspace Thus the theta l rad scope saves its response to the data spd variable and the Vm V scope saves its data to the data vm variable 10 Due to the noise in the measured speed signal it is difficult to obtain an accurate measurement of the speci fications In the Speed Control Simulinkmode set the Amplitude rad block to 0 rads and the Offset rad block to 75 rads in order to generate a constant speed reference of 75 rads Generate a Matlabfigure showing the noise in the signal 11 Measure the peaktopeak ripple found in the speed signal eωmeas and compare it with the estimate in Section 314 Then find the steadystate error by comparing the average of the measured signal with the desired speed Is the steadystate error specification satisfied 12 Measure the percent overshoot and the peak time of the SRV02 load gear step response Taking into account the noise in the signal does the response satisfy the specifications given in Section 3111 13 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 14 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 332 Step Response with LEAD Control 3321 Simulation You will simulate the closedloop speed response of the SRV02 with a Lead controller to step input Our goals are to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not saturated As in the step response with PI control experiment in Section 3311 in this experiment you need to use the s srv02 spd Simulinkdiagram shown in Figure 312 again 1 Enter the Lead control parameters found in Section 3132 These are denoted as Kc a and T in Matlab 2 Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 Frequency 04 Hz 3 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 4 To engage the lead control set the Manual Switch to the downward position 5 Open the load shaft position scope w l rad and the motor input voltage scope Vm V 6 Start the simulation By default the simulation runs for 5 seconds The scopes should be displaying responses similar to Figures 310 and 311 7 Verify if the timedomain specifications in Section 3111 are satisfied and that the motor is not being saturated To calculate the steadystate error peak time and percent overshoot use the simulated response data stored in the data spd variable 8 If the specifications are not satisfied go back in the lead compensator design You may have to for example add more maximum phase in order to increase the phase margin If the specifications are met move on to the next step 9 Generate a Matlabfigure showing the Simulated Lead speed response and its input voltage SRV02 Workbook Student Version v 10 3322 Implementing LEAD Speed Control In this section the speed of the SRV02 is controlled using the lead compensator Measurements will be taken to see if the specifications are satisfied 1 Run the setup srv02 exp03 spdm script 2 Enter the Kc a and T lead parameters found in Section 3132 in Matlab 3 Set the SRV02 Signal Generator block parameters to the following Signal type square Amplitude 1 Frequency 04 Hz 4 In the Speed Control Simulinkmodel set the Amplitude rads gain block to 25 rads and the Offset rads constant block to 50 rads 5 To engage the lead compensator set the Manual Switch in the Speed Control Simulink diagram to the downward position 6 Open the load shaft speed scope w l rads and the motor input voltage scope Vm V 7 Click on QUARC Build to compile the Simulinkdiagram 8 Select QUARC Start to run the controller The scopes should be displaying responses similar to figures 313 and 314 9 When a suitable response is obtained click on the Stop button in the Simulink diagram toolbar or select QUARC Stop from the menu to stop running the code Generate a Matlabfigure showing the lead speed response and its input voltage 10 Measure the steadystate error the percent overshoot and the peak time of the SRV02 load gear For the steadystate error it may be beneficial to give a constant reference and take its average as done in Section 3312 Does the response satisfy the specifications given in Section 3111 11 Using both your simulation and implementation results comment on any differences between the PI and lead controls 12 Click the Stop button on the Simulinkdiagram toolbar or select QUARC Stop from the menu to stop the experiment 13 Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session 333 Results Fill out Table 31 below with your answers to the PreLab questions and your results from the lab experiments SRV02 Workbook Student Version 56 Section Ques tion Description Symbol Value Unit Question 2 PreLab PI Gains Proportional Gain kp Integral Gain ki OpenLoop Time Constant τ OpenLoop Steadystate Gain K Question 4 PreLab DC Gain Estimate DC Gain Estimate of Pis Pi1 Question 5 PreLab Gain Crossover Frequency Gain crossover frequency ωg Section 3311 InLab PI Step Response Simulation Peak time tp Percent overshoot PO Steadystate error ess Section 3312 InLab PI Speed Control Implementa tion Measured peaktopeak ripple eωmeas Steadystate error ess Peak time tp Percent overshoot PO Section 3321 InLab Step Response Simulation with Lead Control Peak time tp Percent overshoot PO Steadystate error ess Section 3322 InLab Lead Speed Control Imple mentation Peak time tp Percentage overshoot PO Steadystate error ess Table 31 Summary of results for the Speed Control laboratory SRV02 Workbook Student Version v 10 34 System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in Reference 1 You have a QUARCcompatible dataaquisition DAQ card installed in your PC For a listing of compliant DAQ cards see Reference 5 SRV02 and amplifier are connected to your DAQ board as described Reference 6 341 Overview of Files Table 32 Files supplied with the SRV02 Speed Control laboratory File Name Description 03 SRV02 Speed Control Stu dent Manualpdf This laboratory guide contains prelab questions and lab experiments demonstrating how to design and implement a speed controller on the Quanser SRV02 rotary plant us ing QUARC setup srv02 exp03 spdm The main Matlab script that sets the SRV02 motor and sensor parameters as well as its configurationdependent model parameters Run this file only to setup the labora tory config srv02m Returns the configurationbased SRV02 model specifica tions Rm kt km Kg eta g Beq Jeq and eta m the sensor calibration constants K POT K ENC and K TACH and the amplifier limits VMAX AMP and IMAX AMP d model paramm Calculates the SRV02 model parameters K and tau based on the device specifications Rm kt km Kg eta g Beq Jeq and eta m calc conversion constantsm Returns various conversions factors s srv02 spdmdl Simulink file that simulates the closedloop SRV02 speed control using either the PI control or the lead compensator q srv02 spdmdl Simulink file that runs the PI or Lead speed control on the actual SRV02 system using QUARC 342 Setup for Speed Control Simulation Follow these steps to configure the Matlabsetup script and the Simulinkdiagram for the Speed Control simulation laboratory 1 Load the Matlabsoftware 2 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 speed controller files eg s srv02 spdmdl 3 Doubleclick on the s srv02 spdmdl file to open the SRV02 Speed Control Simulation Simulink diagram shown in Figure 39 SRV02 Workbook Student Version 58 4 Doubleclick on the setup srv02 exp03 spdm file to open the setup script for the position control Simulink models 5 Configure setup script The controllers will be run on an SRV02 in the highgear configuration with the disc load as in Section 1 In order to simulate the SRV02 properly make sure the script is setup to match this configuration eg the EXT GEAR CONFIG should be set to HIGH and the LOAD TYPE should be set to DISC Also ensure the ENCODER TYPE TACH OPTION K AMP AMP TYPE and VMAX DAC parameters are set according to the SRV02 system that is to be used in the laboratory Finally make sure CONTROL TYPE is set to MANUAL 6 Run the script by selecting the Debug Run item from the menu bar or clicking on the Run button in the tool bar The messages shown below should be generated in the Matlab Command Window The correct model parameters are loaded but the control gains and related parameters loaded are default values that need to be changed That is the PI control gains are all set to zero the lead compensator parameters a and T are both set to 1 and the compensator proportional gain Kc is set to zero SRV02 model parameters K 153 radsV tau 00254 s PI control gains kp 0 Vrad ki 0 Vrads Lead compensator parameters Kc 0 Vrads 1aT 1 rads 1T 1 rads 343 Setup for Speed Control Implementation Before beginning the inlab exercises on the SRV02 device the q srv02 spd Simulinkdiagram and the setup srv02 exp03 spdm script must be configured Follow these steps to get the system ready for this lab 1 Setup the SRV02 in the highgear configuration and with the disc load as described in Reference 6 2 Load the Matlab software 3 Browse through the Current Directory window in Matlaband find the folder that contains the SRV02 speed control files eg q srv02 spdmdl 4 Doubleclick on the q srv02 spdmdl file to open the Speed Control Simulink diagram shown in Figure 312 5 Configure DAQ Doubleclick on the HIL Initialize block in the SRV02ET subsystem which is located inside the SRV02ET Speed subsystem and ensure it is configured for the DAQ device that is installed in your system See Section A for more information on configuring the HIL Initialize block 6 Configure Sensor To perform the speed control experiment the angular rate of the load shaft should be measured using the tachometer This has already been set in the Spd Src Source block inside the SRV02ET Speed subsystem 7 Configure setup script Set the parameters in the setup srv02 exp03 spdm script according to your system setup See Section 342 for more details SRV02 Workbook Student Version v 10 35 Lab Report This laboratory contains two experiments namely 1 step response with PI control and 2 step response with lead control When you are writing your report follow the outline corresponding to the experiment you conducted to build the content of your report Also in Section 353 you can find some basic tips for the format of your report SRV02 Workbook Student Version 60 351 Template for Content PI Control Experiments I PROCEDURE I1 Step Response with PI Control 1 Simulation Briefly describe the main goal of this simulation Briefly describe the procedure Section 3311 2 Implementation Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 3312 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 7 in Section 3311 Step response simulation with PI Control 2 Response plot from step 9 in Section 3312 Step response implementation with PI Control 3 Signal noise plot from step 10 in Section 3312 Step response implementation with PI Control 4 Provide data collected in this laboratory from Table 31 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Step Response with PI Control 1 Step 8 in Section 3311 Step response simulation with PI Control 2 Step 11 in Section 3312 Step response implementation with PI Control 3 Step 12 in Section 3312 Step response implementation with PI Control IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 8 in Section 3311 Step response simulation with PI Control 2 Step 11 in Section 3312 Step response implementation with PI Control 3 Step 12 in Section 3312 Step response implementation with PI Control SRV02 Workbook Student Version v 10 352 Template for Content Lead Control Experi ments I PROCEDURE I1 Step Reponse with Lead Control 1 Simulation Briefly describe the main goal of this simulation Briefly describe the procedure Section 3321 2 Implementation Briefly describe the main goal of this experiment Briefly describe the experimental procedure Section 3322 II RESULTS Do not interpret or analyze the data in this section Just provide the results 1 Response plot from step 9 in Section 3321 Step response simulation with Lead Control 2 Response plot from step 9 in Section 3322 Step response implementation with Lead Control 3 Provide data collected in this laboratory from Table 31 III ANALYSIS Provide details of your calculations methods used for analysis for each of the following III1 Step Response with Lead Control 1 Step 7 in Section 3321 Step response simulation with Lead Control 2 Step 10 in Section 3322 Step response implementation with Lead Control IV CONCLUSIONS Interpret your results to arrive at logical conclusions for the following 1 Step 7 in Section 3321 Step response simulation with Lead Control 2 Step 10 in Section 3322 Step response implementation with Lead Control 3 Step 11 in Section 3322 Step response implementation with Lead Control SRV02 Workbook Student Version 62 353 Tips for Report Format PROFESSIONAL APPEARANCE Has cover page with all necessary details title course student names etc Each of the required sections is completed Procedure Results Analysis and Conclusions Typed All grammarspelling correct Report layout is neat Does not exceed specified maximum page limit if any Pages are numbered Equations are consecutively numbered Figures are numbered axes have labels each figure has a descriptive caption Tables are numbered they include labels each table has a descriptive caption Data are presented in a useful format graphs numerical table charts diagrams No hand drawn sketchesdiagrams References are cited using correct format SRV02 Workbook Student Version v 10 64 Appendix A SRV02 QUARC INTEGRATION In this section we explain how to send command voltages to the QuanserSRV02 and measure the position and speed of its load shaft in realtime using your computer System Requirements Before you begin this laboratory make sure QUARCis installed on your PC as described in 1 You have a QUARCcompatible dataacquisition DAQ card installed in your PC For a listing of compliant DAQ cards see 5 SRV02 and amplifier are connected to your DAQ board as described in 6 Prerequisites The user should be familiar with the following System hardware Data acquisition card eg Q2USB in 2 Amplifier eg VoltPAQ in 4 Main components of the SRV02 ie DC motor and sensors such as the potentiometer 6 Basics of Simulink SRV02 Workbook Student Version v 10 A1 Applying Voltage to SRV02 Motor Here are the basic steps to apply a voltage to the SRV02 motor using QUARC 1 Make a Simulinkmodel that interacts with your installed dataacquisition device using blocks from the QUARC Targets library This is explained in Section A11 2 From the Simulinkmodel build realtime code as shown in Section A12 and 3 Execute the code as explained in Section A13 A11 Making the Simulink Model In this section we will make a Simulinkmodel as shown in Figure A1 using QUARCblocks to feed a sinusoidal voltage to the SRV02 dc motor The blocks from the QUARC Targets library are used to interact with a data acquisition board eg Quanser Q2USB or Q8USB device Figure A1 Simulink model used with QUARC to apply voltage to SRV02 Follow these steps to make the Simulinkdiagram 1 Load the Matlabsoftware 2 Create a new Simulinkdiagram To do this go to File New Model item in the menu bar 3 Open the Simulink Library Browser window by clicking on the View Library Browser item in the Simulink menu bar or clicking on the Simulink icon 4 Expand the QUARC Targets item and go to the Data Acquisition Generic Configuration folder as shown in Figure A2 5 Clickanddrag the HIL Initialize block from the library window into the blank Simulinkmodel This block is used to configure your dataacquisition device eg the Quanser Q2USB or Q8USB hardwareintheloop HIL boards 6 In the Library Browser go to the Data Acquisition Generic Immediate IO category This contains various blocks used to interact with actuators and sensors 7 Clickanddrag the HIL Write Analog block from the library into the Simulinkdiagram This block is used to output a voltage from an Analog Output channel ie digitaltoanalog DA channel on the dataacquisition device SRV02 Workbook Student Version 66 Figure A2 QUARC Targets in SimulinkLibrary Browser 8 Add the Signal Generator block found in the Simulink Source folder and the Slider Gain block from the Simulink Math Operations category into the Simulinkmodel Connect the blocks as shown in A1 9 Doubleclick on the HIL Initialize block In the Board type field select the board that is installed in your PC For example if you have a Quanser Q2USB board then select q2 usb If more than one of the same board is installed eg two Q2USB devices ensure the Board number field is set correctly eg if two boards are used then choose either 0 or 1 10 Go to the Analog Output pane shown in Figure A3 Make sure the Analog output channels field includes 0 This will ensure 0 V is output from Analog Output channel 0 when the QUARC controller is stopped For more information click on the Help button Otherwise click on the OK button and proceed Note If you are using a NI DAQ device make sure you enter 0 in the Analog Output channel box The analog output channels for the NI boards are not selected by default 11 Doubleclick on the HIL Write Analog block Make sure Board name is set to HIL1 ie points to the HIL Initialize block Set Channels to 0 default setting Recall that as instructed in Reference 6 the dc motor is connected to Analog Output Channel 0 on the hardwareintheloop board Therefore Channels should be set to 0 Set Sample time to 1 default setting This implies that the sampling interval is inherited from the previous block 12 Click on the OK button to save and close the HIL Write Analog block properties 13 Save the Simulinkmode by selecting the File Save item in the menu bar or clicking on the Save icon SRV02 Workbook Student Version v 10 Figure A3 Configuring Analog Output channel on DAQ device A12 Compiling the Model The Simulinkmodel we made in Section A1 can now be used by QUARC to generate code When you execute this code a voltage is sent to the SRV02 Follow these steps to generate code from a Simulinkdiagram 1 In the Simulinkdiagram made in Section A1 go to the QUARC Set default options item to set the correct RealTime Workshop parameters and setup the Simulinkmodel for external use as opposed to the simulation mode 2 To view the compiler options shown in Figure A4 go to QUARC Options in the Simulinkmodel tool bar 3 RealTime Workshop pane System target file is set to Target Language Compiler file quarc windowstlc Make command is set to make rtw and the Template makefile is set to quarc default tmf file 4 Solver pane Stop time is set to inf in order for the code to be executed continuously until it is stopped manually by the user Alternatively the Stop time parameter can be set to the desired duration code will cease executing when the stop time value is reached Type parameter is set to Fixedstep When compiling realtime code the solver must be fixedstep as opposed to variable step which can be used in simulations Solver is set to discrete There are no continuous blocks inside the designed Simulink model therefore having a discrete solver is fine However if an Integrator block or another continuous system were be added then the Solver field would have to be changed to an integration method such as ode1 Euler Fixedstep size field sets the sampling interval or sampling time of the controller By default this is set to 0002 seconds which is a sampling rate of 500 Hz SRV02 Workbook Student Version 68 Figure A4 Default QUARC solver settings 5 Click on the OK button to close the Configuration Parameters window 6 Select the QUARC Build item Various lines in the MatlabCommand Window should be displayed as the model is being compiled 7 Once done compiling a QUARC Windows executable file along with a folder containing various C and Matlabfiles are generated Note that once the executable is created the folder is no longer needed If you like you can remove the executable and associated code folder may be removed from the current directory by clicking on QUARC Clean item See 5 for more information about configuring QUARC A13 Running QUARC Code Once the Simulinkmodel has been compiled the code can be executed and the voltage set in the Simulinkmodel can be sent to the SRV02 motor Here are the steps to follow 1 Power ON your power amplifier eg Quanser VoltPAQ 2 To begin executing the code click on the QUARC Start item in the Simulinkmodel The SRV02 external gears on the SRV02 should begin rotating backandforth This command actually does two things it connects to the target and then executes the code Alternatively users may decide to go through these steps individually Option 1 In the Simulinkmodel tool bar click on the Connect to target icon and then click on the Run icon These buttons are shown in Figure A5 Option 2 Select the Simulation Connect to target item from the menu bar and the select Simulation Start RealTime Code item 3 Doubleclick on the Signal Generator block to open its parameter window 4 Set the Frequency field to 05 Hz and click on the OK button Notice how the parameter change effects the SRV02 immediately the gears on the SRV02 begin to switch backandforth slowly SRV02 Workbook Student Version v 10 Figure A5 Simulinkmodel toolbar connect to target and compilation 5 Vary the value of the Slider Gain block between 0 and 2 Examine how the angular rate of the SRV02 gears change proportionally with the amplitude of the sine wave 6 Select the QUARC Stop item to stop the code execution or click on the Stop button in the Simulinkmodel tool bar 7 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 70 A2 Reading Position using Potentiometer In this section the Simulinkmodel previously designed in Section A1 is modified to obtain readings from the potentiometer sensor A21 Reading the Potentiometer Voltage Follow the procedure below to design the Simulinkdiagram as shown in Figure A6 to read the potentiometer voltage Figure A6 Simulinkmodel used with QUARC to read potentiometer 1 From the Generic Timebases category in the SimulinkLibrary Browser clickanddrag the HIL Read Analog Timebase block into the Simulinkdiagram created previously in Section A1 This block will be used to read a voltage from an Analog Input channel ie analogtodigital AD on the dataacquisition device Note Using a Timebase type block causes the running model to be triggered by the hardware timer on the dataacquisition board as opposed to the system clock This increases performance of the controller by reducing jitter and allowing for greater sampling rates If you want to use system clock instead some DAQ cards do not support hardwarebased timing see 5 for details then use blocks from the Immediate IO category instead 2 Recall that as instructed in 6 the potentiometer is connected to Analog Input 0 on the DAQ board Therefore the default setting of 0 in the block is fine 3 Add a Scope block from the Simulink Sinks folder in the Library Browser and connect it to the output of the HIL Read Analog Timebase block as shown in Figure A6 4 Set the Frequency parameter in the Signal Generator block to 10 Hz and the Slider Gain block to 1 5 Doubleclick on the Scope block to open the scope 6 Save the Simulinkmodel if you want to save the model as a different file go to Save As 7 Power ON the power amplifier 8 Go to QUARC Build to compile the code 9 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the Scope should display the potentiometer readings similar to Figure A7 Notice that the readings shown are the voltage output of the potentiometer and not an angular measurement in degrees or radians SRV02 Workbook Student Version v 10 Figure A7 Reading raw voltage from the SRV02 potentiometer Note If the SRV02 gears are rotating but the scope is not plotting any data then you must reconfigure the RTW Signal Triggering properties inside the Simulinkdiagram See the Signal Triggering section under QUARC Basics in 5 for more information 10 Vary the sine wave frequency between 01 and 2 Hz and the Slider Gain value between 0 and 2 Notice how the controller is updated in realtime and the measurement in the scope changes with the new parameters Note The potentiometer has an electrical range of 352 degrees across 5 V 6 As a result the poten tiometer outputs a discontinous voltage signal as seen in Figure A8 Then a disadvantage is that you cannot surpass the 180 degree range when controlling the position or take the derivative of this sensor to control velocity Figure A8 Potentiometer reading when encountering its discontinuity 11 Stop the code by clicking on QUARC Stop A22 Measuring Position The Simulinkmodel will now be modified to read the load angle from the potentiometer and the voltage commanded to the motor as shown in Figure A9 SRV02 Workbook Student Version 72 Figure A9 Simulinkmodel used with QUARC to send voltage to the SRV02 and read its load shaft angle using potentiometer Modify the Simulinkdiagram built in the previous section following these steps 1 Label the Scope block that is presently connected to the HIL Read Analog Timebase block to theta l deg This will display the angular measurement of the load gear in degrees 2 Add a Scope block from the Simulink Sinks folder in the Library Browser and connect it to the output of the Slider Gain block as shown in Figure A9 above Label the Scope block Vm V which stands for the input motor voltage 3 From the Simulink Math Operations category in the Library Browser add two Gain blocks into the Simulinkmodel 4 Connect the gain blocks as illustrated in Figure A9 One gain block between the Amplifier PreCompensation and HIL Write Analog blocks and label it Motor Calibration VV Another gain block between the HIL Read Analog Timebase and theta l Scope blocks and denote it Potentiometer Calibration degV 5 Recompile the Simulinkmodel ie click on QUARC Build 6 Click on QUARC Start to run the code 7 Open the Vm V and theta l deg scopes 8 In the Signal Generator set the Frequency parameter to 025 Hz 9 Set the Slider Gain block to 1 10 Currently when the voltage goes positive the load gear rotates in the clockwise direction However the desired convention is for the load gear to rotate in the counterclockwise direction when the voltage goes positive Thus set the Motor Calibration VV block to 1 11 As described in 6 the potentiometer outputs between 5 V when it rotated 352 degrees Enter the value 35210 in the Potentiometer Calibration degVblock 12 In the theta l deg scope click on the Autoscale icon so the yaxis range is increased and the full signal can be viewed 13 Set the Slider Gain block to 0 14 Rotate the load gear manually and examine the corresponding response in the theta l deg scope Confirm that indeed the correct measurement is being taken 15 Position the load gear such that 0 is read in the theta l deg scope SRV02 Workbook Student Version v 10 16 Set the Slider Gain block to 1 17 Examine the relationship between the input voltage and load position When the input voltage increases in the positive direction the potentiometer angle decreases Add a negative sign to the Potentiometer Calibration degV block so the entered value becomes 35210 Now the angular position of the load gear displayed in the theta l deg scope reads increasingly positive when the commanded motor input voltage ie signal in the Vm V scope is positive Note The theoretical model assumes that the velocity increases when the voltage is positive The feedback control design is based on the model Therefore it is imperative that the actual system follows the same conventions as the model that will be developed Figure A10 Sinusoidal input voltage Figure A11 Load gear position reading using potentiometer 18 Select the QUARC Stop item to stop the code from running 19 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 74 A3 Measuring Speed using Tachometer In this section we will modify the Simulinkdiagram designed in Section A2 to include the readings from the tachometer Before continuing please ensure that the SRV02 unit being used has a tachometer ie SRV02T option Figure A12 Simulinkmodel used with QUARC to send voltage to SRV02 and read the potentiometer and tachome ter sensors Using the Simulinkdiagram built in Section A2 go through this procedure to add the tachometer functionality 1 Doubleclick on the HIL Read Analog Timebase block to open its properties 2 As detailed in 6 the tachometer is connected to Analog Input 1 on the hardwareintheloop board To add a channel set the Analog channels field to 01 and click on the OK button 3 Add a Scope block and a Gain block from Library Browser into the Simulinkmodel 4 Connect the Scope and Gain blocks as depicted in Figure A12 above Connect the Gain block to the output of Channel 1 from the HIL Read Analog Timebase block and label it Tachometer Calibration krpmV Connect the output of this gain block to the input of the Scope block and label the scope w l rpm The speed of the load gear is denoted by the ωl This scope will display the measured speed of the load gear in thousand revolutions per minute 5 Set the Signal Generator Frequency parameter to 10 Hz and the Slider Gain block to 1 6 Open the Vm V and the w l krpm scopes 7 Power ON the amplifier 8 Go to QUARC Build to compile the code 9 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the w l rpmV scope should display the tachometer readings Since the Tachometer Calibration krpmV gain has not been configured yet the scope is displaying the tachometer output voltage which is proportional to the speed of the load shaft SRV02 Workbook Student Version v 10 10 The backemf constant of the tachometer sensor is 15 mVrpm However the measurement is taken directly from the motor itself see 6 Thus to read the velocity of the gear the tachometer calibration gain must be divided by the gear ratio Enter 1 15 70 in the Tachometer Calibration krpmV gain block when using the SRV02 in the highgear configuration or 1 15 14 if using the lowgear configuration Note The measurement will be very small Click on the Autoscale icon in the scope to zoom up on the signal Alternatively the yrange of the scope can be set manually To do this rightclick on the yaxis select Axes Properties from the dropdown menu and set the desired yrange values 11 Examine the relationship between the input voltage and load speed When the input voltage increases in the positive direction the tachometer velocity decreases Similar to the potentiometer the speed of the load shaft should go positive when the input voltage is positive To fix this add a negative sign to the Tachometer Calibration krpmV block so the entered value becomes 1 15 70 or 1 15 14 for lowgear The input voltage and load velocity scopes should read as shown in Figure A13 and Figure A14 Note If you want the measurement to be in RPM instead of kRPM enter 1000 15 70 gear or 1000 15 14 for lowgear Figure A13 Sinusoidal input voltage Figure A14 High gear velocity reading using tachometer 12 Select the QUARC Stop item to stop the code from running 13 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 76 A4 Measuring Position using Encoder The Simulinkdiagram designed previously is modified to include an encoder measurement as illustrated in Figure A15 below Before continuing please ensure that the SRV02 unit being used has an encoder ie SRV02E option Figure A15 Simulinkmodel used with QUARC to send voltage to SRV02 and reads the potentiometer tachometer and encoder sensors Using the Simulinkmodel designed in either Section A2 or A3 follow this procedure to add encoder functionality 1 From the QUARC Targets Data Acquisition Generic Immediate IO category in the Library Browser add a HIL Read Encoder block 2 Recall that as instructed in 6 the encoder is connected to Encoder Input 0 on the data acquisition board The HIL Read Encoder block is already configured for to read channel 0 and the default encoder configurations in the HIL Initialize block are fine but keep in mind that these can be changed 3 Add a Gain block and a Scope block from the Math Operations and Sinks folders in the Library Browser respectively into the Simulinkmodel 4 Connect the scope and gain blocks as depicted in Figure A15 Connect the HIL Read Timebase block output e0 to a Gain block and label it Encoder Calibration degcount Connect the output of this gain block to the input of the Scope block and label the scope enc theta l deg This scope will display the measured angular position of the load gear in degrees 5 Set the Frequency parameter in the Signal Generator block to 10 Hz and the Slider Gain block to 1 6 Open the Vm V and enc theta l deg scopes 7 Save the Simulinkmodel you may want to save the model as a different file 8 Power ON the power amplifier 9 Go to QUARC Build to compile the code SRV02 Workbook Student Version v 10 10 Click on QUARC Start to execute the code As the SRV02 rotates backandforth the enc theta l deg should display the encoder readings Since the Encoder Calibration degcount gain has not been configured yet the scope is displaying the number of counts from the encoder output which is proportional to the position of the load shaft Note The measurement will be very large Click on the Autoscale icon in the scope to zoom out and view the entire signal Alternatively the yrange of the scope can be set manually To do this rightclick on the yaxis select Axes Properties from the dropdown menu and set the desired yrange values 11 As discussed in 6 the encoder outputs 4096 counts for every full revolution To measure the load gear angle set the Encoder Calibration degcount gain block to 360 4096 degrees per count 12 The measurement will be very small Click on the Autoscale icon in the scope to zoom up on the signal or adjust the range of the yaxis manually The input voltage and position scopes should appear similarly as shown in Figure A16 and Figure A17 Note that no further calibration is needed since the encoder position increases when the input voltage goes positive Figure A16 Sinusoidal input voltage Figure A17 Position reading us ing encoder 13 Select the QUARC Stop item to stop the code from running 14 Power OFF the amplifier if no more experiments will be run in this session SRV02 Workbook Student Version 78 A5 Saving Data The scopes in the Simulinkmodel can be configured to save variables in the Matlabworkspace For instance to configure the load gear position scope theta l deg in the Simulinkmodel from Section A2 perform the following 1 Open the theta l deg scope 2 Click on Parameters icon and select the Data History tab as shown in Figure A18 Select the Save data to workspace check box Set the Variable name field to a desired variable eg theta l Set Format to Array Figure A18 Adjusting scope parameters to save data Note By default the Limit data points to last box is set to 5000 This means that only the last 5000 points of data will be saved in the variable Thus given that the controller runs at 500 Hz this implies that the last 10 seconds of data shown in the theta l deg scope will be captured 3 Click on the OK button 4 Save the Simulinkmodel 5 Select QUARC Build to rebuild the model 6 Click on QUARC Run 7 Run the controller for a few seconds and stop QUARC 8 When the controller is stopped the variable theta l is saved to the workspace The variable is a twodimensional array with a maximum of 5000 elements The first vector is the running time and the second vector is the po sition of the load gear You can plot the data into a Matlab figure using a script like t theta l1 th l theta l2 plottth lr You can then add Matlabcommands such as xlabel ylabel and title to desribe the data and units you are plotting Note If the controller has not run for the full 10 seconds then it will have tfTs number of elements where tf is the duration of the controller and Ts is the sampling interval For instance if you ran QUARC for 4 seconds then there will be 40002 2000 elements SRV02 Workbook Student Version v 10 Figure A19 Plotting saved data 9 Running the script generates a Matlab figure as shown in Figure A19 Note Use the Matlabcommand ginput to measure points directly from the Matlab figure There are many different ways to save data for offline analysis eg saving data to a Matlab MAT file Go to 5 in the QUARC Basics Data Collection category for more information SRV02 Workbook Student Version 80 BIBLIOGRAPHY 1 Quanser Inc QUARC Installation Guide 2009 2 Quanser Inc Q2USB Users Manual 2010 3 Quanser Inc VoltPAQ Users Manual 2010 4 Quanser Inc QUARC User Manual 2011 5 Quanser Inc SRV02 User Manual 2011 SRV02 Workbook Student Version v 10 USER MANUAL SRV02 Rotary Servo Base Unit Set Up and Configuration Developed by Jacob Apkarian PhD Quanser Michel Lévis MASc Quanser Hakan Gurocak PhD Washington State University CAPTIVATE MOTIVATE GRADUATE Solutions for teaching and research Made in Canada INFOQUANSERCOM 19059403575 QUANSERCOM Ten modules to teach controls from the basic to advanced level SRV02 Base Unit Flexible Link Inverted Pendulum Ball and Beam MultiDOF Torsion 2 DOF Inverted Pendulum 2 DOF Robot Flexible Joint GyroStable Platform Double Inverted Pendulum 2 DOF Ball Balancer With the SRV02 Base Unit you can select from 10 addon modules to create experiments of varying complexity across a wide range of topics disciplines and courses All of the experimentsworkstations are compatible with LabVIEW and MATLABSimulink To request a demonstration or a quote please email infoquansercom 2011 Quanser Inc All rights reserved LabVIEW is a trademark of National Instruments MATLAB and Simulink are registered trademarks of The MathWorks Inc Quanser educational solutions are powered by