C axis sensorless homing works

Discussion in 'Motion System' started by orcinus, Aug 20, 2019.

  1. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Got it to work after a little trial and error.
    Here’s my homec.g script:

    Code:
    G91
    G92 C500
    M913 C85
    M574 X1 Y1 C1 S3
    M915 H100 C S3 R0 F0
    G1 S1 C-500 F3000
    M913 C100
    G1 C2.5 F50000
    G92 C0
    G90
    
    ;Open Coupler
    M98 P/macros/Coupler - Unlock
    As a bonus, here’s a less violent homex.g:

    Code:
    G91             ; use relative positioning
    
    G1 S2 X0.5 Y-0.5 F10000        ; energise
    
    M400             ; make sure everything has stopped before we make changes
    G4 P100            ; wait 400ms
    M574 X1 Y1 S3         ; set endstops to use motor stall
    
    M913 X25 Y25         ; drop motor currents to 50%
    M915 H200 X Y S1 R0 F0     ; set X and Y to sensitivity 3, do nothing when stall, unfiltered
    
    G1 S2 Z3 F5000        ; lift Z 3mm
    G1 S1 X-400 F2000     ; move left 400mm, stopping at the endstop
    G1 S1 X2 F2000         ; move away from end
    G1 S2 Z-3 F1200        ; lower Z
    G90             ; back to absolute positioning
    
    M400             ; make sure everything has stopped before we reset the motor currents
    G4 P100            ; wait 400ms
    M913 X100 Y100         ; motor currents back to 100%
    
    M574 X1 S0         ; Define active low and unused microswitches
    … and homey.g:

    Code:
    ; homey.g
    ; called to home the Y axis
    
    G91             ; use relative positioning
    
    G1 S2 X0.5 Y-0.5 F10000        ; energise
    
    M400             ; make sure everything has stopped before we make changes
    M574 X1 Y1 S3         ; set endstops to use motor stall
    
    M913 X25 Y25         ; drop motor currents to 25%
    M915 H200 X Y S1 R0 F0     ; set X and Y to sensitivity 3, do nothing when stall, unfiltered
    
    
    G1 S2 Z3 F5000        ; lift Z 3mm
    G1 S1 Y-400 F2000     ; move to the front 400mm, stopping at the endstop
    G1 S1 Y2 F2000         ; move away from end
    G1 S2 Z-3 F1200        ; lower Z
    G90             ; back to absolute positioning
    
    M400             ; make sure everything has stopped before we reset the motor currents
    G4 P100            ; wait 400ms
    M913 X100 Y100         ; motor currents back to 100%
    
    M574 X1 S0         ; Define active low and unused microswitches
    
    Since things can vary from machine to machine, it might not work as well as for me. YMMV.
     
    Greg_The_Maker and Rob Heinzonly like this.
  2. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Trying bumping down the current (first) and reducing the feedrate a little (second) if you’re not getting 100% home success with the C axis, or it gets “sticky” on an end-stop.
     
  3. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Small update on this - it fails to home from cold for some reason (i.e. the very first Home All immediately after turning on the machine).
    X and Y fail too sometimes.

    Every subsequent home works perfectly, but still, this isn’t right.
    Please don’t use for now (or use it and let me know if it works for you, just keep your finger on the e-stop button).

    I vaguely remember the docs for Duet state that sensorless homing can vary greatly based on the temperature of the steppers, so that might be it. My plan is to add some gcode to energize all steppers and wait a few seconds before homing all axes.
     
  4. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    That seems to have done the trick.
    Change your homeall.g to:

    Code:
    G1 S2 X0.5 Y-0.5 C0.5 F10000 ; warm up the steppers
    G4 S2 ; wait 2 seconds
    
    M98 Phomec.g            ; Home C (ToolHead)
    
    M98 Phomey.g            ; Home Y
    
    M98 Phomex.g            ; Home X
    
    M98 Phomez.g            ; Home Z
    
    G1 X150 Y-40 F15000        ; Park
    … and it should work on a cold booted machine too.
     
    Amr, Greg_The_Maker and Spoon Unit like this.
  5. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    I also recommend changing the Y in that last line to e.g. Y-39.5 so it doesn’t needlessly ram into the endstop one more time after homing. Y-40 is right *at* the endstop (at least on my machine).
     
  6. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    Please explain why you needed to do sensorless home in C in the first place. Are you essentially implementing stall detection on the C motor in order to speed up the C homing. It's pretty silent and unworrying for me, but does take a while.

    The crashes during homing X and Y are a bit loud. My be good if @Greg Holloway can comment on the durability of the system under that crashing mechanism. I get the feeling they've done a lot of testing and maybe have already run a test with many thousands of such cycles. That might still not make the sound any less jarring of course, but might be comforting to know that it's not inducing undue wear.
     
  7. Greg_The_Maker

    Greg_The_Maker Administrator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    1,035
    Likes Received:
    632
    Great work! I'll do some testing of the code and if all is good I shall update github :)
     
  8. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    OK. Tested C Homing. Yes, the stall detection works well. Much faster time to complete C Homing. Only slight concern was that during the first couple of runs it seemed to rotate the wrong direction and never complete. After I restarted the machine and tried again I couldn't reproduce it though.
     
  9. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    The clacks have become clicks with the changes to X and Y homing.
     
    Greg_The_Maker likes this.
  10. Amr

    Amr Well-Known Member

    Joined:
    Jun 2, 2019
    Messages:
    130
    Likes Received:
    31
    C Homing Works with me but the X and Y homing did not for some reason it either detects a crash as soon as it starts moving or keeps crashing into the frame. thanks for sharing though, I think I will live with the clunk for now.
     
  11. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    I tested them as separate macros first before replacing them in the system folder. You can do that if you want to play with them without affecting the main ones. That might help identify any issues. In theory though, all the machines should be the same in regard to these macros.
     
  12. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Still having some unreliability issues with a freshly booted, completely cold machine, on the X and Y axes.
    I’ll do some more tweaking.
     
  13. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    — ignore —
     
    #13 orcinus, Aug 23, 2019
    Last edited: Aug 23, 2019
  14. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Ignore the above. Figured it out.
    It’s the X axis that fails to home sometimes.
    And when that happens, it moves off bed instead of to the center of the bed.

    And then the switch is *just* outside the bed, and it never triggers.

    Unless i find the “magic" setting that’s both 100% reliable for Z axis AND does not stop violently, i’m going to revert back to defaults for X.
     
  15. Greg_The_Maker

    Greg_The_Maker Administrator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    1,035
    Likes Received:
    632
    dc42, David Crocker, from Duet who codes the firmware for the Duet etc, picked up a fully assembled production ToolChanger yesterday. I expect we shall see some improvements to the scripting and overall firmware in the coming weeks and months :)
     
  16. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    I think i’ve got it working, but i don’t want to jinx it.
    I originally put a little "exercise" dance script in the homeall.g that moves both axes back and forth a few times.

    I’ve applied a similar concept to homex.g - it moves the axes a little with endstop detection off at a slower speed to “unstick” them, then immediately proceeds to the homing G1 at homing speeds, and that seems to work so far…

    Don’t wanna jinx it by posting the script yet, i’ll play around with it, see if it’s reliable.
     
    Greg_The_Maker likes this.
  17. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Okay, here goes nothing.

    homeall.g:

    Code:
    ; homeall.g
    ; called to home all axes
    
    ; stepper/axis warmup dance
    G91                     ; relative mode to prevent crashes
    G1 H2 Y-2 C2 F10000     ; jig
    G1 H2 Y2 C2 F10000      ; jig
    G1 H2 Y-2 C2 F10000     ; jiggetty
    G1 H2 Y2 C2 F10000      ; jig
    G1 H2 Y-2 C2 F10000     ; jiggy with it
    G1 H2 Y2 C2 F10000      ; jig
    G1 H2 Y-2 C2 F10000     ; jig
    G1 H2 Y2 C2 F10000      ; jiggy
    G1 H2 Y-2 C2 F10000     ; jiggetty
    G1 H2 Y2 C2 F10000      ; jig
    
    G4 S3               ; wait 3 seconds
    G90             ; back to regular programming
    
    M98 Phomec.g      ; Home C (ToolHead)
    
    M98 Phomey.g      ; Home Y
    
    M98 Phomex.g      ; Home X
    
    M98 Phomez.g      ; Home Z
    
    G1 X150 Y-40 F15000   ; Park
    homex.g:

    Code:
    ; homex.g
    ; called to home the x axis
    
    G91             ; use relative positioning
    
    G1 S2 X0.5 Y-0.5 F10000        ; energise
    
    M400             ; make sure everything has stopped before we make changes
    G4 P100            ; wait 400ms
    M574 X1 Y1 S3         ; set endstops to use motor stall
    
    M913 X25 Y25         ; drop motor currents to 25%
    M915 H200 X Y S1 R0 F0     ; set X and Y to sensitivity 2, do nothing when stall, unfiltered
    
    G1 S2 Z3 F5000        ; lift Z 3mm
    G1 S2 X2 F1000
    G1 S1 X-400 F2000     ; move left 400mm, stopping at the endstop
    G1 S1 X2 F2000         ; move away from end
    G1 S2 Z-3 F1200        ; lower Z
    G90             ; back to absolute positioning
    
    M400             ; make sure everything has stopped before we reset the motor currents
    G4 P100            ; wait 400ms
    M913 X100 Y100         ; motor currents back to 100%
    
    M574 X1 S0         ; Define active low and unused microswitches
    
    
    
    The rest of it is the same as in the first post.
    Works fine for now, but it’s 25 deg C here at the moment.
    It might fail when it gets colder, YMMV.
     
    Greg_The_Maker likes this.
  18. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    23 deg C, cold machine, still works.
    Fingers crossed.
     
  19. orcinus

    orcinus Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    336
    Likes Received:
    113
    Unfortunately, today it stopped working for the X axis again, and - weirder - the Y axis started homing at a different offset, causing tool changes to fail (as the toolhead would end up too far away from the tool at Y243).

    I've reverted the sensitivity for both X and Y to S2 for now.

    Temp is 23C still, so no idea what caused the change.
    Pixies, humidity, jupiter ascending, solar flares...
     
  20. Greg_The_Maker

    Greg_The_Maker Administrator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    1,035
    Likes Received:
    632
    recheck all your wiring and connections.

    home each axis individually and see if anything odd happens.

    with the power off move the head around and check it runs free and smoothly.
     

Share This Page