Faster Reading of K Type Thermocouples

Hey,
I’ve made a fairly basic code to read my thermocouples off of 4 MAX31855 boards using a Mega2560. My CLK and CS are daisy chained with each DO going to its own pin.

//LIBRARIES
#include "Adafruit_MAX31855.h"
#include <SPI.h>

//THERMOCOUPLE BOARD SETUP
#define MAXCLK 50
#define MAXCS 51
#define MAXDO1 49
#define MAXDO2 47
#define MAXDO3 45
#define MAXDO4 43

Adafruit_MAX31855 thermocouple1 (MAXCLK, MAXCS, MAXDO1);
Adafruit_MAX31855 thermocouple2 (MAXCLK, MAXCS, MAXDO2);
Adafruit_MAX31855 thermocouple3 (MAXCLK, MAXCS, MAXDO3);
Adafruit_MAX31855 thermocouple4 (MAXCLK, MAXCS, MAXDO4);


//RELAY VARIABLES

int setTemp = 30;
int state = 0;

//SETUP

void setup() {
  Serial.begin(500000);
  pinMode(53,OUTPUT);
  delay(500);

}


void loop() {
  //THERMOCOUPLE READ
  double t1 = thermocouple1.readCelsius();
  double t2 = thermocouple2.readCelsius();
  double t3 = thermocouple3.readCelsius();
  double t4 = thermocouple4.readCelsius();
  

  //RELAY CONTROL

  if(t1 <= setTemp) {
    digitalWrite(53,LOW);
    state = 1;
  }
  else if(t1 >= setTemp) {
    digitalWrite(53,HIGH);
    state = 0;
  }

  //SERIAL READ
  Serial.print("Temperature 1 = "); Serial.print(t1);
  Serial.print(", Temperature 2 = "); Serial.print(t2);
  Serial.print(", Temperature 3 = "); Serial.print(t3);
  Serial.print(", Temperature 4 = "); Serial.print(t4);
  Serial.print(", Relay State = "); Serial.println(state);
  
}

For the project I am working on I need readings as fast a possible, but currently I am only getting data every 271ms. If I adjust my code to only read one thermocouple (by commenting the double t2, t3, t4) I get a readout every 69ms. Is there a way to read all of the thermocouples simultaneously?
Any suggestions would be greatly appreciated, Also feel free to ask any questions about the gear I am running.
Thanks in advance.

PS. The relay control is for a heater (based on the temp reading). I have tried removing the relay control statement and it has had no effect on the response time. The readCelsius() is what is causing the slowdown.

but currently I am only getting data every 271ms.

That is because of all the serial printing you are doing. Store the readings in an array.

It is silly trying to read a thermocouple quickly anyway as the thermal time constant of what you are trying to measure is way in excess of the time you are taking.

Thanks for the reply,
I'm measuring the transient response of a stirling regenerator for research purposes, so many data points is necessary to plot, and the response time of my fine gauge thermocouples is very low (little as .003s).
Thank you for the array information though, I am new to programming so all help is appreciated!

Also, I have removed all serial prints except for 1, and the 271ms time interval is still the same. I believe it is the reads that are the culprit.

Try changing the SPI speed.

MorganS:
Try changing the SPI speed.

Is that as simple as changing the 4MHz to say 5Mhz in the MAX_31855 library?

 SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));

to

 SPI.beginTransaction(SPISettings(5000000, MSBFIRST, SPI_MODE0));

Yes, but why not use double speed? 8MHz? (Standard 16MHz Arduinos can't go faster than 8.)

MorganS:
Yes, but why not use double speed? 8MHz? (Standard 16MHz Arduinos can’t go faster than 8.)

Thanks for the reply, Ive tried going up to 8MHz but still have a 270ms interval unfortunately.

Also the reason I only went to 5MHz originally is because that is the max serial clock frequency listed on the MAX31855 datasheet.

believe it is the reads that are the culprit.

It looks like the conversion time of the chip.

The data sheet also states:-

Temperature Conversion Time (Thermocouple, Cold Junction, Fault Detection)
tCONV
(Note 5)
70 typical 100 max ms

(Note 5)
Specification is 100% tested at TA = +25°C. Specification limits over temperature (TA = TMIN to TMAX) are guaranteed by design and characterization; not production tested.

The MAX31855 datasheet says that each data sample takes 70-100 milliseconds. But that should not cause your program to wait for that period. The SPI data read can function separately to the individual conversions. There's something else going on here.

Thanks for the help guys, I haven't yet found a better way to go about the programming, I have however found a USB-2401 DAQ in the lab that I'm working in (pros of working for a university) and I'm getting a reading every whopping 8ms from all 4 thermocouples. I will be continuing to look for ideas to speed up the arduino DAQ for future though, if I find anything I will post here.