Cartesian - Z-endstop & homing (Max or Min)?

  • I'm converting my cartesian printer (an I3 steel printer) to Duet. It has the IR Z-probe and has had a Z-max endstop for homing as this is what the previous firmware support team recommended (Repetier).

    What is the recommended approach with the Duet / IR-probe combination?

    Should I leave it homing to Z-max with the mechanical endstop switch, or should I use the IR-probe for homing?



  • It doesn't really matter, although using a probe in the centre of the bed is likely to be more accurate than using a switch at the edge of the bed. Also, Z min would be used if you want to run any sort of bed flatness compensation or auto levelling so homing at Z min would make more sense in that situation. One other consideration is that all prints start at (close to) Z min. So homing on Z max means the printer will move all the way to Z max and back again. That may not be a consideration depending on your Z height. For me it is, as my Z axis movement is 760mm so I'd have to move the bed 1520mm every time I home it, and at 600mm\minute it would take a tad over 2 1\2 minutes to travel that distence.

  • Thanks, deckingman. Z height is about 200mm so it is a LOT smaller than your printer. 🙂 All good points you make and it supports my thinking so I think I'll convert it to Z-min homing.

  • Is it possible to have a Z-probe for Z-min and a separate endstop for Z-max as a safety / limit switch?

    What I want to do is to move the head up automatically when powered on to minimise any chance of a head crash when homing. The problem is that the printer won't know the starting position so may try to exceed max Z. I'd therefore like to use the existing Z-max endstop to prevent damage but can't find documentation about how to achieve this.



  • administrators

    Yes you can move the head up at the start of homing, using a G1 S1 move so that the move will be terminated if the Z Max switch is triggered.

    Another reason why you may want to keep your Z max switch is so that you can home the printer when there is already a print on the bed, to resume a print after a power failure.

  • Sorry, David, I should have been more specific in that I was planning to retain the Z-probe to probe the bed and home - but use a second endstop on Z to act as a Z-max travel limiter.

    Your response, though, has caused me to reconsider that and I think I will do what you suggest - I particularly like the idea of using it to resume a print.



  • administrators

    You can use the Z probe for normal homing, and the Z max switch for Z homing when you are resuming a print.

  • Thanks, David, that worked well - but I'm now getting a strange negative reading when doing bed compensation or bed mesh compensation. When running either compensation routine the bed has an overall error of -5.46mm

    I can't figure out how to sort that so any help would be very welcome.



  • administrators

    What do you have in homez.g and in the Z homing section of homeall.g now?

  • homez.g now has:

    ;Z-Max endstop
    G91			; relative positioning
    G1 S1 Z250 F9000	; move quickly to Z axis endstop and stop there (first pass)
    G1 Z-5 F6000       	; go back a few mm
    G1 S1 Z250 F360  	; move slowly to Z axis endstop once more (second pass)
    G1 Z-2 F4000      	; lower Z again
    G90               	; absolute positioning

    homeall.g has the same for Z

    I'm using one of your IR probes and it is working well - but has the weird offset of approximately -4.6 mm.


  • administrators

    You need to set your M208 Z axis limit to the exact Z height at which the switch triggers, so that if after homing you command the nozzle to Z=0 it is just touching the bed.

  • Ah, OK, thanks that makes sense. Will try that.

    I guess it would also be possible to home the Z-axis to Z-max, then probe the bed and set the Z=0 from that. This would eliminate any variation in the Z-max switch and make the IR probe drive the Z=0 setting, I would think.

    Something like the following at the beginning of each print, perhaps?
    G28 Z
    G1 X100 Y100 (or wherever the origin is)
    G92 Z2.3 (or whatever the offset is)
    Or am I missing something basic (again 🙂 )?


  • administrators

    Yes, except:

    1. You probably want something more like G1 X100 Y100 Z5 so that bed probing starts from 5mm height.

    2. You should not use G92 to set the Z height after the G30. Use the G31 Z parameter instead.

  • Fantastic, thank you. I'm busy printing a more robust Z-max switch mount to minimise any play as that may have contributed but I'll report back when I've got it all working.


  • I have reverted to Z-probe homing - I replaced the Z-max endstop with a proximity sensor and it was working well but I was having real trouble levelling the bed so I went back to the Z-probe.

    Only problem is that it is again showing a negative offset. I'm using one of the IR probes, have run through the process on a number of times and have the Z offset set to 2.43mm (I was consistently getting this when I tested). When I lower the head to 0mm it just grips a sheet of paper (I'll set the Z-offset later to make that 0.2mm)

    Despite this, I get a negative offset when running the bed mesh or compensation. What am I doing wrong?

    ; Configuration file for Duet WiFi (firmware version 1.20 or newer)
    ; executed by the firmware on start-up
    ; General preferences    
    M111 S0                                                         ; Debugging off
    G21                                                             ; Work in millimetres
    G90                                                             ; Send absolute coordinates...
    M83                                                             ; ...but relative extruder moves
    M555 P2                                                         ; Set firmware compatibility to look like Marlin
    M911 S21 R22 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000"              ; Configure automatic saving on power loss
    M208 X-19 Y-4 Z0 S1                                             ; Set axis minima
    M208 X240 Y247 Z196.1 S0                                        ; Set axis maxima
    ; Endstops Z-probe
    M574 X1 Y2 S1                                                   ; Set active high endstops
    M574 Z1 S2                                                      ; Set endstops controlled by probe
    M558 P1 H10 F300 T8000                                          ; Set Z probe type to unmodulated and the dive height + speeds
    G31 P500 X9 Y21 Z2.43                                           ; Set Z probe trigger value, offset and trigger height
    M557 X22:220 Y25:210 S40                                        ; Define mesh grid
    ; Drives
    M569 P0 S0                                                      ; Drive 0 goes backwards
    M569 P1 S1                                                      ; Drive 1 goes forwards
    M569 P2 S0                                                      ; Drive 2 goes backwards
    M569 P3 S0                                                      ; Drive 3 goes backwards
    M569 P4 S0                                                      ; Drive 4 goes backwards
    ; M584 X0 Y1 Z2 E4:3						; Added for DC42 diagnostics to swap E0 and E1
    M350 X16 Y16 Z16 E16:16 I1                                      ; Configure microstepping with interpolation
    M92 X80 Y80 Z1600 E2594:2630                                    ; Set steps per mm
    M566 X600 Y480 Z60 E400:400                                     ; Set maximum instantaneous speed changes (mm/min)
    M203 X40000 Y30000 Z1200 E1200:1200                             ; Set maximum speeds (mm/min)
    M201 X2000 Y2000 Z200 E500:500                                  ; Set accelerations (mm/s^2)
    M906 X1000 Y800 Z800 E400:400 I30                               ; Set motor currents (mA) and motor idle factor in per cent
    M84 S30                                                         ; Set idle timeout
    ; Heaters
    M301 H0 S1.00 P10 I0.1 D200 T0.4 W180 B30                       ; Use PID on bed heater (may require further tuning)
    M305 P0 T100000 B4138 C0 R4700                                  ; Set thermistor + ADC parameters for heater 0
    M143 H0 S120                                                    ; Set temperature limit for heater 0 to 120C
    M305 P1 T100000 B4138 C0 R4700                                  ; Set thermistor + ADC parameters for heater 1
    M143 H1 S280                                                    ; Set temperature limit for heater 1 to 280C
    M305 P2 T100000 B4138 C0 R4700                                  ; Set thermistor + ADC parameters for heater 2
    M143 H2 S280                                                    ; Set temperature limit for heater 2 to 280C
    ; Tools
    M563 P0 D0 H1                                                   ; Define tool 0
    G10 P0 X-9 Y0 Z0                                                ; Set tool 0 axis offsets
    G10 P0 R0 S0                                                    ; Set initial tool 0 active (S) and standby (R) temperatures
    M563 P1 D1 H2                                                   ; Define tool 1
    G10 P1 X9 Y0 Z0                                                 ; Set tool 1 axis offsets
    G10 P1 R0 S0                                                    ; Set initial tool 1 active and standby temperatures
    ; Network
    M550 PDuet_I3                                                   ; Set machine name
    ;M551 PPassword                                                 ; Set password
    M552 S1                                                         ; Enable network
    ;M587 S"Network" P"Password" I192.168.0.243 J192.168.0.254 K255.255.255.0 ; Configure access point and IP addresses. You can delete this line once connected
    M586 P0 S1                                                      ; Enable HTTP
    M586 P1 S1                                                      ; Enable FTP
    ;M586 P2 S0                                                     ; Disable Telnet
    ; Fans
    M106 P0 S0.0 I0 F500 H-1                                        ; Set fan 0 value, PWM signal inversion and frequency. Thermostatic control is turned off
    M106 P1 S1 I0 F500 H1:2 T45                                     ; Set fan 1 value, PWM signal inversion and frequency. Thermostatic control is turned on
    M106 P2 S1 I0 F500 H1:2 T45                                     ; Set fan 2 value, PWM signal inversion and frequency. Thermostatic control is turned on
    ; Custom settings
    M307 H7 A-1 C-1 D-1                                             ; Set Heater 7 for PWM for LED driver. Use pin 16 on expansion header
    M42 P7 S35                                                      ; Using heater 7 for PWM, set output at 25 / 255 (PWM value of 0 = LEDs off, 255 full on)
    M376 H10                                                        ; set bed compensation taper (H10 means taper over 10mm)
    M207 S1.0 F3600 T3600 Z0.5                                      ; Set FW retraction length and speed" 1.0 retract, 60mm/s, unretract 60mm/s, 0.5mm lift.
    M200 D1.75                                                      ; set all extruder filament diameters to 1.75mm
    G29 S1                                                          ; Load previously set bed map
    ; Miscellaneous
    T0                                                              ; Select first tool


  • I thought I'd add my bed.g file and explain another weird symptom. When homing Z, it is setting Z0 about 2mm above the print surface. My workflow to that point is (all using the IR Z-probe to home and probe and using the config.g above and bed.g below):

    • disable be compensation and mesh compensation using DWC controls

    • home all axes - after homing, head height displays as 2.00mm but is much more visually

    • drop Z to Z=0 DWC head height - it is still about 3mm above the surface

    • in effort to get it to a 'proper' Z=0, I run G92 Z10 - this to set an artificial position to allow the head to go lower

    • carefully lower head 2.3mm using DWC axes movement buttons until it just grips a sheet of paper.

    • run G92 Z0.2 to set the actual head height to 0.2mm to compensate for the paper thickness

    • raise the head 10mm

    • home all axes

    • head height is once again displaying as 2.0mm but is much higher

    ; bed.g
    ; called to perform automatic bed compensation via G32
    M561 ; clear any bed transform
    G28  ; home all axes
    ; Probe the bed at 5 points
    G30 P0 X10 Y20 H0 Z-99999 
    G30 P1 X10 Y230 H0 Z-99999
    G30 P2 X210 Y230 H0 Z-99999
    G30 P3 X210 Y20 H0 Z-99999
    G30 P4 X110 Y120 H0 Z-99999 S

    I must be misunderstanding the logic and missing something here but I can't see what I'm doing wrong so any pointers gratefully received.


  • Try jogging the nozzle down to paper hight send G92 Z0 raise the nozzle say 5mm send G30 S-1 and read of the resultant Z Hight in the DWC.

    Then adjust the Z Offset param in the G31 line of your Config.g to match

  • Thanks, Doug, I've done that - it is how I got to the offset in the G31 P500 X9 Y21 Z2.43 line of config.g I did it a few times to check, too, and it was consistent and is about as designed on my own-design carriage (designed height was 2.5mm).

    I've also removed the heightmap.csv file (well, renamed it) in case it was causing issues somehow. No change.


  • um strange one

  • Yeah, it has me stumped!


  • Not sure if I mentioned, so adding the firmware version:

    Firmware Name:	        RepRapFirmware for Duet WiFi
    Firmware Electronics:	Duet WiFi 1.0
    Firmware Version:	1.20 (2017-12-23)
    WiFi Server Version:	1.20
    Web Interface Version:	1.20


  • administrators

    After you do Z homing, are you certain that if you command the printer to Z=0 the nozzle is just touching the bed? A very small number of users have reported that their IR sensors sometimes have a secondary trigger height some distance above the proper one. In such cases we have replaced the sensor.

  • Thanks, David. It is perhaps easiest if I explain what I'm doing. I ran my homez.g:

    ;Z-Probe endstop
    G1 X110 Y110
    G91			; relative positioning
    G1 S1 Z-250 F9000	; move quickly to Z axis endstop and stop there (first pass)
    G1 Z5 F6000       	; go back a few mm
    G1 S1 Z-250 F360  	; move slowly to Z axis endstop once more (second pass)
    G1 Z2 F4000      	; raise Z again
    G90               	; absolute positioning

    After running that, the nozzle stopped about 4.5mm from the bed but the Z-height displayed on DWC was 2.0mm. Issuing G1 Z0 dropped the nozzle to about 2.4mm above the bed but DWC height shows 0mm.

    The measured heights were measured using a stack of Post-It notes and a vernier so there is a reasonably large margin of error! 🙂

    I tried this with bed compensation enabled and disabled and it made no noticeable difference.

    Running bed compensation immediately after this returns "Mean error: -2.591 mm" but the bed is very close to level.

    Was the false detect of those IR probes about 2 to 2.5mm greater than the main trigger distance?


  • OK, I think I have found the issue - somehow my homeall.g, did not have G30 in it. Not at all sure how I lost it but added it back and it seems to be working correctly.

    I'm sorry for the confusion - I've been battling this for days and somehow overlooked that missing G30!


  • administrators

    I'm glad you solved it. Your homez.g file should also be using G30, not G1 S2 Z moves. See

Log in to reply