# ENGR 058 (Control Theory) Laboratory

## Rigorous motor control

In this lab you will build on your work from last week, and use some of the theory we've discussed in class.

You will need a PC with data acquisition card a "Universal Power Module" and a
"Srv-02 Plant."  The Power modules has two purposes: 1) it takes signals from the motor set up and converts them to appropriate levels for the computer, and 2) it takes low power signals from the computer and sends much higher power signals to the motor.  The "Plant" is just Control Theory jargon for the system being controlled.

These are all in 310.  Please put away any equipment you use when you are done.  There are only two sets of apparatus, so you may need to schedule with other groups to avoid conflicts.

## The lab

1. Connect "S3" on the "Univeral Power Module" to the unlabelled connector between "ENCODER" and "MOTOR" on the back of "SRV02."  Connect channel 3 (red) of "To A/D" from "Universal Power Module" to "ADIN2" of "NI E-Series Terminal Board." This connection is for measurement of the speed of the output motor. Measure the voltage as you turn the motor slowly. .
2. Now connect the "DAC0" output from the terminal board to the "From D/A" input on the Power Module. Connect the "To Load" output from the Power Module to the "MOTOR" input of the plant. Now, you can turn the motor by applying a voltage from the computer.
3. Turn on the "Universal Power Module" (the tall black box with connectors on the top of the front panel).

1. Load the model "E58Lab5Template.mdl" into Simulink and compile and run it.  Note - this only runs for 2 seconds. Make sure all of your programs for this lab run until equilibrium is achieved.

2. This will find the step response of the system (but not the unit step, because the input is multiplied by 5).
3. Use the data to find the transfer function of the motor in the form:

To do this, find the step response due to Hm(s) and use the final value and the time constant of your response to find tm and Km.  Don't forget to compensate for the fact that the input is 5 volts instead of a unit step.

I used the following MatLab code to isolate the interesting part of the data (for curve fitting):
```>> y=y(find((t>=1) & (t<1.4)));
>> t=t(find((t>=1) & (t<1.4)));
>> t=t-t(1);
>> plot(t,y)```
As a quick check, I got Km≈1.7 and tm≈0.02.  Your numbers will be somewhat different, but in the same ballpark.
Note: in this equation Ωv(s) is the voltage from the output of the tachometer that measures motor speed (it is not the motor speed itself). Vi(s) is the input voltage to the power amplifier (from the D/A convertor).

1. Put your system in a a loop with a proportional controller.  A Simulink model is shown below.  To do the experiment you will need to send the output of the controller to the D/A output that controls the motor (don't forget a saturation block to limit the range of the output to less than ±10V), and read the speed of the motor in from the A/D convertor and feed that back to the summing block.  Make sure your sampling time is 0.001 S (the easiest thing is probably to save the model from Task 2 under a different name, and modify it).  The step should be a unit step (1 V).

2. Measure the output with Kp=2, 10, and 50.  For each value of Kp find the time constant and steady state error.

1. Put your system in a a loop with an integral controller.

2. Present data for 3 values of Ki corresponding to heavily overdamped (ζ≥2), heavily underdamped (ζ≤0.2) and near "optimal" (ζ≈1/√2).

Present at least the following:

• Task 2: Your Hm(s), and data that supports it.  (20 pts)
• Task 3: Responses for the three values of Kp, along with  comparisons with theoretical.  Think carefully about how best to do this - these comparisons are critical to the purpose of this lab (and to technical writing in general).  (35 pts)
• Task 4: Responses for the three values of Ki, and comparisons with theoretical.  How did you choose them?  Again - consider the presentation of data/theory/discussion carefully to make your case strongly and succinctly.  (35 pts)
• Extras - up to 10 pts.

Make sure:

• Writing is clear and concise.
• Considerable thought is given to presentation of data to make them easy to understand.
• Direct comparison of theory and experiment easy for the reader.  This should be done in graphs and tables, and not just in the text.
• Graphs and tables are labeled and discussed in the text.
• Any expressions for theoretical results should have their derivations clearly explained in the text.
• Small amounts of code (if any) are in body of text.   Larger amounts can be in an appendix.