PID controller for an Infra-red heater

Thread Starter

Se7en Axis

Joined Jan 10, 2019
10
Greetings everybody,

I am working on a simple infra-red heater projet, bassically the circuit uses a Zero-Crossing signal to control the firing of the triac, I can properly control the AC voltage through the load(Infra-red bulp) by simply controlling the delay prior to firing the triac.

I now have added a thermocoupler(MAX6675) and I want to make a PID that will varie the delay mentioned earlier based on the temperature of the MAX6675.

I inserted a picture of my code to this post, the only information that isn't included is the #define of all the pins && the PID library and some other unrelated stuff.

Here's where I am at right now, most of the examples I see use the PWM to trigger their Output, in my case it's a simple delay that would need to vary between 5000 and 8100 microSeconds, I am unsure as to how to proceed due to that difference, the Input in the other end seems more simple, the line I wrote is the following: Input = readThermocouple(); ... But again It's unclear to me as to how I can scale the Output (uS delay) with the temperature readings that'll probably range from 15c to 185c since this appliance is going to be used to pre-heat circuit boards.

Thanks in advance for reading this, I will literally be, forever grateful.
 

Attachments

DNA Robotics

Joined Jun 13, 2014
650
I like the Map function for that sort of thing. That will convert temperature directly to time delay units. You would probably want to test for well above room temperature before using it or you would waste a lot of your scale.

map(value, fromLow, fromHigh, toLow, toHigh)

https://www.arduino.cc/reference/en/language/functions/math/map/

Description

Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.
 
Last edited:
Actually, its not a simple delay for PID phase control.

First, P should range from 0-100% or +-100% if you have active cooling. This is like max heating and max cooling.

Let's pretend that it;s resistive heating first, because it makes it easier. You really want to control power, so you end up with 0-100% power. In resistive heating, R is effectively constant, so 0-100% should be proportional to the integral of v^2 from 0 to t. v=sin(wt).+ Then to complicate things a bit, you have both the positive and negative half-cycles to deal with.

IR is a "tungsten" heating element, so nor R is a function of temperature or power. There might be a 10-15x change in resistance from 0-100% power. I think it would be OK to map 0-100% power to cold to hot resistance of the lamp normalized to 100%, so now 0-100% should be proportional to (V^2)/R. Everything is normalized or relative.

So "real" controllers map a process signal like 0-20 mA to 0-100% power to a resistive or tungsten load. They also incorporate current limiting which I'm not exactly sure how to incorporate. They would also compensate for low or high line voltage.

If the load is inductive, like a motor or transformer, you have non-coincident zero crossings to deal with, One of voltage and one of current, thus you have to keep firing the triac, otherwise the triac will turn off at zero current and again at zero voltage.

See: https://www.watlow.com/products/con...-devices/aspyre-intelligent-power-controllers

Back in the 1980's my colleague and I did an interesting 7 Loop PID system using DC voltages for tantalum based heating. We could chose voltage, current, temperature or power control with the other variables being limits.

We incorporated stability criteria and heat-up energy calculations and limits. It allowed us to detect a shorted or misplaced thermocouple. Finally, there were recipies and logging.
 
Last edited:

mvas

Joined Jun 19, 2017
539
Greetings everybody,

I am working on a simple infra-red heater projet, bassically the circuit uses a Zero-Crossing signal to control the firing of the triac, I can properly control the AC voltage through the load(Infra-red bulp) by simply controlling the delay prior to firing the triac.

I now have added a thermocoupler(MAX6675) and I want to make a PID that will varie the delay mentioned earlier based on the temperature of the MAX6675.

I inserted a picture of my code to this post, the only information that isn't included is the #define of all the pins && the PID library and some other unrelated stuff.

Here's where I am at right now, most of the examples I see use the PWM to trigger their Output, in my case it's a simple delay that would need to vary between 5000 and 8100 microSeconds, I am unsure as to how to proceed due to that difference, the Input in the other end seems more simple, the line I wrote is the following: Input = readThermocouple(); ... But again It's unclear to me as to how I can scale the Output (uS delay) with the temperature readings that'll probably range from 15c to 185c since this appliance is going to be used to pre-heat circuit boards.

Thanks in advance for reading this, I will literally be, forever grateful.
To START, I would change the PID parameters to ...
Kp = 1
Ki = 0
Kd = 0

Now, the OUTPUT Signal is simply = Kp * ( SetPoint - Input ) and since Kp = 1 the Output Signal is simply the Error.
So, if your SetPoint and Input values are between 0C and 185C then you Error Output may be between -185 and +185 , where 0 means Temperature = Setpoint Target
-185 or less Error Output means way too HOT, so change Phase Angle to Maximun Delay, 8000 usec or always OFF, Input Temperature is way higher than SetPoint
0 Error Output means NO Change to Phase Angle, keep it constant, Input Temperature = SetPoint Target
+185 or higher Error Output means way too COLD, so change Phase Angle to Minimum Delay, 1 usec or always ON, Input Temperature is way lower than SetPoint

PID OUTPUT ( feedback ) ...
A negative value indicates too much power, too hot - so cool down
A value of zero is steady state - do not change Phase Angle
A positive value indicates too little power, too cold - so heat up

You need to MAP or Scale the PID Output and combine with previous Phase Angle to compute next Phase Angle.

The PID Output tells you how to adjust your Phase Angle, to move the Input Temperature towards the SetPoint Target.
You can Limit the PID Output with a PID function call, MAP( ), or your can process the PID Output in your code.
Display the PID OUTPUT value, watch how the PID Output Error value changes as temperature approaches Target.

Eventually, you can Tune: Kp, Kd & Ki
 
Last edited:

Thread Starter

Se7en Axis

Joined Jan 10, 2019
10
Thank you to DNARobotics, KeepItSimple & last but not least mvas for the replies!!!!!!!!!!!!!

I am at work right-now however I have read the posts and they all make a lot of sense to me, I will read these more carefully once I get home.
 
Top