Temperature control

Hello,

I am trying to control temperature within a system and need some guidance.

I need to basically tell the system a series of commands like:

In 30 seconds get to 80c For 60 seconds maintain 80c In 120 seconds get to 180c Etc...

I can quite easily take a note of the current temp "flip a switch" on the heat source if I'm below the target, but in reality doing this I'm going to get pretty sharp jumps and I want a smoother transition to the target temp with the target temp only being achieved by the end of the "step"

I know the PID library exists and may possibly help achieve this but I'm not entirely sure. Any guidance would be appreciated

Posted Apr 15, 2019, 1:10 PM UTC

19
soopirV•

Yes, PID is intended to do just this. You may find it hard to jump large amounts quickly, will have to tune your algorithm and eliminate heat losses to as high degree as possible.

1
NoPlayTimeOP•

It's such a small system that heat is typically gained/lost very quickly without control (on/off). I'll take a better look in to the tuning values of PID and see how it looks and affects temperature - I think I've just not really understood it properly.

Thanks.

1
soopirV•

It’s all based on calculus, so forgivable to not fully understand. It calculates related rates- the farther away from your setpoint you are, the faster it tries to close that gap; as you approach, it starts to slow down, with the goal of sliding in and not going over your programmed hysteresis. There are a number of variables you can modify to get the profile you want. There are also relatively cheap PID controllers out there that will make this easier if it’s a critical application, but then you don’t get the fun of building your own.

1
NoPlayTimeOP•

Yea. It's looking like I misunderstood one key component of how PID functions.

It looks like this will be perfect.

I'll give it a go and see what my results are like.

Thanks.

1
EnDoubleOhBee•

What device are you controlling might be helpful information.

Usually in these situations (toaster ovens for reflow) I see people use a very slow PWM (like 1-5hz) through a relay (solid state?)

I’ve never done a project like this but I’ve had my eye on it. I’ve seen videos, so you could look for those and watch them too!

1
chopflyer•

I don’t know arduino much yet, but I do a lot of PID tuning.

What are you using to control temperature, is it something that has a variable output? If it is on/ off a PID won’t really work.

Do you have a way to graph what happens in a setpoint change? Tuning is very difficult without a graph showing the setpoint, controlled variable, and your process variable.

Once you start tuning, know that many PID typically use just a PI, controller. When you start, just use P (gain). Make setpoint changes at various values of Gain. If the gain is too low, the temp will drift, if it is too high, the temps will oscillate. Note that with P only controls, you can make the temps stable, but they won’t be at the setpoint.

Once you have a good value of Gain, start adding in Reset (I). If the reset is done too slow, it will take a long time to get to setpoint. If it is too fast, this will also cause oscillations.

1
NoPlayTimeOP•

That simplifies things considerably. Thanks for the explanation. Most controllers I've used with PIDs are fairly preconfigured and only have a single target and a fairly simple "path" to get there, so I'm not too familiar with ones with more control.

The environment I'm working with the heater can essentially be "pulsed" through control, giving the heater a % of "on time" essentially based on frequency . I'm hoping this will give me adequate control.

I'm new to Arduino and have a very (very) basic understanding of electronics, but I'm a developer for a living so the code/logic side of things is relatively straightforward.

I'll build some code up tonight and try and simulate the system a bit before I actually try it out in practice (I'm still waiting on my thermocouple before I actually build anything). I understand it's going to take a bit of configuration (likely through trial and error) to get it right.

1
DougCim53•

You can use PID to control a heater or cooler, but in my experience it is a waste of effort because heat does not have an instant observable effect like mechanical motion does. Heat takes time to radiate from the heating element to the temperature sensor, and that time lag makes high-precision PID calculations rather worthless.

It is much easier to just use a method of controlling the heat either 100% on or off, and then checking the temperature at some interval and turning the heat on if needed. If you use a solid-state method of turning the heating element on and off (like a solid-state relay, for a heater element fed from AC current) then you can just set the check interval to 1 second or so.

What is much more important is how the heat is circulated inside the space you are heating (you need fan/s to circulate the air a lot) and where you place your temperature sensor. You almost just need to place the temperature sensor near the middle-height of the space and just assume that this is the only height that will really hold the temperature you want. If you place one temperature sensor at the bottom of any enclosed space and another at the top, it is nearly impossible to get them both to read the same temperature.

1
NoPlayTimeOP•

Thanks, you've pretty much echoed my initial thoughts when considering the design of this system so I'm glad at least it seems I haven't made any stupid mistakes (at least In the thought process).

After reviewing exactly what a PID does, I've confirmed that I was vastly oversimplifying their behaviour simply because of my experience with prebuilt items I have that utilise them, where the curves in temperature are much less obvious (basically get to temp X and maintain for y seconds)

I've finalised my pre-tested code now, and intend to start building the system for some test cases as soon as my thermocouple arrives.

In regards to heat/fan the unit essentially has a fan that pushes air through the heating element into an open chamber (where the probe will be placed at a point temp is important). The fan is not massively powerful, so for the time being it's practically just going to be running 100%, until it's replaced with a slightly more powerful unit at least.

1