1

I am trying to display on a 16x02 LCD display 2 error codes. The error message is when one or both thermocouple wires get disconnected and the second error message is when the soldering iron temp goes higher than 432 C. I am using MAX6675 module. The problem is that when I disconnect one thermocouple wire (the + or the -) sometimes the displayed message is "Overheating !!!" instead of "No tc conn !!!".

Is there any way to display the correct error ?

heaterTemp = thermocouple.readCelsius();
  Input = heaterTemp - 100; 
   //No TC connection
  if (isnan(Input)) // No TC Connection
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("NO TC CONN !!!");
      delay(1000);
    }
  }

  //Soldering Iron overtemperature
  if (Input >= 432)
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("OVERHEATING !!!");
      delay(1000);
    }
  }

Edit: I finally decided to use the same message for both errors - no TC connection and overheating. I used the code below:

heaterTemp = thermocouple.readCelsius();
  Input = 0.779828 * heaterTemp - 10.3427;
  if (isnan(heaterTemp) or Input >= 432) // No TC Connection OR over-temperature
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      for (int i=0; i<=1; i++){
      lcd.clear();
      lcd.setCursor(0, i);
      lcd.write((byte)0);
      lcd.setCursor(1, i);
      lcd.write((byte)0);
      lcd.setCursor(5, i);
      lcd.print("ERROR!");
      lcd.setCursor(14, i);
      lcd.write((byte)0);
      lcd.setCursor(15, i);
      lcd.write((byte)0);
      delay(1000);
      }
    }
  }

and

byte thermometer[8] = //icon for termometer
{
  B00100,
  B01010,
  B01010,
  B01110,
  B01110,
  B11111,
  B11111,
  B01110
};

The code displays the thermometer symbol at the beginning and at the end of the row and the text (including the symbols) are moving from one to another row.

Now it is sufficiently to display a error message when the thermocouple gets disconnected or when the iron temperature goes above 432 *C.

I have also left the 2 while(true) loops because I need the program to stay in the loop and display the error message until I turn off the power and start again the soldering station.

  • What is the type of Input? an int? float? unsigned? – hcheung Jul 10 at 8:50
  • The type of Input is a double – mike_mike Jul 10 at 8:52
1

I think before the disconnection is detected, it goes into overheating (maybe just for some milliseconds).

However, because there is a while (true) loop within the overheating part, it will never show the NO TC CONN error.

If you consider the NO TC CONN error to be higher than the OVERHEATING error, than check within the while loop of the OVERHEATING error also for the NO TC CONN error and display NO TC CONN when it is detected.

| improve this answer | |
1

I'd reserve line #1 for one message, line #2 for the other

  heaterTemp = thermocouple.readCelsius();
  Input = heaterTemp - 100;
  lcd.clear(); 
  //No TC connection
  if (isnan(Input)) // No TC Connection
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      // lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("NO TC CONN !!!");
      delay(1000);
    }
  }

  //Soldering Iron overtemperature
  if (Input >= 432)
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      // lcd.clear();
      // lcd.setCursor(0, 0);
      lcd.setCursor(1, 0);
      lcd.print("OVERHEATING !!!");
      delay(1000);
    }
  }
| improve this answer | |
1

According to MAX6675 datasheet page 5, it will set Bit 2 of SPI register to HIGH when the thermocouple is open. Adafruit's MAX6675 library however changed this to return a NAN when Bit 2 is set when you call the readCelsius() method of the library, so what you should do is to check is isnan(heaterTemp) instead of innan(Input).

heaterTemp = thermocouple.readCelsius();
if (isnan(heaterTemp)) // No TC Connection
{
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("NO TC CONN !!!");
      delay(1000);
    }
}
else
{
  Input = heaterTemp - 100;
  //Soldering Iron over-temperature
  if (Input >= 432)
  {
    while (true) {
      digitalWrite(relay_pin, LOW);
      digitalWrite(11, LOW);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("OVERHEATING !!!");
      delay(1000);
    }
  }
}
| improve this answer | |
1

You should get rid of the while(true) loops, because when you enter one of them, you'll never get out.

void loop()
{
    heaterTemp = thermocouple.readCelsius();
    Input = heaterTemp - 100; 

    //No TC connection
    if (isnan(Input)) // No TC Connection
    {
        digitalWrite(relay_pin, LOW);
        digitalWrite(11, LOW);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("NO TC CONN !!!");
    }

    //Soldering Iron overtemperature
    if (Input >= 432)
    {
        digitalWrite(relay_pin, LOW);
        digitalWrite(11, LOW);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("OVERHEATING !!!");
    }

    delay(1000);
}

EDIT: code below is needed to cut of the power

Don't know the purpose of
digitalWrite(relay_pin, LOW);
digitalWrite(11, LOW);

Maybe it's better to move these lines to setup()

| improve this answer | |
  • The relay_pin is the relay that cuts down the power to the soldering iron's heater, and the pin 11 is the PWM output pin, which controls the power mosfet. Making them "low" will turn off the power mosfet and the relay will cut the power to the iron's heater. – mike_mike Jul 10 at 21:33
  • 1
    I thought that I need the 2 while(true) loops to stop the loop() until I turn off the power and turn it again on – mike_mike Jul 10 at 22:07
  • 1
    @mike_mike, you are correct in your thinking – jsotola Jul 11 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.