Arduino code not giving target temperature.

Hi all,

I am using an Arduino Uno with an AD595 microcontroller. My code target temp is 220C but it finishes at 206C.

I m using a 240C max oven with a 1300C thermocouple. The amplifier led is not coming on to indicate a problem.

I am not an experienced user and the following code is not of my making. The code is as follows.
I would appreciate if you could advise if the code is satisfactory or not for my target.

/*

Toaster Oven SMT soldering control

Adrian Bowyer

2 November 2011

Licence: GPL

*/

const int heatPin = 13; // the number of the LED pin. This also controls the heater
int heatState = LOW; // heatState used to set the LED and heater
long previousMillis = 0; // will store last time LED/heater was updated
const long interval = 1000; // interval at which to sample temperature (milliseconds)
const int tempPin = 0; // Analogue pin for temperature reading
long time = 0; // Time since start in seconds
bool done=false; // Flag to indicate that the process has finished

// The temperature/time profile as {secs, temp}
// This profile is linearly interpolated to get the required temperature at any time.
// PLEN is the number of entries
#define PLEN 6
long profile[PLEN][2] = { {0, 15}, {120, 150}, {220, 183}, {280, 215}, {320, 183}, {350, 0} };

// Linearly interpolate the profile for the current time in secs, t

int target(long t)
{
if(t <= profile[0][0])
return profile[0][1];
if(t >= profile[PLEN-1][0])
{
done = true; // We are off the end of the time curve
return profile[PLEN-1][1];
}
for(int i = 1; i < PLEN-1; i++)
{
if(t <= profile*[0])*
_ return (int)(profile[i-1][1] + ((t - profile[i-1][0])(profile[1] - profile[i-1][1]))/_
_ (profile[0] - profile[i-1][0]));
}
return 0;
}
// Measure the actual temperature from the thermocouple*
int temperature()
{
return ( 5.0 * analogRead(tempPin) * 100.0) / 1024.0;
}
// Get the show on the road
void setup() {
* pinMode(heatPin, OUTPUT);
pinMode(tempPin, INPUT);
Serial.begin(9600);
Serial.println("\n\n\nTime, target, temp");
done = false;
}
// Go round and round*
void loop()
{
* int t;
unsigned long currentMillis = millis();*_

* if(currentMillis - previousMillis > interval)*
* {*
* previousMillis = currentMillis; // set next time*

* // Get the actual temperature*

* t = temperature();*

* // One second has passed*

* time++; *

* // Find the target temperature*

* int tg = target(time);*

* // Simple bang-bang temperature control*

* if (t < tg)*
* {*
* heatState = HIGH;*
* } else*
* {*
* heatState = LOW;*
* }*
* // Turn the heater on or off (and the LED)*
* digitalWrite(heatPin, heatState);*

* // Keep the user amused*
* if(done)*
* {*
* Serial.print((char)0x07); // Bell to wake the user up...*
* Serial.print((char)0x07);*
* Serial.print("FINISHED ");*
* }*
* Serial.print(time);*
* Serial.print(", ");*
* Serial.print(tg);*
* Serial.print(", ");*
* Serial.println(t);*
* }*
}
If the code appears to be OK could you suggest how I might go about further diagnosing the problem?
Thank You for any help you can give.

Please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum

Post a link to the datasheet for the AD595

How are you checking that the temperature is not what you want it to be?

Is the Arduino returning the same temperature reading as your independent thermometer?

if (t < tg)

You probably should have a deadband so the heater only comes on or off if there is a difference in temperature of a few degrees.

...R

Thanks for your reply & guidance

The data sheet for the AD 595 is at this link.
http://www.analog.com/media/en/technical-documentation/data-sheets/AD594_595.pdf

The temp is measured automatically on the fly by invoking the 'serial monitor' in the Arduino software as 'time/ target/ temp'.

For the record I am using a K thermocouple and the oven is set to max temp & timer full on.

Thanks again for any help.

Bowyer code.txt (2.72 KB)

Hi,
Is the controller shutting OFF the element at 206C or is it still turned ON.
Can you post picture of your project so we can see the arrangement and size of the oven.?
Is the oven and heater element designed to go to 240C, what power wattage is the element.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Do you have the supply input to the 595 AMPLIFIER bypassed and the output from the AMPLIFIER bypassed?

We need all this to ensure you get accurate and relevant answers to your requests.

Thanks.. Tom... :slight_smile:

Although it might not have given you any trouble so far, to avoid problems, change this:-long previousMillis = 0;    // will store last time LED/heater was updatedto this:-unsigned long previousMillis = 0;    // will store last time LED/heater was updated

dalpets:
The temp is measured automatically on the fly by invoking the 'serial monitor' in the Arduino software as '

You have not told us what independent thermometer you are using to check the Arduino and whether the two give consistent readings.

...R

Thanks guys for taking the time to respond to my problem.

My old thermometer meter died a couple of weeks ago & today I received my new RS42 meter from the UK (RS Components), ordered thru' RS Australia. Brilliant service, 5 days turnaround, & free postage to boot. It claims an 0.8C accuracy & that did show up the lesser accuracy (2/3C) of the Arduino setup.

Anyhow, today I used it on my oven independently of the Arduino & the oven maxed out at 275C.

The oven, a BT2600 Sunbeam, is 1400 watts. It receives mixed reviews on-line.

After some hours of testing & retesting I think I have found the answer.

The oven front panel temp dial has 3 settings viz., 240C, Grill & Toast. Only the Toast setting was able to take me through the sketch code without a problem. I have only verified that success on 3 runs-I'm keeping my fingers crossed.

So, one again thank you all. I will need to come back if the problem re-emerges.

Hi folks,

Well it didn't last! The profile is still finishing at 206C, darn!

When I get my act together with some photos & a circuit drawing (thanks TomGeorge) I'll have to get back to you kind folk for more help.

I've changed the code as recommended by OldSteve. Thanks mate.

I may be missing something, but I have not yet seem where you have checked that the Arduino can measure a temperature and show the same value as some independent thermometer. That is the first step to ensuring a working system.

...R

Robin2

The oven power is switching on in sync with the arduino indicator light and the serial monitor temps and the independent thermometer are roughly within 5C of each other.

Have you bypassed the ovens mechanical thermostat ?

Probably a bimetal heating contraption located in the knob itself.

dalpets:
It receives mixed reviews on-line.

Mostly related to the thermostat.......

This project is based on the technique developed by a small company. See their link @

http://reprap.org/wiki/Toaster_Oven_Reflow_Technique

Unfortunately the company stopped operating a few months ago, due to competitive pressures in the burgeoning 3D printer market. As a consequence the links at the their above site no longer work for this project. So I'm sort of on my own except for what help you guys can give me.

As requested and appreciated I have put together a number of attachments here which I hope will aid you in giving me some help.

1 circuit sketch.

2 Australian 240v plug.

3 hardware setup.

4 relay connections

5 switch connections

6 thermo amplifier schematic (scroll to very bottom of otherwise blank pdf)

7 arduino & amplifier pic

8 oven

9 oven dials

10 oven interior (there are 4 heaters, 2 above & 2 below). As previously mentioned I have taken the oven to 275C, independently of the Arduino.

11 screen grab of serial monitor in action & falling short of max temp of 220-225C (ppt file)

Hope the above meets your comprehensive expectations towards meaningful replies.

Thanks again all.

dalpets:
. As previously mentioned I have taken the oven to 275C, independently of the Arduino.

If its the contraption i mentioned above, PWM will interfere with its proper operation

Sorry! Here are the first 3 of my 11 my attachments, due to attachment post limitations.

2 Australian 240v plug .jpg

Here are attachments 4 & 6

6 thermo amplifier Schematic.pdf (6.06 KB)

dalpets:
Robin2

The oven power is switching on in sync with the arduino indicator light

But what does he thermostat light do ? The one at the top

I am saying in a different way what tom george has already asked but you have not answered.

When you reach 206, does the flashing stop ?

Here is attachment 5

This is attachment 7

Sorry for all the XX posts. It appears when one does a preview to add attachments that the preview is posted beforehand. Didn't expect that!

You can delete them.
Lot of unnecessary posts there.

Your circuit is clearly working, its behaviour is not clear from any picture, you have to use words for that.