Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interpreting PID Output

Status
Not open for further replies.

buck8pe

Electrical
Apr 13, 2015
10
Hi, first time poster - so go easy:) and I'm relatively new to control systems and electronic engineering, so noddy answers are actually appreciated.
I'm going to post a link to the question I posted on another site to save me typing in all the detail again. I've decided to ask here because the site is more specialized.

Link:
The specific question I have is in the update section, although it's worth reading the entire post to get a sense of what I'm trying to achieve. As a further update, I've disabled the I contribution from the controller and the error response is more stable, which I would expect.
I'm actually OK on PID theory, in that I understand enough to get by. My question really relates to how the PID affects the system itself (Position Vs Velocity). I didn't get a good intuitive understanding of either of these approaches from the contributors and my efforts to find good entry level descriptions on the net was poor. I'd appreciate a decent (intuitive) description of either in relation to my particular project. Regards.
 
Replies continue below

Recommended for you

For a green house?? It sounds as if you are confusing yourself with details that may not matter. Use P only, no I, no D.
Dial in about 10% proportional band and go for a beer.
A green house may be similar much less challenging that a lumber kiln. I have seen a few disasterous control schemes applied to lumber dry kilns. Al responded well to 10% proportional band. The worst application was a sophisticated and expensive analogue computer that took about 20 to 30 days to dry a charge of lumber. A few hundred dollars for cheap PID controllers and we were drying a charge in 7 or 8 days.
Another disaster was a pneumatic controller. Out of the box the controller was set for on-off control. This led to painting the chart. The recording chart showed rapid swings from over shoot to under shoot.
Someone tried to correct this by installing an adjustable restriction in the air line to the actuator. This helped a little but not enough. The next attempt was two restrictions and check valves. The idea was that the speed of actuation in one direction could be slowed by one check valve and restrictor to lessen overshoot. The speed of actuation in the other direction was controlled by the other check valve and restrictor to lessen under shoot.
We threw away all the extra hardware and dialed in 10% Proportional band. The control was working smoothly and drawing a straight line when we left.
And by the way, for many years the de-facto standard softwood lumber kiln controller used on-off action and the pens happily "painted the charts". For many years this did an adequate job of drying lumber.
By the way, you may missed this part of PID theory, The temperature goes a little above set point. The window opens a little. the temperature goes a little higher and the window opens a little further. repeat
At some point the window is open enough that the temperature no longer rises and the actuator no longer moves.
If you are going full open and full closed, you don't need a controller or a processor. A $12 thermostat will do that for you.

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
Thanks Bill, well actually you may have guessed that this isn't a life or death project. It's another foray into the murky world of electronics albeit one with some utility. If all that happens at the end of all this is that I learn a few things, I'll be happy enough.

I have disabled the I contribution so that it's now running on the P only. I get a gained up error signal from the PID which is what I'd expect. The problem is how to apply that signal to the actuator. The motor driving the actuator has an encoder and I'm OK on how to translate that into actuator movement (Counter IC & Microcontroller most probably - but that part I'm OK with).

So, just focusing on your statement "The window opens a little. the temperature goes a little higher and the window opens a little further" my question is how should the PID error signal make the window open a little further, incrementally (i.e., velocity) or by going to a certain position (positional). I must say, I don't understand what is meant by positional. Does it mean that one extreme of the PID output (say -3V) represents actuator fully retracted and the other extreme (say 3V) represents fully extended? As I pointed out on the stackexchange thread, that doesn't make sense to me since it means you know where the zero point is. So, when the PID settles down (no error) it commands the actuator to move to a particular point. Is that what position (as opposed to velocity) means?? I would have thought that figuring out where to put the actuator next should be done at each step, so that a new settled (zero point) is found as you have pointed out in your statement. Mind you, that raises other questions, like what happens during the "dead-time" while the system is responding.
 
It really depends on what type of input or control signal your actuator uses. You said that the actuator uses an encoder. This would imply that the actuator system needs a position signal. Anyway two examples of the two types of actuators:

1. Velocity: With an input of 0V the actuator does not move. With an input of 1V it moves slowly in the forward direction. With an input of 5V is moves quickly in the forward direction. With an input of -1V it moves slowly in the reverse direction. With an input of -5V it moves quickly in the reverse direction.

2. Position. With an input of 0V it moves one end of the travel. With an input of 5V it moves to the other end of the travel. With an input of 2.5V it moves to the center of the travel.

Tell us which type of actuator you, and we can help you out.
 
Hi djs, the actuator is one I've built myself. You can see it in the stackexchange thread (see link above), it's basically a wooden box with an m6 threaded rod for a lead screw pushing an aluminium bar. It's simple, but it works pretty well (a little noisy maybe). The motor is a gear motor I got from an old Canon Phaser printer. It's a 12V Buehler gear motor with an encoder attached. I managed to decode the encoder lines using a scope and the encoder pulses look OK. I haven't quite figured out what the resolution is yet, that's the next step (there's a big fat zero doco on any of Beuhler's custom built motors).
I've built a motor driver using relays and that all works fine, so I can drive the motor back and forward. I'm planning to count the encoder pulses either directly (using an Atmel microprocessor - probably a 2313) or using a combination of counter ICs + uP. Originally, I had planned to convert the encoder count to a voltage signal using a DAC (I even built an R2R DAC just for the hell of it) and although the DAC works well and I'm getting a nice incremental signal, 8 bits is simply not enough to get me any decent distance. So, I'll just feed the count into the uP and go from there.
So, that's where I'm at, I have all the major components built or prototyped, now I just need to put them all together - hence the question about the PID. By the way, you can see the circuit diagram for the PID on the SE thread.
Thanks for your explanation of velocity vs position, by the way. So, it looks like the PID that I've built is better suited to velocity, or there's something else needed between PID and actuator. I wouldn't expect the PID to effectively instruct that the window be closed when the error is zero (if I understand position description correctly). That doesn't make sense to me. Any other insights you have will be greatly appreciated. Regards.
 
Well now that we know that you are not using industrial equipment, it looks like you still have to design and build a positioner.
An industrial PID controller will output a signal in air pressure, current or voltage.
The signal will vary from 0% to 100% (or from 100% to 0%)
The signal will go to the positioner and the positioner will control the position of the actuator.
The old pneumatic systems often used pneumatic actuators with calibrated return springs. For instance, a pneumatic PID a would output a pressure signal varying from 3 Psi. to 15 Psi. The valve actuator would not start to move until the input pressure was at least 3 Psi, and would reach the end of the stroke when 15 Psi. was applied. Dampers with calibrated springs are still common.
A very common output signal from electronic PID controllers is 4ma to 20 ma. The current signal would be sent to an I/P transducer. (Current to Pressure transducer). The I/P would convert the 4-20ma signal to a 3-15Psi pressure signal. The 3-15 Psi signal would operate the damper actuator directly.
Positioners accept the signal from the PID controller, (ma, V, Psi. as the case may be) and drive the final control element to a position commanded by the value of the input signal.
Signals and positions are conveniently measured in percentage. ie: A 40% signal will result in the actuator moving to the 40% position.

Now where do we go from here? What do you really want to do? If you want to develop a conventional PID control system based on industrial control principles, you probably need to design and build a positioner.

If you want to just control the darn window and get back to watching the game on TV, read on.
I mentioned a system based on an analogue computer. This system used motor driven actuators. The actuators had resistance wipers that reported the position of the actuator back to the controller/computer. In effect the positioner was built in as part of the computer.
After I threw out the existing computer I was faced with the challenge of controlling non-standard motor operators with an off the shelf PID controller.
The solution was off the wall and kludgy, but it worked. The mill in question was in the process of constructing 4 new dry kilns as the existing kilns were not capable of supplying enough dried lumber to operate at peak capacity. After a week the construction was halted. After a month construction was abandoned and the structures converted to storage.
The PID controller that I selected had a variety of available outputs. Current, voltage and time proportional.
This is the part that may solve your issues with little or no new hardware.
Time proportioning gives a pulsed output that may drive a relay. A 10% output on a one minute base results in 6 seconds on and 54 seconds off, repeating.
Pick a time, one minute to start.
Pick a deadband, one degree to start.
Every one minute compare the setpoint with the actual temperature.
If the actual temperature is more than one degree above the setpoint, apply a pulse long enough to drive the actuator about 10% of its travel.
If the actual temperature is more than one degree below the setpoint, apply a pulse long enough to drive the actuator about 10% of its travel in the opposite direction.
Repeat every minute.
Let us know how you choose and how it goes.
Once the system is running, tweak the time base, the deadband, and the pulse width (actuator run time).
Not PID and not pretty, but it will do the job.

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
Aha, waross, I think I'm starting to see the solutions now! It's funny, but the suggestion at the end of your last post was exactly what I had in mind when I asked the question on the SE forum. That's what I meant when I posted "One idea I had was to slow down the command delivery by sampling the PID output". I'm guessing it would cause the actuator to hunt about a bit, but it's a good start and one I'll try.

But I'm intrigued by this additional Positioner component. It's worth pointing out that my old-fashioned analog PID, built using op-amps is basically just an op-amp subtractor circuit with gain (I've removed the I contrib at this stage). The output signal is thus -3V to +3V, with zero meaning the setpoint has been reached.

I'm still struggling to understand how a Poitioner can convert a +/- error from the PID algorithm to an absolute 0 - 100% position on the actuator travel. When the PID algorithm outputs -1V it's saying the "current" actuator position is not right, it's -1V short of the SP (in my case it's saying it's too cold, close the window a bit from where you have it). So, I'm guessing the Positioner takes the "current" actuator position into account when it calculates it's percentage output. Have I got that right? But doesn't that make it incremental?
 
The PID output does not care about the positioner position. The PID is looking at the process variable (in your case the actual temperature) and comparing it to the setpoint. The PID is generating a signal based on the deviation of the temperature from the setpoint.
It is convenient to refer to the output in percent. You signal of -3V to +3 V is a range of 6V. -1V is 2V/6V or 33.33%.
When the controller receives an input of 33.33% it commands and controls the actuator to move to the 33.33% position.
This is a dynamic action. The process variable will be changing in response to the control action. That is, the temperature starts to drop and as a result the window starts to close. The temperature may range between the points corresponding to -3V to +3V. If the temperature consistently stabilizes at a few degrees above or below the setpoint, you can add in some offset. The easiest way is to get a given offset is to change the setpoint. For example if the temperature stabilizes at 1 degree below the setpoint just raise the setpoint 1 degree.

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
Thanks for sticking with this waross, I appreciate it. As you describe it then, zero output from the pid would be 3/6 or 50% which would mean the window is half open. And since zero output from the PID means no error you're saying that you expect the temperature(PV) to equal the SP when the actuator is in that position. Or, in other words, whenever the PID gives an output of 0, the actuator is instructed to position itself at 50% (half-open).

If I've got that much right, then how do you deal with the following scenario: the sun is out (a rare thing in Ireland!) the SP is 25degrees and the PV is a happy 25degrees. The actuator is in the 50% position. Now the sun goes in (very likely) and the PID signal starts to fall below zero, the actuator is instructed to move to a position below 50% (close, in other words). After a few minutes, the temperature in the greenhouse starts to climb, not because the sun has come out (it won't be out again for days!) but because the window is closed/closing. As the PID output climbs towards zero again, the actuator is instructed to move towards the 50% mark. The PID may well have a zero error once more, but it's unlikely to be at the point where the window is 50% open. I suppose that's my problem with the idea of fixed positions, they don't seem to allow for multiple zero points.

But then what I think you're saying is that in the scenario given above, the system would settle below the SP, so you add a little extra to the SP to make the 50% mark (zero error) the settling point. I get that, but I wouldn't fancy having to do it every time the sun went in! I take it there's a better way to achieve that? Regards.

 
The position of the window/actuator is PROPORTIONAL to the temperature.
Some numbers:
Range of input to the PID (NOTE: P in PID stands for PROPORTIONAL) is from 0 degrees C to 50 degrees C. or 50 degrees C range.
Proportional band is 10%
Set point is 25 degrees C.
Range is 50 degrees C, 10% is 5 degrees C
The actuator will move from full closed to full open with a 5 degree change in temperature.
Set point 25 C
Full closed at 22.5 C
Full open at 27.5 C
That is proportional control.
You can reduce the proportional band (10) until the system becomes unstable and then dial a little back in.
You have selected an output range of -3V to +3V. Nothing wrong with that, but for your general information, many industrial control schemes use an elevated zero.
There are a couple of reasons.
Response when dropping to zero% signal. The original PID control systems used 3-15PSI air pressure signals. It would take a very long time for the control pressure to drop to zero through the small orifice in the controller, especially with long control lines in an large industrial plant.
Broken line detection. The control lines could be monitored with a pressure switch set at about 2 PSI. A switch closure would signal a broken control line.
Now a lot of systems are 4-20ma. zero ma signals an open loop.
In your system -3V = 0%, +3V = 100%
In a 3-15PSI system 3PSI = 0%, 15PSI = 100%
In a 4-20ma system 4ma = 0%, 20ma = 100%

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
buck8pe said:
But then what I think you're saying is that in the scenario given above, the system would settle below the SP, so you add a little extra to the SP to make the 50% mark (zero error) the settling point. I get that, but I wouldn't fancy having to do it every time the sun went in! I take it there's a better way to achieve that?

Yes, it's called integral action. Put the integrator back into your analog circuit and eventually the error should go to zero, and the disturbances should be fully rejected. If the temperature in the greenhouse drops far enough, the PI controller will shut the window, for example, at night. Once the sun comes back up in the morning and the temperature rises above setpoint, it should start to open the window - though your analog integrator will likely have to unwind some before the control action begins.

I'm actually confused about why you're using a separate analog PID controller as input to the ATTiny 2313 in the first place. Your ATTiny 2313 is able to implement PID. There's an application note here and example code here.

xnuke
"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand, Atlas Shrugged.
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
@waross, your answers are definitely bringing me closer to figuring this out. I'll re-state what I think you've said in your last two posts and you can let me know if I'm there.

So, firstly - and lets forget about PID and assume you were doing this yourself: sunny; 25degrees SP; you move the window to "no error" position A. Cloudy; same SP; you close the window to achieve SP which is "no error" position B. So, intuitively, we can see that depending on the outside conditions, there are many points along the actuator travel that lead to SP attainment in the gh.

When we use an absolute positioning system (where one end of the actuator travel is 0% (fully closed) and the other end is 100% (fully open)), then if we map the PID output directly to this absolute position the "no error" point will be half open. So far, so good.

The problem, of course, is that the absolute actuator "no error" point represents only one of many, many potential "no error" points depending on the conditions (we only discussed two above - sunny, cloudy). So, assuming our, window half open, 50% absolute actuator position is spot-on for a sunny interval, what happens when the sun goes in. Well, the PV drops, the PID produces a negative error which dials in a new (closing) position into our actuator. However, as the window closes the PV rises again. This causes the PID to dial in a new position to open the window. Now, we know (intuitively) that since it's still cloudy, the SP won't be attained at the absolute "no error" actuator position. Rather, the system will settle(balance) somewhere less than the SP (this can be understood because of the tendency for the PID to move the actuator towards the half-open position as the PV rises - but this position is not correct given the ambient conditions).

We deal with this situation as waross suggested by raising the SP to make the system settle at the correct PV. We're essentially tricking the system and producing those infinitude of "no error" points by adjusting the SP. Very clever. So, when it's cloudy the system will settle at 25degrees, the PID won't be producing a zero output signal, but the settle point should be 25degrees. The only problem for me is that the SP is manually dialled in. So, I'd need some way of auto tuning the SP.

As to your last post, I think what you're saying is that you can define a narrow band of error (by adjusting the P gain, I assume) to give a finer control.

@xnuke: the I contrib just gets you to "no error" faster, the problem is where "no error" lies on the actuator (using the absolute positioning method - that is, not incremental).
 
@xnuke: sorry just saw your comment about doing this using the ATTiny. Well, yes, that would make sense, but lets face it, this is all about education. If I had any cop-on I'd just go and open the window myself. The thing is, I'm a software guy by trade, so programming uP's is in my comfort zone. This is more about learning electronics and hardware systems and in particular discrete systems. Because I'm a masochist, I had originally intended to do this without a uP, but that's just crazy, even for me:)
 
I re-read your post xnuke a few times, and I've realized something else. Going back to the point in my scenario above where the P contribution has taken the window to just below the SP. As I said earlier, it can't open the window to the zero (no error/window half open) actuator position because that would make the gh too cool given the cloudy conditions. However, if you put back in the I contrib, then the longer the error persists, the more the error ramps up, which has the effect of closing the window. Now, I wonder about your statement "and eventually the error should go to zero". Even with the I enabled, if the PID outputs a zero and that dials in the half open position for the window, the gh will be too cold. So, I expect the PID will not output a zero in the scenario described. However, in a sense, it's like altering the SP, it has the effect of pushing the settling point towards the SP you desire without actually being at the zero or 50% position on the actuator. Am I on the right track? Or have I fallen down another hole?
 
At this point the best suggestion that i can make is that you do some studying on industrial PID systems. A lot of studying.
Look at typical textbook P response curves, PI curves and PID curves.
I was misled by this statement in your first post"
"I'm actually OK on PID theory, in that I understand enough to get by."
By

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
You seem terribly confused, and should heed waross' advice to study the subject some more. Your hangup seems to be that you think that the control system simply outputs a control signal and stops. That is open-loop behavior and the antithesis of closed-loop PID control, A PID is a feedback control system, so it's total function lies in a continuous process of minimizing the difference between the command and the measurand. Whatever is going with the physical hardware is irrelevant; its only goal in life is to get the error signal to zero, if at all physically possible. It may be that the setpoint is unachievable, in which cause, the command is railed to one of its extremes. If the setpoint is achievable, the control system will command the hardware until the setpoint is achieved.

Your 50% point is irrelevant to the control system; it has no knowledge of it, nor does it care. The 50% point is solely a design constraint to ensure that the control system has ample headroom to drive the system in either direction it needs to go.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529


Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
There is a homework forum hosted by engineering.com:
 
You might just want to forget about the encoder completely. Just using the "P" channel, connect the output of the gain stage directly to the motor. If the temperature is higher than the setpoint, the output of the gain stage will start to become slightly positive, which will run the motor slowly to open the window. When the temperature falls in the GH, the output of the gain stage will go to zero. The motor acts as your "I" channel giving you zero steady state error.

Devil is in the details, you will have to slow the rate of change of the motor to make the system work. One example of this is to work the motor on a duty cycle. Very similar to what waross said:
waross said:
Pick a time, one minute to start.
Pick a deadband, one degree to start.
Every one minute compare the setpoint with the actual temperature.
If the actual temperature is more than one degree above the setpoint, apply a pulse long enough to drive the actuator about 10% of its travel.
If the actual temperature is more than one degree below the setpoint, apply a pulse long enough to drive the actuator about 10% of its travel in the opposite direction.
Repeat every minute.

Believe it or not the above is actually "P" channel controller with the motor acting as the "I" channel. No real need for complex calculations.
 
My apologies if I misled anyone, that wasn't my intention. I think my confusion has been evident from the very start and can be summed up by these lines from my posts:

"I don't understand what is meant by positional. Does it mean that one extreme of the PID output (say -3V) represents actuator fully retracted and the other extreme (say 3V) represents fully extended?"

then

"So, when the PID settles down (no error) it commands the actuator to move to a particular point. Is that what position (as opposed to velocity) means?"

From my 5th post: "Or, in other words, whenever the PID gives an output of 0, the actuator is instructed to position itself at 50% (half-open). If I've got that much right..."

It would help if someone could just answer yes or no to these questions.

Then I presented a scenario where I felt placing the actuator in the half-open position for a zero output made no sense. I could restate the scenario using the ubiquitous "driving the car at a fixed speed" analogy. Car on flat; 40kph desired; accelerator at position A. Car meets hill and hill is long; PID produces error; accelerator is adjusted to produce more speed; error is adjusting in response to increased speed (closed loop feedback) - but you wouldn't expect the driver to ease off the accelerator, you're still going up the hill.

This would all make sense if the PID error caused the actuator to move with respect to its current position. Is that clear enough?
 
I think when some refer to a "positional" output of a PID, they are perhaps referring to a closed loop positioning system. In this system a PID is used to make a positioning system move to an position setpoint. The actual output of the PID in that case is usually a "velocity" signal to the servo motor driver. So once the system is at the commanded setpoint, the "velocity" command to the servo motor goes to zero. However if an outside disturbance tries to move the system, then the PID will send a "velocity" signal to the servo motor to compensate. In many system where a worm gear is used, the holding power is provided by the worm gear and no "velocity" signal is needed. The confusion is that at low levels the "velocity" signal is actually a "torque" signal so there is no movement. Also in the case of stepper motors, the motors themselves provide the holding torque so no output from the PID is necessary.
 
"Then I presented a scenario where I felt placing the actuator in the half-open position for a zero output made no sense. I could restate the scenario using the ubiquitous "driving the car at a fixed speed" analogy. Car on flat; 40kph desired; accelerator at position A. Car meets hill and hill is long; PID produces error; accelerator is adjusted to produce more speed; error is adjusting in response to increased speed (closed loop feedback) - but you wouldn't expect the driver to ease off the accelerator, you're still going up the hill."

Your analogy doesn't make any sense. The fact that the error signal is zero does not mean there is no longer a command. YOU driving such a car IS the PID. You adjust the your accelerator pedal until you see that your speed is as commanded (zero error), but your foot stays at the same position to maintain the required speed. This is exactly what a PID loop is expected to do. Your problem seems to stem from the concept, "whenever the PID gives an output of 0;" the error is zero, not the command. The command is whatever it takes to get the error to be zero.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529


Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
There is a homework forum hosted by engineering.com:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor