lab pid motor control

Upload: acajahuaringa

Post on 02-Jun-2018

233 views

Category:

Documents


4 download

TRANSCRIPT

  • 8/10/2019 Lab Pid Motor Control

    1/17

    Chapter 10L

    Lab 10: Op Amps V: PID Motor Control

    REV 2 1 ; October 1, 2013Time: 130 min.: 2hours, 10 min.

    Contents

    10LLab 10: Op Amps V: PID Motor Control 110L.1Introduction: Why Bother with the PID Loop? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    10L.1.1 Todays Feedback Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210L.1.2 . . . And why it interests us . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    10L.2PID Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310L.2.1 The Motor-Pot Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310L.2.2 The Motor Control Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310L.2.3 Motor Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410L.2.4 Pseudo Op Amp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610L.2.5 Drive the Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710L.2.6 Close the Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    10L.3Add Derivative of the Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    10L.3.1 Derivative Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010L.4Add Integral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    10L.4.1...but Too Much I again brings Instability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    1 Revisions: small rewordings (2/13); insert photo of motor pot (10/10); insert better drawings; renumber gures to 11pid... (8/07);try to cut repetition (3/07).

    1

  • 8/10/2019 Lab Pid Motor Control

    2/17

    2 Lab 10: Op Amps V: PID Motor Control

    10L.1 Introduction: Why Bother with the PID Loop?

    10L.1.1 Todays Feedback Loop. . .

    Todays circuit looks straightforward: a potentiometer sets a target position ; a DC motor tries to achieve that

    position, which is measured by a second potentiometer. Lags cause the difculty: the correction signal islikely to arrive too late to solve a problem that the circuit senses. If that happens, the remedy can make thingsworse.

    This motor control circuit is a classic feedback network called a PID circuit: the circuit response ulti-mately will include three functions of the circuit error signal, P , I , and D : proportional, integral, andderivative. Stability is the central issue.

    10L.1.2 . . . And why it interests us

    This feedback problem holds two sorts of interest, for our course.

    Pedagogical Appeal:

    It gives us a chance to applyand to apply in concerta collection of circuits that you have seeneither only as fragments, or only on paper:

    differential amplier, made of op amps (this we have met only on paper)

    differentiator

    integrator

    summing circuit

    high-current driver (with motor as load)

    PID confronts a classic control problem; it provides a scheme with many practical applications

    10L.1.2.1 Putting the pieces together

    Students often tell us that they like to build circuits that do somethingincontrast to circuits that produce justimages on a scope screen. Todays circuit qualies: it guarantees to make a little DC motor squirm (squirmwhen its unstable; tamely spin, then stop, when its stable).

    This PID circuit is by far the most complex in this course to date. That makes it a good setup for improving

    your debugging skills (this is a glass-half-full way to say that youre very likely to make some wiringerrorstoday). We often boast that in this course, bugs are our most important product . This boast becomes mostconvincing near the end of the course, when you may choose to put together a computer from ICs; but eventoday the circuit is complex enough to make it a challenge. (The debugging will be especially challenging if your sloppy lab partner fails to keep leads short and color-coded, and forgets to bypass power supplies. Weknow you wouldnt make such errors.)

    Finally, were happy to let this lab reinforce a concern rst discussed in the fourth op amp lab: stability.Although todays circuit problem is singularintegrator within the loopand the remedy more subtle thanusual, the general stability problem is one that confronts us in almost every circuit that has gain.

  • 8/10/2019 Lab Pid Motor Control

    3/17

    Lab 10: Op Amps V: PID Motor Control 3

    10L.2 PID Motor Control

    The task we undertake here is one we have described in the class notes for Op Amps 5. We will repeat someof what appears in those notes, to save you the trouble of consulting those as you do the lab. But those notesare more thorough than what we will write in this lab.

    Our goal, most simply stated, is just to use a feedback loop to get one DC voltage to match another; and sinceboth voltages come from potentiometers, the goal can also be described (maybe sounding more exciting) asmaking the position of one potentiometer shaft mimic that of another. We want to be able to use our ngersto turn a potentiometer by hand and see a motor-driven pot mimic our action. Such controls are sometimesoffered on fancy audio equipment, so that the equipment can be controlled either by twisting a knob, or byusing a remote that controls the knob from across the room.

    10L.2.1 The Motor-Pot Assembly

    The motor-pot gadget is nicely made, with an extreme gear-reduction box driving the pot slowly at hightorquebut mediated by a nylon clutch that can slip:

    Figure 1: Motor-potentiometer assembly, exposed

    The clutch serves two purposes: it permits a human hand to control the potentiometer directly, when themotor is stopped. It also protects the motor against stalling and overheating, if the motor drives the pot to oneof its limits.

    10L.2.2 The Motor Control Loop

    Heres a minimal sketch of todays circuit:

    Figure 2: Basic Motor-Position Control Loop: Very Simple!

    The special difculty, today, comes from the fact that the motor-to-potentiometer block, our circuits load,

  • 8/10/2019 Lab Pid Motor Control

    4/17

    4 Lab 10: Op Amps V: PID Motor Control

    integrates voltages. So, we cant use an ordinary op amp as the triangle in the feedback loop of g.2.

    The extra -90 degree shift, or integration, in todays circuit forces us to alter our methods. Since we cannotafford the phase shift of an ordinary op amp, we build ourselves a custom amplier: one that provides modestgain and no phase shift. We will apply the radical remedy, in other words of altering not the load in the loopbut the op amp itself.

    And heres a reminder of todays circuitredrawn to suggest that we now will be able to tinker with theampliers gain. Later, we will alter also its phase behavior.

    Figure 3: Proportional-only drive will cause some overshoot;gain will affect this

    We will rst try this circuit with its gain adjusted low , and we expect to nd the circuit fairly stable. Then, aswe increase gain, we should begin to see overshoot and ringing; if we push on to still higher gains, we shouldsee the circuit oscillate continuously.

    At the end of these notes we attach some scope images describing just such responses to variations in simpleproportional gain.

    10L.2.3 Motor Driver

    Time: 25 min.

    Lets start with a subcircuit that is familiar: a high-current driver, capable of driving a substantial current (upto a couple of hundred milliamps). Well use the power transistors youve met before: MJE3055 (npn) andMJE2955 (pnp). The motor presents the kind of troublesome load likely to induce parasitic oscillations, asin the last exercise of Lab Op Amps 4. We need, therefore, the protections that we invoked there: not onlydecoupling of supplies, but also both a snubber and high-frequency feedback that bypasses the troublesomephase-shifting elements.

    We are trying hard, here, to decouple one part of the circuit from the others: the 15 F caps shouldprevent sup-ply disturbances from upsetting the target signal. Similar caps at the ends of the motor-driven potentiometeraim to stabilize the feedback signal.

    You may also want to use an external power supply to provide the motors 15 V supplies, if you havesuch an extra supply handy. We suggest this not for decoupling, but because the motors maximum currentexceeds the breadboards 100mA rated output, and might disturb those supplies even if one inserted plenty of decoupling caps. The external supply, unlike the breadboard supply, can provide the necessary current. (Butwe have also built this lab happily without this separate power supply.)

  • 8/10/2019 Lab Pid Motor Control

    5/17

    Lab 10: Op Amps V: PID Motor Control 5

    Figure 4: Motor-driver

    Note that your motor pots resistance value may differ from the 10k shown in g. 4 on the facing page. If so, scale the resistors appropriately. If your motors potentiometer has value 100k, for example, just scale thetarget pot (labelled breadboard pot in g. 4 on the preceding page) and the 4.7k and 6.8k divider Rs up bya factor of ten.

    Note, also, that you must not use 411 op amps . The 411 has the nasty propertycommon to bi-fetdevicesthat it can ip its output phase if the input voltage goes below its specied common-mode inputrange. 2 The result is that if an input to any of the ampliers in this loop momentarily swings to within abouta volt of the negative supply, the loop is very likely to get hung up by this nasty positive feedback. 3

    Wire up the two potentiometers, as well as the motor-driver itself. The resistors at the ends of the twopotentiometers6.8k resistors on input, 4.7k resistors on the motor potrestrict input and output range toa range of about 7V, so as to keep all signals well within a range that keeps the op amps happy. Thedifference in R values makes sure that the input range cannot exceed the achievable output range.

    You can test this motor driver by varying the input voltage, and watching the voltage out of the motor-drivenpot. Dont be dismayed if you see a good deal of hash on the scope screen. This hash may look very muchlike a parasitic oscillation, familiar to you from the recent nasty oscillators lab. The image just below showswhat we saw, when watching the motor drive, with the motor moving:

    Figure 5: Motor drive hash looks like a parasitic oscillation.. .

    2 The op amp output is forced high in this event. If the input going too far negative is the non-inverting, this changes the avor of feedback from negative to positive.

    3 This hazard is not hypothetical; we rst breadboarded this circuit with 411sand were forcibly reminded of the parts nastyphase-inversionby the occasional lock-up failure of the loop.

  • 8/10/2019 Lab Pid Motor Control

    6/17

    6 Lab 10: Op Amps V: PID Motor Control

    But if we look at this hash more closely, we nd some clues that it is not the usual parasitic oscillation atwork:

    Figure 6: Motor drive hash seen in greater detail: not parasitic oscillation, after all

    These spikes seem to be the effects of the DC motors brushes breaking contact periodically with the motorscommutator. One clue is the fact that noise is not continuous, but seems to be a set of narrow spikes at alow repetition rate. The other cluepretty conclusiveis the fact that the spike voltages exceed the powersupply: this effect looks a lot like the behavior of an inductor (the motor winding), angry each time thecommutator switches the current off . So, dont let this hash worry you. Its ugly, but well live with it.

    Any V IN more than a few tenths of a volt should evoke a change of output voltage. You will hear the motorwhirring, and will see the shaft slowly turning (the motor drive is geared down through a two-stage worm-and conventional- gearing scheme 4 ). After perhaps 20 seconds, the pot will reach its limit and will ceaseturning. But thats all right: a clever clutch scheme, mentioned back in 1 on page 3, allows the motor toslip harmlessly when the pot reaches either end of its range. If the signs of V IN and the change in V OUT donot match , then be sure to interchange leads of one of the pots, so as to make them match. We dont want ahidden inversion, here. It would upset our scheme when we later close the loop.

    10L.2.4 Pseudo Op AmpTime: 25 min.

    Now we do a strange thing: we use three op amps to make a rather-crummy op-amp like circuit.

    Figure 7: Differential Amp Followed by Gain Stage and an inversion

    4 See photo of motor-pot innards, g. 1 on page 3.

  • 8/10/2019 Lab Pid Motor Control

    7/17

    Lab 10: Op Amps V: PID Motor Control 7

    The rst stage you recognize as a standard differential amp. It shows unity gain. The second stage simplyinverts; 5 the third stage seems to be doing no more than undoing the inversion of the preceding circuit, alongwith permitting adjustment of gain. That is true, at this stage; but we include this circuit because soon wewill use it, fed by two more inputs, as a summing circuit. So used, it will put together the three elements of the PID controller: Proportional, Integral, and Derivative. In the present P -only circuit 6 we also use the thirdamplier to vary the overall gain of our home-made op amp.

    The entire circuit, then, is simply a differential amplier with adjustable gain. And this gain is always lowrelative to the very-high values we are accustomed to in op amps. We need the modesty of this gain, and weneed an associated virtue of this simple circuit: no appreciable phase-shift between input and output. Bothcharacteristics contrast with those of an ordinary op amp, as you know. The xed, high gain of an ordinaryop amp, along with its integrator behavior beginning at 10 or 20 Hz would get us into trouble today, turningnegative feedback into positive.

    10L.2.4.1 Check Common-mode and Differential Gains

    Common-mode gain.. . We suggest that you use a resistor substitution box to set the summing circuitsgain. Set the gain at ten, and see whether a common-mode signala volt or so applied from the input pot,

    applied to both inputsevokes the output you would expect. (Do you expect zero output?)

    . . . (Pseudo-) Differential Gain Then ground one input (the 100k that feeds the rst op amps invertinginput), using the level from the potentiometer as input. Watch that input, and the circuit output, with the Rsubstitution box value set to 100k: see if you get the expected gain of +10.

    A couple of features of this test may bear explaining:

    Yes, the gain is positive when the input pot drives the non-inverting input to this home-made op amp,since two inverting stages follow the diff amp;

    we are applying a pseudo-differential signal by grounding one input of the diff amp and driving theother. (You did this also in Lab 5, as you drove the home-made op amp.) Since the differential gain isso much higher than the common-mode , this pseudo-differential signal works almost as a true differen-tial signal would: an applied signal of v appears as a differential signal of magnitude v, combined witha common-mode signal of magnitude v/ 2 . Given even a mediocre CMRR, this modest common-modesignal mixed with the differential is harmless.

    A DVM may be handier than a scope, at this point, to conrm that the output of this chain of three op-amp circuits shows a pseudo-differential gain of +10, while you drive the input with the input potentiometervoltage. When you nish this test, leave the output voltage close to zero volts.

    10L.2.5 Drive the Motor

    You have already tested the motor driver. Lets now check the three new stagesthose that form the pseudoop ampby letting their output feed the motor-driver. Conrm that you can make the motor spin one way,then the other, by adjusting the input pot slightly above and then below zero volts. (The motor-driven pot, aswe have said, fortunately can take the pot to its limit without damaging pot or motor.)

    5 This inversion is included so as to let this signal share a polarity with the Derivative and Integral signals, soon to be generated;these signals will come from circuits that necessarily invert.

    6 We call this P, as we call the other signals, soon to be added, D and I, although all are inverted. Strictly, then, this is -P. Weomit the minus in these labels, thinking it easier to refer to P than to minus P.

  • 8/10/2019 Lab Pid Motor Control

    8/17

    8 Lab 10: Op Amps V: PID Motor Control

    Figure 8: Try making motor spin, to test the diff amp, gain stage, sum and motor drive

    10L.2.6 Close the LoopTime: 15 min.

    Now reduce the gain , using the R substitution box : set gain to about 1.5 ( R gain = 15 k). Replace the ground connection to the inverting input of our pseudo op amp with the voltage from the output potentiometer .

    Figure 9: The loop closed, at last: Proportional only

    Watch V in on one channel of the scope, V output pot on the other channel. If a digital scope is available, thisis a good time to use it , because a very-slow sweep rate is desirable: as low as 0.5 second- or even 1 second-per division.

  • 8/10/2019 Lab Pid Motor Control

    9/17

    Lab 10: Op Amps V: PID Motor Control 9

    Several ways to test the loop: Apply Voltage Steps, by Hand or from Function-Generator? Two orthree methods are available to you, to test the new setup:

    Two ways to drive the input:

    square wave from function generator : a function generator can provide a small square wave( 0.5V, say), at the lowest available frequency (about 0.2Hz on our generators). This input canreplace the manual input potentiometer, temporarily. This is probably the best choice, since itprovides consistency you cannot achieve by hand.

    Manual step input : you may, however, prefer the simplicity of manually applying a step inputfrom the input pot: a step of perhaps a volt.

    The output pot should followshowing a few cycles of overshoot and damped oscillation.

    An alternative test: Disturb the output, and watch recovery : a second way to test the circuitsresponse is available, if you prefer (and you may want to try this in any case, after looking at theresponse to a step input): leave the input voltage constant, then manually force the pot away from itsresting position, simply by turning the knob of the output pot. Let go, and watch the knob return to itsinitial positionshowing some overshoot and oscillation, as when the change was applied at the inputpot.

    You start with a very low gain (1.5), which should make the circuit stable, even in this P-only form. Now usethe substitution box to dial up increasing gain. At RSum = 220 k (|gain | = 22) we saw some overshoot anda cycle or two of oscillation, evident in the motion of the motor and pot shaft. If this shaft were controlling,say, the rudder of an airplane, this effect would be pretty unsettling. The circuit worksbut it would be niceif we could get it to settle faster and to overshoot less.

    Increasing the gain, at RSum = 680 k (|gain | = 68), we were able to make out several cycles of oscillation(the bigger, uglier trace shows the motor drive voltage; there the oscillation is more obvious):

    Figure 10: P only: gain is high enough to take us to the edge of oscillation

    With a little more gain ( R Sum = 1 M, in our case |gain | = 100) and the application of either a step changeat the input, or a displacement of the output pot by hand we saw a continuous oscillation. Find the gain thatsets your circuit oscillating, and then note the period of oscillation , at the lowest gain that will give sustainedoscillation. We will call this the period of natural oscillation, and soon we will use it to scale the remediesthat well apply against oscillation.

  • 8/10/2019 Lab Pid Motor Control

    10/17

    10 Lab 10: Op Amps V: PID Motor Control

    10L.3 Add Derivative of the ErrorTime: 40 min.

    Well, of course we can get it to settle faster; we can improve performance. (If we couldnt, would the nameof this sort of controller include the I and D in its name, PID?)

    We can speed up the settling markedly, and even crank up the P gain (proportional) a good deal, oncewe have added this derivative. Thinking of the stability difculty as a problem of taming the phase shifts of sinusoidsas we did for op amps generallywe can see that inserting a derivative into the feedback loopwill tend to undo an integration .

    The integrations are the hazard, here: one is built in, the translation from motor rotation to motor position.Additional integrations resulting from lagging phase shifts can carry us to the deadly minus-180-degree shiftthat converts nice feedback into nasty the sort that brings on the oscillation you have just seen.

    10L.3.1 Derivative Circuit

    The standard op amp differentiator shown below can contribute its output to the summing circuit. Here, weshow the entire prior circuit, with the differentiator added. The differentiators gain is rolled off at about

    1.5kHz. Again we recommend that you use a resistor substitution box to set the D gain, if such a box isavailable.

    Figure 11: Derivativeadded to Loop

    Fig. 11 also shows a switch in the feedback path that permits you to kill the derivative when you choose to.You may sometimes want to revert to the simpler P-only scheme, as a note in 10L.3.1.1 on the next pagesuggests.

  • 8/10/2019 Lab Pid Motor Control

    11/17

    Lab 10: Op Amps V: PID Motor Control 11

    10L.3.1.1 How Much Derivative?

    Our goal, in adding derivative, is to cancel the extra phase shift otherwise caused by a low-pass effect thatbrings on instability. How do we know at what frequency this trouble occurs, and therefore how to set thefrequency-response or (equivalently) gain of the differentiator?

    It turns out that you already have this information: you got it by measuring the frequency (or period) of natural oscillation, back in section 10L.2.6. There, as you know, you gradually increased the P-onlygain till you saw that an input disturbance would evoke either an output that took a long time to settle, or acontinuous oscillation. (When we ran that experiment, for example, we got a natural oscillation period of roughly 0.6 second).

    We aim to make the derivative contribution, D, equal to the P contribution, at the corner frequency wheresustained oscillation would occur. The D should keep the loop stable, until yet another low-pass cuts in; atthat point, we should have arranged to make the loop gain safely low: less than unity, so that a disturbancemust die away.

    RC denes the differentiators gain (youll nd an argument for this proposition in the Class Notes for OpAmps 5, in case you need to be persuaded). Here, we reproduce the argument made in those Op Amps 5notes, for setting the D gain.

    How to Calculate the needed DerivativeGainHow do we calculate the necessary differentiator gain? To avoid complications, lets assume that the gain of the P path is unity. Then our goalis to arrange things so that the derivative contribution, D, is equal to the P contribution, at the frequency where trouble otherwise would occur.The D should keep the loop stable, until yet another low-pass cuts in; at that point, we should have arranged to make the loop gain safely low:less than unity, so that a disturbance must die away.Lets start by reminding ourselves what we mean by differentiator gain; then well calculate what RC we need for stability. Gain for adifferentiator, by denition is

    V out / (dV in /dt ). We know that, for the op amp differentiator,

    V out = I R Feedbackand this I is just

    C dV in /dt.So (neglecting the sign of the gain; the op amp version inverts)

    Gain (Deriv) = V out / (dV in /dt ) = R C dV in /dt

    dV in /dt= RC.

    So, RC denes the differentiators gain .a

    If V in = Asin (t ) , then V out Deriv = RCAcos (t ) . We want to nd the value of RC , the differentiators gain, that would set V out Derivequal V out Proportional . Lets treat P gain as unity; then we want both P and D to equal V in .

    If we set the D gain equal to unity, thenV out Deriv = V out Proportional = V in

    And, equivalently RCAcos (t ) = Asin (t )

    Consider just the maximum amplitudes of V in and dV in /dt (where sin and cos terms equal one). We want to set these amplitudes equal toeach other, and both equal to the input amplitude, A. Then

    RCA = Aand RC = 1 , or RC = 1 /Or

    RC = 1 / (2 f ) .To paraphrase this equation in words: RC should be about 1/6 of the period of natural oscillation.

    a Perhaps you nd this a rehearsal of the obvious! Just a look at units make it very plausible that RC should be the differentiators gain:input is volts/second; output is volts; the conversionfactor needs units of seconds.

    A Scaling Rule of thumb: frequency of natural oscillation dictatesD gain. If as this formula suggests,RC should be about 1/6 of the period of natural oscillation, then for our T oscillation = 0 .6 s wed set RC to

  • 8/10/2019 Lab Pid Motor Control

    12/17

    12 Lab 10: Op Amps V: PID Motor Control

    about 0.1 s, or a bit less. 7 If we use a convenient C value of 0.1 F, the R we need is about 1M. Lets make thisvalue adjustable, thoughbecausewe want to be able to try the effect of more or less than the usual derivativeweight: if you have a second resistor substitution box , use it to set the differentiators gain ( RC ). Otherwise,use a 1M variable resistor. Watching the position of the rotator will let you estimate R to perhaps 20 percent;the midpoint value certainly is 500k, and 750k is close to the 3/4-rotation position. The differentiators outputgoes into the summing circuit installed earlier, through a resistor chosen to give this D term weight equal tothe P s.

    We hope you will nd this D to be strong and effective medicine. Once it has tamed your circuits responseeliminating the overshoot and ringingcrank up the P gain, to about twenty ( R SUM GAIN = 220 k) or more.Is the circuit still stable? Try more D. Does an excess of D cause trouble? The scope image of the circuitsresponse will let you judge whether you have too much or too little D : too little, and youll see remnants of the overshoot you saw with P-only; too much D, and youll see an RC-ish curve in the output voltage as itapproaches the target: it chickens out as it gets close. And if you keep increasing the D gain still further, aswe said in the PID Class Notes, the circuit goes unstable once again; it oscillates.

    Switch The toggle switch across the feedback resistor will let us cut D in and out; the switch seems prefer-able to relying, say, on a very-large variable R to feed the summing circuit. We nd it can be hard to keeptrack of multiple pot settings, to know whether were contributing D or not. A switch makes the ON/OFFcondition easier to note.

    10L.4 Add Integral

    Time: 15 min.

    Adding the third termthe I of PIDcan drive residual error (a difference between the input pot voltageand the output pot voltage) to zero. Here is a diagram of the full PID circuit, with the integrator added.

    7 See., e.g., Tietze and Schenk, Electronic Circuits: Design and Applications (1991). A less formal approach appears inSt.Clairs paperback tutorial, self-published (Controller Tuning and Control Loop Performance By David W. St. Clair ISBN0-9669703-6 Straight-Line Controls, Inc.; from his website (members.aol.com/pidcontrol/) one can download a simulator that al-lows one to try his rules. The easiest simulator, along with a good tutorial, appears in a University of Exeter, U.K., site(http://newton.ex.ac.uk/teaching/CDHW/Feedback/). The simulation lets you try (as you would expect!) the effect of varying P gain andof adding in D and Ijust as we do in todays lab.

  • 8/10/2019 Lab Pid Motor Control

    13/17

    Lab 10: Op Amps V: PID Motor Control 13

    Figure 12: Integral added, to complete the PID loop

    Two details of the integrator may be worth noting:

    two polarized caps placed end-to-end: this odd trick works to permit use of polarized capacitors in a set-ting that can put either polarity across the capacitance. The effective capacitance is, of course, only onehalf the value of each capacitor. We use polarized caps only because large-value caps like these 15 Fparts are hard to nd in non-polarized form.

    seeming absence of DC feedback: at rst glance, this integrator seems doomed to drift to saturation, sincethe integrator includes neither of our usual protections against such driftfeedback resistor or momen-tary discharge switch. But neither is necessary, here, because overall feedbackall the way around thelarge loop, from input pot to output potmakes such unwanted drift impossible. In short, there is DCfeedback, despite appearances to the contrary.

    Watching the effect of I : In todays circuit, the residual error is hard to see on the scope, so adding I willnot reward you as adding D did. Your best hope will come if you cut the P gain very low: try RSum = 100 k,so that the circuit feedback ought to tolerate a noticeable residual error, when not fed an I of the error. If youhave been using a functiongenerator to provide step inputs to your circuit, now replace that signal source withthe manually-adjusted pot input. Slow the scope sweep rate, to a rate that permits you to see the multi-secondeffect of the integration.

  • 8/10/2019 Lab Pid Motor Control

    14/17

    14 Lab 10: Op Amps V: PID Motor Control

    If you are using a digital scope, you will be able to watch input (Target), output (Motorpot)and Integrator signals, after a step input applied from your input potentiometer. If you are patient, you can even make outthe effects of the motor and pots sticktion (a cute term for static friction): the motor and pot do not movesmoothly in response to a slowly-changing input (here, the I term 8). Instead, the motor fails to move till the I voltage reaches some minimal level; then output voltage jumps to a new level, and waits for another shove.You can see these effects in some of the scope images attached at the end of these lab notes.

    10L.4.1 ...but Too Much I again brings Instability

    It sounds dangerous, doesnt it?tacking in an integral term when integration, plus other lagging phaseshifts, are just what threatens the circuits stability. It is dangerous, as you can conrm by overdoing the I .You should be able to evoke continuous oscillation, as in the dark days before you knew about the stabilizingeffect of D ! Yet, remarkable though this fact is, some I does improve loop performance, and need not bringon instability.

    (end lab notes; scope images follow)

    8 We dont want you to think we mean current, here, when we speak of I .

  • 8/10/2019 Lab Pid Motor Control

    15/17

    Lab 10: Op Amps V: PID Motor Control 15

    Scope Images: Effect of Increasing Gain, in P-only loop

    Figure 13: Increasing P-only gain brings increasing overshoot

  • 8/10/2019 Lab Pid Motor Control

    16/17

    16 Lab 10: Op Amps V: PID Motor Control

    Figure 14: Increasing P-only gain, taken to brink of oscillation; and effect of integration term

    lb op5 pid july12.tex; October 1, 2013

  • 8/10/2019 Lab Pid Motor Control

    17/17

    Index

    PIDP: proportional to error (lab), 8derivative of error

    calculating (lab), 1112derivative of error (lab), 1012integral of error (lab), 1214

    17