Heater element controller with Arduino - Not the same problem as always!

Hello

Im new to Arduino programing.

I have a project in which I have to control a heater element. The requirements are that the temperature has to increase +20°C from ambient (20-22°C) at a rate of 5°C/min. After that, It has to wait 2 min or until the temperature reaches again ambient. The cycle has to repeat 4 times.

I have a heating coil which I can control trough a Relay and an LM35 temperature sensor.

I have an Arduino UNO with ATMEGA 328-P

The problem I have is that I dont know how to guarantee that rate. Everything that I have found so far its just to reach a temperature but without any time requirements.

If anyone could help me solve this problem, I really appreciate it!!

Thanks in advance!

The requirements are that the temperature has to increase +20°C from ambient (20-22°C) at a rate of 5°C/min.

First, make sure your heating element is capable of rising that fast.

Then "think digitally". ;) Increment it in 1 degree or 1/10 of degree steps, etc. (you'll have to calculate the steps per minute).

You need to know the thermal capacity of what you are trying to heat. Only then can you work out what energy you have to put in to raise it to a specific temprature.

Hi

Thank you for your response.

What Im trying to heat its just air. and my heating element heats really fast. So I need to slow it down in order to match that rate.

What sort of control do you want. This sort of thing is a feedback system controlled by complex equations. Do you need under shoot, over shoot or critical damping?

Under shoot I believe its the most appropriate.

Please someone?

At least an insight on how to do it? If a PID controller would work? or not?

And how can I keep the temperature for 4min after it reached the ambient temp +20°C?

Thank you! I appreciate it.

Don’t use a relay. The relay should not be switched more often than once or twice per second and PWM switches thousands of times per second.

What is the power source for the heater? 12v or AC mains power?

12v (or any DC) is pretty easy with a MOSFET. AC requires different components.

Then find a PID library online that you think you can understand. This will usually take a “set point” input and a thermometer as feedback. Then ramp up/down the set point over time to the value you want at that time.

I suspect that you will need two thermometers to keep track of ambient and heater temps. It is possible to do this with no feedback but that will take a lot more work to characterise the heater.

dforero: The requirements are that the temperature has to increase +20°C from ambient (20-22°C) at a rate of 5°C/min.

Does this mean that you want to control the actual temperature of the element? OR The temperature of the body of air heated by the element?

...R

dforero: Please someone?

I have to sleep you know.

And how can I keep the temperature for 4min after it reached the ambient temp +20°C?

You have a function that holds the temperature at a figure that you pass to it. After 4 min you change the number you pass to it.

Is this a project assignment because it seems quite vague. For how can you have a heater at 20°C when your ambient is 25°C.

If a PID controller would work?

Yes.

Thank you all for your responses.

MorganS:

AC is the main power of the heater

How can I implement this:

MorganS: Then ramp up/down the set point over time to the value you want at that time.

Robin2:

I want to control the temp of the body of air heated by the element.

Grumpy_Mike:

Grumpy_Mike: You have a function that holds the temperature at a figure that you pass to it. After 4 min you change the number you pass to it.

What do you mean with this? I cannot keep the heater on for 4 min. My heater consumes 1.3KW, so If I leave it on that long it will literally burn and will not keep an steady temperature.

What do you mean with this? I cannot keep the heater on for 4 min. My heater consumes 1.3KW, so If I leave it on that long it will literally burn and will not keep an steady temperature.

I guess we were all assuming you knew how to to that....

Have you ever noticed how a home furnace or electric heater works? It turns-on when the temperature is below target and cycles off when the temperature is above target.

In the real world, there is usually some hysteresis or "swing" so if your target is 40 degrees it will turn on at 39 degrees (or 39.9 degrees, etc.) and off at 41 degrees (or 40.1 etc.). That helps to smooth things out so the heater doesn't try to cycle on & off several times per second.

dforero: My heater consumes 1.3KW, so If I leave it on that long it will literally burn and will not keep an steady temperature.

That seems very strange. Heaters such as in an electric cooker can be left on all the time.

How long can it be left on? Write a program that limits the ON time.

...R

Hi all,

My heater is a coil from a heat gun, I dont know if it makes it easy to understand.

Yes, of course I could switch on and off to keep it at certain temperature. What I understood of his comment was to leave it on for 4 min.

This is my code so far:

int outputpin = 0; //Analog 0
float temp;
float tempMin = 0;
float tempMax = 0;

#define RELAY1 8

void setup() {
Serial.begin(115200);
pinMode(0, OUTPUT);
pinMode(8, OUTPUT);
tempMin = readTemp();
tempMax = tempMin + 20.0;
Serial.print("this is tempMin: ");
Serial.println(tempMin);
Serial.print("this is tempMax: ");
Serial.println(tempMax);
// initialize the LED pins 2, 3, 4, 5:
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}

}

void loop() {
temp = readTemp();
Serial.print(“TEMP=”);
Serial.print(temp);
Serial.println();

if((temp >= tempMin)&&(temp<tempMin+5)){ //1
digitalWrite(RELAY1, HIGH);
digitalWrite(2, HIGH);
delay (500);
digitalWrite(RELAY1, LOW);
digitalWrite(2, LOW);
delay (3000);
}

else if((temp >= tempMin + 5)&&(temp <tempMin + 10)){ //2
digitalWrite(RELAY1, HIGH);
digitalWrite(3, HIGH);
delay (1500);
digitalWrite(RELAY1, LOW);
digitalWrite(3, LOW);
delay (3000);
}

else if((temp >= tempMin + 10)&&(temp <tempMin + 15)){ //3
digitalWrite(RELAY1, HIGH);
digitalWrite(4, HIGH);
delay (1800);
digitalWrite(RELAY1, LOW);
digitalWrite(4, LOW);
delay (2000);
}

else if((temp >= tempMin + 15)&&(temp <tempMin + 20)){ //4
digitalWrite(RELAY1, HIGH);
digitalWrite(5, HIGH);
delay (2000);
digitalWrite(RELAY1, LOW);
digitalWrite(5, LOW);
delay (2000);
}

else{
digitalWrite(RELAY1, LOW);
digitalWrite(6, HIGH);
delay(180000);
digitalWrite(6, LOW);
temp = readTemp();
Serial.print(“TEMP=”);
Serial.print(temp);
Serial.println();

}

}

float readTemp()
{
float rawvoltage = analogRead(outputpin);
float mmv = ((rawvoltage/1024)*5000); //milivolts
temp = mmv/10;
return temp;

}

For each if-else I have one LED so I know which one is being executed. The delays are very random, im just trying to follow that rate (5°C/min) which doesn’t happen most of the time.
It is not repeatable and after it reached tempMax it just turns off and lets it cool down for 3 min. then starts the cycle again.
How can I add another loop in order to keep the temp for 4 more min?
Do you guys have any other input to my code to make it more repeatable?

Thank you!

What I understood of his comment was to leave it on for 4 min.

Then read the comments again. I said:-

You have a function that holds the temperature at a figure that you pass to it.

Read again the words that say HOLDS. I did not say leave the heater on for 4 min.

The delays are very random,

Why use delays at all? It seems like you don't "get" how to control temperature. You do not turn the heater on for a fixed amount of time and then off for a fixed amount of time. You measure and then turn on or off depending on what you measure. You do this as often as you can or at 1 second intervals if you are using a mechanical relay to turn on and off the heater.

Use code tags when posting code.

How can I add another loop in order to keep the temp for 4 more min?

You write the control as a function and pass the temperature into it. Then you use a state machine to time how long it has been on. Using the blink without delay technique.

See my http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html Or Robin2's several things at once http://forum.arduino.cc/index.php?topic=223286.0

The problem I have is that I dont know how to guarantee that rate. Everything that I have found so far its just to reach a temperature but without any time requirements.

Without proportional control of the heater the only thing you can do is to break the temperature rise down into a number of steps.

the temperature has to increase +20°C from ambient (20-22°C) at a rate of 5°C/min.

So +20°C at a rate of 5°C/min is a 5 min temperature ramp time. You will not be able to get this smooth, you will have to just reach a temperature but without any time requirements. But the temperature you request the function to reach can be incremented by one degree every 12 seconds. Thus giving you close to a ramp in temperature.

Thank you Grumpy_Mike,

I'll see what I can come up too :)

dforero: My heater is a coil from a heat gun, I dont know if it makes it easy to understand.

Get a second one and wire them in series. Double the resistance, half the current. Double the surface area.

...R

read up on toaster oven and pcb making. they hold the results of testing done by others.

no need to re-invent the circuits of parts.

lotsnof data about ramping and controls.

no idea why what you are heating but I would look at using a ptc heater element and a pwm fan. The ptc will max out at what ever its design temp is then reduce its amp draw. The fan will pull the heat away thus dropping the ptc temp so it will pull more amps to heat back up.

code like grumpy mike suggested so the temp is adjusted every second and ramp the fan up or down to control the temp. With out knowing the size of the area its difficult to judge as heat interchange with air is not a simple science so one zone may be hotter than the rest of the area.