Conditonal script for homing and autolevel - help!
-
@dc42 said in Conditonal script for homing and autolevel - help!:
if !move.axes[0].isHomed || !move.axes[1].isHomed || !move.axes[2].isHomed
Thank you @dc42
I created a new macro file, homing.g, copied text in and tried to run it and I get this error message.M98 P"0:/macros/Scripts/Homing.g" Error: in file macro line 1 column 5: M98: unknown value
there is no M98 in the command.
I do not understand!
Regards,
Paul -
@PaulHew There is a typo in dc42's code, actually it's
homed
instead ofisHomed
.PS: Please upgrade to the latest RC when you can.
-
@chrishamm Thanks, appreciated.
you already know this, but I have learnt that the text needs to be lowercase for homed.
Just incase someone finds this post and needs some help.Works well, just need to drop my probing temps into the macro.
Also saves wear and tear on the printer!Sorry, one other thing, what happens if it cannot for some reason hit 0.03.
I am calling the macro from my start gcode in my slicer. I presume it will just carry on printing even though the deviation is off.Regards,
Paul -
@PaulHew said in Conditonal script for homing and autolevel - help!:
Sorry, one other thing, what happens if it cannot for some reason hit 0.03.
It will carry on running G32 forever. You could set a limit on the number of iterations, or have it abort if it reaches a specific number of iterations.
-
@PaulHew After using a script like this for a while, I've found it's best to always home z before and after G32. I've actually added M98 P"0:/sys/homez.g" to the top and G28 Z to the bottom of bed.g. The reason is after the printer warms or cools the z height changes a little causing an inconsistent first layer.
Here's my bed.g for a coreXY
if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it M98 P"0:/sys/homeyx.g" ; home y and x ; M98 P"0:/sys/homez.g" ; home z ; M561 ; clear any bed transform M558 P9 H5 F120 T24000 ; increase dive height M98 P"bed_threeScrews.g" ; perform bed tramming echo "Bed Traming Cycle: 1 - Difference was " ^ move.calibration.initial.deviation ^ "mm" ; while move.calibration.initial.deviation >= 0.01 ; perform additional tramming if previous deviation was over 0.01mm if iterations = 5 abort "Too many auto tramming attempts" M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config M98 P"bed_threeScrews.g" ; perform bed tramming echo "Bed Traming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm" continue ; M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config G28 Z ; home z
homeyz.g
; homeyx.g ; called to home x and y axes ; ; Warning: do not home individual axes by calling G28 X or G28 Y. It will cause errors. Instead run the macro file directly. IE M98 P"0:/sys/homex.g" ; M106 P2 S1 ; turn on virtual fan 2 to indicate homeall is in progress ; G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position M98 P"0:/sys/homey.g" ; home y M98 P"0:/sys/homex.g" ; home x G90 ; absolute positioning ; M106 P2 S0 ; turn off virtual fan 2 to indicate homeall is done
bed_threeScrews.g
G30 P0 X10 Y18 Z-99999 ; probe near a front left leadscrew G30 P1 X10 Y300 Z-99999 ; probe near a back left leadscrew G30 P2 X320 Y166 Z-99999 S3 ; probe near a right leadscrew and level
-
@mwolter said in Conditonal script for homing and autolevel - help!:
bed_threeScrews.g
Apologies for the delay in saying thanks. Really appreciate you sending me this info.
Just need to work out what I need to modify to implement it into my config.
I noticed this, just wondering what is in this file, I am presuming it is not in your config.g possibly.M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config
Otherwise, really appreciate the help, conditionals I write in another language are nothing like this!
Regards,
Paul. -
@PaulHew said in Conditonal script for homing and autolevel - help!:
I noticed this, just wondering what is in this file, I am presuming it is not in your config.g possibly.
Haha, sharp eye!
I did my best to use modular configs and macros to prevent changes needing to be done in multiple locations. What you are seeing is a macro to set the BLTouch parameters back to default. Since you mentioned it, I'll try to be as complete as possible with the macros and configs.All it does is reset the probe height parameter back to 2mm from 5mm set in line 7. It's increased to 5mm to allow for probing of a bed that is extremely out of tram.
bltouch_config
M558 P9 C"^io7.in" H2 F120 T24000 ; set Z probe type to bltouch and the dive height + speeds ; M98 P"0:/macros/Utilities/Config/bltouch_offset_config"
For completeness here is bltouch_offset_config also
; ; G31 - +Z Nozzle closer to bed, -Z Nozzle further from bed ; G31 X0 Y-28.58 Z2.90 P500 ; 200411 powder coated pei
There another thing that was not explained. At the top of homeyx.g are the following commands that turn on and off a virtual fan to indicate a multi axis home is in progress. This is only necessary until RRF provides actual variables that can be shared among macros. This should come in RRF 3.02. Until then I'm using a virtual fan.
M106 P2 S1 ; turn on virtual fan 2 to indicate homeall is in progress M106 P2 S0 ; turn off virtual fan 2 to indicate homeall is done
This is the code in config.g that configures the virtual fan
; Virtual Fans Used as Variables ; M950 F2 C"out6" M106 P2 S0 C"vFan Homeall"
Here is the homex.g that uses the firtual fan. I did it this way so the homex.g and homey.g files can be used in a homeall script and the bed doesn't go up and down 5mm when homing each axes.
; homex.g ; called to home the X axis ; ; if fans[2].actualValue = 0 ; not homeall? G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position ; G1 H1 X357 F6000 ; move quickly to X axis endstop and stop there (first pass) G1 X-5 F3600 ; go back a few mm G1 H1 X357 F360 ; move slowly to X axis endstop once more (second pass) ; if fans[2].actualValue = 0 ; not homeall? G1 Z-5 F6000 H2 ; lower Z again G90 ; absolute positioning
; homey.g ; called to home the Y axis (G28 Y) ; ; if fans[2].actualValue = 0 ; not homeall? G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position ; G1 H1 Y350 F6000 ; move quickly to Y axis endstop and stop there (first pass) G1 Y-5 F3600 ; go back a few mm G1 H1 Y350 F360 ; move slowly to Y axis endstop once more (second pass) ; if fans[2].actualValue = 0 ; not homeall? G1 Z-5 F6000 H2 ; lower Z again G90 ; absolute positioning
-
Morning. So I was kindly given the above scripts to use on my RailCore II, thank you @mwolter
Modified only the bits I understand, like bedscrews file as I use a 4 point probe.I am getting this error in my console and I do not understand what is wrong...
02/05/2020, 09:19:00 Leadscrew adjustments made: -0.000 0.001 -0.000, points used 4, (mean, deviation) before (-0.000, 0.003) after (-0.000, 0.003) Error: in file macro line 38 column 42: meta command: 'iterations' used when not inside a loop 02/05/2020, 09:18:19 g32 Leadscrew adjustments made: -0.048 -0.048 -0.050, points used 4, (mean, deviation) before (-0.049, 0.003) after (0.000, 0.003) Bed Traming Cycle: 1 - Difference was 0.003mm
this is my Bed.g - It has my original Bed info
;M561 ; clear any existing bed transform ;G1 Z5 ; _RRF3_ remove S2 ;G30 P0 X15 Y45 Z-99999 ;G30 P1 X15 Y275 Z-99999 ;G30 P2 X275 Y150 Z-99999 S3 ;;G30 P3 X275 Y45 Z-99999 S3 ;G1 X0 Y0 F5000 ; move the head to the corner (optional) ;Satre suggestion ;M561 ; clear any existing bed transform ;G1 Z5 ; RRF3 remove S2 ;G30 P0 X15 Y45 Z-99999 ;G30 P1 X15 Y275 Z-99999 ;G30 P2 X275 Y275 Z-99999 ;S3 ;G30 P3 X275 Y45 Z-99999 S3 ;G1 X0 Y0 F5000 ; move the head to the corner (optional ; New 2/5/2020 if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it M98 P"0:/sys/homex.g" ; home x M98 P"0:/sys/homey.g" ; home Y M98 P"0:/sys/homez.g" ; home z ; M561 ; clear any bed transform ;M558 P9 H5 F120 T24000 ; increase dive height M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming ; echo "Bed Traming Cycle: 1 - Difference was " ^ move.calibration.initial.deviation ^ "mm" ; while move.calibration.initial.deviation >= 0.02 ; perform additional tramming if previous deviation was over 0.02mm if iterations = 5 abort "Too many auto tramming attempts" ; ;M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming echo "Bed Traming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm" continue ; ;M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config G28 Z ; home z
I understand it is referring to this line
echo "Bed Traming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm"
but am not knowledgeable enough to understand and fix it.
As always your assistance is appreciated.
Regards,
Paul.
-
@PaulHew, the problem is that your M98 command at line 36 isn't indented with respect to the while-command at line 31, therefore the loop body ends just after the abort-command at line 33.
-
@dc42 and @mwolter Thank you both for your help.
As I mentioned conditionals are not my forte.I eventually got it working and am pleased with what it does.
I include it for anyone else, even the original above by @mwolter would work but tweaked what I knew I could tweak, namely I used 4 screw locations instead of 3.This is for a RailCore II CoreXY with 3 Z motors but could probably be applied to anything else.
New bed.g
; New 2/5/2020 if !move.axes[0].homed || !move.axes[1].homed ; If the printer hasn't been homed, home it M98 P"0:/sys/homex.g" ; home x M98 P"0:/sys/homey.g" ; home Y M98 P"0:/sys/homez.g" ; home z ; M561 ; clear any bed transform ;M558 P9 H5 F120 T24000 ; increase dive height M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming ; echo "Bed Traming Cycle: 1 - Difference was " ^ move.calibration.initial.deviation ^ "mm" ; while move.calibration.initial.deviation >= 0.02 ; perform additional tramming if previous deviation was over 0.02mm if iterations = 5 abort "Too many auto tramming attempts" M98 P"0:/sys/bed_FourScrews.g" ; perform bed tramming echo "Bed Traming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm" continue ; ;M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config G28 Z ; home z
bed_Fourscrews.g
G30 P0 X15 Y45 Z-99999 G30 P1 X15 Y275 Z-99999 G30 P2 X275 Y275 Z-99999 G30 P3 X275 Y45 Z-99999 S3
If you make it better, please let me know so I can implement it also!
Regards,
Paul