Posted on

Duet WiFi/Eth – PID tuning hotend

Since I just changed my old cartridge for a 24v 80w heater on my 5way Diamond hotend and used High Temperature Liquid Gasket Silicone as a sealant on the heatsinks and the Diamond nozzle itself, as is clearly evident on the photo, I need to do a new PID tuning, which is a good starting point for writing a short blog-post on doing just that.

  1. Gcodes used
  2. Prepare for PID tuning
  3. PID-tune hotend heater
    1. Parameters
    2. Heater to tune
    3. Power
    4. Target Temperature
  4. Parameters to use and store in config.g
    1. New PID-Tuning
    2. I’ll add this in my Heaters/Hotend section
  5. Debug – Failing to tune?
    1. Temperature was not reached
    2. Starting temperature is not stable
    3. Over-powered and a fire risk

1) Gcodes used

  • For the actual PID tuning, we are going to use M303
  • M307 H1 to display the parameters we garnered from the PID tuning.
  • Finally you could use M500 to store the parameters in a config-override.g file, which matches the old school Eeprom M500, and overrule the settings in config.g file.
    • I personally have an aversion to this sort of having configurations stored in different places. Especailly for core parameters that shouldn’t change.
    • In my opinion it just leads to confusion as people tends to forget they have anything stored in the override file and can’t figure out why the printer doesn’t accept the new parameters written in the config.g file.

2) Prepare for PID tuning

I prefer to put my hotend close to the heated bed, heat the bed to my most used temperature and then turn on the object-cooling fans at maximum before doing a hotend PID-tuning.

Why you might ask?

I prefer to similuate actual printing situation to get a PID tuning that most closely matches the actual usage scenarios of my printer.

3) PID-tune hotend heater

Parameters

Hnnn heater number
Pnnn PWM to use, 0 to 1 (you should normally use 1 i.e. full power)
Snnn target temperature

Heater to tune
To actually do a PID tuning we need to use the M303 command followed by H1 to denote the heater used, which is the first heater.

If you PID tune your bed, it is H0 by default.

Power
Next we need to define the amount of power we feed our heater cartridge. This is denoted by P followed by a number like P1 for 100% power and P0.5 for 50% power.

RepRapFirmware used to be very, very restrictive regarding power setting. I had to put it at P0.1 (10%) to do a succesfull tuning in january, but His time I could run it at P1 (100%).

Target temperature
Finally we need to define target temperature using S followed by temperatures in celcius like S220 for 220c. Target the temperature you use the most. So 200ish for PLA if that is what you print, or 240 or something like that, if you mostly print ABS.

It means I’ll tune my to 200c at full power like this (mine failed when target was 220):
M303 H1 P1 S200

Sequence is from the bottom and upwards

4) Parameters to use and store in config.g

As mentioned above I’m not a fan of using the M500 to store in config-override.g method, so I’ll get the result from the PID tuning using M307 H1 and put it into my config.g file.

It all seems a bit confusing to be sure

Lets look at the top line, which is the one we are going to be using:
Heater 1 model: gain 188.4, time constant 121.7, dead time 1.4, max PWM 0.50, mode: PID

This translates into:

  • M307 H1 for Heater 1
  • A188,4 for Again
  • C121.7 for Constant
  • D1.4 for Dead time
  • and S0.5 for max PWM

* Default is PID for hotend, so we don’t need to write parameter for this.
* Default for BED is Bang-Bang method, so you’d have to add B0 in the end, to force it to use PID.

M307 H1 A188.4, C121.7, D1.4 S0.5

I honestly do not know why it puts max power at 50%, so i’ll put it at S1 (100%) and use the new parameters to do a new PID tuning like this:

M307 H1 A188.4, C121.7, D1.4 S1

4.1) New PID-Tuning

Saving config.g with the above parameters I’ll run a new PID-tuning target at 220c like so:

M303 H1 P1 S220

I ended up with new parameters with full power on my heater:
Heater 1 model: gain 375.3, time constant 125.9, dead time 3.8, max PWM 1.00, mode: PID

This translates into:

  • M375.3 H1 for Heater 1
  • A125.9 for Again
  • C125.9 for Constant
  • D3.8for Dead time
  • and S0.5 for max PWM

Which means we are going to add this line to our config.g file.

M307 H1 A375.3, C125.9, D3.8 S1

4.2) I’ll add this in my Heaters/Hotend section.

So, this is ho my Hotend section turned out looking 🙂

5) Debug – Failing to tune?

There are different reasons why it migh fail to tune.

Temperature was not reached

Auto tune cancelled because target temperature was not reached Heater 1 switched off

Solution: Try using a lower temperature. It might fail if it took too long to reach the target temperature.

Starting temperature is not stable

Auto tune cancelled because starting temperature is not stable

Solution: You need to wait for temperature to get almost back to room temperature before trying again.

Over-powered and a fire risk

Warning: Heater 1 appears to be over-powered and a fire risk if left on at full power, its temperature is predicted to reach XXXc

Solution: Lower the value of the P parameter, which is the current you feed your heater during testing

2 thoughts on “Duet WiFi/Eth – PID tuning hotend

  1. Hi,
    Nice blog, and a lot of good info…
    I am new to the Duet WiFi board but I am curious and I decided to buy one for my home built CoreXY.
    Would you be happy to share your config file?
    Just for a good start, as in the Duet website is a bit confusing.
    PS. I do not need a Z probe, as my Bedplate is 12mm and CNC machined and the overall mechanic chassis tolerance is about 0.02mm.
    Thank you!!
    Best regards
    Emanuel

    1. Hello Emanuel and thank you.
      When you recieve your Duet WiFi (remember to buy from real reseller and not china) the firmware and files are located on the SD card.

      You then start buy going to the RepRapFirmware Configuration Tool website https://configurator.reprapfirmware.org/ to generate the files for your printer, which you put on the SD card. This way you have created your configuration.
      Settings you need to change are if motors go the wrong way and PID tune hotend and such, but its the best way to get started, as my config might not match your printer at all.

      I created a Duet facebook group where we talk about Duet as well and help each other, you should go there: https://www.facebook.com/groups/duet3dunofficial/

      Hope it helps
      Cheers,
      Morten
      Denmark

Leave a Reply

Your email address will not be published. Required fields are marked *

*