PID controller: dummy questions

I think the wrong assumption was: as soon as the error goes to zero, P and I term should be zero as well, because we reached the set-point.

For example, when I need to move the optical bar of a scanner to a certain position. As soon as the bar reached the wanted position, the power from the motors must be cut off immediately (because the bar doesn't move if the motors are off). This means that when the error is zero, P+I must be zero as well. However this is impossible. P is really zero, but I isn't zero, because it's the sum of all the previous errors that are all positive. So the power doesn't drop to zero and we have an overshoot (the bar moves after the wanted position). Now the error starts being negative and I starts decreasing.

I think that systems similar to optical bars (where the controlled signal must be stopped as soon as the set-point is reached) is best controlled by a P-only algorithm.

Now come to mind another scenario. Suppose I need to transfer heat to a

I know I can tune the PID controller (i.e., find an optimal Kp, Ki, Kd) to avoid overshoots, but I'm wondering if some other techniques can be implemented too.

For example, changing dynamically PID coefficients when the error is negative.

Reply to
pozz
Loading thread data ...

Yes - P goes to zero, and I /stabilises/ to a value of output that results in a steady state.

If you overshoot - perhaps I has built up too much - the error term will be negative, so the I term will decrease (but remain positive for a while), while the P term will be negative.

That works for some kinds of systems. In other systems, you might have gravity or a spring that means keeping the same position requires a constant small force - you get that from the I term.

In this case, the I term will be zero at the perfect stable spot. But it could well be non-zero while moving - a P term alone rarely gets you to the target. (Imagine you are near the target. The P term might give too low a force to overcome the static friction and move the bar - then the I term will build up until things are moving.)

Yes.

In any regulation system, you have a balance between reacting quickly to changes and minimising overshoot and oscillations. The D term can be helpful in reducing these unwanted effects.

You'll never get to the target that way. Maybe that's okay, and you'll get close enough. Sometimes overshoot must be avoided at all costs, other times it is merely a mild inconvenience - there is no single answer to all regulation problems.

And pure PID is just one way to regulate a system. You can use variations or ad-hoc methods (such as P regulation, but using an artificial setpoint beyond the real target, or applying a break when you hit the target), or you can use completely different regulation techniques.

Reply to
David Brown

The error is *after* all three PID factors are added. The I factor reduces the error. If it reduces the error to zero, the I term stops increasing.

In real life terms, consider this: you want to heat a pot of water to a slow boil. You turn on the stove, at first a lot as a "guess" but as the pot approaches the boiling you turn the heat down (P term). Eventually you have to start tweaking the heat up a bit to bring the temperature up, this is the I term. As you approach the right temp, you tweak in smaller increments, until you're there.

Error is 30.

Better example: when the heat gets to 45 degrees (error=5) the P term has been reduced enough that the water doesn't get any warmer. If the water were to warm up, the heat would be reduced, and it would cool again. You've reached steady state, and this is as close as the P term can get you. This happens relatively quickly. Let's say the P term is providing 500 watts at this point.

Now, you need a little more heat to make up the difference.

The I term sees the small remaining error, and slowly adds more heat, until the temperature slowly climbs to the set point. The I term might be adding another 5 watts or so

And the error quickly jumps up, the P term immediately reacts. The I term slowly starts rising again. More heat pours in. The temperature might rise past the set point, but then the error is *negative* and the I term slowly goes down until it's back where we started.

You're missing that if the I term keeps increasing, eventually the water will be too hot, the error negative, and that reduces the I term again.

It's like the pot on the stove. You turn the heat up until the water is the right temperature, but if you *keep* turning the knob up, the water becomes too hot, and you have to turn the knob back down again.

Reply to
DJ Delorie

The motor situation where you want 0 signal to hold at the desired set point, basically implies that the system has an integrator in its response. (A pole at zero). With the motor that is because the input Voltage determines the Speed of the motor, and the motor mechanics integrates that speed to become a position, which is the thing that is being controlled. Such a system may not need an integral term for 0 error (because the plant provides that integral term).

On the other hand, if there is a bit of force on the motor (maybe gravity) and with zero input, the system slides of the control point, so we need to add a bit of voltage to provide some torque to counter that force, that brings back the need for the integral loop to provide that balancing voltage.

One issue with your P only controller for position, is that as you get close, you slow down, so you close slower, and slower, so it takes a while to get to where you want (theoretically, forever, as you will close exponentially). You can make the loop faster by raising P, but at some point, the gain gets too high, and other dynamics or time delays get in the way and the system may mal-perform.

PID loops, when properly tuned, can get you closer faster when you tune the system to be critically damped, the key being that you let the PI terms give you a higher starting gain, but then the damping term backs that off giving you more gain at slow speeds, which handles the base error, and less gain at high frequencies where the instabilities live.

As to changing parameters, yes that can be done, and that gets you into the domain of non-linear control. Such system can be harder to think about or analyze, and it can introduce strange phenomenon like limit cycles. I would probably not have a sharp change of values at 0 error, as that would likely be the nominal operating point, so very apt to create limit cycles. You might either gradually adjust the parameters as you go negative, or have a break-point at a certain amount of error that you don't normally expect to reach.

Reply to
Richard Damon

ut

own, but

hes

t,

ain more

oes

at

ting the

creases

es and

ror

ith

s

se

eally,

? If

Not "if" but just "how much" I will cause overshoot. The I term is an osci llator with P as a damping factor.

r

Not correct. This design incorporates the integrator into the mechanism. Position is the integral of velocity which is proportional to the output of the controller. So the additional integrator is not required in the contr oller. But the P term will get to the end position because there is non-id eal behavior in moving the bar because of it's mass. So velocity is not pe rfectly proportional to the control output.

This is why the theory is so hard to manage in real world situations. Ther e are many, many nonidealities. While many of them won't have a significan t impact on the controller, some may and it can be hard to know which need to be factored in.

I'm working on a PID simulation in LTspice. I thought I'd use the "univers al op amp" as an ideal device, but I guess I should have read the data shee t first... lol. I should have something working later in the day.

Working on lunch at the moment.

--

  Rick C. 

  ++ Get 1,000 miles of free Supercharging 
  ++ Tesla referral code - https://ts.la/richard11209
Reply to
Rick C

The integral term is supposed to be a pure integral, no decay. It will only keep getting bigger if you keep having error of the same sign.

Often, limits are put on the integration, to limit the overshoot from 'windup' as the system tries to get close or special rules to hold the integrator when the P-D part of the loop is driving hard.

Reply to
Richard Damon

On Saturday, June 27, 2020 at 1:10:00 PM UTC-4, Rick C wrote:

out

s own, but

h.

aches

int,

Drain more

goes

heat

reting the

decreases

rees and

error

with

is

case

really,

s
d

at

? If

n

re

P
l

cillator with P as a damping factor.

he

e

se

ter

s
o

Position is the integral of velocity which is proportional to the output of the controller. So the additional integrator is not required in the con troller. But the P term will get to the end position because there is non- ideal behavior in moving the bar because of it's mass. So velocity is not perfectly proportional to the control output.

ere are many, many nonidealities. While many of them won't have a signific ant impact on the controller, some may and it can be hard to know which nee d to be factored in.

rsal op amp" as an ideal device, but I guess I should have read the data sh eet first... lol. I should have something working later in the day.

I didn't like the op amp circuits too many components. Here is an LTspice simulation with voltage sources as amplifiers, simpler.

The ringing of the controlled quantity can be managed by "tuning" the ratio of the proportional section to the integral section. Too little P term an d ringing starts. Too much P term and the response is slow. I tried it wi th no P term and the ringing is all you see practically. Ramping down both together rounds the corners of the response. Ramping up both together sha rpens the corners crisply.

PID.asc

Version 4 SHEET 1 884 740 WIRE -368 -224 -384 -224 WIRE -304 -224 -368 -224 WIRE -176 -224 -224 -224 WIRE -384 -192 -384 -224 WIRE -432 -176 -768 -176 WIRE -432 -128 -464 -128 WIRE -464 -112 -464 -128 WIRE -384 -80 -384 -112 WIRE -768 0 -768 -176 WIRE -736 0 -768 0 WIRE -624 0 -656 0 WIRE -592 0 -624 0 WIRE -480 0 -528 0 WIRE -368 0 -384 0 WIRE -304 0 -368 0 WIRE -176 0 -176 -224 WIRE -176 0 -224 0 WIRE -832 16 -912 16 WIRE -768 16 -768 0 WIRE -768 16 -832 16 WIRE -384 32 -384 0 WIRE -912 48 -912 16 WIRE -480 48 -480 0 WIRE -480 48 -560 48 WIRE -432 48 -480 48 WIRE -1024 64 -1072 64 WIRE -960 64 -1024 64 WIRE -560 64 -560 48 WIRE -624 80 -624 0 WIRE -608 80 -624 80 WIRE 80 80 64 80 WIRE 160 80 80 80 WIRE 288 80 240 80 WIRE 400 80 288 80 WIRE 496 80 400 80 WIRE 544 80 496 80 WIRE -432 96 -448 96 WIRE -1024 112 -1072 112 WIRE -960 112 -1024 112 WIRE -448 112 -448 96 WIRE 64 112 64 80 WIRE -608 128 -624 128 WIRE -384 128 -384 112 WIRE -176 128 -176 0 WIRE -112 128 -176 128 WIRE -64 128 -112 128 WIRE 16 128 -64 128 WIRE 288 128 288 80 WIRE 400 128 400 80 WIRE 544 128 544 80 WIRE -1072 144 -1072 112 WIRE -624 144 -624 128 WIRE -912 160 -912 128 WIRE -560 160 -560 144 WIRE -64 176 -64 128 WIRE 16 176 0 176 WIRE 0 192 0 176 WIRE 64 224 64 192 WIRE 672 224 592 224 WIRE 736 224 672 224 WIRE -1072 240 -1072 224 WIRE 288 240 288 192 WIRE 400 240 400 208 WIRE 544 240 544 208 WIRE 736 240 736 224 WIRE -368 256 -384 256 WIRE -304 256 -368 256 WIRE -176 256 -176 128 WIRE -176 256 -224 256 WIRE 592 256 592 224 WIRE -768 288 -768 16 WIRE -720 288 -768 288 WIRE -624 288 -656 288 WIRE -608 288 -624 288 WIRE -592 288 -608 288 WIRE -480 288 -512 288 WIRE -64 288 -64 256 WIRE -384 320 -384 256 WIRE -480 336 -480 288 WIRE -480 336 -544 336 WIRE -432 336 -480 336 WIRE 544 336 544 320 WIRE 592 336 592 304 WIRE 592 336 544 336 WIRE 736 336 736 320 WIRE 736 336 592 336 WIRE -544 352 -544 336 WIRE 544 352 544 336 WIRE -624 368 -624 288 WIRE -592 368 -624 368 WIRE -432 384 -448 384 WIRE -448 400 -448 384 WIRE -592 416 -624 416 WIRE -384 416 -384 400 WIRE -624 432 -624 416 WIRE -544 448 -544 432 FLAG 288 240 0 FLAG 400 240 0 FLAG 544 352 0 FLAG -64 288 0 FLAG 672 224 WaterDraw FLAG -624 432 0 FLAG 496 80 WaterTemp FLAG -1024 64 WaterTemp FLAG -1072 240 0 FLAG -832 16 Error FLAG -1024 112 SetPoint FLAG -112 128 SUM FLAG -368 256 DIF FLAG -368 0 INT FLAG -368 -224 PROP FLAG -608 288 D- FLAG -624 144 0 FLAG -624 0 I- FLAG -384 -80 0 FLAG -464 -112 0 FLAG -912 160 0 FLAG -560 160 0 FLAG -544 448 0 FLAG 64 224 0 FLAG 0 192 0 FLAG 80 80 Correction FLAG -448 112 0 FLAG -384 128 0 FLAG -448 400 0 FLAG -384 416 0 SYMBOL cap 272 128 R0 SYMATTR InstName HWTank SYMATTR Value 1 SYMBOL res 384 112 R0 SYMATTR InstName HeatLoss SYMATTR Value 10 SYMBOL res -208 -240 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R2 SYMATTR Value 1 SYMBOL res 528 112 R0 SYMATTR InstName DrawPipe SYMATTR Value 1 SYMBOL sw 544 336 R180 SYMATTR InstName S1 SYMATTR Value MYSW SYMBOL voltage 736 224 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName V1 SYMATTR Value 0 SYMBOL res 256 64 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R7 SYMATTR Value 1 SYMBOL res -208 -16 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R3 SYMATTR Value 1 SYMBOL res -208 240 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R4 SYMATTR Value 1 SYMBOL res -48 272 R180 WINDOW 0 36 76 Left 2 WINDOW 3 36 40 Left 2 SYMATTR InstName R1 SYMATTR Value 1 SYMBOL cap -656 272 R90 WINDOW 0 -4 60 VBottom 2 WINDOW 3 -3 2 VBottom 2 SYMATTR InstName Kd SYMATTR Value 1 SYMBOL cap -528 -16 R90 WINDOW 0 0 64 VBottom 2 WINDOW 3 1 6 VBottom 2 SYMATTR InstName Ki SYMATTR Value 1 SYMBOL res -608 304 R270 WINDOW 0 34 32 VTop 2 WINDOW 3 34 76 VTop 2 SYMATTR InstName R6 SYMATTR Value 1 SYMBOL voltage -1072 128 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName V4 SYMATTR Value PULSE(0 2 1 1 1 50) SYMBOL res -640 -16 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R5 SYMATTR Value 1 SYMBOL e -384 -208 R0 SYMATTR InstName E2 SYMATTR Value 90.854 SYMBOL e2 -560 48 R0 SYMATTR InstName E3 SYMATTR Value 1Meg SYMBOL e2 -384 16 R0 SYMATTR InstName E4 SYMATTR Value 100 SYMBOL e 64 96 R0 SYMATTR InstName E5 SYMATTR Value 3 SYMBOL e2 -912 32 R0 SYMATTR InstName E1 SYMATTR Value 1 SYMBOL e2 -544 336 R0 SYMATTR InstName E6 SYMATTR Value 1Meg SYMBOL e2 -384 304 R0 SYMATTR InstName E7 SYMATTR Value 0 TEXT 192 424 Left 2 !.model MYSW SW(Ron=30m Roff=1G Vt=1 Vh=0.1) TEXT 192 368 Left 2 !.tran 5 RECTANGLE Normal 832 560 -1136 -336

PID.plt

[Transient Analysis] { Npanes: 1 { traces: 7 {524291,0,"V(error)"} {524290,0,"V(setpoint)"} {524292,0,"V (watertemp)"} {524293,0,"V(prop)"} {524294,0,"V(int)"} {524295,0,"V(dif)"} {524296,0,"V(sum)"} X: (' ',0,0,1,10) Y[0]: (' ',1,-2,0.5,4.8) Y[1]: ('m',1,1e+308,0.0002,-1e+308) Volts: (' ',0,0,1,-2,0.5,4.8) Log: 0 0 0 } }
--

  Rick C. 

  --- Get 1,000 miles of free Supercharging 
  --- Tesla referral code - https://ts.la/richard11209
Reply to
Rick C

I've found Tim Wescott's website helpful

formatting link

Especially this:

formatting link

--
Best wishes, 
--Phil 
pomartel At Comcast(ignore_this) dot net
Reply to
Phil Martel

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.