Klipper noise margin configuration options for operations like M109

I’ve recently upgraded to a Phaetus Rapido 2 with a PT1000 thermistor. I’m learning that the precision of the thermistor comes at a cost of not settling very flatly. For example from cold, when I set the nozzle temperature to 150ºC (using only M109 S150), it gets to 150ºC very quickly but then oscillates between about 148.6ºC and about 151.3ºC with a period of about 20 seconds:


waited a bit longer for the initial ramp to work off the screen…

What this means is that the M109 command is actually never satisfied and effectively locks up my printer because it’s waiting for a more stable signal. I must use emergency stop to bring it out! :frowning: Now, I know that there is an alternative, and I’ve already converted all my own macros to use TEMPERATURE_WAIT because I can set the amount of margin and make it ±2º. However, now I’m running into issues with other parts of my configuration which rely on M109. I recently updated my Cartographer probe’s installation and now it issues an M109 during operation which locks up the printer. :-1:

I’m going to take this up with the cartographer devs, but I figured I’d go to the source and ask first:

is there is any way to increase the amount of noise margin for operations like M109 on klipper?

I’m not sure if there’s a better solution than this – please let me know if one exists but Yell from the Cartographer discord server shared this with me when I asked there about the same problem:

[gcode_macro M109]
rename_existing: M109.1
gcode:
  {% set S = params.S|float %}
  {% set actual_temp = printer.extruder.temperature|float %}
  {% set max_fuzzy = S + 2 %}

  M104 { rawparams } 
  {% if S != 0 %}
    {% if actual_temp <= S %} TEMPERATURE_WAIT SENSOR=extruder MINIMUM={S}
    {% else %}                TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={max_fuzzy} {% endif %}   
  {% endif %}

It effectively remaps the M109 to use M104 and TEMPERATURE_WAIT applying a wider noise margin. I just tried it out and the console was released as soon as I was within bounds (like within just over a minute for ramp and settle). :+1:

1 Like

Can you show pictures of how you implemented the PT1000 thermistor? I’d also be interested in seeing how your PID tuning came out.

That’s an unusual oscillation range and while I’m guessing that the lower fluctuating line is the hot end power, I’m wondering if there is some kind of electrical coupling going on there.

Actually, I didn’t build it – it’s just a standard issue Phaetus Rapido 2 /w PT1000 thermistor. It looks like this rendering from their website:

Here’s the calibration detail saved to my printer.cfg file. I re-ran it when I installed the new hotend. I’ll try running it again and see if I get different results and/or better response to 150ºC.

#*# [extruder]
#*# control = pid
#*# pid_kp = 14.853
#*# pid_ki = 0.900
#*# pid_kd = 61.270

I guess it could be electrical coupling but I’m not sure how to investigate that. I’m using an SB2209 board and the plugs for all the components are VERY small. :face_with_diagonal_mouth: everything on the printer seems to work correctly and I upgraded from a Phaetus Rapido (v1) with standard thermistor and I had used that configuration for several months, if not over a year.

Are your heater wires alongside your thermistor wires? If so, what happens if you physically separate them? How are you powering the SB2209?

I’m still curious to see how you put everything together - so if you could take a minute with your phone, I’d appreciate it.

Thanks for the interest! Actually, I re-ran the PID tune at 250ºC and it seems to have improved substantially.

The new values look like this:

#*# [extruder]
#*# control = pid
#*# pid_kp = 13.193
#*# pid_ki = 0.687
#*# pid_kd = 63.325

Currently, the 215ºC ripple is much more muted and the M109 command actually completes much quicker.

Just for the record, I’m using a Voron Stealthburner tool head so the heater wires and thermistor wires are run together through the same channel. It would be challenging to physically separate them without redesigning/reprinting a hotend carrier.

I’m powering the SB2209 with a CANbus umbilical wire. It has some pretty thick gauge power cable and it came with the board. I don’t know what gauge it is but I’m running 24V to the board with it. I’m guessing the board itself has a buck converter on it.

Here’s a photo of the side of the tool head but you can’t see much…

Looking at your latest operation screen shot:

It looks like to me you have some kind of coupling between the heater wiring and the the PT100’s.

Could you take off the side cover, pull the wires apart and rerun your test to see if that improves the ripple even further?

Okay, I tried it out. This is how the side looks after I tried to pull the wires further apart:

The part below, in the hotend holder, is going to be a lot more challenging to separate. After I took that photo, I set the temp to 150ºC and unfortunately the oscillation ripple still persists:

Actually, I’m not convinced that this is coupling. I would think that if it were, wouldn’t the phase & frequency would be the same? In this case, the frequency looks very close but the phase is out of sync.

I took a screenshot of the waves zoomed in, and use a fancy select tool to select the reddish waveform. Then pushed the waveform down to align with the yellowish power waveform. The result was this:

I’m not sure this could be electrical coupling… what do you think?

Yes, that’s what I was suggesting - maybe a bit lower in the thermistor wiggle’s amplitude? I think you’ve done a pretty good job quantifying the values.

The only other thing I can suggest is that you look at the gauge of the power wires going into the SB2209. Maybe if it’s too thin then when the heater is on, it affects the voltage in the board. It should be 20 AWG.

Sorry, that’s all I can suggest.

1 Like

Yeah, sometimes the Klipper PID_CALIBRATE code doesn’t do a good job of obtaining PID values - in particular with some high-power heaters. Some people have had better success when performing the pid calibration with fan enabled, at higher temperatures, with a lower max_power setting, or by manually obtaining PID settings.

-Kevin