MAX31855 chip transplant

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

MAX31855 chip transplant

Post by jefflawr »

Hi,
Though an electro-newbie, I'd like to use the Arduino kit I got for Christmas to build a logging system for ceramic kiln atmosphere and temperature.
My atmosphere sensor unit has an R-type thermocouple as well as the oxygen sensor so I'd rather read temperature from it than from my K-type thermocouples elsewhere in the firebox.
Question #1: Could I transplant an R-type MAX31855 chip into the Adafruit K-type break-out board to get the functionality I want?
Question #2: What could possibly go wrong?
Thanks,
Jeff Lawrence

jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

Re: MAX31855 chip transplant

Post by jefflawr »

Answer from Maxim tech support:
Staff Comment 2013-08-01 13:35:00 PST
| By: Brian R
|
| Hi Jeff,
|
| Everything should work fine when you replace the part and the
| thermocouple.

That was fast. Now to see what can possibly go wrong...

User avatar
adafruit_support_bill
 
Posts: 84615
Joined: Sat Feb 07, 2009 10:11 am

Re: MAX31855 chip transplant

Post by adafruit_support_bill »

Another customer has successfully performed this operation on the MAX31855 breakout. As surface mount chips go, these are not too difficult to work with.

User avatar
ashurbr
 
Posts: 28
Joined: Fri Jun 29, 2012 3:14 pm

Re: MAX31855 chip transplant

Post by ashurbr »

Greetings Jeff,

Adafruit support is correct. I have "transplanted" both type S and R and they work very well. I too am using these for control on a furnace. Here are several things you need to know, though.

1. The MAX31855 modules use a constant multiplier to convert the microvolt signal from the thermocouple to a temperature. The real temperature versus microvolt conversion is substantially more complex and a constant scale factor. Type S and R are especially vulnerable to significant error in reported temperature due to the nonlinear character of the emf versus temperature. You can look at the NIST website for primary emf data. You can take the reported temperature and back calculate the measured emf, then use your own lookup table or polynomial to find the correct temperature.

2. Once corrected for the true emf versus temperature, there is a "shaped error" that is correctable. you would need a thermocouple calibrator that can accurately source known temperatures, then record the measured temperature with your max module. you can then generate a error shape correction curve.

3. Using these methods, I have been able to get agreement between a NIST calibrated source and the MAX module of less than 2 degrees C over the entire valid temperature range.

Pop back a reply to this if you are interested and I can supply more detail.

Good luck,

Bob A.

jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

Re: MAX31855 chip transplant

Post by jefflawr »

Hi Bob,
Thanks for the info. I performed the surgery and the patient survived. It seemed to be reporting ballpark believable temperatures - 75F for an uncooled house and hotter when I heated the tip with a barbecue lighter.
I've got two K-type probes in the kiln where the R-type lives, which means I'm not totally reliant on it, but would obviously prefer accuracy. How much of an error were you detecting?
Best,
Jeff

User avatar
ashurbr
 
Posts: 28
Joined: Fri Jun 29, 2012 3:14 pm

Re: MAX31855 chip transplant

Post by ashurbr »

Greetings Jeff,

The error depends on the temperature. Please see the referenced plots. For example, when the true temperature is 400C, the emf produced by the thermocouple is about 3.407 mV. The MAX will report this as a temperature of about 324.4 C (about 75.6 C error). It is my belief that the MAX was designed to be correct at 0 and 1000C. Fortunately for you, the error is smaller at temperatures around 1000C, but grows rapidly in the (-) direction past 1000C.

Image

Image

Let me know if you want to make the corrections to your data - there is a not-so-obvious method you would need to employ to calculate the emf from measured temperature AND measured reference junction temperatures (you need both).

Good luck,

Bob A.

jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

Re: MAX31855 chip transplant

Post by jefflawr »

Hi Bob,
I'm very impressed with your analysis and solution.
I fire to 1200C and a difference of 10-20C matters, so I'm obviously concerned over the differences you determined.
I'd really appreciate you sharing how you correct the MAX31855 results. Do you just hardcode the corrections for the steps in the temperature range or did you come up with some slick equation?
Best,
Jeff

User avatar
ashurbr
 
Posts: 28
Joined: Fri Jun 29, 2012 3:14 pm

Re: MAX31855 chip transplant

Post by ashurbr »

Greetings Jeff,

Are you using Python or some other language? All my stuff is in C/C++. I can post some code that you can use.

jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

Re: MAX31855 chip transplant

Post by jefflawr »

Hi Bob,
I used to program in C, so that would be most straightforward for me, but whatever's most convenient for you - the algorithm's the main thing.
Thanks again.
Jeff Lawrence
jefflawr@gmail.com

User avatar
ashurbr
 
Posts: 28
Joined: Fri Jun 29, 2012 3:14 pm

Re: MAX31855 chip transplant

Post by ashurbr »

Greetings again Jeff,

I developed a 22nd order polynomial to fit the NIST primary data. I determined that this was "good enough" for me in that it accurately captured the NIST data to well within 1 microvolt of emf error over the entire range. I then used a NIST traceable calibrated thermocouple source to sweep the range from 0 to 1350 C in 50 C increments. By taking averaged readings from the MAX and knowing the sourced values, I developed a ratio of polynomials to correct the shape of the error. I'll get the C/C++ code and post it here soon (probably tomorrow sometime).

Good luck,

Bob A.

User avatar
ashurbr
 
Posts: 28
Joined: Fri Jun 29, 2012 3:14 pm

Re: MAX31855 chip transplant

Post by ashurbr »

Greetings Jeff,

Below is some code segments/snippits that should help. The MAX send a 4 byte response. The code below shows how to interpret the response and break out the reference junction temperature and the measured temperature. Then piece together the real emf generated by the thermocouple. Then use the 22nd order polynomial to turn that true emf into an accurate temperature. I only have error shape information for type S modules, so I am not sure if it will be the same for the type R or K modules. Any thoughts on that?

Please let me know if this is helpful or if you can suggest a better way.

Bests,

Bob A.

Code: Select all


// MAX31855 Chip Specific Constants
const double MAXTEMF_R =  0.010506;  	// mV/deg C per MAX31855 documentation
const double MAXRJEMF_R = 0.006158;  	// mV/deg C per MAX31855 documentation

// pTofEMF coefficients determined by Matlab Analysis of NIST Primary Type R TC EMF data, 22nd order polynomial
const double pTofEMF_R[23] = {0.041972611381969158, 187.47799997295849, -81.010972018177782, 70.674125648340649, -53.336316986817231, 31.689979653709834, -14.52796490510924, 5.1548610132167969, -1.4291253409395299, 0.31268790343562863, -0.054460051592675508, 0.0075999273393827175, -0.00085333756111468447, 7.7217435176066274e-005, -5.6241765059029609e-006, 3.2822431932377676e-007, -1.5214709572999446e-008, 5.5223101261692754e-010, -1.5345183172922749e-011, 3.1500265622575896e-013, -4.4991905942266958e-015, 3.9912725332936798e-017, -1.6556723793012656e-019};


//compute polynomial - change coefficients vector to correct TC type
double correctedT (double EMF){
	double temp = 0;
	for (int k=0; k<23; k++){temp += pTofEMF_R[k]*pow(EMF, k);}
	return refineTemp(temp);



//MAX sends a 4 byte word that contains both measured temp and reference junction temp.
	int temp = 0;
	double rjTemp = 0;
	double measTemp = 0;
	double emf = 0;
	int frpart = 0x03;
	int refpart = 0xFFFF;
	int reffrpart = 0x0F;
	int errchk = 0x10000;  //the one bit that is set when a TC error occurs - see MAX documentation

	//stick the 4 bytes together to form the word
	temp += message[0]; temp<<=8;
	temp += message[1]; temp<<=8;
	temp += message[2]; temp<<=8;
	temp += message[3];
	
	if((errchk & temp)==errchk){
		return ERRTEMP;}  //if bit 16 is 1, there is a TC error, and return ERRTEMP
	else{
		refpart = refpart & temp;
		refpart>>=4;
		reffrpart = reffrpart & refpart;
		refpart>>=4;
		rjTemp = (double) refpart + ((double) reffrpart)*0.0625;
		temp>>=18;
		frpart = frpart & temp;
		temp>>=2;
		measTemp = (double) temp + ((double) frpart)*0.25;
		emf = MAXTEMF_R*measTemp - (MAXTEMF_R - MAXRJEMF_R)*rjTemp;  //the key line
		return correctedT(emf);
	}
}



jefflawr
 
Posts: 25
Joined: Thu Aug 01, 2013 2:24 pm

Re: MAX31855 chip transplant

Post by jefflawr »

Hi Bob,
Thanks a million for sharing your work. I'm out of my depth in the polynomial development waters, but have a technical friend I've intrigued into helping me with the project who's been wrestling thermocouple problems for years and I'm sure he can dig up some kind of error shape coefficients we can use for the R-type. When that happens, I'll post his solution for the common good.
Since it's been twenty years since I wrote anything in C, it's a huge boon to have your code to use. Fortunately, it all seems to still make some sense.
I appreciate your taking the time to be so generous.
Best regards,
Jeff

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”