Sei sulla pagina 1di 21

ELECTRICAL ENGINEERING 4 LABORATORY

DC SERVO CONTROL SYSTEM DESIGN

1
1.1

INTRODUCTION
Objective

The aim of this laboratory is to design and implement a DC servo control system. The control system is to meet a given set of specications and achieve a rise time which is as fast as possible. Each student will undertake laboratory preparation which will involve a dry run control system design using a given nominal transfer function. In the actual laboratory session, student groups will act as design teams competing with each other to produce the fastest servo system. First experiments will be undertaken to determine the actual transfer function of their servo system. Then the design will be carried out using ideas from the group members preparation. Students can use any design technique which they are familiar with to produce the controller design. Finally the design will be implemented and its performance evaluated. The laboratory including the preparation will be graded out of 100. There will be a prize of 20 bonus marks (up to a maximum of 100) for the group which meets all the specications and achieves the shortest rise time. To receive the bonus marks, the design and satisfaction of the specications together with the nal results must be fully documented.

1.2

Hardware Description

The hardware used in this laboratory experiment consists of the following: DVH-1000 Control System Module DVH-10 Power Amplier Comdyna 767 Interface unit A PC containing a dSPACE ds1102 board.

1.3

Estimating the plant transfer function

A DC servo system such as can be found in the control laboratory can be modelled by a transfer function of the form a Y (s) = (1.1) Gam (s) = X (s) s(s + b) where a and b are parameters of the system; see Figure 1.1.

U(s)

a (s+b)
Figure 1.1: Transfer Function Model

Y(s)

Before, we can design a controller for the DC servo system, we must estimate the parameters a and b in the transfer function given in equation (1.1).

A general linear second order system can be described by the transfer function model
2 Y (s) n = 2 2 X (s) s + 2n s + n

(1.2)

where n is dened as the undamped natural frequency and is the system damping constant. For a unit step input X (s) = 1/s, taking the inverse Laplace Transform of equation (1.2) yields the unit step response y (t) y (t) = 1 en t 1 2 sin(n 1 2 t + tan1 1 2 ). (1.3)

From equation (1.3), the transient oscillation frequency is t = n 1 2. (1.4)

Also, the corresponding transient oscillation period is Tt = 2 . t

The expression for percentage overshoot (PO) is obtained by nding the rst time when y (t) = 0. Using this method, it can be shown that P O = 100exp and hence
O ln2 ( P 100 ) = O 2 ln2 ( P 100 ) +

1 2
1 2

(1.5)

Also, it follows from (1.4) that n =

t 1 2

(1.6)

The percentage overshoot and the transient oscillation frequency are both quantities which can be easily determined from the system step response as shown in Figure 1.2. This gure also indicates the rise time of the system.

1.5

% overshoot transient oscillation period

100% 1 90% Amplitude 0.5

rise time 10% 0 0 1 2 3 4 5 6 Time (secs) 7 8 9 10

Figure 1.2: System Step Response The approach to estimating the parameter a in transfer function (1.1) is to form a closedloop, feedback system around the DC servo motor. A proportional control system for the DC servo motor is illustrated in Figure 1.3, where Kc is the controller gain Vi

placements

e -

Kc

Kpa

Motor/Load

Ks

Vo

+ Power Amp

Figure 1.3: Proportional Control Block Diagram and K = Potentiometer Gain 4

Ks Kc KP A

= = =

Potentiometer Scaling Controller Gain Power Amplier Gain.

In the block diagram shown in Figure 1.3, we now replace the DC servo motor system and its associated components by the corresponding transfer function. This leads to the block diagram shown in Figure 1.4. The closed loop transfer function for the system of Figure 1.4 is Y (s) Kc a = 2 . X (s) s + bs + Kc a (1.7)

Equating like coecients in equations (1.2) and (1.7) provides the following relationships: Kc a b = =
2 n

2n .

(1.8)

The procedure to estimate the a parameter value of the plant transfer function (1.1) is to determine the undamped natural frequency n and the system damping constant for the closed loop system in Figure 1.4.  - +  6 Kc -

Vi

a s(s+b)

X -

Figure 1.4: Closed Loop system From the step response of this system, the percentage overshoot and oscillation frequency can be obtain. From this, both n and can be estimated using equations (1.5) and (1.6). Then it follows from equation (1.8) that 2 (1.9) a= n. Kc Note that equation (1.8) could also be used to estimate the b parameter. However, a more reliable method is given below. The procedure for determining the b parameter is quite simple. It involves recording the output response of an open loop system driven by a step input. The block diagram of the open loop system conguration is illustrated in Figure 1.5. In order to estimate b, the step response is required. It follows from the transfer function (1.1) that the transfer function of the signal X of this system will be of the form (s)/Vi (s) = a X s+b where is a scaling constant dependent on the Tachometer gain. The time constant m of this to reach 62.3% of transfer function is then calculated to be the time required for the output X its nal value. This is illustrated in Figure 1.6. The b parameter is then obtained from the relationship 1 . (1.10) b= m 5

X Vi a s+b -

Figure 1.5: Open Loop System

Step Response F

0.63F

Amplitude

Time Constant

0 0 1 2 3 4 5 6

Time (sec.)
Figure 1.6: Step Response of Open Loop System

USING THE 767 CONTROL PANEL

The 767 control panel is used to interface to the DC servo system. The functions of the connections in this panel relevant to this experiment are given in Figures 6

2.1 and 2.2


SYMBOL + COLOUR CODE Orange DESCRIPTION +10 Volts reference

Yellow

-10 Volts reference

. X Brown Scaled velocity sensor input

X Brown Scaled position sensor input

Green

Power amplifier input

Do not ever connect anything to this red connector (if you have one) It can be at a high voltage which can damage the dSPACE board.

Figure 2.1: 767 Control Panel Functions

SYMBOL Voltage

COLOUR CODE

DESCRIPTION Selects current or voltage mode operation of the power amplifier

White Current Norm Zero Max

Grey

Enables calibration through the power amplifier. Norm gives the green patch panel input, Zero gives zero volts and Max gives +10 volts.

ON

Red

Disconnects the power amplifier from the load

OFF

H M L

Yellow

Senosr input gain selections; H is unity gain M is middle gain selection, L is the greatest gain

Knob

Adjust sensor output to zero.

Knob

Adjust sensor gain

Figure 2.2: 767 Control Panel Functions (Continued) The Power amplier mode switch should be set to voltage mode throughout the experiment. The power amplier calibration switch should be set on norm throughout the experiment. The power amplier load switch should be set on o while a circuit is being wired up and then set to on when the circuit is ready for operation. The sensor gain selection switches should be set to H to give unity gain. The sensor gain knobs should be set to maximum. The position sensor zero knob should be set to give zero output when the load angle is zero degrees. The velocity sensor zero knob should be set to give zero output when the load is stationary.

USING THE dSPACE SYSTEM

The dSPACE system is high performance digital control system based on the TI TMS320C31 DSP processor. It is directly interfaced with MATLAB/SIMULINK running on a PC. A simulink block diagram is converted to real time C code, cross compiled and downloaded to the DSP board. Software is also available for controlling the DSP from the PC and plotting variables in real time in the DSP. In this laboratory, you will familiarize yourself with some of the capabilities of the dSPACE system including the implementation of transfer functions and the ability to provide step inputs and to plot the resulting step responses of the systems under consideration. Each of the four IBM PCs in the control lab contains a dSPACE ds1102 DSP board. This board can be connected to the outside world via a connector box. The rst step in using the dSPACE system involves logging on to the PC. You should use the username student and the password Eleceng1. All of the les that you generate during the course of the laboratory should be stored in the directory C:\MATLABR11\work\student Do not create any other les or directories on the PC. Also, you should remove your les in the above mentioned directory after the end of the laboratory period. The demonstrator will check the PCs after the end of the laboratory and if you do not leave the PC in the condition you found it, all members of your group may lose marks from their nal lab grade.

3.1

Creating a dSPACE Block Diagram

We now present a case study of using the dSPACE system. The implementation of this case study is not part of the laboratory but should give you an idea as to how to carry out the actual laboratory. In order to use the dSPACE system, you must construct block diagrams on MATLAB/SIMULINK and run them on your dSPACE board. After you log onto the PC, run MATLAB as follows: Start Programs Matlab Matlab 5.3 Run simulink and create a block diagram which you wish to implement on dSPACE; e.g., see below:

ADC #1 ADC #2 ADC #3 ADC #4

1 s Integrator

1 s Integrator1

DAC #1 DAC #2 DAC #3 DAC #4

DS1102ADC

1 Gain

DS1102DAC

1 Gain1
Figure 3.1: A simple simulink block diagram Note that the ADC and DAC blocks included in this block diagram are specic to dSPACE and should be obtained from the dSPACE RTI1102 folder of the simulink library browser. Also, ensure that you use the correct board which is ds1102. The signal applied to a dSPACE ADC channel must be in the range -10 to 10 volts. A signal of +10 volts gives an internal value of 1.00 within simulink. The dSPACE DAC converters give an output in the range of -10 to 10 volts. An internal value of 1.00 gives +10 volts on the DAC. Give your model a suitable name and save it in the directory C:\MATLABR11\work\student. Compiling and Downloading First make sure the matlab default directory is C:\MATLABR11\work\student by giving the command: >> pwd If you are not in the right directory use the matlab command cd to get to the right directory. In order to generate C code for your block diagram, go to the Tools menu and select RTW options (RTW stands for Real Time Workshop). This is necessary in order to congure simulink C code generation for use with dSPACE. Select the Solver tab and set the step size to a suitable value in seconds. (Say 0.001) This determines the sample period used in the real time implementation of the system. Choose the Real Time Workshop Tab and click build. This will compile the block diagram and download it to the dSPACE board. From now on, if you change the block diagram and do not need to change the step size, you can compile the block diagram simply by going to the tools menu and choosing RTW build.

3.2

The ControlDesk Package

This is a powerful dSPACE software package used to interact with the program you have running on the dSPACE DSP board. In particular, it is used to change parameters in the model and to plot variables and signals in the DSP.

10

The following write up gives some basic instructions on the use of the ControlDesk package. However, in order to use the package correctly you will need to use the online help. The online help package is called dSPACE HelpDesk. To run this package choose the windows menu items as follows: Start Programs dSPACE Tools dSPACE HelpDesk This online help system contains all the information about the ControlDesk package. In particular, if you cant do something in ControlDesk, do not immediately ask the demonstrator how to do it but rather try looking it up in HelpDesk rst. Overview ControlDesk allows you to collect the various les you need for a particular model in an Experiment. An experiment can consist of (i) Hardware specication: This species which board the program runs on (In our case there is only one DSP board to worry about). (ii) Instrumentation layout: In control desk, the instrumentation layout is used to display signals from the DSP and to adjust parameters in the DSP model. For each experiment, you must construct a layout to display the required variables and adjust the required parameters. (iii) The ControlDesk package requires a .trc le corresponding to the simulink model which is running on the DSP board. This le is automatically generated when the simulink block diagram is compiled as above. This le is specied for the given experiment in the Variable Manager section. Main Window A typical ControlDesk window is shown below

11

Figure 3.2: ControlDesk Window As illustrated in this diagram, the main window contains a number of elements: Navigator. The Navigator panel provides access to the dierent parts of a real-time experiment. These are, the Hardware View, the Experiment View and the Instrument View. The current view is controlled by the tabs at the bottom of the Navigator panel. Menu Bar. These menus allow for the various commands to be given to ControlDesk. The menus are dynamic and depend on the view and element selected in the Navigator. Tool Bars. These provide quick ways of giving ControlDesk commands rather than using the menus. The tool bars can be turned on or o. Tool Window. This window is used for various tools controlling the experiment depending on the view chosen from the Navigator. Most commonly used is the variable manager which enables the selection variables from a simulink model. Working Area. This is the area in which a ControlDesk instrument layout is constructed and used. Status Bar This displays some information about the state of the ControlDesk system. We now outline how to create a simple experiment which is based on the simulink block diagram above. The aim of this experiment is to display the output signals for this system using 12

an CRO type display. This example is not part of the lab but is intended to illustrate the use of ControlDesk. To start ControlDesk, double click on the dSPACE ControlDesk icon on the windows screen. Create a new experiment using the following menu commands: File New Experiment You should give your experiment a name and make its working root directory: C:\MATLABR11\work\student Click on the green Hardware tab (Ha ...). This should indicate that a program is running on your ds1102 board (by the green triangle). If not, you can drag and drop the corresponding .obj le onto the ds1102 icon to download this program. Add this hardware description to your experiment by right clicking on the window with the ds1102 icon and then choose Add to Experiment Click on the blue Experiment tag (E...). You should now see the hardware icon included in your experiment. To add the required .trc le to your experiment use the following menu commands: File Open Variable File and choose the .trc le corresponding to your simulink block diagram constructed above. This should open a new window with your model name and also a window listing some variables for your model. To add the .trc le to your experiment, right click on this window and choose Add to Experiment. This should give you a new icon in your experiment which includes your .trc le. Also, you may wish to add your simulink block diagram to the experiment. This .mdl le is not used by ControlDesk directly but it is useful to keep track of it. To add this le to your experiment, give the following menu command: File Import Files Then locate the .mdl le for your block diagram. This should lead to a new External Files section in the Navigator panel (under Experiment) with your .mdl le included. To construct an instrumentation layout for your experiment, give the menu commands File New Then scroll down and select layout. This should create a blank layout window. Click on the multi-coloured Instrumentation tab (In...). You should then see a virtual instrument panel. In this example, we wish to create a CRO type display to plot the variable Integrator1 which is the output of our system. We will also include a gauge which displays the model turnaround Time. This is useful if we want to know how short we can make the system sample time (It must be at least greater than the turnaround time.). Click on Data Acquisition in the Virtual Instruments panel and then click on the plotter icon. (Note, in some cases, your Virtual Instruments panel may not have a Data Acquisition section. In this case simply click on the plotter icon directly.) Then move to the Layout panel and draw a rectangle which will determine the size of your plot (It should take up about half the available area but can be adjusted later if desired.) A set of axes should appear on your layout panel.

13

We now need to set up this plotter to plot the desired variable. First move to the Tool Window and click on Model Root. The variable panel should display a list of variables associated with your simulink block diagram. For the simulink example described above, there should be a variable denoted B:Integrator1. Click on this variable. (The notation B:Integrator1 refers to the fact that we are interested in the output signal corresponding to the simulink block labelled Integrator1.) Now drag and drop to the area just to the left of the plotter y-axis in the Layout panel. The y-axis now should be labelled Integrator1 and a red square appears indicating the color of the plot for this variable. We can adjust the parameters of the plotter by right clicking on the plotter area and then choosing the Properties menu item. Then click on the axes tab. At this stage, the only thing we will adjust will be the Y-min value to -0.05 and the Y-Max value to 0.05. The time and triggering of the plotter can be controlled by using a capture settings instrument. Click on the capture settings icon and then draw a suitable rectangle in the layout panel (About half of the available area. Also, note that a capture setting block may also automatically appear to the right of the layout when we use the plotter.) Double click on the settings button in the capture instrument and click on the Capture tab. In the Capture window, click on the right downarrow and choose the only option available DSP - ... - Service #1. Also, set the length variable to 1sec. Then click OK. In this case, our trigger variable will be the same variable that we are going to plot. Hence, again click on B:Integrator1 in the Variable panel and drag and drop it in the trigger window in the capture instrument panel (This is just below the words level and delay.) You can then adjust the plot interval and trigger level to suitable values depending on the signal you are plotting. If the signal applied to the lter is a 1Hz sine wave with amplitude of 10V, then a suitable length is 1sec. Turn the trigger on with AutoRepeat and leave the trigger level at 0. To start plotting (assuming that the signal generator has been connected to the DSP board connector panel), simply give the following menu command Instrumentation Animation Mode This should commence the interaction between your instrumentation layout and the DSP board. To stop, choose the menu command Instrumentation Edit Mode This enables you to make further adjustments to your instrument panel. (Note, there are also menu bar icons which perform these commands.) The controldesk program does not have a direct way of printing plots. A simple way to print plots is to use screen capture (hold down the alt key and press the print screen key). Then run the paint program and paste the screen capture into the program. The required plot can then be cut out and printed. If you wish to save your traced data to a le so that it can be later loaded into matlab and printed, make the following adjustment to the properties of the capture instrument: Under Acquisition, choose simple capture and check Automatic storage. Then specify a lename in which the data will be stored; e.g., output.mat. Then run the animation again. It is best to turn o Autorepeat this time since every time a trace is plotted, it will also overwrite this le. After the capture is complete, you can open this le and plot it from your matlab command window as follows:

14

>> load output >> plot(trace_x,trace_y),xlabel(trace_x_n),ylabel(trace_y_n) This plot can then be printed if required. (Before printing, be sure to choose matlab print setup and set the paper type to A4. If you dont do this, you will need to press shift continue on the printer to obtain the plot.) Our nal step in this example will be to add a gauge to our layout which displays the program turnaround time. With the layout in edit mode, click on the virtual instrument button in the virtual instruments panel and then click on the Gauge icon. Then draw a suitable size rectangle in the layout panel for the gauge. A gauge should appear in the layout. To get this gauge to display the turnaround time, click on the Timer Task 1 item in the Tool Window. The variable panel should then display various variables associated with the program running on the DSP board. Drag and drop the turnaroundTime item onto the gauge instrument in the layout panel. The gauge should now be labelled turnaroundTime. Right click on the gauge instrument and choose properties. Then click the gauge tab. Adjust the stop value to 100e-6. Then click on the Tics tab and adjust the Delta to 25e-6. Restarting the animation, this gauge should now display the turnaroundTime in micro seconds. This completes our layout for this experiment. The layout can be added to the experiment by right clicking on the layout panel and then choosing Add layout to Experiment (This will also ask you to save your layout which you should do). A new Instrumentation element should appear in your experiment listing which contains the corresponding layout le. The nal ControlDesk window should look something like the following:

15

Figure 3.3: Final ControlDesk Window

3.3

Using dSPACE to nd a Step Response

The best way to use the dSPACE system to construct a step response is to add a constant block to your simulink block diagram which will provide the step input. Then use the ControlDesk package to control the step and view the resulting step response using a plotter instrument. To provide the step input, we do NOT use the standard simulink step block. (The step would be over before we had time to set things up). Rather we add a Constant block whose value will be adjusted by ControlDesk to provide the step input at the required time. Also, the ADC and DAC blocks can be removed. For the above example, this leads to the following simulink block diagram.

16

0 Constant

1 s Integrator

1 s Integrator1

1 Gain

1 Gain1
Figure 3.4: Simulink block diagram for step response Compile the system as normally. Return to ControlDesk and close any old experiments. Open a new experiment and give it a suitable name. As described in the previous example, add the hardware conguration and .trc le to this experiment. Create a new layout (or modify the existing layout) as follows:

17

Figure 3.5: Instrument layout for step response In this instrument layout, the plotted signal is the output of the system B:Integrator1. Also, plotted on the same graph is input to the system B:Constant. This is achieved by dragging both of these variables to the Y-axis of the plot. The capture instrument is set as above. In this case, the trigger variable is the step input signal B:Constant. The time interval is 10sec and a factor of 10 down sampling is used to ensure the DSP does not run out of memory with this long time interval. Triggering is set up as above. Also, the data can be saved to a le and loaded into matlab as above. A step input is achieved by using an On/O button to control the constant block in the simulink block diagram. A suitable On/O button can be obtained as one of the options in the RadioButton Instrument. To achieve a step input, the constant value parameter variable P: Constant Value is dragged to the On/O button in the layout. Also, the properties of this instrument are set so that its form is as shown above and the On value is set to the size of the required step and the O value is zero. The above layout also includes two Display instruments. One displays the input variable B: Constant and the other displays the output variable B: Integrator1 To use this ControlDesk experiment, the layout should be put in animation mode and then the constant value set from o to on. This should trigger the data capture and produce the resulting step response. The parameters of this step response such as percentage overshoot, rise time and transient oscillation period can be measured using the cursor feature of the plotter instrument.

18

The above procedure can be used to plot the step response of any physical system connected to the dSPACE board. Connect the input of the system to a DAC channel (Vout(1) in the connector box) and connect the output of the physical system to an ADC channel (Vin(1) in the connector box). Construct a simulink block diagram as shown below

0 Constant

DAC #1 DAC #2 DAC #3 DAC #4

ADC #1 ADC #2 ADC #3 ADC #4

1 Output

DS1102DAC

DS1102ADC

Figure 3.6: Physical system step response Compile the system and obtain the step response using ControlDesk as above.

Specications

In this laboratory, you must design a controller for the DC servo system of the form shown in Figure 4.1.

Ref Input Controller H(s) + Plant G(s)

Shaft angle

Figure 4.1: Block diagram of DC servo system The DC servo control system must meet the following specications: (i) Based on your identied plant transfer function, your controller should achieve a Gain Margin of at least 6dB to both gain increase and gain decrease. It should also achieve a Phase Margin of at least 30 to both phase advance and phase lag. 19

(ii) For a step change in the reference input of 20 , your control system should have an overshoot of at most 4 (20%). (iii) In addition to meeting all of the above specications, your control system should achieve the shortest possible rise time for a step change in the reference input of 20 .

Laboratory Preparation

All students should undertake the following laboratory preparation which should completed before the beginning of the laboratory session. Have the demonstrator sign your laboratory preparation report during the laboratory session and hand it in with your nal laboratory report. Assuming that the plant transfer function is 1000 Gam (s) = s(s + 30) design a controller so that all of the above specications are met. For this inital design, you can assume that the potentiometer sesnor scale factor is as follows: 1 volt corresponds to 14 degrees. You may use any method you please to design the controller including Pole Placement, Root Locus, and Frequency Domain Loop Shaping using Bode, Nyquist or Nichols plots. The form of your controller may be a simple constant gain, PID or lead-lag controller or it may be a complex controller including many lead and lag blocks together with complex poles and high frequency roll-o poles. Remember actuator saturation (the fact that the output signal of the dSPACE is constrained to the range [10, 10] volts) is one of the main factors limiting the performance of a control system. A design which looks very good without taking into account the eect of actuator saturation may perform poorly when taking into account the eect of actuator saturation. For this preliminary controller design, it is a good idea not to make the controller gain too large. Otherwise, you may excite unmodelled dynamics in the plant and lead to an unstable system when implemented on the real plant. In particular, it is a good idea to limit the gain crossover frequency of your initial desing to something less than 100 rad/s. The report on your laboratory preparation should include all steps in your design and should verify that all of the specications are met.

Laboratory Procedure

Before you can begin your controller design, you will need to carry out a number of experiments in order to obtain an accurate model of your plant. Note that the dynamics of your plant will change if you change the screw tightness on the motor gears. Your are free to set this at any tightness you like (provided you do not damage the equipment). However, you should keep in mind that the model will change if you change this screw. Important. When using the DC servo system, there are voltages on the control panel which can damage the DSPACE system. Have the demonstrator check any circuit involving the DSPACE system before turning it on. Identify the plant model. (i) Carry out the experiment shown in Figure 1.4 in order to determine the parameter a in the model (1.1). Note, it is important to choose suitable values of the controller gain Kc and input step size in order to get an accurate answer. (Some trial and error may be required here.) (ii) Carry out the experiment shown in Figure 1.5 to determine the parameter b. (iii) Devise and carry out an experiment to calibrate the potentiometer angle sensor; i.e., nd its gain factor in volts/degree. 20

The controller design Working as a team, use your identied plant model and matlab to design a suitable controller to meet all of the above specications and minimize the rise time. Use matlab to simulate the predicted performance of your controller. Controller Implementation (i) Implement your controller in dSPACE. (ii) Devise experiments to verify that your controller does meet all of the above specications. (iii) Carry out an experiment to measure the rise time of your controller in response to a 20 step. When you have obtained your nal step response, notify the demonstrator who will check it. (iv) If your controller does not meet all of the specications, you will need to return to the design step and adjust your controller. (v) Compare the measured performance of your controller with the simulated performance obtained at the design stage. Laboratory Report A formal laboratory report is required. There should be one report for each student. Each student should include his laboratory preparation (signed by the demonstrator) as part of his nal report. Each student should list the other students in his group. All experiments carried out in the lab should be fully described and the results should be full documented. Your design procedure needs to be fully documented including simulations showing how you controller should meet the specications. Experiments showing that your controller meets the specications should be fully documented. In order to be eligible for the 20 marks bonus for the fastest rise time, your controller design process together with the experiments verifying the specications and controller performance need to be fully documented. Thus, it is possible that some members of a group may receive the bonus while other members do not.

21