Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help required for Arduino Uno Heater Controller

Status
Not open for further replies.

chi239

Newbie level 6
Newbie level 6
Joined
Sep 13, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,388
I am a novice in Arduino. I am working on a temperature controller for a hot plate. I have a PT100 as sensor which is being driven by a 1mA constant current source. As the resulting output voltage is quite low, I am using an OpAmp for a gain of 11. The output of the OpAmp is connected to pin A4 of the Arduino.

The desired temperature is set by means of a potentiometer, the output of which (0-5V) is connected to pin A1 on the Arduino.

The PWM output for the heater is from Pin 9 and is fed to an opto-isolator (the output of which is connected to a Triac, which in turn controls the power to the heater element).

All this works quite well, except for a bug that I have not been able to find:
On switching on, the PWM output is zero. It activates only when the potentiometer setting is brought quite low. After that, the setting can be changed as desired and everything works well. For example, if the potentiometer setting is for say, 150 degrees, the system will work just fine as long as it is not switched off (or if the power is not disrupted). In case of switching off (or power failure), followed by a subsequent switching on, the PWM output remains zero. It is only on bringing the potentiometer to a relatively lower setting that the PWM output gets reactivated. Once it does, then the potentiometer can safely be brought back to the original (or any other desired setting) and everything works just fine.
Can anyone help me in finding the bug? I want that on switching on, the system should start working right away and control the heater (PWM) so as to attain the temperature as set by the potentiometer.

My sketch is as below:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Heater Controller 
 
int heatingInPin = A1;// Heating pot slider connects here
int sensorPin = A4;// Temp Sensor output (amplified) connects here
int heaterPin = 9;// PWM heater output is available here
int tempDiff;
 
int sensorCount;// this holds the value of the Temperature Sensor after amplification
int heatSetCount;// this holds the value of the Temperature Control Pot
int pulseWidth;
 
void setup(){
 
pinMode(heaterPin, OUTPUT);
}
void loop()
{
sensorCount = analogRead(sensorPin);
sensorCount = (sensorCount - 247);// apply offsetvalue  
heatSetCount = analogRead(heatingInPin);
 
heatSetCount = map(heatSetCount, 31,1023,0,440);// This gives a maximum temp of 400 degrees
 
if (sensorCount >= heatSetCount)
{
analogWrite(heaterPin,0);
}
 
else
{  
tempDiff = (heatSetCount - sensorCount);
 
if (tempDiff >= 25)
{
  pulseWidth == 255;// heater is full ON
}
else
{
  pulseWidth = (10 * tempDiff);
}
 analogWrite (heaterPin,pulseWidth);
}
delay (10);
}

 
Last edited by a moderator:

Thank you, mate. I understand that it should be "pulseWidth - 255." Although I don't see how it will affect the working of the sketch, I will try it out tomorrow and revert. Thanks once again.
 

I am a novice in Arduino. I am working on a temperature controller for a hot plate. I have a PT100 as sensor which is being driven by a 1mA constant current source. As the resulting output voltage is quite low, I am using an The PWM output for the heater is from Pin 9 and is fed to an opto-isolator (the output of which is connected to a Triac, which in turn controls the power to the heater element).

PWM and Triac are not playing well together.
 

I understand that it should be "pulseWidth - 255."

No, it should be a single equal sign (= and not ==).

Make the suggested change, compile and upload again and report the outcome.
 
  • Like
Reactions: chi239

    chi239

    Points: 2
    Helpful Answer Positive Rating
Hello c_mitra,

Thank you for your suggestion. I made the correction and now it is working fine.

Thank you once again! :)
 

As others have pointed out, using a triac with a PWM signal is not the right way to control the output power. You should use a power MOSFET with a PWM signal (with additional driver, if needed). If the heater is low power (say <500W) you can use rectified and filtered power to driver the heater in series with the power transistor. If you are having a big heater (say >1000W), you may use a triac with a zero crossing detector and calculate the trigger time from temp difference (set point-actual point).

There is another mistake in your software. Sometimes the temp overshoots and actual temp can be higher than the set point. If the temp diff is negative (actual temp > set temp), pulse width should be set zero. That will allow the actual temp to come below the set temp. That needs to be fixed.
 

Hello c_mitra,

Thank you for your suggestions. I am already using a zero-crossing detector detector with the triac for heater control. I didn't mention it in my earlier post for the sake of brevity.

Regarding the case of negative temp difference, it is also taken care of in lines 24-26 of my sketch.

Thank you once again.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top