DEV: Stabilize temperature corridor

This parametr is not working on my Mega2560+RAMPS 1.5.7
When I use the M109 S225 printer starts printing at 220

Stabilize temperature corridor (TEMP_HYSTERESIS) = 1
Skip extruder temp. wait if within (SKIP_M109_IF_WITHIN) = 2
Skip temp. wait if within (SKIP_M190_IF_WITHIN) = 5

Comments

  • I have tried different settings, but it did not help
    Stabilize temperature corridor (TEMP_HYSTERESIS) = 1
    Skip extruder temp. wait if within (SKIP_M109_IF_WITHIN) = 0
    Skip temp. wait if within (SKIP_M190_IF_WITHIN) = 0
  • edited March 2017
    It was a week since I posted this topic. Is there any solution?
  • Is anyone can solve this?
  • are you by any chance using cura as a slicer ?
  • Please send manually

    M109 S225
    M115

    and watch log and temperature. At which temperature do you see the M115 output? If it is near 225 your firmware settings are ok and you have something in slicer gcode that makes the difference e.g. later setting temperature to 220.
  • I know the topic is old but I experiencing exactly the same issue.
    M109 will always be skipped if the temperature is (exactly) 5 degrees below the target temperature.
    Current settings are:
    SKIP_M109_IF_WITHIN 0 
    EXT0_WATCHPERIOD 15  
    TEMP_HYSTERESIS 2
    Is there any other parameter for setting up the M109 command correctly?
    Regulating the temparature with PID is working fine except.
    Im sure this is not a slicer issue, since it will also occur if manually using M109 command (and checking skipping point with M115 etc.).
    I am also using the Ramps board.

    I would realy appreciate if someone could provide me some tipps.
    Any idea could be helpful :)
  • Assuming you are using latest firmware version this would be the relevant code:

    if (wait && temperatureInCelsius > MAX_ROOM_TEMPERATURE
    #if defined(SKIP_M109_IF_WITHIN) && SKIP_M109_IF_WITHIN > 0
    && !(abs(tc->currentTemperatureC - tc->targetTemperatureC) < (SKIP_M109_IF_WITHIN)) // Already in range
    ) {
    Extruder* actExtruder = &extruder[extr];
    UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_HEATING_EXTRUDER_ID));
    EVENT_WAITING_HEATER(actExtruder->id);
    bool dirRising = actExtruder->tempControl.targetTemperatureC > actExtruder->tempControl.currentTemperatureC;
    //millis_t printedTime = HAL::timeInMilliseconds();
    millis_t waituntil = 0;
    #if RETRACT_DURING_HEATUP
    uint8_t retracted = 0;
    millis_t currentTime;
    millis_t maxWaitUntil = 0;
    bool oldAutoreport = Printer::isAutoreportTemp();
    Printer::setAutoreportTemp(true);
    do {
    previousMillisCmd = currentTime = HAL::timeInMilliseconds();
    /*if( (currentTime - printedTime) > 1000 ) //Print Temp Reading every 1 second while heating up.
    {
    Commands::printTemperatures();
    printedTime = currentTime;
    }*/
    Commands::checkForPeriodicalActions(true);
    GCode::keepAlive(WaitHeater);
    //gcode_read_serial();
    #if RETRACT_DURING_HEATUP
    if (actExtruder == Extruder::current && actExtruder->waitRetractUnits > 0 && !retracted && dirRising && actExtruder->tempControl.currentTemperatureC > actExtruder->waitRetractTemperature) {
    PrintLine::moveRelativeDistanceInSteps(0, 0, 0, -actExtruder->waitRetractUnits * Printer::axisStepsPerMM[E_AXIS], actExtruder->maxFeedrate / 4, false, false);
    retracted = 1;
    }
    if (maxWaitUntil == 0) {
    if (dirRising ? actExtruder->tempControl.currentTemperatureC >= actExtruder->tempControl.targetTemperatureC - 5 : actExtruder->tempControl.currentTemperatureC <= actExtruder->tempControl.targetTemperatureC + 5) {
    maxWaitUntil = currentTime + 120000L;
    }
    } else if ((millis_t)(maxWaitUntil - currentTime) < 2000000000UL) {
    break;
    }
    if ((waituntil == 0 && (dirRising ? actExtruder->tempControl.currentTemperatureC >= actExtruder->tempControl.targetTemperatureC - 1 : actExtruder->tempControl.currentTemperatureC <= actExtruder->tempControl.targetTemperatureC + 1))
    #if defined(TEMP_HYSTERESIS) && TEMP_HYSTERESIS >= 1
    || (waituntil != 0 && (abs(actExtruder->tempControl.currentTemperatureC - actExtruder->tempControl.targetTemperatureC)) > TEMP_HYSTERESIS)
    ) {
    waituntil = currentTime + 1000UL * (millis_t)actExtruder->watchPeriod; // now wait for temp. to stabilize
    }
    if (Printer::breakLongCommand) {
    break;
    }
    } while (!Printer::failedMode && (waituntil == 0 || (waituntil != 0 && (millis_t)(waituntil - currentTime) < 2000000000UL)));
    Printer::setAutoreportTemp(oldAutoreport);
    #if RETRACT_DURING_HEATUP
    if (retracted && actExtruder == Extruder::current) {
    PrintLine::moveRelativeDistanceInSteps(0, 0, 0, actExtruder->waitRetractUnits * Printer::axisStepsPerMM[E_AXIS], actExtruder->maxFeedrate / 4, false, false);
    }
    EVENT_HEATING_FINISHED(actExtruder->id);
    }

    you see only way to skip waiting in your case is temperatureInCelsius > MAX_ROOM_TEMPERATURE" but I assume 5°C less is not MAX_ROOM_TEMPERATURE

    There is also no special case for 5° as you see. What happens at 4°C or 6°C difference? It is hard to get exactly 5°C especially since it is a float value so it could also be 5.01 difference.

    Which firmware version are you using?
  • Thanky for your fast reply. 
    I am using version 1.0.3.
    MAX_ROOM_TEMPERATURE is set to 40.

    I did not check if the skipping happens at numericaly exactly 5 degrees below target temperature, but I realised that is always skipped at roughly 5 degrees idepent of the target temperature.

    When using M109 S250 it was skipping at 245.?? degrees and when using M109 S60 at 55.?? degrees.
    Is there a command that is blocked by the M109 watiting and is showing the temperature at the point when waiting is over? M105 seems to get executed always without any waiting.

    However, I set up a completly fresh config file only changing board, thermistor type and used the same M109 settings. Now it works flawless.
    So the problem is definetly on my side and not a firmware problem.
    But since I dont know at which point I crashed my configuration file, I would be very interested in any hints about  what else could cause this behaviour. 
  • It is only the function I showed that is responsible for it. So for that firmware version I can not explain why it happens. Maybe in older versions there is a different code that behaves like that.
  • edited September 26
    I had a closer look at the code you posted and actualy spotted a bug leading to the skipping exactly  5 degrees before reaching the target temperature. 
    The loop beginning at line 1064 is left to early because of the else-if condition at line 1084:

    else if ((millis_t)(maxWaitUntil - currentTime) < 2000000000UL) {
    break;
    }

    maxWaituntil is set to a value other than 0 at the moment the temparature has a 5 degrees difference to the target leading to the execution of the loop break (line 1080):

    if (maxWaitUntil == 0) {
    if (dirRising ? actExtruder->tempControl.currentTemperatureC >= actExtruder->tempControl.targetTemperatureC - 5 : actExtruder->tempControl.currentTemperatureC <= actExtruder->tempControl.targetTemperatureC + 5) {
    maxWaitUntil = currentTime + 120000L;
    }

    By the commenting out the else-if condition at line 1084, M109 works fine but I do not realy get whats the intention behind this condition is so Im worried a bit that this will maybe break something else.
     Could you maybe explain whats the idea behind this check?

    The bug is also present in version 1.0.4. 
    When testing with the new configuration file I was accidentaly using version 0.92. So its not a configuration as I thought first. 

    Sorry for bad code formatting.
  • Uh, I really missed the 5° part. And I think you are right, should be
    if (maxWaitUntil == 0) {
    if (dirRising ? actExtruder->tempControl.currentTemperatureC >= actExtruder->tempControl.targetTemperatureC - 5 : actExtruder->tempControl.currentTemperatureC <= actExtruder->tempControl.targetTemperatureC + 5) {
    maxWaitUntil = currentTime + 120000L;
    }
    } else if ((millis_t)(maxWaitUntil - currentTime) > 2000000000UL) {
    break;
    }

    so > instead of < for comparison.

    What it does is adding an escape to badly configured extruders. Once you are within the +/- 5°C corridor it will exit with 2 minutes regardless of hysteresis or target temperature being reached. This was added because I got complains that M109 never stopped. Just until now nobody noted it stopped 5°C before reaching the target temperature.
  • Thanks for confirming and the explanation  :)
Sign In or Register to comment.