Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Adafruit MAX31856
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit MAX31856

by sdumans on Tue Aug 18, 2020 5:02 pm

My problem relates to the MAX31856 thermocouple board. I have been using it, along with an Arduino
UNO to control the time-temperature profile of a ceramic kiln. The problem is that, for some reason the
temperature reading from the MAX31856 as seen through the Arduino serial port will hang up at a fixed
value, in spite of the fact that I know that the thermocouple voltage is increasing properly as the kiln
heats up because I can monitor it with a digital volt meter. Here is an example:

2020-08-18_164045.jpg
2020-08-18_164045.jpg (222.61 KiB) Viewed 59 times


The first column is simply time in minutes, the second is the temperature in F as read by the Arduino UNO
and the third is the temperature goal. As you can see the temperate reading hangs up at 1498.28 F in spite
of the fact that prior to that time, the temperature is increasing at something like 11 F/minute. What is even
stranger is that I can unplug the thermocouple and the reading still remains fixed, in this case at 1498.28 F.

I've attached a copy of my Arduino code. I 've tried many ideas as to why this might be occurring but obviously
haven't figured it out. If anyone can offer a suggestion as to what might be going on, I'd certainly appreciate it.
Attachments
KilnControl2_Cone5.ino
(6.38 KiB) Downloaded 5 times

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Re: Adafruit MAX31856

by mikeysklar on Tue Aug 18, 2020 5:25 pm

Hello sdumans,

Thank you for verifying the voltage still increasing that is helpful.

Which type of thermal couple are you using?

Would you mind uploading your code with in the [CODE} tag it makes it much easier for everyone to scan it in-line.

mikeysklar
 
Posts: 1974
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit MAX31856

by sdumans on Tue Aug 18, 2020 5:30 pm

I am using a Type-K thermocouple. I clearly am new at this because when I hit
the
Code: Select all | TOGGLE FULL SIZE
 button all I get is " [code]
" in my post and I don't know what
to do next to load the code. I just copied and pasted it.


//*****************************
KilnControl.ino

Ceramic-kiln controller.
S. Umans
Last modified, July 25, 2020
*****************************/

/*********************************
Include the Adafruit MAX31856 universal thermocouple
amplifier and set it up
**********************************/
#include <Adafruit_MAX31856.h>
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(10, 11, 12, 13);

//Set the number of steps for the firing Profile
const int NSTEPS = 9;

// Define the profile structure
struct Profile {
float Temp; // Temperature goal for that step
int Time; // Minimum time for that step
int Seconds; // # of seconds per minute of eating for that step
} step[NSTEPS]; // Array containing the steps of the profile


// Use pin 3 to signal the heater status
#define LedPin 3
// Use pin 5 to start/halt the program
#define ControlPin 5
// Use pin 6 to control the kiln
#define KilnPin 6

// counter variable used for timing
int counter = 1;

// Useful variables
float TempC; // Thermocouple temperature in C
float TempF; // Thermocouple temperature in F
float CurrentTempRef; // Holds the current temperature reference
float Time; // Time since the start of the program
float Time0; // Sets zero time
float TIMER; // Time in the various stages
float TIME0; // Sets zero time for each stage
float CurrentTimeRef; // Holds time duration for each stage
float to_sec = 1/1000.; // Convert from milli-sec to seconds
float to_min = 1/(1000.*60.); // Convert from milli-sec to minutes
int STEP = 0; // Current profile step - initally set to 0
bool Kiln = 0; // Kiln = 0 --> heater off, Kiln = 1 --> heater on
bool DutyCycleSwitch = 0; // Used to control the duty cycle of the heater
float StepTemp; // Temperature goal for current step
float StepTime; // Minimum time at the current step
float StepSeconds; // Seconds/minute of heating at current step
bool SwitchState; // State of the control switch.
const bool ON = 1;
const bool OFF = 0;

void setup(){
Serial.begin(9600);

// Steps which define the profile
step[0] = {150, 30, 10};
step[1] = {220, 30, 15};
step[2] = {440, 60, 20};
step[3] = {800, 60, 30};
step[4] = {1100, 60, 40};
step[5] = {1400, 60, 50};
step[6] = {1700, 60, 60};
step[7] = {2000, 60, 60};
step[8] = {2167, 60, 60};

//set pins as outputs
pinMode(LedPin, OUTPUT);
pinMode(KilnPin, OUTPUT);

/**********************************
Set up the Arduino UNO Timer1 to issue a timer interrupt
each second (1 Hz). This will be used both for timing the
temperature sampling and the duty of the kiln-heater power.
For details of setting up the timer, see for example:
https://www.instructables.com/id/Arduin ... nterrupts/
************************************/
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 15624;
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << CS12) | (1 << CS10);
TIMSK1 |= (1 << OCIE1A);

// Enable the Timer1 interrupt
sei();

// Set up pin to control kiln heater
pinMode(KilnPin,OUTPUT);
digitalWrite(KilnPin,LOW);

// Set up pin to read control switch
pinMode(ControlPin,INPUT);
digitalWrite(ControlPin,HIGH);

// Set up pin which turns on LED
pinMode(LedPin,OUTPUT);
digitalWrite(KilnPin,LOW);

// Initiate Adiafruit thermocouple board software.
maxthermo.begin();
// Set Thermocouple type to K
maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);

// Set the zero time
Time0 = millis()*to_min;
TIME0 = Time0;

} // End of setup()


void loop(){

// Calulate the time since the start of the run
Time = millis()*to_min;

// Get the state of the control switch
SwitchState = digitalRead(ControlPin);

// Calculate the time in the current Stage
TIMER = millis()*to_min - TIME0;

// If the control switch is in the off position set
// to STEP 0
if (SwitchState == 0){
STEP = 0;
StepSeconds = 0;
StepTemp = 0;
// Turn kiln heater off
Kiln = OFF;
}

// When the control switch is turned on, start
// with the first step in the profile
if ((SwitchState == 1) && (STEP == 0)){
STEP = 1;
// reset the Step Timer to 0
TIME0 = Time;
TIMER = millis()*to_min - TIME0;
}


if ((STEP > 0) && (STEP <= NSTEPS))
{

TIMER = millis()*to_min - TIME0;
// Get the step profile elements
StepTemp = step[STEP-1].Temp;
StepTime = step[STEP-1].Time;
StepSeconds = step[STEP-1].Seconds;

// Will turn on heater if temperature is below goal
if (TempF <= StepTemp) Kiln = DutyCycleSwitch;
// Turn off heater if temperature is above goal and
// minimum step time has not been reached
else if ((TempF > StepTemp) && (TIMER < StepTime)) Kiln = OFF;
// If both temperature goal and minimum time have been reached,
// go to the next step
else
{
STEP = STEP + 1;
// reset the Step Timer to 0
TIME0 = Time;
}

}

// if all profile steps are completed turn heater off
if (STEP > NSTEPS)
{
Kiln = OFF;
StepSeconds = 0;
StepTemp = 70;
}

// Call the heater control function
heater(Kiln);

} // end of loop()

/*****************************
The Timer1 interrupt function. It is called once
each second
******************************/
ISR(TIMER1_COMPA_vect){

// Each second check kiln-heater status.
if (counter <= StepSeconds) DutyCycleSwitch = ON;
else DutyCycleSwitch = OFF;

// Update the status
if ( (counter % 10) == 0) UpdateStatus();

// Update the counter and reset after one minute
counter++;
if (counter == 61) counter = 1;
}

void UpdateStatus()
{

// Read the temperature
TempC = maxthermo.readThermocoupleTemperature();
// Convert temperature to Farenheit
TempF = 32.+9.0*TempC/5.0;


// Current time since start of the program
Serial.print(Time,1);
Serial.print(" ");

// Temperature
Serial.print(TempF);
Serial.print(" ");

// Print the step temperature goal
Serial.print(StepTemp);
Serial.print(" ");

// Print the current step
Serial.print(STEP);
Serial.print(" ");

// Print the heater on-time fraction
Serial.println(StepSeconds/60);
}

void heater(bool Kiln) {
if (Kiln != 1) // Turn of the kiln heater and the status led
{
digitalWrite(KilnPin,LOW);
digitalWrite(LedPin,LOW);
}
else // Turn on the kiln heater and the status led
{
digitalWrite(KilnPin,HIGH);
digitalWrite(LedPin,HIGH);
}
}

]

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Re: Adafruit MAX31856

by sdumans on Tue Aug 18, 2020 8:39 pm

An additional bit of information ... I checked for faults and this behavior corresponds to and Over/Under-Voltage fault
which never seems to clear, independent of whether or not the kiln is on, whether or not the thermocouple is plugged
in or unplugged, etc.

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Re: Adafruit MAX31856

by sdumans on Wed Aug 19, 2020 4:30 pm

I just upgraded to the latest Arduino library for the Adafruit MAX31856
(version 1.2.1) and now, in spite of the fact that I still get over/under-voltage
fault indications, the temperature readings don't hang up and checking
them with a voltmeter I confirmed that the temperatures are reading
correctly. I now also get thermocouple-high fault indications which I did
not before. At this point, I will turn off printing the fault indications and
consider my problem solved ... although I would be happy if someone
was able to explain what is going on. By the way, to better understand
if there was really a voltage problem caused by some sort of noise that
didn't even show up on an oscilloscope, I tried putting 10V zener diodes
to ground on the + and - thermocouple connections on the board. It
didn't make a bit of difference; I still got the over/under-voltage fault
indications.

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Re: Adafruit MAX31856

by mikeysklar on Wed Aug 19, 2020 5:02 pm

Hello sdhumans,

I'm glad to hear the library update put you in a workable situation.

Based on another forum thread it appears the under/over voltage faults can be an SPI library issue which is platform specific. I've also seen it mentioned that using shorter wire lengths for the K-type probe and small capacitors might help.

viewtopic.php?f=8&t=130091

mikeysklar
 
Posts: 1974
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit MAX31856

by sdumans on Wed Aug 19, 2020 5:06 pm

Since my "success" is based only on a single kiln firing, I will certainly
give those additional suggestions a try. I certainly don't feel that I've
found a real solution at this point but rather a work around.

Thanks.

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Re: Adafruit MAX31856

by Thermoread on Thu Aug 20, 2020 2:32 am

Hi I am trying to read -ve temperature(Ice cream temp -11deg) using J type thermocouple with Max31856 arduino controller, but it is getting stuck at -3deg and reading very slow after that. Has anyone faced this kind of issue before? Where am I going wrong?

Thermoread
 
Posts: 6
Joined: Thu Aug 20, 2020 2:28 am

Re: Adafruit MAX31856

by mikeysklar on Fri Aug 21, 2020 2:58 pm

Hi Thermoread,

Please start a new thread with your J-type / Max31856 stall at -3 deg. It sounds like a wiring issue so we will need to troubleshooting this further with you to confirm.

mikeysklar
 
Posts: 1974
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit MAX31856

by Thermoread on Mon Aug 24, 2020 7:01 am

I have created a new thread viewtopic.php?f=25&t=168713 here.

Thermoread
 
Posts: 6
Joined: Thu Aug 20, 2020 2:28 am

Re: Adafruit MAX31856

by sdumans on Thu Aug 27, 2020 7:29 pm

So I thought that upgrading the MAX31856 library solved my "stuck temperature" problem.
I did a test run where I simply turned the kiln full on and let it heat for a bit over 5 hours.
All seemed fine until I plotted the temperature:

TempPlot.jpg
TempPlot.jpg (31.98 KiB) Viewed 23 times


As you can see, for some reason the temperature reading as printed to the Arduino serial
port got "stuck" for roughly 23 minutes at around 410 F. After 23 minutes, it "magically"
fixed itself and the temperature read correctly for the remainder of the heating transient.
I checked the output file and saw that during this period of time, each reading was
accompanied by an over/under-voltage fault indication. At this point, I am at a loss as
to what causes the problem and why it fixes itself ... or more to the point, what I can do
to eliminate it. It is a serious problem since my temperature-control algorithm depends
upon accurate temperature readings to achieve a desired temperature-vs time profile.

sdumans
 
Posts: 8
Joined: Sun Jan 31, 2016 12:51 pm

Please be positive and constructive with your questions and comments.