# Closed-Loop Response with Lead Compensator and Integrator

## Controller Circuit

In this section, you will add the integral controller and lead compensator. The controller uses three op-amps from the LM324 quad op-amp chip. The circuit is shown below. Notice that since there are three op-amps, and each one inverts, the negatives result in a negative feedback (which is what we want) and a negative on the input (which we don't want). This is not a problem since we can simply invert one of the signals when viewing them on the oscilloscope to get the proper sign. The sign of the feedback term depends on which way the tach wires are connected. The left op-amp in the circuit is an inverting summer/integrator. The input/output relationship for this portion of the circuit is: The center op-amp is the lead compensator. It's transfer function is: Given the capacitor value(s) the pole is determined by R3 (a potentiometer used as a variable resistor between 0 and 100K Ohms) and the zero is determined by R2, another potentiometer. You will compute the values of R2 and R3 to give the desired response based on the root locus.

The right op-amp is an adjustable inverting gain. R5 is a potentiometer which is adjustable between 0 and 100K Ohms. The input/output relationship for this portion of the circuit is: These three circuits together provide the inverting adjustable integral controller and lead compensator represented by the dotted box in the block diagram. It's transfer function (ignoring the extra negative sign) is: ## Lead Compensator Concept

The lead compensator helps speed the response of the system by moving the closed-loop poles to the left. Without the lead compensator, the root locus has a vertical asymptote halfway between the integrator (s=0) and the open loop pole (as shown below). Therefore, the the fastest the system can respond in closed-loop would be half as fast as in open loop (with better error and disturbance rejection of course) which will not be fast enough to meet the specifications.

After placing a pole and a zero on the negative real axis before closing the loop, there will still be a vertical asymptote (#p-#z=2) but the position of the asymptote can be changed. The asymptote will be at: So the asymptote will be shifted by (b-a)/2. Therefore, if you place the compensator pole further to the left than the zero (but both further to the left than the motor pole) you can ``bend'' the root locus to the left as shown below. ## Designing the Controller

You will choose the lead compensator pole (-b) and zero (-a), as well as the controller gain (Kc) to meet the following response specifications: S.S. Error to a step = 0 %OV = 16.3% Ts = 0.04s

You will use MATLAB to make the calculations using the root locus. The basic procedure is, that after placing the zero (-a) you will find the pole (-b) to make the root locus go through a desired point. Then you will find the gain using rlocfind. You will then calculate the appropriate resistor values to give you the appropriate gains and positions. The root locus is a plot of all possible closed-loop pole locations as the gain, Kc is varied. MATLAB cannot draw the root locus until particular positions for the pole and zero are chosen. This is an iterative process, so you will have to calculate the appropriate values, plot the root locus, and see how well it worked.

1. Choose Compensator Zero
Since this is a third order system, and you will pick a sufficiently large gain, in closed-loop, there will be a complex conjugate pair of poles and a single real pole. One pole moves from the lead compensator pole to the lead compensator zero as the gain is increased. You will design the rest of the controller such that the complex conjugate poles will be at the desired settling time. To assure that the complex poles are the dominant poles, you can try to cancel the plant pole with the zero, i.e. place the zero at exactly the location of the pole. The two monomial factors in the numerator and the denominator of the transfer function will cancel each other out, and the system will have a second order transfer function with pole at 0 and at -b. Even if the pole-zero cancellation is not exact, the open-loop system will behave very like a second order system with pole at 0 and at -b.
2. Choose Compensator Pole
To choose the location of the compensator pole, you must first calculate the location of the desired closed loop poles in the complex plane. Since you know the %OS and the settling time, you can compute the damping ratio and the natural frequency, and ultimately the pole location. You can then choose the compensator pole location to assure that these closed-loop poles are on the root locus. Use the angle criterion for this part.
3. Determine Gain Using Root Locus in MATLAB
Plot the root locus given the above calculated pole and zero. The following procedure may be helpful (but not necessary). Define the variables numo and deno to be the numerator and denominator polynomials of the open-loop transfer function, including the 1/s in the controller (but not Kc, and not the lead compensator).\ Define numl and denl to be the numerator and denominator of the lead compensator with a and b as obtained previously. Type num=conv(numo,numl) and den=conv(deno,denl) to multiply the compensator transfer function by the plant transfer function. Type rlocus(num,den). The root locus, similar to the previously shown compensated root locus will be drawn. Print it out. (Be sure to label it appropriately)
4. Calculate Potentiometer Values.
For the values of controller gain and compensator pole and zero locations you just computed you will calculate the corresponding values for the potentiometers R2, R3 and R5 The other resistor values can be obtained by matching the controller circuit transfer function to the desired controller transfer function: The values of C, R1, and R4 are shown in the circuit diagram.

## Build Controller Circuit

1. Apply Power to Breadboard
The pictures following this and the next items may be helpful in assembling the circuit. Also refer to the pin diagram of the op-amp chip.  Be sure the power is turned off. Connect the GND terminal of the amplifier to the GND post on the breadboard with a banana cable. Connect the GND post to the top row of the breadboard with a small jumper wire. Connect the top row of the breadboard to the second column in from the right with a small jumper. This is the GND column. Use a long wire to connect the -V terminal of the amplifier to the rightmost column of the breadboard. This is the -V column. Use a long wire to connect the +V terminal of the amplifier to the first column to the left of the right half section of the breadboard.
2. Insert Op-Amp Chip and apply +/-V Insert the chip in the center of the right half of the breadboard so that it straddles the small gap in the middle with the end with the notch facing up (see picture). Connect the +Vcc pin of the chip (pin 4) to the +V column with a small jumper. Connect the -Vcc pin of the chip (pin 11) to the -V column with a small jumper. Connect the + input pins of two of the op-amps (pins 12 and 5 in the picture) to the GND column with jumpers. This sets the zero reference voltage for the first and third op-amps. Connect the + input pin (pin 3) of the second op-amp to that of a third op amp (pin 5) with a short jumper. This grounds the third op-amp. Circuit Power Connections

3. Build Summer/Integrator Connect a capacitor between the output and negative input pins of the first op-amp (pins 14 and 13). The capacitor will be labeled either with .1M or with 104 (meaning ). Attach two 560K resistors (green-blue-yellow) between the negative input of the first op-amp (pin 13) and two different free rows of the breadboard. These free resistor ends will be referred to as the controller inputs.
4. Build Lead Compensator Connect a capacitor between two free rows of the breadboard (it shouldn't be connected to the rest of the circuit yet.) Set 100K potentiometer to the value for R2. Connect it between these same two free rows (in parallel with the capacitor.) Connect one end of these two components to the output of the first op-amp (pin 14) with a jumper. Connect the other end of these two components to the negative input of the second op-amp (pin 2). Connect another capacitor between the output of the second op-amp (pin 1) and the negative input of the same op-amp (pin 2). Set the resistance of a potentiometer to the value you computed for R3. Connect it between the same output and negative input pins you just connected the capacitor between.
5. Build Gain Circuit Set the resistance of a second potentiometer to the value you computed for R5. Connect it between the output of the third op-amp (pin 7) and the corresponding negative input (pin 6). Connect a 1.5K resistor between the negative input of the third op-amp (pin 6) and the output of the second op-amp (pin 1).
6. Connect Controller to System Detach the red clip from the IN terminal of the amplifier (this should be the signal from the function generator) and attach it to the free end of one of the controller input resistors in the op-amp circuit. This is r, the reference input. Detach the red clip from the tachometer signal wire. Attach both the clip and the wire to the free end of the other controller input resistor. This is the feedback signal, -y. Connect a wire between the output pin of the third op-amp (pin 7) and the IN terminal of the amplifier. This is the control signal, u. Complete Controller Circuit (Note R2 is simply a resistor in this photo.)

## Obtain Response

1. Step Response Check your connections. It is particularly important that the power be applied to the op-amp in the right direction, and that none of the pins on the chip are shorted to each other. Be careful that none of the resistor or capacitor leads touch each other. Set the function generator to a square input of amplitude 1V, offset 1V, and frequency 1Hz. This will be a square wave alternating between 1V and 3V. Set the trigger to source 1 at a level of 2V with upward slope. Set both voltage scales on the oscilloscope to 1V/div. Set the time scale to 10ms/div, and the horizontal delay to 40ms. Adjust the vertical position of traces 1 and 2 so that the origin of each is exactly at the center of the screen. Set trace 2 to invert mode. This will get rid of the negative sign when viewing the signal. Turn on the power. If the voltage levels on the power supply do not go up to 20V, then turn it off immediately since something is most likely shorted. If this is the case check your connections. If the motor spins uncontrollably, you are in positive feedback. If this is the case, interchange the two leads from the tachometer. Measure the error by using the math function on the oscilloscope. To do this, press the +/- button, turn the math function on, select menu, and choose the ``-'' function. Set units/div=1V and offset=3V using the knob normally used for cursors. Use the cursors to measure the following: Steady State Error Peak Time, Tp. 98% Settling Time, Ts. % Overshoot, %OV. Print this screen.  Step Response Ramp Response

Next-Writeup

Up ] Plant Identification ] [ Closed Loop Response ] Writeup ]