max 31855 intermitent readings
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
max 31855 intermitent readings
I am using max 31855 to type k thermocouple and uno with lcd to control a pottery kiln. written a sketch and all is well. I log temp and time every 5 mins to the serial monitor. Takes several hours to complete a firing . it works as expected up to about 1600 F ( I fire to 2180 F) I then start to get zero F as the temp alternating with the real temp. (lcd display is updated every few seconds) Keeps doing this till final temp is reached and kiln shuts down. This has been a very challenging project but it is getting the job done.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
How fast are you reading from the Max31855? It sometimes will give zero readings if you poll it too fast.
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
The program is in a do while loop with about a dozen instructions. When 5 minutes has passed it goes through a further six or seven instructions to print to the serial monitor. What I don't understand is how it can run perfectly for a couple of hours because it takes that long to get to 1600. Then it starts to send 0 alternately with the correct temperature. While it is in the do while loop the LCD is flashing the correct temperature and then zero and then back to the correct temperature continuously only when it is above 1600 f .
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
Can you post the code you are using?
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
i don't know how to do that. I tried to copy and paste here but can't I am
using linux ubuntu
i tried harder ......
using linux ubuntu
i tried harder ......
Code: Select all
//Mod Apr11/13
#include "Adafruit_MAX31855.h"
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
int thermoCLK = 5;
int thermoCS = 4;
int thermoDO = 3;
// Initialize the Thermocouple
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define WHITE 0x7
unsigned long time = millis();
int kilnmode ;
int y = 5;//variable to test with min counter
int heatrate;//variable for temp rise per hour
int temp1;//var to store temp for next calculation
int f = thermocouple.readFarenheit();
int c = thermocouple.readFarenheit();
//int time = millis();
int x = (time/60000); //gives a minute counter
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(2,OUTPUT);
lcd.print("MODE");
// wait for MAX chip to stabilize
delay(5000);
}
void loop() {
lcd.setCursor(0, 1);
if (isnan(c))
{
lcd.print("T/C Problem");
}
else
{
lcd.print("F=");
lcd.print(f);
}
{
//prints time since program started in seconds
lcd.setCursor(10, 1);
lcd.print("T");
lcd.setCursor(11, 1);
lcd.print(time/60000);
//stuff for serial mon
}
//check for a button that is pressed
uint8_t buttons = lcd.readButtons();
if (buttons) {
if (buttons & BUTTON_UP)
kilnmode = 1;
if (buttons & BUTTON_DOWN)
kilnmode = 4;
if (buttons & BUTTON_LEFT)
kilnmode = 2;
if (buttons & BUTTON_RIGHT)
kilnmode = 3;
if (buttons & BUTTON_SELECT)
kilnmode = 5;
//use kilnmode to print "the state" and do the actual temp control
switch (kilnmode) {
case 1: //warm kiln to 500 F
lcd.setCursor(6, 0);
lcd.print("WARM ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
//output to element
digitalWrite(13,HIGH);
delay(2000);//on time 2 sec
digitalWrite(13,LOW);
delay(6000);//off time 6 sec
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 500);
//finish audio signal
tone(2,500,10000);
delay(300);
//clear display and print DONE
lcd.setCursor(6, 0);
lcd.print("WARM DONE ");
break;
case 2:
lcd.setCursor(6, 0);
lcd.print("BISQUE ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
//output to element med power
digitalWrite(13,HIGH);
delay(4000);//on time 4 sec
digitalWrite(13,LOW);
delay(4000);//off time 4 sec
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 800);
//second stage of firing cycle
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
digitalWrite(13,HIGH);//output to element full power
digitalWrite(12,HIGH);// turn on 2nd element full power
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 1888); //cone 05 is 1888 F
digitalWrite(13,LOW);//shuts off the element
digitalWrite(12,LOW);//shuts off the 2nd element
//clear display and print DONE
lcd.setCursor(6, 0);
lcd.print("Bisqe DONE ");
break;
case 3:
lcd.setCursor(6, 0);
lcd.print("GLAZE ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time ");
lcd.print(x);
//output to element med power
digitalWrite(13,HIGH);
delay(4000);
digitalWrite(13,LOW);
delay(4000);
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
}
while (f < 800);
//second stage of firing cycle
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time ");
lcd.print(x);
digitalWrite(13,HIGH);//output to element full power
digitalWrite(12,HIGH);// turn on 2nd element full power
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
}
while (f < 2180); //cone 6 is 2180
digitalWrite(13,LOW);//shuts off the element
digitalWrite(12,LOW);//shuts off the 2nd element
break;
case 4:
lcd.setCursor(5, 0);
lcd.print("Man Full On");
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
break;
case 5:
lcd.setCursor(6, 0);
lcd.print("STOP ");
break;
}
}
}
Last edited by adafruit_support_bill on Fri Apr 19, 2013 11:56 am, edited 2 times in total.
Reason: Please use the 'code' button when submitting code
Reason: Please use the 'code' button when submitting code
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
Hmmm. I'm not an Ubuntu user, but the usual Ctrl-C/Ctrl-V don't work?
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
here it is
Code: Select all
//Mod Apr11/13
#include "Adafruit_MAX31855.h"
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
int thermoCLK = 5;
int thermoCS = 4;
int thermoDO = 3;
// Initialize the Thermocouple
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define WHITE 0x7
unsigned long time = millis();
int kilnmode ;
int y = 5;//variable to test with min counter
int heatrate;//variable for temp rise per hour
int temp1;//var to store temp for next calculation
int f = thermocouple.readFarenheit();
int c = thermocouple.readFarenheit();
//int time = millis();
int x = (time/60000); //gives a minute counter
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(2,OUTPUT);
lcd.print("MODE");
// wait for MAX chip to stabilize
delay(5000);
}
void loop() {
lcd.setCursor(0, 1);
if (isnan(c))
{
lcd.print("T/C Problem");
}
else
{
lcd.print("F=");
lcd.print(f);
}
{
//prints time since program started in seconds
lcd.setCursor(10, 1);
lcd.print("T");
lcd.setCursor(11, 1);
lcd.print(time/60000);
//stuff for serial mon
}
//check for a button that is pressed
uint8_t buttons = lcd.readButtons();
if (buttons) {
if (buttons & BUTTON_UP)
kilnmode = 1;
if (buttons & BUTTON_DOWN)
kilnmode = 4;
if (buttons & BUTTON_LEFT)
kilnmode = 2;
if (buttons & BUTTON_RIGHT)
kilnmode = 3;
if (buttons & BUTTON_SELECT)
kilnmode = 5;
//use kilnmode to print "the state" and do the actual temp control
switch (kilnmode) {
case 1: //warm kiln to 500 F
lcd.setCursor(6, 0);
lcd.print("WARM ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
//output to element
digitalWrite(13,HIGH);
delay(2000);//on time 2 sec
digitalWrite(13,LOW);
delay(6000);//off time 6 sec
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 500);
//finish audio signal
tone(2,500,10000);
delay(300);
//clear display and print DONE
lcd.setCursor(6, 0);
lcd.print("WARM DONE ");
break;
case 2:
lcd.setCursor(6, 0);
lcd.print("BISQUE ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
//output to element med power
digitalWrite(13,HIGH);
delay(4000);//on time 4 sec
digitalWrite(13,LOW);
delay(4000);//off time 4 sec
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 800);
//second stage of firing cycle
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time");
lcd.print(x);
digitalWrite(13,HIGH);//output to element full power
digitalWrite(12,HIGH);// turn on 2nd element full power
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
} while (f < 1888); //cone 05 is 1888 F
digitalWrite(13,LOW);//shuts off the element
digitalWrite(12,LOW);//shuts off the 2nd element
//clear display and print DONE
lcd.setCursor(6, 0);
lcd.print("Bisqe DONE ");
break;
case 3:
lcd.setCursor(6, 0);
lcd.print("GLAZE ");
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time ");
lcd.print(x);
//output to element med power
digitalWrite(13,HIGH);
delay(4000);
digitalWrite(13,LOW);
delay(4000);
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
}
while (f < 800);
//second stage of firing cycle
do {
f = thermocouple.readFarenheit();
unsigned long time = millis();
int x = (time/60000); //gives a minute counter
lcd.setCursor(2, 1);
lcd.print(f);
lcd.setCursor(8, 1);
lcd.print("Time ");
lcd.print(x);
digitalWrite(13,HIGH);//output to element full power
digitalWrite(12,HIGH);// turn on 2nd element full power
//data to serial mon if 5 min elapsed
if (x == y)// x starts at zero, counts up 1 min steps
// when x = multiple of 5, data prints to computer
{
Serial.print("temp deg F ");
Serial.println(f);
Serial.print("time since start ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
//code to print rate of temp increase
heatrate =((f-temp1) * 12);
Serial.print("temperature rise per hour ");
Serial.println(heatrate);
y = (y + 5);
temp1 = thermocouple.readFarenheit();//temp used to compare
}
}
while (f < 2180); //cone 6 is 2180
digitalWrite(13,LOW);//shuts off the element
digitalWrite(12,LOW);//shuts off the 2nd element
break;
case 4:
lcd.setCursor(5, 0);
lcd.print("Man Full On");
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
break;
case 5:
lcd.setCursor(6, 0);
lcd.print("STOP ");
break;
}
}
}
Last edited by adafruit_support_bill on Fri Apr 19, 2013 11:57 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code
Reason: Please use the 'code' button when submitting code
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
Try adding some delays after each reading - about 100 milliseconds should do it.
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
I added 500 msec after each reading. I just did a test with a propane torch heating the thermocouple and it was stable (no zero readings) up to 1800 F. (it would not go higher) I will try an actual firing in the kiln soon. Fingers crossed but it looks good!! Thanks
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
I just did another test using my sketch and firing a kiln. I noticed the same intermittent 0 readings at the higher temperature. I switched to the serial thermocouple sketch from adafruit and observed the same thing. I would get five or six good readings followed by a number of something wrong with the thermocouple messages. I discovered however that as soon as I switched off the power to the elements all of the bad readings went away. This points to the possibility of noise getting to be 31 855 chip. For my first version of this I connected the breakout board directly to the thermocouple and used 5 wires to connect to the Arduino. I was getting lots of bad reading so I moved the board to the Arduino and ran twisted pair to the thermocouple, about 4feet of wire. Should I be using shielded wire
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
So this is an electrically fired kiln. Noise can be a real problem with thermocouples. Their output is in the microvolt range, so even tiny amounts of noise can swamp the reading.as soon as I switched off the power to the elements all of the bad readings went away
Are you using thermocouple extension wire? You can't use just any wire or it will throw off the cold-junction compensation of the amplifier. If twisted pair doesn't eliminate the problem, shielding it should help. As much as possible, route the thermocouple wire away from and perpendicular to any noise inducing conductors (such as your heating elements).I moved the board to the Arduino and ran twisted pair to the thermocouple, about 4feet of wire. Should I be using shielded wire
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
I do use an electric kiln. About 3000 watts 220 volts. I connected about 18 " of shielded twisted pair.I fired it again today. Problem apeared as before. At 1700 and above I get intermittent zero readings. . When the kiln switched off I used the adafruit serial thermocouple sketch to monitor things as the kiln cooled.(takes a long time to cool). I discovered that if I unplugged the power cord to my laptop or unpluged the cord to the kiln (kiln switches are off now, drawing no power) the bad readings went away. I power the arduino from the usb to the laptop and the max chip from the arduino. I don't have access to an oscilloscope but maybe the power to the chip is causing this. Why only at high temperatures is a mystery.
I am not concerned with small errors from non thermocouple wire. I just compensate at the upper end . I actually read about 40 millivolts at 2100 F so the chip has lots to work with.
I am not concerned with small errors from non thermocouple wire. I just compensate at the upper end . I actually read about 40 millivolts at 2100 F so the chip has lots to work with.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
That does sound like a noise problem. Not sure why it would only happen at higher temperatures though. How is this wired up? If it is on a breadboard, make sure all your connections are firmly gripped by the breadboard contacts and keep your jumpers short.
The 5v power from the Arduino tends to be noisy. But it is further regulated on the breakout to 3.3v.
The 5v power from the Arduino tends to be noisy. But it is further regulated on the breakout to 3.3v.
-
- Posts: 13
- Joined: Thu Apr 18, 2013 9:40 pm
Re: max 31855 intermitent readings
I did another kiln fire last night and still got intermittent readings at the high temperatures. I rewired everything to shorten wires and I also mounted the LCD shield directly onto the Arduino as previously it was not. I think I am possibly getting 60 cycle noise so I added a 2200 micro farad capacitor across the supply to the max chip. It seems to get fewer errors than previously although that's not a exact observation.
I was looking at postings by other users about intermittent reading. There is a posting by EVRE on March 5 2013 with an image of his readings that looks very similar to what I see on my serial monitor except my numbers are higher.
There is something causing the max chip to return readings of 0 and I don't think it's because we have bad connections.
My problem still disappears when I unplug the power supply to the laptop and run on the laptop battery. I can't run this way as my kiln needs five or six hours to do a fire.
I am now considering to power the thermocouple board from: a small battery from a cell phone. I think it's draws very little current so this would work.
Your input is always appreciated.
I was looking at postings by other users about intermittent reading. There is a posting by EVRE on March 5 2013 with an image of his readings that looks very similar to what I see on my serial monitor except my numbers are higher.
There is something causing the max chip to return readings of 0 and I don't think it's because we have bad connections.
My problem still disappears when I unplug the power supply to the laptop and run on the laptop battery. I can't run this way as my kiln needs five or six hours to do a fire.
I am now considering to power the thermocouple board from: a small battery from a cell phone. I think it's draws very little current so this would work.
Your input is always appreciated.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: max 31855 intermitent readings
It does run on 3.3v, so a small LiPo like this one would probably do the job: http://www.adafruit.com/products/1317
Since it only happens when connected to the laptop, It sounds like maybe the noise is coupling in via the power supply rather than the probe.
Since it only happens when connected to the laptop, It sounds like maybe the noise is coupling in via the power supply rather than the probe.
Please be positive and constructive with your questions and comments.