How to heat hot end only if it's below a threshold
deckingman last edited by
Short version....In my homeall file, I use M104 S140 followed a little later by M116 P0 to wait for the hot end to attain that temperature. What I want to do is only set that temperature if the hot end is below 140 deg C and then later on, only wait for it to to reach 140 deg C if it's still blow 140 deg C. So something along the lines of "If hot end temp is below 140, then wait for it to reach that temperature, otherwise don't set it and don't wait either. What do I need to put in my file to achieve that?
Long version.....I use the nozzle as a probe for my Z homing. When the bed touches the nozzle, it lifts it off of it's seat which break a circuit and gives me the Z=0 position (the physical mount is also the end stop switch). If filament had oozed out of the nozzle and solidified, it would give me a false Z0 position when I start a print. So I heat the nozzle to around 140 deg C to soften any plastic which might have oozed prior to homing Z. But, the latest iteration of my 6 input mixing hot end has a large thermal mass and takes a very long time to heat up and cool down (roughly 6 minutes to go from 25 to 195 deg C but very much longer to cool). So I start heating the nozzle (but don't wait) then I home XYUVA and B while the nozzle is heating. Then I wait for the nozzle to reach 140 degC before homing Z. But if I had already heated the nozzle to (say) 195 deg C and I use M104 S140 followed by M116 P0 it would wait several minutes to cool down to 140. This is undesirable because any temperature above 140 would work just as well. So I only want to heat the nozzle (and wait) before homing Z if the nozzle is below 140 deg C. I'm sure it can be done but I don't have time right now to dig into the vagaries of conditional gcode so I through I'd throw it out there for the more knowledgable.
o_lampe last edited by
[pseudo code] If nozzletemp < 140 M116 P0 elif go on homing Z
Like so? Just have to figure out, whats the current temp is in object model.
@deckingman if you know the sensor number (as configured using M308) then the temperature is sensors.analog[N].lastReading where N is the sensor number. So I think you want something like this:
if sensors.analog.lastReading < 140 G10 P0 S140 ... while sensors.analog.lastReading < 140 G4 S2
deckingman last edited by
@dc42 Brilliant! I'll give that a try when I get chance. The hot end thermistor is indeed configured as M308 S1.
Thinking it through, I'll use the "If sensor....then G10 thing" twice. Once before homing XYUVA and B and again just before homing Z. The reason being that there is the remote possibility that the hot end could be off and cooling so before homing XYUVA and B it could be (say) 141 deg C but after homing XYUVA and B it might have dropped to something lower and the "While loop" would never end (because the heater didn't get turned on earlier). So the second "If sensor....G10"check would catch that (unless you have a more elegant solution).
@deckingman good catch! I wish I always thought of the edge cases before they happen.
You can also pick up from the object model what the set temperature is, and whether the tool is selected or not.
deckingman last edited by deckingman
Just reporting back that I've implemented this and it works a treat.
I added a few M291 commands so that I get to know what's happening. So at the start of homing I have this
; start by warming the hot end so that any oozed filamnt is molten T0; select a tool - any one will do ; check if tool is hot, if not start to heat it to 140 deg C if sensors.analog.lastReading < 140 G10 P0 S140 M291 P"Hot end set to 140 deg C" R"Homing Macro" S1 T10
Then I home XYUVA and B after which I check the hot end again and reset the temperature if it's still below 140. Then I wait until it attains that value (or higher) like so...
; check again if tool is still at or above 140 deg C, if not heat it if sensors.analog.lastReading < 140 G10 P0 S140 M291 P"Hot end below 140, so set to 140 deg C" R"Homing Macro" S1 T10 ; now wait for temp to get to 140 or above while sensors.analog.lastReading < 140 M291 P"Waiting for hot end to heat" R"Homing Macro" S1 T4 G4 S4
Then I go on to wipe the nozzle before moving the hot end to the centre of the bed and homing Z. The final part of the homing routine is to set the hot end back to 0 and restore the motor currents.