1
\$\begingroup\$

I have developed a computer controlled BBQ smoker, using a raspberry pi and car throttle valve damper, driven by a stepper motor, the temperature pick up is a thermocouple.

I have a python PID class to control the system and am struggling to tune it. When the set point temperature is reached (rising temp) the damper closes as expected, then re-opens once the temperature passes the set point (falling) but by this point the charcoal fire has gone out. I have tried different kP values to get a steady oscillation about the set point but I am plagued with it fully undershooting, ie going out. I need the damper to start re-opening as soon as the temperature starts falling, not once the system is in falling overshoot. I feel it is something to do with kI and kD. Please can I have some advice before spanking another kilo of charcoal! Many thanks people.

\$\endgroup\$
  • \$\begingroup\$ I'd use a binary search. At, say, 20 degrees below the target, close the throttle half way. The temperature will probably still rise, but more slowly. Continue to monitor 'til it reaches 10 degrees below target. If it's still rising fairly quickly, close it half the remaining distance. Continue closing half the remaining opening until the temperature steadies. You should quickly find a couple of points where it 1) rises slowly, and 2) drops slowly. You can then basically just shift between those. \$\endgroup\$ – Jerry Coffin Oct 14 '17 at 23:27
  • \$\begingroup\$ seeing as it has been bumped, there are other control responses to the usual quarter amplitude decay, in your case you would be deliberately winding up the P and D terms to make the circuit oscillate with just slightly less than a gain of 1, this way the circuit is constantly oscillating around your set point, and will have the fastest response at the cost of constantly over and undershooting by a small amount. \$\endgroup\$ – Reroute Aug 31 at 13:41
3
\$\begingroup\$

There are several methodologies to tune a PID, some can be fully automated and rely on some level of system identification. But most of them are just rules of thumb.

For temperature control, you want to avoid the integral term as much as you can. It is necessary to remove steady state error, but any time spent far from the set point is time that the I term is increasing, and once you reach the desired temperature you need to spend the same error area in the opposite direction to decrease it back to where the other terms take control.

Work with a pure PD control, and if that is not good enough then introduce a small amount of an I term, making sure that the integral of the temperature ramp-up time error times the I gain does not overwhelm the contribution of the PD terms. The more I you introduce, the more D you are likely to need to accelerate the response. This is not likely to be steady-state optimal, but it would ensure the least controller overshoot.

Think of I as the history of the system while D is the prediction of its future trend.


You can start with a pure proportional control, set a proportional gain that provides 100% air when the error is 5°C below the target and 0% when it is 5°C above the target. This might be enough for your purposes and could result in a stable system if the system inertia is low enough. Increase the gain to reduce the error (this is likely to result in oscillations) and add a derivative term to keep the system stable. Only add an integral term is the resulting steady-state error of the stable system is too large for your application.

\$\endgroup\$
-2
\$\begingroup\$

The general rule of thumb when tuning a PID is to do it in that order. Turn all factors to 0.0f . First the Proportional should be increased in magnitude until it minimizes the error rate as much as it can. Then the integral, then the derivative. Of course it depends on the exact PID equation. is it P+I+D (the most common), P+I/D, P*I/D, etc. There are numerous forms, and I have seen people buy the wrong one.

I don't really use PID as much as I used to, neural networks are better and can adapt to system changes over time, while a PID has to be retuned occasionally.

\$\endgroup\$
  • \$\begingroup\$ It is a P+I+D. I've seen one which seems a lot more complicated with a logarithmic (base e) element to it but this one seems understandable by me!! I tested it on a flywheel, then went onto the BBQ. I like the idea of a neural network, there is a lot of high level information in the net, can you point me in the direction of an introduction? Tvm. \$\endgroup\$ – Edward Hammock Oct 15 '17 at 20:03
  • \$\begingroup\$ I use FANN for just about everything. github.com/libfann/fann As for an introduction, it depends on your level of math. The standard is Neural networks by Simon S. Haykin, but that one is very heavy in math and deals with theoretical neural networks, which have arbitrary precision (i.e. unlimited precision). I recommend Neural networks for pattern recognition by Christopher Bishop. It is a little more approachable, but it does focus on pattern recognition, not so much controls. \$\endgroup\$ – Anthony Bachler Dec 18 '18 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.