Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    Zeroing Macro For Carbide3D BitZero

    Gcode meta commands
    1
    3
    289
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CthulhuLabs
      CthulhuLabs last edited by CthulhuLabs

      So I am in the process of converting my Shapeoko CNC to use a Duet 3 6HC running 3.3-rc3 RRF. I have the motion system working great. I am now moving onto getting the probes I have for it working. The first one I am working on is their BitZero:

      https://shop.carbide3d.com/collections/accessories/products/bitzero-v2?variant=32936948236349

      which is similar to the OpenBuilds XYZ Probe. I want to mimic the way Carbide3D has the probe working in their Carbide Motion software. They have you

      1. Insert a precision ground dowel pin into your spindle instead of a cutter
      2. Align the BitZero on the corner of your workpiece
      3. Attach the Magnetic lead to the dowel pin
      4. Then you jog spindle so the dowel pin so that it is in the hole
      5. Start the probing sequence
      6. The spindle moves to the right till the dowel pin touches the right wall of the hole
      7. The spindle moves to the left till the dowel pin touches the left wall of the hole
      8. The spindle moves to the spot exactly in the middle of the two and sets that as work X zero
      9. The spindle moves towards the back of the machine till the dowel pin touches the back wall of the hole
      10. The spindle moves towards the front of the machine till the dowel ping touches the front wall of the hole
      11. The spindle moves to the spot exactly in the middle of the two and sets that as work Y zero
      12. The spindle raises till it is above the probe plate
      13. The spindle moves about 20mm in both X and Y towards machine home
      14. The spindle dives till the dowel pin touches the probe plate
      15. The Z position minus the thickness of the probe plate is saved as the work Z zero

      This seems like the perfect job for Gcode Meta Commands. Here is what I have so far:

      M291 P"Please insert a dowel pin into your spindle and jog it so the dowel pin is in the BitZero's hole" R"BitZero" S3 X1 Y1 Z1
      
      var XMaxPos = 0;
      var XMinPos = 0;
      var XZeroPos = 0;
      var YMaxPos = 0;
      var YMinPos = 0;
      var YZeroPos = 0;
      
      var CoordSystem = 20;
      
      ; If the printer hasnt been homed, home it
      if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
      	G28
      	
      G21							; Metric
      
      ; Find X Zero
      G91							; Relative positioning
      G38.2 P0 X50 F100					; Seek right along X until contact with probe plate
      set var.XMaxPos = {move.axes[0].machinePosition}	; Save our current X position as the max
      
      G38.2 P0 X-50 F100					; Seek left along X until contact with probe plate
      set var.XMinPos = {move.axes[0].machinePosition}    	; Save our current X position as the min
      set var.XZeroPos = {(var.XMinPos + var.XMaxPos) / 2}	; Find the Spot in the middle
      G90							; Absolute positioning
      G1 X{var.XZeroPos}					; Move to the middle spot
      G10 L{var.CoordSystem} X0				; Store probe offsets in the work offset co-ordinates system for X
      
      
      ; Find Y Zero
      G91							; Relative positioning
      G38.2 P0 Y50 F100					; Seek up along Y until contact with probe plate
      set var.YMaxPos = {move.axes[1].machinePosition}	; Save our current Y position as the max
      	
      G38.2 P0 Y-50 F100					; Seek down along Y until contact with probe plate
      set var.YMinPos = {move.axes[1].machinePosition}    	; Save our current Y position as the min
      
      set var.YZeroPos = {(var.YMinPos + var.YMaxPos) / 2}	; Find the Spot in the middle
      
      G90							; Absolute positioning
      G1 Y{var.YZeroPos}					; Move to the middle spot
      G10 L{var.CoordSystem} Y0				; Store probe offsets in the work offset co-ordinates system for Y
      G91							; Relative positioning
      
      
      ; Find Z Zero
      ; TODO add code here for zeroing Z
      
      
      
      G90							; Absolute positioning
      

      This is the first time I have ever programmed with the Meta Commands so I was hoping someone could look this over and check if I missed anything. I would hate to break my probe by doing something dumb.

      I plan on writing this Macro in such a way that it can be used with other probes of this sort.

      CthulhuLabs 1 Reply Last reply Reply Quote 0
      • CthulhuLabs
        CthulhuLabs @CthulhuLabs last edited by

        Well I tried my Macro and it does not get past the first G38.2 command:

        var XMaxPos = 0;
        var XMinPos = 0;
        var XZeroPos = 0;
        var YMaxPos = 0;
        var YMinPos = 0;
        var YZeroPos = 0;
         
        var CoordSystem = 20;
         
        ; If the printer hasnt been homed, home it
        if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
        	G28
        	
        
        M291 P"Please insert a dowel pin into your spindle and jog it so the dowel pin is in the BitZero's hole" R"BitZero" S3 X1 Y1 Z1
        
        G21							; Metric
        M291 P"Metric" R"BitZero" S3
         
        ; Find X Zero
        G91							; Relative positioning
        M291 P"Relative" R"BitZero" S3
        
        G38.2 P0 X50 F100					; Seek right along X until contact with probe plate
        M291 P{"X Max " ^ move.axes[0].machinePosition} R"BitZero" S3
        
        set var.XMaxPos = {move.axes[0].machinePosition}	; Save our current X position as the max
         
        G38.2 P0 X-50 F100					; Seek left along X until contact with probe plate
        set var.XMinPos = {move.axes[0].machinePosition}    	; Save our current X position as the min
        set var.XZeroPos = {(var.XMinPos + var.XMaxPos) / 2}	; Find the Spot in the middle
        G90							; Absolute positioning
        G1 X{var.XZeroPos}					; Move to the middle spot
        G10 L{var.CoordSystem} X0				; Store probe offsets in the work offset co-ordinates system for X
         
         
        ; Find Y Zero
        G91							; Relative positioning
        G38.2 P0 Y50 F100					; Seek up along Y until contact with probe plate
        set var.YMaxPos = {move.axes[1].machinePosition}	; Save our current Y position as the max
        	
        G38.2 P0 Y-50 F100					; Seek down along Y until contact with probe plate
        set var.YMinPos = {move.axes[1].machinePosition}    	; Save our current Y position as the min
         
        set var.YZeroPos = {(var.YMinPos + var.YMaxPos) / 2}	; Find the Spot in the middle
         
        G90							; Absolute positioning
        G1 Y{var.YZeroPos}					; Move to the middle spot
        G10 L{var.CoordSystem} Y0				; Store probe offsets in the work offset co-ordinates system for Y
        G91							; Relative positioning
         
         
        ; Find Z Zero
        ; TODO add code here for zeroing Z
         
         
         
        G90							; Absolute positioning
        

        The first three dialog boxes pop up and then everything stops. Here is my config:

        ; Configuration file for Duet 3 (firmware version 3)
        ; executed by the firmware on start-up
        ;
        ; General preferences
        G90                                         ; send absolute coordinates...
        M83                                         ; ...but relative extruder moves
        M550 P"Duetoko"                             ; set printer name
         
        ; Dual Y
        M584 X0.0 Y0.1:0.2 Z0.3
         
        ; Drives
        M569 P0.0 S1                                ; X  physical drive 0.0 direction (0 = backwards, 1 = forwards (default 1))
        M569 P0.1 S1                                ; Y1 physical drive 0.1 direction (0 = backwards, 1 = forwards (default 1))
        M569 P0.2 S0                                ; Y2 physical drive 0.2 direction (0 = backwards, 1 = forwards (default 1))
        M569 P0.3 S1                                ; Z  physical drive 0.3 direction (0 = backwards, 1 = forwards (default 1))
         
        M350 X16 Y16 Z16 I1                         ; configure microstepping with interpolation
        M92 X80.00 Y80.00 Z640.00                   ; set steps per mm
        M566 X900.00 Y900.00 Z100.00                ; set maximum instantaneous speed changes (mm/min)
        M203 X10000.00 Y10000.00 Z800.00           ; set maximum speeds (mm/min)
        M201 X500.00 Y500.00 Z100.00                ; set accelerations (mm/s^2)
        M906 X1900 Y1900 Z1900 I40                  ; set motor currents (mA) and motor idle factor in per cent
        M84 S30                                     ; set idle timeout
         
        ; Axis Limits
        M208 X-845 Y-850 Z-150 S1                            ; set axis minima ( 0 = set axis maximum (default), 1 = set axis minimum)
        M208 X0 Y0 Z0 S0                      ; set axis maxima ( 0 = set axis maximum (default), 1 = set axis minimum)
         
        ; Endstops
        M574 X2 S1 P"!io0.in"                       ; configure active-high endstop for low  end on X via pin io0.in
        M574 Y2 S1 P"!io1.in"                       ; configure active-high endstop for low  end on Y via pin io1.in
        M574 Z2 S1 P"!io2.in"                       ; configure active-high endstop for high end on Z via pin io2.in
         
        ; OUT
        M950 F0 C"!out6+out6.tach"                  ; create fan 0 on pin out6 
        M106 P0 S255                                ; set fan 0 to 190 speed (max 255)
         
        ; Tools
        M950 R0 C"io6.out" L40000 Q50               ; Spindle acts like a 3.3V RC Servo on io6.out
        M563 P0 R0 F0 S"Spindle"                    ; define tool 0 as controllable spindle
        G10 P0 X0 Y0 Z0                             ; set tool 0 axis offsets
        T0                                          ; select tool 0
        
        ; BitZeroV2
        M558 K0 P8 C"!io3.in" H20 F120 T300        ; Z probe 0
        G31 K0 P500 X0 Y0 Z10
         
        ; General
        G54                                         ; Use Workspace coordinate system
        M453                                        ; CNC Mode
        M564 S0 H0                                  ; Allow movement without homing (without axis maxima)
        
        CthulhuLabs 1 Reply Last reply Reply Quote 0
        • CthulhuLabs
          CthulhuLabs @CthulhuLabs last edited by CthulhuLabs

          I was an idiot. The spindle was moving. Just doing so slowly I did not see it. All the same I ran into a bunch of issues with the G38.2 command and ended up redoing my code based off someone else's macro. Here it is:

          var ProbeThickness = 13;
          var ProbeXWidth = 58;
          var ProbeYWidth = 58;
          var CoordSystem	= 20;
          
          ; If the printer hasn't been homed, home it
          if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
          	G28
          
          M291 P"Insert a Dowel Pin into your spindle and center it in the probes hole" R"Probing" S3 X1 Y1 Z1
          
          ; Find center of cavity
          M675 X R2 F300 K0							; Find center in X axis
          M675 Y R2 F300 K0							; Find center in Y axis
          
          G10 P1 L{var.CoordSystem} X0 Y0						; Store X and Y as zero in CoordSystem
           
          ; Set bit above center of probe
          G91									; relative positioning
          G0 Z{var.ProbeThickness + 2}						; rapid move Z axis over the surface of the probe
          G0 X{var.ProbeXWidth / 2} Y{var.ProbeYWidth / 2}			; rapid move X and Y axis to middle of probe
           
          ; Probe Z component
          G38.2 Z{move.axes[2].userPosition - (var.ProbeThickness + 2.25)}	; seek until the probe circuit is closed Z-axis 25 mm
          G0 Z5									; rapid move Z axis 5 mm
          
          G10 P1 L{var.CoordSystem} Z{var.ProbeThickness + 5}			; store relative probe offset for coordinates system 1
          G0 X{(var.ProbeXWidth / 2) * -1} Y{(var.ProbeYWidth / 2) -1}		; go back over the hole
          
          G90									; Absolute positioning
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA