Posted on

Duet WiFi – Configuration walkthrough and adjust – Part 1

We allready did a basic setup using the online RepRapFirmware Configuration Tool and it’s time to take a look at the config.g file and see what it all means and make sure it all works as it should.

Don’t be depressed if, say, your object cooling fan is blowing as soon as you turn on your printer or one or more axes are moving the wrong way.

Before continuing you should go get some coffee or similar, as this blog-post ended up as a huge post with lots of information.

I also hope you appreciate how I managed to get rid of the right hand column, so the reading quality on this site improved a lot!

For more technical info, you should take a look at the official Configuring RepRapFirmware for a Cartesian printer wiki page.

Duet WiFi overview.

Lets start by putting up the Duet WiFi overview I made for my previous blog-post: Duet WiFi controller from the previous Duet WiFi – Intro & Explained.

General preferences

 

These are all set from the online configurator and we really only need to adjust the M208 axis min and max.

You can change the M555 Pn if you want to change the compatiblity mode, ie. if you want it to respond in a certain way when you input commands in the Terminal.

We will however let this be for the moment, as we need to verify our movement settings before doing this.

Note: I’ve later discovered that we should remove or comment out the M83 line as it is causing all kinds of problems. From what I gather I believe it’s a bug, that this command is in there in the first place.

Endstops

Lets take a look at what is going on here.

First we have M574  which is used to define the XYZ endstop parameters. A setting of 1 after axis letter denotes an endstop placed at the minium of that axis, a 2 if it is placed at the max. If you do not have an endstop, you insert a 0.

Meaning we have X at minium and Y and Z and maximum.

Sn – Active low or high

S1 defines the switches as Normally Closed (NC), which means current is running through when the switch is not engaged, and the circuit is broken when the switch arm is engaged. This is also called “Active high” in the Duet documentation.
S0 defines the switch as Normally Open (NO), which means there is no current running through the endstop when not engaged. When the endstop is activated a current will go through. This is also called “active low” in the Duet documentation

Sum up Endstop M574

It all means we have X at minium and Y and Z at maxium and the endstop switches are normally closed.

; Endstops
M574 X1 Y2 Z2 S1 ; Define active high microswitches

Z-Probe Type

The M558 Gcode defines Z-probe type and settings. Insert ; in front of it, as we do not have a Z-probe.

Z-Probe Status

The G31 Gcode can be used several times to define different probe types (i.e. 0+4 for switches, 1+2 for IR probes and 3 for alternative sensors).

We are not using any Z.probe, so uncomment it, by placing a ; in front of the line.

Set Z-probe point or define probing grid

The M557 is also used for use with a Z-probe to define a mesh grid.

As before, we do not use a Z-probe, so we’ll put a ; in front of the line to uncomment it.

Endstops final settings

Since we do not use a Z-probe, we really only need 1 line in the Endstops section

; Endstops
M574 X1 Y2 Z2 S1 ; Define active high microswitches

Here’s the entire Endstops’ section

I  have left the z-probe part in place, as I might use a z-probe later, and it’s nice to have as a reference.

; Endstops
M574 X1 Y2 Z2 S1                  ; Define active high microswitches

; M558 P1 X0 Y0 Z0 H5 F120 T6000  ; Set Z probe type to unmodulated, the axes for which
; it is used and the probe + travel speeds
; G31 P600 X0 Y0 Z2.5             ; Set Z probe trigger value, offset and trigger height
; M557 X15:215 Y15:195 S20        ; Define mesh grid

Drives

Next up we look at the movement of our printer.

When using the RepRapFirmware our motors are listed as Drives. The first 4 lines each denotes a motor, where the first three from 0 to 2 are our XY and Z drive, while number 3 is our extruder.

Movement direction

Lets go to machine control and test each axis by pressing the associated +1 buttons for each axis.

Yours is probably different, but my X axis is going the wrong way, so I’ll have to change the direction of X:

Changing this: M569 P0 S1 to M569 P0 S0

Note how we “use” the Gcode M569 to change the settings for drive P0 from direction S1 to direction S0

Extruder direction

I also hit the extruder bottom, but since my hotend are cool I recieed this error:

We’ll let this be for now, and return to it once we have configured our hotend heater.

Save the changes, click yes to reboot and check your new configuration.

Microstepping mode

Next up is the configuration of microstepping mode using M350.

We start by issuing the M350 command and list each drive followed by microstepping mode.

The trailing In denotes wheter or not we have interpolation mode enabled. I1 to enable and I0 to disable it.

After running through the Web Configurator I learned that only by running at 16 microstepping the I1 parameter causes the microstepping to be interpolated to 256x.

Allthough you can turn on interpolation and set microstepping at 32, I have come to believe interpolation is in fact not enabled, so 32 would generate more noise than 16 with interpolation enabled.

I means I change

M350 X32 Y32 Z32 E32 I1        ; Configure microstepping with interpolation
to
M350 X16 Y16 Z16 E16 I1        ; Configure microstepping with interpolation

Steps pr mm

Since I just changed microstepping from 32 to 16, I need to change the line, where I used the M92 Gcode to define steps pr mm.

My current setting is 160 steps pr mm for XY, 800 for Z and 2050 for E:

M92 X160 Y160 Z800 E2050       ; Set steps per mm

I’ll change that to 80 steps pr mm for XY, 400 for Z and 1025 for E

M92 X80 Y80 Z400 E1025       ; Set steps per mm

Speed configurations

Last part of the Drivers section consists of settings for instantaneous speed changes, which roughly translates to marlins jerk setting. the maximum speeds, accelerations, motor current and motor idle current and lastly idle timeout for how long the motors stays engaged before turning off.

Allowable instantaneous speed changes

The M566 sets the allowable instantaneous speed changes. I’lll leave this as is, as I need to test some.

M566 X900 Y900 Z12 E120        ; Set maximum instantaneous speed changes (mm/min)

Maximum feedrate

The M203 set maximum feedrate pr mm/min as opposed the more commonly used mm/sec, so keep that in mind.

M203 X12000 Y12000 Z6000 E1200 ; Set maximum speeds (mm/min)

Accelleration

The M201 is used to set max printing acceleration. Instead of mm/sec, or even mm/min, this now uses mm/ s^2. I personally find this an odd size, as it is very hard to relate to. I’ll leave it as is.

M201 X500 Y500 Z250 E250       ; Set accelerations (mm/s^2)

Motor current

The M906 command is required. Without it, motor currents will remain at zero.

We have listed 800 for each of our motors, which stands for 800 miliamp for each.

A risk of going too low is that if you get a blob or curl up on your print and the head hits it, at lower currents the motor is more likely to skip steps. Also at very low currents, the microsteps are less uniform because the detent torque becomes significant in comparison to the torque due to current. That’s why the suggested minimum is 50% of rated current.

The last I parameter is % of power for the motors on idle.

In our case we have set idle power at 30% by using the I parameter followed by 30.

M906 X800 Y800 Z800 E800 I30   ; Set motor currents (mA) and motor idle factor in per cent

Note/quote: The I parameter is the percentage of normal that the motor currents should be reduced to when the printer becomes idle but the motors have not been switched off. The default value is 30%.

You can use an optional H parameter to issue seperate power a z-probe should use if you have one such.

Drives settings.

This leaves us with this setting:

; Drives
M569 P0 S0               ; Drive 0 goes forwards
M569 P1 S1               ; Drive 1 goes forwards
M569 P2 S1               ; Drive 2 goes forwards
M569 P3 S1               ; Drive 3 goes forwards
M350 X16 Y16 Z16 E16 I1  ; Configure microstepping with interpolation
M92 X80 Y80 Z400 E1025   ; Set steps per mm
M566 X900 Y900 Z12 E120  ; Set maximum instantaneous speed changes (mm/min)
M203 X12000 Y12000 Z6000 E1200 ; Set maximum speeds (mm/min)
M201 X500 Y500 Z250 E250       ; Set accelerations (mm/s^2)
M906 X800 Y800 Z800 E800 I30   ; Set motor currents (mA) and motor idle factor in per cent
M84 S30                        ; Set idle timeout

Click Save Changes and choose Yes to reboot your Duet WiFi in order for the changes to take effect.

Heaters

In this section we are going to configure both of our heaters: Hotend P1 and Heated Bed P0

We use thje M143 gcode to configure maximum temperature for all our heaters.

During our tour through the Web Configurator, we set our hotends’ maximum temperature at 320c by using the parameter S. Note: how we do not need to specify heater number for this. It’s due to our hotend as heater 1 being default when none is specified.

We want to add maximum temperature for our heated bed as well. This is also done using the M143 command. This time we need to use the Parameter H to specify the heater in question, and 0 as the number of heater in question.

I need my bed very hot, as I print Polycarbonate, so I’ll set it at 140. You probably want it somewhat lower.

Note: From RepRapFirmware 1.17 onwards, the default maximum temperatures are 262C for extruders and 125C for the bed.

; Heaters
M143 S320 ; Set maximum heater temperature to 320C
M143 H0 S140   ; set the maximum bed temperature to 140C

PID Tuning

PID tuning in RepRapFirmware is very different from marlin and smoothieware where you basically just set target temperature and number of cycles to test, and the system runs its test-cycles and output the variables for our use.

There is a usefull page at the Duet Wiki Tuning the Heater Temperature Control and a Duet forum post you might find usefull as well.

First we have our M301 gcode which is used to define the parameters for our heaters.

The H parameter is used to specify the heater in question, and heater 1 (hotend) is once again default if none is entered. Here we see the output for our heated bed, so H0 is used to specify the bed heater.

M301 H0 S1.00 P10 I0.1 D200 T0.4 W180 B30 ; Use PID on bed heater

Configuring Heated Bed

The output from the Web Configurator only has values from our bed, but we really need to run a new PID tuning cycle using M304 to get the proper parameters for our Heated bed.

Lets start by taking a look at the running configuration of the Heated bed using the M307 command that sets or report the heating process parameters.

I got the following output:

M307 H0
Heater 0 model: gain 90.0, time constant 700.0, dead time 10.0, max PWM 1.00, mode: bang-bang

Lets be honest, I really do not know what it all means, but we don’t need to either.

The important things here for our purpose are Heater 0, which matche the above H0 and the max PWM 1.00 which corrolates to S1.00.

A setting of S1 means we run at 100% power. If you want it at 50% power, you set it at S0.5

PID Tuning Heated Bed

I want my Heated Bed to use PID since I use a powerfull 500w AC heater, so lets run a PID tuning cycle using the M304 gcode.

If we just run M304 on it’s own, we get the message that it currently is in Bang-Bang mode, so we need to change that.
M304
Heater 0 is in bang-bang mode

The Heated Bed is by default started up as Bang-Bang. In order to change it, we insert a line in our heaters section, after the M301 line.

The M307 command I use here, defines H as 0 (heated bed) to start up in PID mode, by using B0.

Note: Do not confuse the B parameters in M301 and M307, as they are not the same.
; Heaters
M143 S320 ; Set maximum heater temperature to 320C
M301 H0 S1.00 P10 I0.1 D200 T0.4 W180 B30; Use PID on bed heater (may require further tuning)
M307 H0 B0
M305 P0 T100000 B3988 C0 R4700 ; Set thermistor + ADC parameters for heater 0 ; BED
M305 P1 T100000 B4138 C0 R4700 ; Set thermistor + ADC parameters for heater 1 ; Heater 1

After saving and rebooting the Duet, we run the M307 H0 again, to check the status of our Heated Bed.

Our Heated Bed is now in PID mode, so lets continue to use M303 to run PID tuning.

We use the parameters:

  • H = Heater. H0 for heated bed.
  • P = Power in %. Default is 50%, written as 0.5.
  • S = Maximum temperature. Default is 225, so it’s important for bed, which I set at 100c here.

M303 H0 P0.5 S100

Here we witness a hugely annoying part of RepRapFirmware… it fails tuning if temperature exceeds the maximum temperature. As opposed to Marlin, which automatically compensate and turn the heater on/off, this one just fails, so we have to wait for temperature to drop before trying again with a lower power setting than our current P0.5

I did 0.4, 0.3, 0.2 before succeeding at 0.1 after an hour and 5 minutes!

You have to wait some time after each failed attempt, or the tuning is cancelled as you see here.

An hour and 5 minutes later, I manged to finish the PID tuning at 10% power, along with a warning about it being overpowered.

I really hope this function is tweaked asap as it’s a huge bother and doesn’t take into consideration the large part of people starting to use faster heaters as we don’t want to wait 15 or more minutes for the bed to heat up.

Now that the PID tuning completed, we use the M307 H0 command to see the result.

Our parameters and variables are:

  • Heater = 0
  • Gain = A
  • Time Constant = C
  • Dead time = D
  • Mode ( 0 for PID) = B

Which results in this line for our config.g file.
M307 H0 A252.2 C635.5 D7 B0

Saving PID settings

First we remove or uncomment the old M301 line.
; M301 H0 S1.00 P10 I0.1 D200 T0.4 W180 B30; Use PID on bed heater

.. and we are going to replace the snippet we inserted in order to change Heated Bed to PID mode

M307 H0 B0
with:
M307 H0 A252.2 C635.5 D7 B0

Instead of writing it in our config.g file, we could also use M500 command, which would save it to save the heater parameters in config-override.g, which is supported in firmware 1.17 and later.

Save Changes and reboot before continuing

Configuring Hotend PID

The output from the Web Configurator only has values from our bed, so we really need to run a new PID tuning cycle using M303 to get the proper parameters for our hotend.

PID Tuning Hotend

In order to setup our tuning of the hotend PID we use M303 and these parameters:

  • H = Heater. H1 for Hotend
  • P = Power in %. Default is 50%, written as 0.5.
  • S = Maximum temperature. Default is 225, so it’s important for bed, which I set at 100c here.

M303 H1 P0.5 S240

Aww, thought I was safe as I use standard E3Dv6 and used standard power settings at 50%, but it still overshot, so have to wait for it to cool down and try again.

After completing the tuning, which luckily is much faster than tuning the bed, we get a nice output like this:

As with the bed, we now need to use the M307 to have the result displayed. This time using H1 instead of H0
M307 H1

Lets sort out the parameters and variables here:

Our parameters and variables are:

  • Heater = 1
  • Gain = A
  • Time Constant = C
  • Dead time = D
  • max PWM = 1 (1= 100% power. 0.8 equals 80%)
  • Mode ( 0 for PID) = B

This results in the following line, which we need to put into our config.g file in our heaters section.
M307 H1 A352.6 C122.2 D8.0 S1 B0

Note: after updating thermistor settings farther down this blog-post to accurate settings, the code looks like:
M307 H1 A313.8 C118.7 D8.1 S1 B0

Thermistor and ADC parameters

Before wrapping up our Heaters section, we might want to look at the M305 command.

If you have some experience in configuring these kinds of things, you might miss some parameters. More precicely the ones related to ADC. It’s because the Duet WiFi have automatic ADC calibration so you should not need to use the H or L parameter.

Heated bed sensor configuration

I’m using a 500w 220AC Keenovo silicone heater, which comes equipped with a NTC 100K thermistor ( Beta 25/50 3950K-1%) as temperature control sensor ( Click Here (pdf file) also for thermistor R-T Datasheet.)

It means it has a restiance of 100.000 and beta coefficent of 3950.

These matches up to:

  • P = Sensor number
  • T = Thermistor resistance at 25oC
  • B= Beta value, or the reciprocal of the Steinhart-Hart thermistor model B coefficient
  • C = Steinhart-Hart C coefficient, default 0
  • R = Series resistor value, which is R4700 for Duet WiFi

So, lets make a command based on our parameters and variables for our heated bed sensor:
M305 P0 T100000 B3950 C0 R4700

Hotend sensor configuration

I am using a genuine full metal 24v bowden E3Dv6 hotend, which comes equipped with a Semitec 104GT-2 thermistor. It has a quoted B value of 4267, but the actual value over 25C to 220C is 4388 (quoted source).

Looking at Configuring Firmware documentation on E3D site it says:
For firmware versions 1.16 and earlier, set the B parameter (beta value) to 4388. This value gives better accuracy at typical printing temperatures in the range 190 to 250C than the B value of 4267 quoted in the datasheet.

For firmware versions 1.17 and later, set the B parameter to 4725 and the C parameter to 7.06e-8.

I’m not sure about that C parameter to 7.06e-8, but it doesn’t give an error when used.. I’ve posted on the Duet forum to get an answer

It means I’ll change the B value for temperature sensor 1 from 4138 to 4725 and C from 0 to 7.06e-8
M305 P1 T100000 B4725 C7.06e-8 R4700

This results in two new lines of codes for our config.g file:
M305 P0 T100000 B3950 C0 R4700 ; Set thermistor + ADC parameters for heater 0 ; BED
M305 P1 T100000 B4725 C7.06e-8 R4700 ; Set thermistor + ADC parameters for heater 1 ; Heater 1

So, what does it mean?

Yes, we need to run PID Tuning again… I’ll not post about that, as we just spend 2 hours doing it 🙂

I’ll post the complete Heaters section though:
; Heaters
M143 S320 ; Set maximum heater temperature to 320C
; M301 H0 S1.00 P10 I0.1 D200 T0.4 W180 B30; Use PID on bed heater
M307 H0 A252.2 C635.5 D7 B0
M307 H1 A352.6 C122.2 D8.0 S1 B0
M305 P0 T100000 B3950 C0 R4700 ; Set thermistor for heater 0 ; BED
M305 P1 T100000 B4725 C7.06e-8 R4700 ; Set thermistor for heater 1 ; Heater 1

Using Thermocoupler or PT100 sensor.

Using a Thermocoupler or PT100 sensor is a great way to avoid annoying temperature measuring issues. I normally use either one and is going to make a blog-post about it at a later date.

In both cases we would need an expansions board, which can be bought from the Duet3D.com addons page.

Coming up

I had hoped to finish up everything, but this is is for now.

In the next part, i’ll write about the rest of the items in the config.g file

  • Tools
  • Network
  • Fans
  • Custom settings
  • Miscellaneous
Leave a Reply

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

*