# ENGR 058 (Control Theory) Laboratory

## Seat-of-the-pants motor control

In this lab you will build on the last lab to control a motor, a much faster (and more linear) system than the hairdryer/box system.  In this lab I want you to become familiar with the system and try to control the system without much recourse to theory.\

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.  There are only two sets of apparatus, so you may need to schedule with other groups to avoid conflicts.

## The lab

### First steps

1. Connect "S1 & S2" on back of "SRV-02 PLANT" to "S1 & S2" on "Universal Power Module." Connect channel 1 (yellow) of "To A/D" from "Universal Power Module" to "ADIN0" of"NI E-Series Terminal Board." This connection is for measurement of the angle of the output of the plant. Measure the voltage as you turn the motor slowly. Try this as you do a full revolution and note the discontinuity in the voltage. In particular, record the voltage when the motor is at 0 degrees (the line on the disc attached to the motor is at 0 degrees - this should give close to 0 volts), and at 45 degrees counter clockwise (close to -1.5 volts).
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.  Note: all your connections should be robust - there should be no need for banana clips or twisted wires...
4. Turn on the "Universal Power Module" (the tall black box with connectors on the top of the front panel).
5. Load the model "E58Lab3Template.mdl" into Simulink and compile and run it.  The pulse generator gives an output between 0 and -1.5 V.

Here is the output when I ran it (note: -1.5V corresponds to about 45°).

The blue is the command input, the red is the output of the controller, and green represents the angle of the motor.  Note that the output tries to follow the input.

The fact that the gain is 1.5 and the voltage corresponding to 45° is -1.5V is purely coincidental.  Keep the -1.5V angle, and try adjusting the gain and note how the response behaves.  You might need to slow the square wave down to let the system achieve equilibrium.

### Linear controller

Your first task is to see if you can get "better" response by replacing the simple gain block (set to 1.5) with something else.

• Come up with a definition (either verbal, or an equation) for "best" response.  This should be an exact enough description that somebody reading your report would be able to look at two responses and tell which one is "better."
• Strive for the best response possible while ensuring that the output of the controller doesn't exceed 9.9 volts (i.e., there is no clipping).

### Anything goes

Repeat the first task, with no restrictions on the blocks used or the output of the controller.  You may want to use a saturation block to saturate the output at ±9.9V (I got strange behavior if I tried to output larger voltages).  Record your best attempt.

This should be a short report.

Present:

• your definition of "best" response.  (10 pts)
• a description of the design process for the linear controller.  (20 pts)
• Another person in the class should be able to take your report, follow your procedures, and come up with the same controller.
• Describe how the controllers were chose.
• Describe how initial controller parameter (e.g., gains, thresholds...) were chosen.
• Describe how controller parameters were varied to achieve the "best" response.
• your best linear controller (10 pts)
• a description of your design process for the "best controller"  (this should be similar to description of the linear controller)  (20 pts)
• your best overall controller  (10 pts)

Bring your results to class on 2/28.  We will discuss these in class.