Pid Regulyator Na Arduino
The basic PID equation is not that difficult to implement and there are many PID implementations out there. But there are a lot of 'gotchas' in making a PID perform well in a real-world application. These gotchas have been expertly addressed by Brett Beauregard in his Arduino PID Library.
Gulnara rakisheva foto styuardessa. Experience — or at least education — often makes a big difference to having a successful project. For example, if you didn’t think about it much, you might think it is simple to control the temperature of something that is heating.
Just turn on the heater if it is cold and turn it off when you hit the right temperature, right? That is one approach — sometimes known as bang-bang — but you’ll find there a lot of issues with that approach. Best practice is to use a PID or Proportional/Integral/Derivative control.
[Electronoob] has a good tutorial about how to pull this off. You can also see a video, below. The demo uses a 3D printer hot end, a thermocouple, a MAX6675 that reads the thermocouple, and an Arduino. There’s also an LCD display and a FET to control the heater. The idea behind a PID controller is that you measure the difference between the current temperature and the desired temperature known as the setpoint.
The proportional gain tells you how much output occurs due to that difference. So if the setpoint is way off, the proportional term will generate a lot of output to the heater. If it is close, only a little bit of output will result. This helps prevent overshoot where the temperature goes too high and has to come back down. The integral term adds a little bit to the output based on the cumulative error over time.
The derivative term reacts to changes in the temperature difference. For example, if something external causes the temperature to drop suddenly, the derivative term can goose the output to compensate. However, the operative word is “can.” Part of setting up a PID is finding the coefficients for each term which for some systems could be zero or even negative (indicating a reverse effect). There are a lot of other subtleties, too, like what happens if the output stops affecting the temperature for a long period and the integral amount grows to unmanageable magnitude.
By the way, we’ve covered a for Arduino before. While this post talks about temperature, PID control is used for everything from to.
• • • • Posted in, Tagged, Post navigation. Ehmmm temperature control by modulating the heater element in the correct way is one thing but measuring the temperature is another.
When a thermistor tells you that you project is exactly 100C you are not done. Because this doesn’t mean that the whole block is heated up to 100C, the block ins’t perfectly insulated, there are losses and in case of an extruder, the plastic it is being fed will cool down the block locally. Also the thermistor needs to make propper contact with the block, a glass beat thermistor isn’t perfect. As glass is a thermal insulator, although the glass is thin it does create an error or lag. Also how how does the heat energy propagate through the block itself, the accuracy of the thermistor (and the way you read it and calculate it) is of course important but that’s for another time. A thermal couple with a dedicated IC is therefore much better but could introduce problems in some cases as the tip of the thermal couple is electrically conductive and could require some additional insulation, creation the same problem again.
Anyway, there are many things that can go wrong, modulating the element using a PID algorithm is great but only a small part of proper temperature control. But then again it all comes down to how accurate you really want it to be. Therefore in many cases the bang-bang approach is certainly far from perfect, but in most cases it’s more then good enough. PS: nice video, nice article, PID is certainly the way to go, but use it wisely. Industry have used PID for decades – you are correct about the lag etc. But in industry, a certain level of pragmatism is required so we accept that there is a lag and either tune the loop accordingly or change the system by having another loop connected to the item under temperature control or some form of dummy block which is analagous to the thing you are trying to heat. Some systems do both at the same time – they will control the heating power by a primary loop and monitor the rate of temperature rise (or fall) of the component in the furnace then pull back the heating primary loop as required to avoid overshoot.
We deal with accuracy through regular calibration checks using a primary or secondary standard instrument which is solely used for calibration never control. Cavity magnetron based ovens only do this because magnetrons only work “on” – there’s no half-power setting that wouldn’t drive the cost of the (very simple) internal circuitry enormously high. “Off and on” through timed duty cycles is the traditional, economical way around that. Ovens with solid state emitters are being test-marketed and seem to be economically competitive and offer the advantage of emitter array modulation so this may change (and possibly rapidly as the device cost/simplicity could possibly drop). Of course you have the usual food loonies that think microwave ovens magically transmit bad juju into their soy milk but that can’t be helped. Here’s a pretty good article on the changes in the wind.