Trying to connect multiple thermocouplle boards to one teensy 3.6

Status
Not open for further replies.

tikawawa

Member
Hi,

I am trying to connect 8 thermocouple boards (4 x MAX31855 and 4 x MAX31856) to one teensy 3.6. I managed to get one MAX31855 working. How do I add the rest to the code. I know that the DO and CLK pins could be shared with all boards and each board has to have it's own CS pin that has to be high to read from that board. How do I do that?

Thanks a bunch

Code:
/***************************************************
  This is an example for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

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

// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:

// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXDO   30
#define MAXCS   31
#define MAXCLK  32

// initialize the Thermocouple
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);


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

  while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
   Serial.print("Internal Temp = ");
   Serial.println(thermocouple.readInternal());

   double c = thermocouple.readCelsius();
   if (isnan(c)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C = ");
     Serial.println(c);
   }
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

   delay(1000);
}
 
Update

I found this code online and I modified it to work. It seems like I have to split all pins DO, CS, CLK. I am getting zeros temperature on both thermocouples when I connect the DO and CLK pins to the same pin on the teensy. Is that true, if so why? Are both modules sending data at the same time because both CS pins are high? If so, how do set a specific CS pin to low?

Also, there seems to be a stabilization period for the chip, is that for every time I enable the chip?

Thanks

Code:
/***************************************************
  This is an example for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

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

// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:

// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXDO   30
#define MAXCS1  31
#define MAXCS2  29
#define MAXCLK  32

// initialize the Thermocouple
Adafruit_MAX31855 thermocouple1(MAXCLK, MAXCS1, MAXDO);
Adafruit_MAX31855 thermocouple2(MAXCLK, MAXCS2, MAXDO);

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

  while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
  // From 1st thermocouple
  
   Serial.print("Internal Temp 1 = ");
   Serial.println(thermocouple1.readInternal());

   double c1 = thermocouple1.readCelsius();
   if (isnan(c1)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C1 = ");
     Serial.println(c1);
   }
   Serial.print("F1 = ");
   Serial.println(thermocouple1.readFahrenheit());

// Read the second thermocouple
   
   Serial.print("Internal Temp 2 = ");
   Serial.println(thermocouple2.readInternal());

   double c2 = thermocouple2.readCelsius();
   if (isnan(c2)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C2 = ");
     Serial.println(c2);
   }
   Serial.print("F2 = ");
   Serial.println(thermocouple2.readFahrenheit());
   
   delay(1000);
}
 
Thanks for the reference to PJ's article on SPI bus design. That is tremendously useful.
 
Status
Not open for further replies.
Back
Top