Lcd unable to display negative value with k type thermocouple

Hi, I have a K Type Thermocouple connected to a Arduino Portenta Machine Control and when temperature is at negative, the lcd connected does not display the exact negative value.
It only display negative value of -1 and -2 at most and does not go below that.

I am using GitHub - arduino-libraries/Arduino_MachineControl library.

#include <Arduino_MachineControl.h>

using namespace machinecontrol;

void setup() {
  Serial.begin(9600);
  // Initialize temperature probes
  temp_probes.tc.begin();
  Serial.println("Temperature probes initialization done");
  // Enables Thermocouples chip select
  temp_probes.enableTC();
  Serial.println("Thermocouples enabled");
}

void loop() {
  //Set CH0, has internal 150 ms delay
  temp_probes.selectChannel(0);
  //Take CH0 measurement
  float temp_ch0 = temp_probes.tc.readTemperature();
  Serial.print("Temperature CH0 [°C]: ");
  Serial.print(temp_ch0);
  Serial.println();
}

I am using the basic code to read temperature.
Edit: my original code is too long so I just copied paste the example but I am using exactly the same code just that the serial is changed to lcd for my application

Any help is appreciated Thank you!

i see no LCD implementation

sorry the code I used is exactly the one I provided just that the serial is changed to lcd as my original code is too long

does serial unable to show negative values too?

I have tried this new library however I faced some issue with the reading of the temperature and is giving NAN everytime, I have reached out to the arduino support team and they have adviced to use the old library while waiting for new updates to the new library

yes it does not show negative values only -1 and -2

float MAX31855Class::readTemperature(int type)
{
  uint32_t rawword;
  int32_t measuredTempInt;
  int32_t measuredColdInt;
  double measuredTemp;
  double measuredCold;
  double measuredVolt;

  rawword = readSensor();

  // Check for reading error
  if (rawword & 0x7) {
    return NAN; 
  }
  // The cold junction temperature is stored in the last 14 word's bits 
  // whereas the ttermocouple temperature (non linearized) is in the topmost 18 bits
  // sent by the Thermocouple-to-Digital Converter

  // sign extend thermocouple value
  if (rawword & 0x80000000) {
    // Negative value, drop the lower 18 bits and explicitly extend sign bits.
    measuredTempInt = 0xFFFC0000 | ((rawword >> 18) & 0x00003FFFF);
  } else {
    // Positive value, just drop the lower 18 bits.
    measuredTempInt = rawword>>18;
  }

  // convert it to degrees
  measuredTemp = measuredTempInt * 0.25f;

  // sign extend cold junction temperature
  measuredColdInt = (rawword>>4)&0xfff;
  if (measuredColdInt&0x800) {
    // Negative value, sign extend
    measuredColdInt |= 0xfffff000;
  }

  // convert it to degrees
  measuredCold = (measuredColdInt/16.0f);
  // now the tricky part... since MAX31855K is considering a linear response 
  // and is trimemd for K thermocouples, we have to convert the reading back
  // to mV and then use NIST polynomial approximation to determine temperature
  // we know that reading from chip is calculated as:
  // temp = chip_temperature + thermocouple_voltage/0.041276f
  // 
  // convert temperature to mV is accomplished converting the chip temperature
  // to mV using NIST polynomial and then by adding the measured voltage 
  // calculated inverting the function above
  // this way we calculate the voltage we would have measured if cold junction 
  // was at 0 degrees celsius

  measuredVolt = coldTempTomv(type, measuredCold - _coldOffset)+(measuredTemp - measuredCold) * 0.041276f;

  // finally from the cold junction compensated voltage we calculate the temperature
  // using NIST polynomial approximation for the thermocouple type we are using
  return mvtoTemp(type,measuredVolt);
}

Type K thermocouples have a general temperature range of -200 to 1260°C (-326 to 2300°F), however there are some caveats to this:

If used for temperatures below 0°C special material is needed in order to meet the specified accuracies. Also, Special Limits of Error are not specified for temperatures below 0°C.

What is the Voltage of Type K Thermocouples?

The following is a selection of output values for Type K Thermocouples at selected temperatures. Note: The following output is based on a reference Junction at 0°C/32°F:

Temperature Output
0°C 0.000 mV
100°C 4.096 mV
200°C 8.138 mV

how do you create negative temperature? industrial freezer?

this is the part where I am unsure, I have read about the uint32_t which is not able to display negative value,

yes in an industrial setting

how do you connected thermocouple to portenta?

image
Negative wire (Red) to TN0 and Positive wire (Yellow) to TP0

what revision is your PMC ?
what if you try with channel 1 ?

result is still the same

SKU AKX00032

i suppose to get found the problem in lib:

Arduino_MachineControl-master\src\utility\THERMOCOUPLE\MAX31855.cpp

  rawword = rawword & 0x7FF; << here data shorted to 11 bit but
  // check sign bit  and convert to negative value.
  if (rawword & 0x800) {           << but here is asked if bit 12 is present, which shows the value is negative

so these 2 should be same?

  rawword = rawword & 0xFFF;
  // check sign bit  and convert to negative value.
  if (rawword & 0x800) {

ahm, it will not help, in .readTemperature() it is written correct

so is that just the library code error?

idk. you can test if it make some difference