Auto-Tramming a RailCore Using conditional GCode
-
So, here's how I'm iterating through auto-tramming to level a RailCore. This can be cleaned up once we have variables, but even still, it's very cool (and confirmed working)!
First, to simplify, I moved my "G32" commands for probing the bed into a macro called "bedlevel". So I can use that like a function. (Feature request: can we send arguments to macros? Then they really would be functions!)
;bedlevel ;Call from auto-level Routine in bed.g ;Run initial 4 point leveling routine G30 P0 X15 Y45 Z-99999 G30 P1 X15 Y275 Z-99999 ;G30 P2 X275 Y150 Z-99999 S3 G30 P2 X275 Y275 Z-99999 G30 P3 X275 Y45 Z-99999 S3
Now that those commands are there, the following can go in your bed.g
The goal is to level across the bed to a deviation of < 0.01, and then do another round, and have that round within 0.005 of the previous. If not, it repeats.M561 ; clear any existing bed transform ; If the printer hasn't been homed, home it if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed G28 ;Move up 7.5mm in Z to clear the bed G1 Z7.5 ;Run an initial auto-tramming M98 P"/macros/bedlevel" while true if iterations = 5 abort "Too many auto calibration attempts" if move.initialDeviation.deviation < 0.01 if move.calibrationDeviation.deviation < move.initialDeviation.deviation + 0.005 if move.calibrationDeviation.deviation > move.initialDeviation.deviation - 0.005 break echo "Repeating calibration because initial deviation (" ^ move.initialDeviation.deviation ^ "mm) must be < 0.01" echo "and (" ^ move.calibrationDeviation.deviation ^ "mm) must be within 0.005 of initialDeviation" M98 P"/macros/bedlevel" echo "Auto calibration successful, deviation", move.calibrationDeviation.deviation ^ "mm" echo "Auto calibration successful, initialDeviation", move.initialDeviation.deviation ^ "mm" G28 Z G1 X0 Y0 F24000
-
Here is sample output from running this (I intentionally got out of level, and also changed my leadscrew locations to make it take longer to converge):
-
Confirmed working, but as an addendum to anyone reading this , this does require RepRapFirmware for Duet 2 WiFi/Ethernet 3.01-beta1+1 (2020-01-15b2)
RepRapFirmware for Duet 2 WiFi/Ethernet 3.01-beta1 (2020-01-14b3) gives "unknown value initialDeviation.deviation" errors.
Thanks dc42
-
Upvoted for "tramming".
-
Here's another macro, "Pre-Print-Checks" to make sure the printer has been trammed and is homed before starting a print (this would be run in start.g, or out of your startup gcode). I check tramming first because homing is part of the tramming script above.
;If the printer hasn't been trammed, tram it echo move.calibrationDeviation.deviation ^ move.initialDeviation.deviation ^ move.calibrationDeviation.mean ^ move.initialDeviation.mean if move.initialDeviation.deviation > 0.01 echo "You need to tram, initial deviation is > 0.01 " ^ move.initialDeviation.deviation G32 abort if move.calibrationDeviation.deviation > move.initialDeviation.deviation + 0.005 echo "You need to tram, deviation is not within 0.005 of initial deviation " ^ move.calibrationDeviation.deviation ^ " " ^ move.initialDeviation.deviation G32 abort if move.calibrationDeviation.deviation < move.initialDeviation.deviation - 0.005 echo "You need to tram, deviation is not within 0.005 of initial deviation " ^ move.calibrationDeviation.deviation ^ " " ^ move.initialDeviation.deviation G32 abort if move.initialDeviation.deviation == 0 if move.initialDeviation.mean == 0 if move.calibrationDeviation.deviation == 0 if move.calibrationDeviation.mean == 0 echo "You need to tram, or you hit the lotto and got all zeroes" G32 abort ; If the printer hasn't been homed, home it if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed echo "Printer Not homed, homing" G28 abort else echo "Printer is homed"
-
@kraegar Thanks for sharing.
@ Moderators I can't help thinking that we could do with a separate section and or repository where users can post the clever things that are doing with conditional gcode.
-
@deckingman I agree 100% that conditional GCode is going to need its own section Heck, just my posts on it may need their own section, I'm geeking out over here.
-
@kraegar said in Auto-Tramming a RailCore Using conditional GCode:
@deckingman I agree 100% that conditional GCode is going to need its own section Heck, just my posts on it may need their own section, I'm geeking out over here.
I'm stuck 10,000 miles away from my printer but itching to play with conditional gcode
-
@deckingman I wouldn't worry too much just yet...
Now when variables arrive, then we're talking!
-
Hello,
@kraegar, just wondering if you ever revisted this since variables have been implemented.
I recently upgraded my railcore 2 300 zl to reprap firmware 3.3rc3 thanks to your config and help in discord. I'm hoping to not always have to call three g32's if not always necessary.
-
the following is a couple of manual g32's and then I ran you macro as well:
5/31/2021, 7:06:10 PM 4 points probed, min error -0.240, max error 0.121, mean -0.040, deviation 0.150 Height map saved to file 0:/sys/heightmap.csv 5/31/2021, 7:05:27 PM Leadscrew adjustments made: -0.001 0.002 0.001, points used 4, (mean, deviation) before (0.001, 0.187) after (-0.000, 0.187) 5/31/2021, 7:04:58 PM Leadscrew adjustments made: 0.008 0.003 -0.005, points used 4, (mean, deviation) before (0.001, 0.189) after (0.000, 0.189) 5/31/2021, 7:04:29 PM M98 P"0:/macros/Prep-To-Print" Leadscrew adjustments made: -0.065 -0.084 -0.104, points used 4, (mean, deviation) before (-0.089, 0.186) after (0.000, 0.185) 5/31/2021, 7:02:02 PM Upload of Pre-Print_Checks successful after 0s 5/31/2021, 6:30:20 PM g32 Leadscrew adjustments made: 0.010 0.001 -0.009, points used 4, (mean, deviation) before (-0.002, 0.187) after (-0.000, 0.187) 5/31/2021, 6:29:29 PM g32 Leadscrew adjustments made: -0.067 -0.081 -0.079, points used 4, (mean, deviation) before (-0.077, 0.185) after (-0.000, 0.185)
If already printed something
prepose adding to end.gcode is slicer
M84 S15 ;So railcore will hold motor current for 15mins after a print.
Then no G32's should be necessary...
Heat steppers
Homeall
start new print
If cold printer, tram status unknown
Have macro determine if tram ie 1 g32
if yes - result below threshold > dont tram again > continue
yes - result above threshold > tram again > repeat if necessary
if no - continuejust ideas
-
Thank you very much for sharing this! I will give it a try.
I also think a forum section for conditional Gcode would be nice.-Max
-
@maxgyver said in Auto-Tramming a RailCore Using conditional GCode:
I also think a forum section for conditional Gcode would be nice.
You mean like this one?
-
@phaedrux Whoops, my bad! I have totally missed this.