# Control System - Changing damping on-the-fly?

I'm trying to implement a PID algorithm on a microcontroller that controls an actuator with a hard physical limit. In MATLAB, there's no consequence to large overshoots/hitting saturation at high velocity - the graph just flattens out. In application however, hitting saturation very fast will eventually break the actuator. I would like to decelerate before this happens so that the actuator doesn't max out at full force. Going critically or overdamped will avoid this problem, but for reference values that are less than saturation, I can accept overshoot (max 10%) for the sake of speed so long as the peaks never cross this hard limit. In other words, if my reference value changes to 50%, an underdamped response is okay, but if my reference value goes to either extreme, it needs to be critically damped so I don't slam into anything mechanically.

Implementing this seems straightforward enough - create gain functions as a function of reference value and linearly interpolate between the sets of precomputed values as necessary. But I have to ask, is dynamically changing damping crazy or something that's actually used in control systems? Is this a naive approach?

• What you are looking for is called Adaptive control which is a well documented control method. You can probably find books devoted to the subject easily. Here is an example of a book on the subject Commented Nov 20, 2013 at 19:32

Any particular reason you are considering implementing a D term? The reason I ask is while they are great in theory, providing a higher component for high error steps and smaller component for smaller error steps THEY are very prone to noise.

They are at the end of the day, differentiators. As a result they are usually not considered for practical implementations of control loops. If they are, it is small component or in the form of a lead-lag compensator.

For you specific example with an actuator hitting an end-stop, the issue isn't so much with hitting the end-stop, but with hitting it with "high velocity". One option to consider is at the output of your PI (maybe D) position loop, the output which is a speed demand into the next loop, is to include a dynamic saturation block.

The saturation limits are then dependent on the absolute position of the actuator. 100% rate for say... 90% of the stroke. then as the actuator comes closer and close to the end-stop, saturation limits are decreased so at... 98% IF there is any high speed demand out of the position loop for whatever reason (instability, noise, BAD command...) the actual speed limit is 10% of maximum

Not naive at all. Let's face it many control systems have to cope with plenty of variability in mechanical systems and one of these might well be the natural damping of the mechanics.

Providing you have a decent idea about position of the actuator you can choose to accelerate or decelerate as you think appropriate.

Part of the idea behind PID is that you use the combination of where you are and how fast you're moving to figure out how far the system is going to "coast", to ensure that the system can be commanded to slow down before reaching its setpoint. If assumes a maximum "desirable" rate of change on the output stimulus, one may figure out for a given combination of position and velocity, what would be the maximum output stimulus that would avoid a collision if one started decreasing the output at the maximum allowable speed. Clamping the output stimulus to that level should then allow you to avoid a collision.

Note that part of the design philosophy behind PID is that position and all its derivatives (including velocity, acceleration, impetus) should vary "smoothly" as the system approaches its target. The clamping behavior of a "safety limit" may not be as terribly smooth, though if it starts clamping at the level where it estimates that the output would have to change faster than desired to prevent a collision (rather than merely clamping at the level where output would have to quickly drive maximum negative) it shouldn't be too bad. If one accurately estimates what would be required to avoid a collision assuming the output is ramped at the maximum desirable rate, the output will ramp smoothly at that rate. If one overestimates the ability of the equipment to avoid a collision with the desirable ramp speed, the output will have to ramp faster than desirable. If one underestimates the system's ability to avoid a collision, the output will start slowing down sooner than would have been necessary. In any case, if the assumed "desirable" ramp speed is well below what the system can actually achieve, that should provide some safety margin with regard to one's estimation.