Duet 2 / RepRap Firmware 3.x gcode Macros
Reprap Firmware 3.x usage overview
RepRap Firmware version 3.x macros utilize gcode meta commands to perform logic checks determining whether or not the probe is deployed.
Examples are given for both fixed docks (X, Y, Z constant) and docks that bed attached and can move in the Z axis (X & Y constant, varying Z).
RRF employs a ‘probe deployed token’ and thus, if a gcode is issued that relies on probe deployment, the system will deploy and retract it automatically.
If a series of probing commands is desired, then it is recommended that and M401 and M402 pair bracket the sequence of gcodes. See the example homez.g and bed4point.g macros for recommendations.
Tip: The most up-to-date macros are in the github repository as a bundled .zip file for download - Euclid github repo
RRF3_Example_Manual_Deploy_Probe.g
; ***********************************************************
; Euclid Probe M401 Manual Deploy Probe Macro
; RRF3.x Firmware Example
; saveas system/deployprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
; echo "Running deployprobe.g"
; if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it
; M98 P"0:/sys/homexy.g"
; uncomment next line to echo the probe deploy state
echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
M564 H1 S0 ; Allow movement BEYOND axes boundaries (for Y to reach probe dock)
G91 ; relative positioning
; echo "Lift Z in advance of deploy"
G1 H2 Z15 F3000 ; move Z 15 for clearance above dock.
G90 ; absolute positioning
; echo "Probe Value =" ^sensors.probes[0].value[0]
if sensors.probes[0].value[0]!=1000 ; if sensor is value other than 1000 do this
; uncomment next line to echo the probe deploy state
; echo "deployuser token = " ^sensors.probes[0].deployedByUser
; echo "Probe State = " ^sensors.probes[0].value[0]
abort "deployprobe start value Probe already picked up. Manually return probe to the dock"
; if we're here we know it's becasue the above is true which I assume is because you have an NC switch as a probe.
; echo "Passed first logic test to deploy probe"
G1 X100 Y10 F3000 ; move to center receiving position
M400 ; wait for moves to finish
M291 P"Attach Probe" S3 ; Deploy Probe Display Message Box "OK" and "Cancel" are displayed
; uncomment to echo the probe deploy state
; echo "Object Model Deployuser token (after while loop) = " ^sensors.probes[0].deployedByUser
G90 ; absolute positioning
G1 X150 Y150 Z15 F3000 ; move bed to clear probe from build surface
M400 ; wait for moves to finish
if sensors.probes[0].value[0]!=0
; uncomment to echo the probe deploy state
; echo "Object Model Deployuser token (in abort if section)= " ^sensors.probes[0].deployedByUser
abort "Deployprobe endvalue not 0 Probe not picked up! Deployt cancelled."
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro deployprobe.g complete"
RRF3_Example_Manual_Retract_Probe.g
; ***********************************************************
; Euclid Probe Manual Retract Probe Macro M402
; RRF3.x Firmware Example
; saveas system/retractprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
echo "running retractprobe.g macro"
; uncomment next line to echo the probe deploy state
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
G90 ; absolute positioning
M564 S0 ; allow beyond limit axis to print area
if sensors.probes[0].value[0]!= 0
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe: Probe not currently picked up!"
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
; if we're here we know it's becasue the above is true which I assume is because you have an NC switch as a probe.
; echo "Passed first logic test to deploy probe"
G1 X100 Y10 F3000 ; move to center receiving position
M400 ; wait for moves to finish
M291 P"Dettach Probe" S3 ; Deploy Probe Display Message Box "OK" and "Cancel" are displayed
G1 X150.0 Y150.0 F6000 ; move to the center of the bed
M400
M564 S1 ; limit axis to print area
; echo "complete movement commands"
if sensors.probes[0].value[0]!= 1000
;echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe.g Probe not correctly dropped off in dock!"
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro retractprobe.g complete"
RRF3_Example_Auto_Deploy_Probe_Fixed_Dock.g
; ***********************************************************
; Euclid Probe Fixed Dock M401 Deploy Probe Macro
; RRF3.X Firmware Example
; saveas system/deployprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
; __________________________________________________________________________
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | * Probe Ready Position |
; | X150 Y150 |
; | |
; | |
; | * Dock staging position |
; | X0 Y70 |
; | |
; | |
; | * Dock Exit Position |
; | X0 Y40 |
; | |
; | |
; | |
; | |
; | |
; | X0 Y0 X30 Y0 X100 Y0 |
; | * Dock * Dock Side * Dock Preflight |
; |________________________________________________________________________|
;
; Above is example 300x300 bed to coorelate with macros and movements below.
; This example is for a fixed dock, fixed gantry/carraige and moving bed motion system.
; RailCore, Ender5, V-Core3, etc...
; coordinates are re-written below above the macros
echo "Running deployprobe.g"
if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it
M98 P"0:/sys/homexy.g"
; uncomment next line to echo the probe deploy state
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
M564 H1 S0 ; Allow movement BEYOND axes boundaries (for Y to reach probe dock)
G91 ; relative positioning
echo "Lift Z in advance of deploy"
G0 H2 Z15 F3000 ; move Z 15 for clearance above dock.
; ; need to figure out some safety check on this
G90 ; absolute positioning
; uncomment next line to echo the probe value
; echo "Probe Value =" ^sensors.probes[0].value[0]
if sensors.probes[0].value[0]!=1000 ; if sensor is value other than 1000 do this
; uncomment next line to echo the probe deploy state
; echo "deployuser token = " ^sensors.probes[0].deployedByUser
; echo "Probe State = " ^sensors.probes[0].value[0]
abort "deployprobe start value Probe already picked up. Manually return probe to the dock"
; if we're here we know it's becasue the above is true which I assume is because you have an NC switch as a probe.
; echo "Passed first logic test to deploy probe"
; Preflight position is X100 Y0
; Dock Side position is at X30 Y0
; Docked probe postion is at X0 Y0
; Dock exit point is at X0 Y40
; Dock Re-Entry Staging Position is at X0 Y70
; Probe Ready Position X150 Y150
; echo "Probe Pickup macro running"
G0 X100 Y0 F6000 ; move to Preflight Position
M400 ; wait for moves to finish
G0 X0 Y30 F6000 ; move to Dock Side dock location
M400 ; wait for moves to finish
; uncomment next line to echo the probe deplot state
; echo "Object Model Deployuser token (before while loop) = " ^sensors.probes[0].deployedByUser
G0 X0 Y0 F3000 ; move over Dock
G4 P500 ; pause 0.5 seconds
M400 ; wait for moves to finish
; uncomment next line to echo the probe value
; echo "Probe Value =" ^sensors.probes[0].value[0]
G0 X0 Y40 F300 ; slide probe out of dock - slowly
G0 X0 Y70 F3000 ; move to re-entry position
M400 ; wait for moves to finish
echo "Probe Pickup complete"
; uncomment to echo the probe deploy state
; echo "Object Model Deployuser token (after while loop) = " ^sensors.probes[0].deployedByUser
G90 ; absolute positioning
G0 X150 Y150 G3000 ; move to the center of the bed
M400 ; wait for moves to finish
if sensors.probes[0].value[0]!=0
; uncomment to echo the probe deploy state
echo "Object Model Deployuser token (in abort if section)= " ^sensors.probes[0].deployedByUser
abort "Deployprobe endvalue not 0 Probe not picked up! Deployt cancelled."
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro deployprobe.g complete"
RRF3_Example_Auto_Retract_Probe_Fixed_Dock.g
; ***********************************************************
; Euclid Probe Fixed Dock Retract Probe Macro M402
; RRF3.x Firmware Example
; saveas system/retractprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
; __________________________________________________________________________
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | * Probe Ready Position |
; | X150 Y150 |
; | |
; | |
; | * Dock Re-entry staging position |
; | X0 Y70 |
; | |
; | |
; | * Dock Exit Position |
; | X0 Y40 |
; | |
; | |
; | |
; | |
; | |
; | X0 Y0 X30 Y0 X100 Y0 |
; | * Dock * Dock Side * Dock Preflight |
; |________________________________________________________________________|
;
; Above is example 300x300 bed to coorelate with macros and movements below.
; This example is for a fixed dock, fixed gantry/carraige and moving bed motion system.
; RailCore, Ender5, V-Core3, etc...
; coordinates are re-written below above the macros
echo "running retractprobe.g macro"
; uncomment next line to echo the probe deploy state
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
; Preflight position is X100 Y0
; Dock Side position is at X30 Y0
; Docked probe postion is at X0 Y0
; Dock exit point is at X65 Y0
; Dock Re-Entry Staging Position is at X0 Y70
; Probe Ready Position X150 Y150
G90 ; absolute positioning
M564 S0 ; allow beyond limit axis to print area
if sensors.probes[0].value[0]!= 0
echo "Probe Value =" ^sensors.probes[0].value[0]
echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe: Probe not currently picked up!"
; echo "pass first logic loop"
; uncomment next line to echo the probe value and probe deploy state
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
G0 X0 Y70 F3000 ; move to ready position
M400 ; wait for moves to finish
G0 X0 Y40 F3000 ; move to the entry position for the dock
M400 ; wait for moves to finish
G0 X0 Y0 F300 ; move into the dock position
M400 ; wait for moves to finish
G4 P250 ; pause 250 usecs
G0 X0 Y30 F6000 ; move to the side adjacent to the dock swiping the probe off
G0 X100 Y0 F3000 ; move to the side adjacent to the dock swiping the probe off
M400 ; wait for moves to finish
; uncomment next line to echo the probe value and probe deploy state
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
G0 X150.0 Y150.0 F6000 ; move to the center of the bed
M400 ; wait for moves to finish
M564 S1 ; limit axis to print area
; echo "complete movement commands"
if sensors.probes[0].value[0]!= 1000
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe.g Probe not correctly dropped off in dock!"
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro retractprobe.g complete"
RRF3_bed4point.g
; ***********************************************************
; Euclid Probe Independant Screw Leveling Macro
; RRF3.X Firmware Example
; saveas system/bed4point.g
; could save it as conventional bed.g but for illustration purposes
; the name is purposefully altered
; comments and echo statements throughout are provided for convenience
; ***********************************************************
; probe is -16.4 in X -29.4 in Y bed is 290 in X 325 in Y
; locations of probe points are at
; (18, 285) (270,285)
;
; (18,65) (270,65)
;
; adjust coords so that probe hits symmetric points on the bed and avoids dock
;
; echo "Running bed4point.g"
M558 F60 A3 ; fix probe speed to 1mm/s
G90
G4 P250
G30 P0 X18.0 Y65.0 F9000.0 Z-99999 ; probe front left PEI
G30 P1 X18.0 Y285.0 F9000.0 Z-99999 ; probe back left PEI
G30 P2 X270.0 Y285.0 F9000.0 Z-99999 ; probe back right PEI
G30 P3 X270.0 Y65.0 F9000.0 Z-99999 S3 ; probe near front right leadscrew and calibrate 3 motors PEI
; echo "bed4point.g complete"
RRF3_homez.g
; ***********************************************************
; Euclid Probe homez.g Example Macro
; RRF3.X Firmware Example
; saveas system/homez.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it
M98 P"0:/sys/homexy.g"
M561 ; clear any bed transform
M290 S0 R0 ; clear baby steps
G91 ; relative positioning
G1 H2 Z6 F6000 ; lift Z relative to current position to clear any obstructions
M400
G90 ; absolute positioning
; echo "Call deployprobe.g macro"
M401 P0 ; This runs macro file deployprobe
; echo "Return"
G1 X145 Y162.5 F9000 ; go to center of bed in advance of probe that point
M400
; echo "G30 Command"
G30 ; Probe the bed at the current XY position. When the probe is triggered,
; adjust the Z offset of the current tool to make the current position Z=0.
G1 Z10 ; raise Z=10
M400
G4 P500
; echo "Call bed4point.g macro"
M98 P"0:/sys/bed4point.g" ; tram bed
; echo "Return"
G1 X145 Y162.5 F9000 ; go back to the first probe point and reprobe 0 in case it moved
G30
; echo "Call retractprobe.g macro"
M402 P0 ; retract probe
; echo "Return"
G1 Z10 F600 ; lift Z relative to current position
G90 ; absolute positioning
M564 S1 H0 ; reset the bounding limits
; G1 X150 Y0 F9000 ; move carraige to center front
RRF3_Example_Auto_Deploy_Probe_MovingZ_Dock.g
; ***********************************************************
; Euclid Probe Moving Z Dock Deploy Probe Macro M401
; RRF3.X Firmware Example
; saveas system/deployprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
; echo "Running deployprobe.g"
; if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it
; M98 P"0:/sys/homexy.g"
; uncomment next line to echo the probe deploy state
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
M564 H1 S0 ; Allow movement BEYOND axes boundaries (for Y to reach probe dock)
G91 ; relative positioning
echo "Lift Z in advance of deploy"
G1 H2 Z15 F3000 ; move Z 15 for clearance above dock.
; ; need to figure out some safety check on this
G90 ; absolute positioning
; echo "Probe Value =" ^sensors.probes[0].value[0]
if sensors.probes[0].value[0]!=1000 ; if sensor is value other than 1000 do this
; uncomment next line to echo the probe deploy state
; echo "deployuser token = " ^sensors.probes[0].deployedByUser
; echo "Probe State = " ^sensors.probes[0].value[0]
abort "deployprobe start value Probe already picked up. Manually return probe to the dock"
; if we're here we know it's becasue the above is true which I assume is because you have an NC switch as a probe.
; echo "Passed first logic test to deploy probe"
; Dock side position is at X0 Y30
; Docked probe postion is at X0 Y0
; Dock exit point is at X65 Y0
G1 X5.0 Y30 F6000 ; move adjacent to probe dock location
M400 ; wait for moves to finish
G91 ; realtive coordiantes
G1 Z-15 ; recover the z clearance
; echo "Probe Pickup while loop running"
; uncomment next line to echo the probe deplot state
; echo "Object Model Deployuser token (before while loop) = " ^sensors.probes[0].deployedByUser
G90 ; absolute coordinates
G1 X0 Y0 F3000 ; move over dock
G4 S1 ; pause for pickup
M400 ; wait for moves to finish
while sensors.probes[0].value[0]=1000
; echo "Probe Pickup while loop running"
G91 ; realtive coordiantes
G1 Z-0.25 F600 ; jog bed up 0.25mm change to suit user preference
M400 ; wait for moves to finish, allow polling interval to trigger and check probe value
G90 ; absolute coordinates
; echo sensors.probes[0].value[0]
; echo iterations
if iterations=100 ; if probe has moved 100*step increment without pickup detection, exit loop
break
G4 P250 ; pause 1 seconds
echo "Probe Value =" ^sensors.probes[0].value[0]
G1 X65 Y0 F1200 ; slide probe out of dock - slowly
M400
G4 P250 ; pause 1 seconds
echo "Probe Pickup while loop complete"
; uncomment to echo the probe deplot state
; echo "Object Model Deployuser token (after while loop) = " ^sensors.probes[0].deployedByUser
G90 ; absolute positioning
G1 X150 Y150 Z10 F3000 ; move bed to clear probe from build surface
M400 ; wait for moves to finish
if sensors.probes[0].value[0]!=0
; uncomment to echo the probe deploy state
echo "Object Model Deployuser token (in abort if section)= " ^sensors.probes[0].deployedByUser
abort "Deployprobe endvalue not 0 Probe not picked up! Deployt cancelled."
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro deployprobe.g complete"
RRF3_Example_Auto_Retract_Probe_Moving_Dock.g
; ***********************************************************
; Euclid Probe Fixed Dock Retract Probe Macro M402
; RRF3.x Firmware Example
; saveas system/retractprobe.g
; comments and echo statements throughout are provided for convenience
; ***********************************************************
echo "running retractprobe.g macro"
; uncomment next line to echo the probe deploy state
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
; Dock side position is at X0 Y30
; Docked probe postion is at X0 Y0
; Dock entry/exit point is at X65 Y0 Z10 **USER MUST ESTABLISH EXIT HEIGHT Z
G90 ; absolute positioning
M564 S0 ; allow beyond limit axis to print area
if sensors.probes[0].value[0]!= 0
echo "Probe Value =" ^sensors.probes[0].value[0]
echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe: Probe not currently picked up!"
; echo "pass first logic loop"
; uncomment next line to echo the probe value and probe deploy state
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
G1 X150 Y30 Z10 F3000 ; move to ready position
G1 X65 Y0 Z10F 3000 ; move to the entry position for the dock
G1 X0 Y0 Z10 F300 ; move into the dock position
G4 P250 ; pause 250 usecs
G1 X0 Y30 Z10 F6000 ; move to the side adjacent to the dock swiping the probe off
M400
; uncomment next line to echo the probe value and probe deploy state
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
G1 X150.0 Y150.0 Z10 F6000 ; move to the center of the bed
M400
M564 S1 ; limit axis to print area
; echo "complete movement commands"
if sensors.probes[0].value[0]!= 1000
; echo "Probe Value =" ^sensors.probes[0].value[0]
; echo "Object Model Deployuser token =" ^sensors.probes[0].deployedByUser
abort "retractprobe.g Probe not correctly dropped off in dock!"
M564 H1 S1 ; Restrict movement to within axes boundaries (for normal Y movement)
echo "Macro retractprobe.g complete"