![]() |
Wescott Design Services Systems - Embedded Software - Circuits |
|||||||||||||||||||||||||||||||||||||
| Home | Capabilities | Contact Us | Articles | Books | Seminars | ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
1 MotivationTwo of the most prevalent issues in controlling moving mechanisms are friction and backlash. These effects are present in nearly every mechanism that one may wish to control and they have a serious negative impact on the control system designer's ability to accurately control mechanism motion, yet often they can be eliminated only through heroic efforts on the part of mechanism designers. Thus it is often necessary to deal with these effects in the controller. This article explains friction and backlash effects, why they are a source of problems in motion system design, how a control system designer can predict their effects and how to mitigate those effects. 2 BehaviorThe property that makes both friction and backlash difficult to deal with is the existence of sudden, difficult to quantify discontinuities. This not only makes it difficult to deal with their behavior mathematically, it also means that the performance of common PID and PD controllers will not be close to optimal, and will often not be satisfactory. Everyone is familiar with friction in everyday life. Friction lets us stand and walk, it lets us hold tools and food, it makes our machines run. Friction also defeats our attempts to build 100% efficient machines, and it can make life difficult for a control systems designer. Figure 1 shows the main characteristics of a mechanical interface with friction. The stiction (or starting friction) is the amount of force required to break the interface loose. The Coloumbic (or “dry”) friction is that portion of the running friction that is dependent only on the direction of motion but has constant magnitude. Finally most mechanisms with friction also display some viscous drag that is more or less proportional to velocity.
Looking at Figure 1 there are not one, but two discontinuities around zero velocity. First there's the Coulombic friction, where the force resisting motion is proportional to the sign of the velocity. If that weren't enough, most interfaces with friction also exhibit stiction, where if the interface has remained still for any length of time the amount of force required to start the relative motion is greater than the amount required to sustain it. This results in the force/velocity relationship having an effective gain that is both nearly infinite and negative, neither of which are conducive to loop stability. Backlash is the term that is commonly used to describe any sort of coupling that has slack when it is unloaded, such as a geartrain or a pair of levers that are held together with a pin. Such devices require a certain amount of running clearance to work, and this running clearance must be taken up before the output of the device will respond to the input. This all means that for a given input position the position of the output is indeterminate within the limits of the backlash.
Figure 2 shows that backlash presents problems to the would-be plant model that are nearly as severe as friction does. In the case of backlash there is a hidden state – the difference between the input and output positions. This state is only independent of the input position when it is within the indeterminate region – beyond that it is pinned to the input position. This causes the plant model to have variable structure, with a discontinuous transition between the “free” and “pinned” modes. Figure 3 shows the motor model that will be used in this paper. The motor armature velocity determines the friction torque available. This toque is subtracted from the applied torque. If there is any torque left over this is used to accelerate the motor armature. The armature velocity is integrated into motor shaft position. The motor drives a device (usually a gearbox) that has some backlash; the output of this device is the output of the motor model.
2.1 Continuous RotationIf the system to be controlled is going to be running continuously and in such a manner that the backlash is always taken up, then the behaviors shown by figures 1 and 2 will be reduced to a fixed friction torque and a fixed positional offset. In this case then the system behavior can be modeled easily by linearization and simple PID control techniques can be used quite successfully.
Example 1: When Friction isn't So Bad. A motor that can be accurately modeled by Figure 3 is connected to a small conveyor belt, and is controlled by a PID controller connected to the motor via tachometer feedback as shown in Figure 4. The response of the motor velocity to a torque disturbance is a damped pass-band response which can be approximated by (1), where the damping ratio (z) is no less than 0.7, the loop natural frequency (w0) is approximately 14 radians/sec, and the coupling constant at the motor kd is no more1 than 100 RPM/N-m/sec (N-m = Newton-meter). The breakaway torque is 0.4N-m, the running friction is 0.2N-m, and there are other disturbance torques in the system that can reach 0.4N-m peak-peak.
Solution: If the motor never stops then the friction will always be a constant force which can be easily compensated for by the integrator in the controller. Therefore this problem reduces to one of finding the amount of speed variation in the system, and keeping the motor speed above that figure. As a worst case assume that the system disturbance torque is at the natural frequency where the system response is most sensitive, and furthermore that the system will tend to oscillate at that frequency due to the effect of breakaway torque. The system sensitivity at that point is
The maximum disturbance that will be seen is 0.8N-m peak-peak, so the maximum peak disturbance will be half that, or 0.4N-m. This means that the minimum speed that must be maintained is at least
3 Linear ControllersNormally one linearizes a plant model by choosing an operating point and finding the first derivative of the plant output to the “important” plant inputs. Often this is done so early in the modeling process that one doesn't even notice it. This approach works in cases where the first derivative exists and where it doesn't vary over too wide a range, and where the plant model doesn't dramatically change it's character as a function of it's state. In the case of friction and backlash, however, the plant's input-output behavior makes this method invalid. 3.1 PD ControlWhen one uses proportional-derivative control in a mechanism with no backlash all of the nonlinear effects of friction will work with the proportional control to help damp the motion of the motor, and the system will tend to have fairly robust stability assuming that the proportional gain isn't pushed to absurdly high levels. The problem with this approach is that the system will never reach zero error, and it isn't sufficient to guarantee stability in a system with backlash. Figure 5 shows the block diagram of the motor-controller that is used for this section and the following one. The motor is driven by a current-output amplifier, so ideally it acts as a double integrator. The motor output position is sampled and compared with the motor command position. The position error is applied to a linear compensator (H), the current command is saturated to stay within the limits of the current drive, then the command is applied to a DAC which acts as a zero-order hold.
Figure 6 shows a plot of a motor with friction that's being controlled by a PD controller. Compare this to Figure 7, which shows a similar motor without friction. The system shown in Figure 6 never reaches the target position – it gets to about 0.4 units away, then stops. Note that if you reduce the derivative term just right and start with just the right error you can make the motor in Figure 6 settle out to zero, but this doesn't work in general. If your system changes with time (which it will invariably do) or if you have to servo from different starting points then the technique will not work.
The system response shown in Figure 6 can be adequate if the position error is smaller than your needed precision, either through controlled friction or controlled expectations. Adding backlash into the mix can present difficulties, however. Figure 8 shows the response of a motor with backlash (and lower friction than the motor in Figure 6). Initially the motor response is more or less correct, but the motor overshoots somewhat, then gains speed in the opposite direction and “thunks” into the backlash, then commences to oscillate with the limit cycle shown.
A PD controller can be used in a system with friction and no appreciable backlash, as long as one is willing to accept the fact that the target point will never be reached, and that as a consequence the drive to the motor may stay on for long periods of time. Applying PD control to a motor with friction and backlash is less safe, as indicated by Figure 8. Such systems can be designed to be stable, but the steady-state error cannot be guaranteed to be zero and stability verification must be done on the nonlinear system model which can be difficult. Some systems that include a motor with friction can be controlled with a PD controller in a satisfactory manner. The primary requirement is that it not be necessary to come to rest exactly on the target point, that there are no other significant disturbance torques and that some residual drive to the motor can be tolerated in the long term. In that case the maximum error that can be expected from such a system is the one where the torque command just equals the breakaway torque. For a given breakaway torque (Fs) and proportional gain (kp) this position angle can be found:
When the system settles, there will generally be a position error and the controller will continue driving the motor. Depending on the system design this may cause excessive power dissipation. If this angular error is within an acceptable range and the power dissipation is acceptable then you don't need to do anything at all; just use the controller as it is. If the angular error or power dissipation is too large then you'll need to use one of the nonlinear compensation methods presented later in this paper. 3.2 Motor FeedbackIn the system shown in Figure 8 the limit cycle is due to the acceleration of the motor while the backlash is being taken up. During the interval when the output is not moving the motor is building up speed. Once the backlash is taken up the motor impacts the gears or mechanism causing the backlash, and the output inevitably overshoots. In this case the primary cause of trouble is the fact that the motor accelerates uncontrollably – if the motor speed could be controlled even while the mechanism was within its slack area then the limit cycle could be reduced in amplitude or eliminated altogether. Figure 9 is a block diagram of a system with a sensor added to the motor shaft and used to control the motor velocity. The sensor can be a position encoder (which would require the differentiator shown) or a tachometer. The advantage of adding motor shaft feedback is that the controller can sense the behavior of the motor itself; this allows the control system to prevent the motor from going too fast as it takes up the slack in the gearbox thereby reducing or eliminating the overshoot when the slack is taken up.
3.3 PID ControlFigure 10 shows a plot of a motor with friction that's being controlled by a PID controller. Compare this to Figure 11, which shows a similar motor without friction. All appears well with this motor, but there's a hidden problem. The friction in the motor leaves a slight residual position error on the motor that cannot be overcome immediately by the controller. After a time, the motor with friction will go into a limit cycle, as shown in Figure 12. This can be insidious because it may take quite some time before the limit cycle starts up and because the level of friction generally varies greatly with temperature, so it's not always obvious what's causing the problem.
Applying a PID controller to a motor with both friction and backlash will likely either result in the behavior seen in Figure 8 or Figure 12 (or both on a bad day). Because the motor will never settle to exactly the right spot, and because the PID will never quit pushing you're almost guaranteed to see a limit cycle of some sort. 4 Nonlinear CompensatorsWhen a straight linear controller doesn't provide adequate performance there are two nonlinear compensation schemes that have been developed over the years to deal with friction and backlash. These are pulse-width modulation of the motor drive and the use of deadband in the feedback loop. 4.1 PWM Motor DriveOne fairly easy and effective measure that can be taken to increase servo system performance is to pulse-width modulate (PWM) the drive to the motor. Rather than letting the drive to the motor fall continuously to zero from the maximum drive, the drive is allowed to fall to some point, then it is pulsed on and off with a duty cycle that provides the correct average drive. In cases where the motor can take the treatment the driver circuitry can be simplified by pulsing the full motor voltage on and off. Note that the PWM drive to the motor is not occurring at very high frequencies. The switching in the PWM motor drive is not being done for efficiency as in the case of a switching power supply, and the effect is lost if it is too fast. PWM motor drive frequencies are generally in the 10Hz to 1000Hz range, where modern switching amplifiers generally operate well above 20kHz. The advantage of a PWM drive to a motor which is limited by friction is that the motor will always move for small inputs. This means that the motor can be slowed down to a crawl without the jerkiness associated with a continuous drive. In fact, using PWM drive to a motor often means that the controller doesn't have to have an integrator to achieve zero steady-state position error, so you can often drop from a PID loop to a PD loop. There are disadvantages, however. The motor will always move by a discrete amount, however small, and the difficulty of controlling the system well go up as this amount goes down. The velocity to drive relationship can be quite nonlinear, if not as bad as without PWM. Finally, the current pulses to the motor can be severe; full-voltage PWM drive requires that you use a motor with stout brushes in an assembly that can take the strong torque pulses. 4.1.1 PWM Drive CharacteristicsIf the motor is stopped, the amount that the motor will move in response to a single pulse depends on the level of friction in the motor, the torque generated at the motor armature in response to a pulse, and the length of the pulse. This can be found by calculating the motor motion in response to a single pulse. The motor will accelerate in response to a pulse, then it will slide to a stop. The following discussion assumes that the pulse width is at least as long as the motor's electrical time constant and short enough that the motor velocity doesn't get large enough to create any restraining torque other than friction. Given that, the motor's velocity and position profile will follow the relationship
where w is the motor velocity, q is the distance traveled by the motor, Ts is the theoretical stall torque of the motor, Tf is the friction torque, Jm is the moment of inertia seen by the motor armature and tp is the pulse duration. After the pulse is removed the motor will slide to a stop in time ts, which can be found from
where won is the motor speed attained in (4). The total distance that the motor travels in response to a pulse can then be determined:
(6) can be substituted into (7) to eliminate ts:
The stall torque, Ts, in the above equations is the torque generated by the motor when it's driven by the given pulse, and ignoring friction. If you know the characteristics you can derive this from the motor data using the motor torque constant and the drive current:
where Ia is the drive current and kt is the motor's torque constant. If the motor is being driven by a voltage then the drive current can be found from the motor's armature resistance and drive voltage:
where Vd is the commanded voltage and Ra is the armature resistance. The above calculations indicate that the motor will always move in response to a pulse, but that the amount that the motor moves will be proportional to the square of the pulse width. These calculations only hold if the motor is not moving before the onset of the pulse. Once the pulses are spaced closely enough that the motor does not stop between pulses. This duty cycle is a constant over a fairly large range of pulse on-times, and is equal to the ratio of the motor's friction torque divided by it's frictionless drive torque during a pulse:
Example 2: Setting PWM Duration. You are designing a motor controller for a motor with substantial friction. The motor has an armature resistance of 1.7 ohms, a torque constant of 5.9 mNm/A (millinewton-meter/amp), a rotor inertia of 3.8 gram-cm2 and a rotor inductance of 110microhenry. The motor is attached to a mechanism with a moment of inertia of 5 gram-cm2, a breakaway friction torque that can range from 2 to 5 mNm, and a running friction torque that can range from 1 to 2 mNm. You are driving this mechanism from a controlled-voltage source that can deliver from -5V to +5V.
Solution: The torque at the motor armature is equal to the armature current times the torque constant. To generate 5mNm this current must be:
The voltage required to develop this current across the motor armature can be found from the motor armature resistance:
The motor torque at this voltage, when the motor is not running, is
which is 20% greater than the specified 5mNm. We can find the displacement vs. time from (8):
To find the maximum allowable time we need to use the maximum displacement and the minimum Tf. This time is:
Given this time, with the maximum friction the displacement will be
The electrical time constant of the motor is simply the L/R constant of the armature. This is
The duty cycle where the motor will start running continuously ranges from
If the on-time of the motor pulse is known then the motor speed will depend on the duty cycle up to the point where the motor begins to run continuously. At that point the motor speed will depend on the nature of the motor driver and on any viscous drag in the mechanism. For a current driver the motor speed above the continuous-rotation duty cycle will be limited only by mechanism drag. For a voltage driver the motor speed will also be limited by the motor's back EMF. As an example, consider a driver that delivers a controlled voltage to the motor, with the voltage transitioning from a constant-voltage drive to a PWM drive to maintain motor motion according to
where u is the voltage command, Vfric is the drive voltage chosen to overcome friction, and pwm(r, t) generates a PWM pulse train with the specified duty cycle. Given this drive the average motor speed will follow the characteristics shown in Figure 13.
The slope of the velocity/drive curve in the continuous rotation regions (segments AB and CD) are a function of the motor's velocity constant and any viscous drag that may be present. The slope of the velocity/drive curve in the region full-stop region (line BC) depends on the length of the motor on pulse and on the drive current (or voltage). If the pulse on time is held constant and the pulse off time is varied to modify the duty cycle then the cycle time is
and the average velocity is just the position offset from (8) divided by the cycle time:
Figure 13 and equations (8) and (14) combine to illustrate an important trade off when using PWM drive: Reducing ton will give you a smaller position increment, but the slope of the average velocity vs. drive will be smaller, thereby making the break in the velocity/drive curve more pronounced. This break will cause difficulties in tuning a controller that get greater as the on time is reduced. This effect can be ameliorated by increasing Ts, but doing so can be hard on the motor's brushes and on the mechanical assembly.
Example 3: Gain Variation with PWM Drive. The motor and PWM drive specified in Example 2 is to be used in a system with PD position control. The minimum on-time has been set to 2ms. Due to mechanical considerations the control system bandwidth must be held to 20Hz or less. Assume a sampling rate of 200Hz, and a running friction of 2mNm.
Solution: With a running friction of 2mNm, the current required from the motor will be
With 5 volts applied to the motor terminals the motor armature voltage will be
Using the torque constant as the speed constant2, the maximum motor speed will be
From Example 2 the inflection point occurs at a duty cycle of 33% with an on voltage of 1.74V. The average speed will be
This duty cycle will be commanded when the voltage command is
The slope of the low-slope portion of the curve is
The two higher-slope curves are symmetrical, so the two slopes are equal. The upper curve ranges from the inflection point at (0.574V, 4.5rad/sec) to the maximum-speed point of (5V, 746rad/sec). The slope is
which closely matches the value predicted from 1/km = 170 rad/volt-sec. Note that these slopes differ by a factor that exceeds 1:20.
4.1.2 Implementing PWM DriveThere are a number of ways that PWM drive can be implemented to drive a motor. Four methods that are most often convenient are a pure analog implementation, an implementation using digital circuitry (either custom-built or as part of a microcontroller) and implementing PWM drive in software. 4.1.2.1 Pure AnalogPure analog PWM generators are most valuable in small control systems that are purely analog, but may also have application where a very small microprocessor is used for control and there aren't enough clock cycles for the processor to generate the PWM. Figure 14 shows a block diagram of a simple analog PWM generator. The circuit generates a sawtooth wave of the right frequency. The sawtooth wave is applied to a comparator along with the command voltage, and the output of the comparator is applied to a power amplifier which drives the motor.
4.1.2.2 Digital HardwareIn many motion control systems the control loop is closed in software running on a microcontroller or microprocessor. Feedback from the plant is converted to digital for the processor to read, and plant drive is converted to analog. In systems of this type it often makes sense to generate the PWM signal in the digital realm, then amplify the resulting logic-level pulses to drive the motor. Most dedicated microcontrollers have dedicated PWM hardware that can be used to generate an appropriate PWM signal to drive a motor. If your system does not, or if it isn't convenient to use the on-board PWM generator, then dedicated digital hardware can be designed instead. In this case it's probably best to study the data sheets for a few microcontrollers, decide which PWM generator features you want, and implement them. 4.1.2.3 Software GeneratedIn the case where the final motor drive voltage is under software control (either through a DAC and a linear amplifier, or from a high-speed switching amplifier driven directly from the microprocessor) the necessary PWM waveform can usually be generated in software. The software should be structured with an interface routine that determines the necessary voltage and PWM duty cycle, and a driver that actually switches the drive on and off. When PWM is generated in software it is generally best to switch the PWM signal on and off from an ISR driven by a hardware timer. It also generally works well to have the PWM on-time be determined by the timer cycle time, and the duty-cycle to be controlled by software. 4.2 DeadbandWhile PWM drive will allow you to design a system with a much smaller resting error, it is not possible to bring this error to zero. This small residual error can cause problems with hunting. Since there is nothing that can be done to prevent the residual error, it is necessary to find a way to cope with it. The method that works best for this is to put some deadband in the controller's error term. Deadband sets the drive to the motor to zero when the input error is within some defined limit, so the motor will come to rest even if it is at a slightly incorrect position. The two most commonly used deadband methods are defined in (15) and (16) and shown in Figure 15.
Figure 16 shows the preferred method of designing a controller with backlash. The deadband is only applied the proportional feedback – derivative feedback is treated separately, so the motor velocity will always have a damping effect on the motor motion, and so there won't be any “hiccups” in the motor drive if the error term passes through zero.
Using deadband in a control loop with a PID controller can present some interesting difficulties, and should be approached with care. Deadband reduces the effective loop gain to zero at small errors. Because a PID driving a motor is only marginally stable as the loop gain decreases this can cause problems, which are compounded by using PWM. Additionally, the deadband can leave the integrator with some non-zero stored value that will waste power and heat the motor. Setting the amount of deadband in a system can be problematic. At a minimum the deadband should be set to the amount that the motor can jump if the error is just outside the deadband region, to prevent small limit cycles. For a mechanism that has significant friction and backlash, however, this deadband will prove to be too small in practice. Normal system design will usually include quite a bit of cut-and-try tuning of backlash parameters to arrive at acceptable system behavior. 5 Mechanical MitigationWhile friction and backlash can be difficult or impossible to eliminate from a mechanism, there are some measures that the mechanical designer can take that may mitigate their effects. These measures must be considered on a whole-system basis, with cooperation between the control system designer and the mechanical designer. Simply reducing backlash and friction is an obvious step, and it is to be assumed that the mechanical designers will do this as a matter of course, so I will not mention it further. Treating the effects of stiction separately from dry friction is often a good idea. Dry friction often has a stabilizing effect on a system, while stiction has a destabilizing effect (the limit cycle seen in Figure 12, for instance, would not exist if it were not for stiction). Often measures that lower stiction at the expense of higher dry friction are beneficial. Adding flywheels to motors is a direct method to reduce the effect of friction: as seen in Example 1 a motor with significant flywheel action can run quite slowly without friction problems. Backlash effects can be mitigated with tachometer feedback such as the system shown in Figure 9. 6 ConclusionWhile there are no magic control techniques that will eliminate the problems caused by friction and backlash, using the methods outlined in this paper will allow a control system designer to get the most out of a system with these effects. Return to the Wescott Design Services homepage. 1Note that this implies a fairly hefty flywheel on the motor. 2In general this is valid with DC motors. |
||||||||||||||||||||||||||||||||||||||
| Copyright © 2007, Wescott Design Services, Inc. All Rights Reserved. |