Quantcast
Channel: Sensors - Arduino Forum
Viewing all articles
Browse latest Browse all 1071

Using SEN30007 (MAX31856) for Thermocouples with Arduino Uno R4 Wifi

$
0
0

I am running into a problem while using Playing with Fusion SEN30007 connected to 3 Type J Thermocouples. When I am trying to access all three of them, I get the error message for all thermocouples:

"Unknown Fault with cold junction measurement"

The same code runs fine with an Arduino Uno R3, or if I run it with individual thermocouple (only one number in tcChipSelects) on R4, but I need R4 due to the large amount of data need to be processed in the actual project. I am trying to see if anyone can give me some ideas on how I can modify PWFusion_MAX31856 library so the error can be fixed, or maybe there is something I can add in my code to resolve the issue.

This is the code I am using, which is one of the examples from Playing with Fusion:

#include <PWFusion_MAX31856.h>

#define NUM_THERMOCOUPLES (sizeof(tcChipSelects) / sizeof(uint8_t))

uint8_t tcChipSelects[] = { 7, 8, 9 };  // define chip select pins for each thermocouple
MAX31856 thermocouples[NUM_THERMOCOUPLES];


void setup() {
  // Give the MAX31856 a chance to stabilize
  delay(1000);

  Serial.begin(115200);  // set baudrate of serial port
  Serial.println(F("Playing With Fusion: MAX31856, SEN-30007/8"));
  Serial.println(F("Continous Mode Example"));

  // Initialize each MAX31856... options can be seen in the PWFusion_MAX31856.h file
  for (int i = 0; i < NUM_THERMOCOUPLES; i++) {
    thermocouples[i].begin(tcChipSelects[i]);
    thermocouples[i].config(J_TYPE, CUTOFF_60HZ, AVG_SEL_1SAMP, CMODE_AUTO);
  }
}


void loop() {
  delay(500);  // 500ms delay... can be as fast as ~100ms in continuous mode, 1 samp avg

  for (int i = 0; i < NUM_THERMOCOUPLES; i++) {
    // Get latest measurement from MAX31856 channels
    thermocouples[i].sample();

    // Print information to serial port
    print31856Results(i, thermocouples[i]);

    // Attempt to recove misconfigured channels
    if (thermocouples[i].getStatus() == 0xFF) {
      thermocouples[i].config(J_TYPE, CUTOFF_60HZ, AVG_SEL_1SAMP, CMODE_AUTO);
      Serial.print(F("re-attempt config on TC"));
      Serial.println(i);
    }
  }
  Serial.println();
}


void print31856Results(uint8_t channel, MAX31856 &tc) {
  uint8_t status = tc.getStatus();

  Serial.print("Thermocouple ");
  Serial.print(channel);

  if (status) {
    // lots of faults possible at once, technically... handle all 8 of them
    // Faults detected can be masked, please refer to library file to enable faults you want represented
    Serial.print(F(": FAULTED - "));
    if (TC_FAULT_OPEN & status) { Serial.print(F("OPEN, ")); }
    if (TC_FAULT_VOLTAGE_OOR & status) { Serial.print(F("Overvolt/Undervolt, ")); }
    if (TC_FAULT_TC_TEMP_LOW & status) { Serial.print(F("TC Low, ")); }
    if (TC_FAULT_TC_TEMP_HIGH & status) { Serial.print(F("TC High, ")); }
    if (TC_FAULT_CJ_TEMP_LOW & status) { Serial.print(F("CJ Low, ")); }
    if (TC_FAULT_CJ_TEMP_HIGH & status) { Serial.print(F("CJ High, ")); }
    if (TC_FAULT_TC_OOR & status) { Serial.print(F("TC Range, ")); }
    if (TC_FAULT_CJ_OOR & status) { Serial.print(F("CJ Range, ")); }
    Serial.println();
  } else  // no fault, print temperature data
  {
    Serial.println(F(": Good"));

    // MAX31856 External (thermocouple) Temp
    Serial.print(F("TC Temp = "));  // print TC temp heading
    Serial.println(tc.getTemperature());
  }

  // MAX31856 Internal Temp
  Serial.print(F("Tint = "));
  float cjTemp = tc.getColdJunctionTemperature();
  if ((cjTemp > -100) && (cjTemp < 150)) {
    Serial.println(cjTemp);
  } else {
    Serial.println(F("Unknown fault with cold junction measurement"));
  }
  Serial.println();
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1071

Trending Articles