double Adafruit_MAX31855::readCelsius(void) {

  uint32_t v;

  v = spiread32();

  //Serial.print("0x"); Serial.println(v, HEX);

  /*
  float internal = (v >> 4) & 0x7FF;
  internal *= 0.0625;
  if ((v >> 4) & 0x800) 
    internal *= -1;
  Serial.print("\tInternal Temp: "); Serial.println(internal);
  */

  if (v & 0x7) {
    // uh oh, a serious problem!
    return NAN; 
  }

  // get rid of internal temp data, and any fault bits
  v >>= 18;
  //Serial.println(v, HEX);

  // pull the bottom 13 bits off
  double temp = v & 0x1FFF;
  // check sign bit
  if (v & 0x2000) 
    temp *= -1;
  // LSB = 0.25 degrees C
  temp *= 0.25;
  return temp;
}
int AdafruitMAX31855::init(void) {
    if (_spimode) { //hardware mode
        pinMode(_cs, OUTPUT);
        SPI.setClockDivider(SPI_CLOCK_DIV8);
        SPI.setDataMode(SPI_MODE0);
        SPI.setBitOrder(MSBFIRST);
        SPI.begin(_cs);
    } else { //software mode
        pinMode(_cs, OUTPUT);
        pinMode(_sclk, OUTPUT);
        pinMode(_miso, INPUT);
    }
    chipSelectHigh();

    // now we need to do an initial value on the moving average. 
    // this also confirms that thermocouple is attached and working
    int32_t v;
    v = spiread32();
    if (v & 0x7) {
        // uh oh, a serious problem!
        return NAN;
    }
    if (v & 0x80000000) {
        // Negative value, drop the lower 18 bits and explicitly extend sign bits.
        v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);
    } else {
示例#3
0
double Jm_MAX31855::readCelsius(void) {

  int32_t v;

  v = spiread32();

  //Serial.print("0x"); Serial.println(v, HEX);

  /*
  float internal = (v >> 4) & 0x7FF;
  internal *= 0.0625;
  if ((v >> 4) & 0x800) 
    internal *= -1;
  Serial.print("\tInternal Temp: "); Serial.println(internal);
  */

  if (v & 0x7) {
    // uh oh, a serious problem!
    return NAN; 
  }

  if (v & 0x80000000) {
    // Negative value, drop the lower 18 bits and explicitly extend sign bits.
    v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);
  }
示例#4
0
double MAX31855::readCelsius() {
  int32_t v = spiread32();

  if (v & 0x7) {
    // uh oh, a serious problem!
    return NAN; 
  }

  // get rid of internal temp data, and any fault bits
  v >>= 18;
  
  // LSB = 0.25 degrees C
  return v * 0.25;
}
void Thermocouple_Max31855::getTemperature(float &dataOut)
{
	int32_t v;

	v = spiread32();

	if (v & 0x7) {
		// uh oh, a serious problem!
		dataOut = 0x7FFFFFFFFF;
	}

	if (v & 0x80000000) {
		// Negative value, drop the lower 18 bits and explicitly extend sign bits.
		v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);
	}
double Adafruit_MAX31855::readInternal(void) {
  uint32_t v;

  v = spiread32();

  // ignore bottom 4 bits - they're just thermocouple data
  v >>= 4;

  // pull the bottom 11 bits off
  float internal = v & 0x7FF;
  internal *= 0.0625; // LSB = 0.0625 degrees
  // check sign bit!
  if (v & 0x800) 
    internal *= -1;
  //Serial.print("\tInternal Temp: "); Serial.println(internal);
  return internal;
}
示例#7
0
double MAX31855::readInternal(void) {
  uint32_t v = spiread32();

  // ignore bottom 4 bits - they're just thermocouple data
  v >>= 4;

  // pull the bottom 11 bits off
  float internal = v & 0x7FF;
  internal *= 0.0625; // LSB = 0.0625 degrees
  
  // check sign bit!
  if (v & 0x800) {
    internal *= -1;
  }

  return internal;
}
示例#8
0
double Jm_MAX31855::readInternal(void) {
  uint32_t v;

  v = spiread32();

  // ignore bottom 4 bits - they're just thermocouple data
  v >>= 4;

  // pull the bottom 11 bits off
  float internal = v & 0x7FF;
  // check sign bit!
  if (v & 0x800) {
    // Convert to negative value by extending sign and casting to signed type.
    int16_t tmp = 0xF800 | (v & 0x7FF);
    internal = tmp;
  }
  internal *= 0.0625; // LSB = 0.0625 degrees
  //Serial.print("\tInternal Temp: "); Serial.println(internal);
  return internal;
}
uint8_t Adafruit_MAX31855::readError() {
  return spiread32() & 0x7;
}
示例#10
0
uint8_t MAX31855::readError() {
  return spiread32() & 0x7;
}