From f9d2a9e94703aa6ec70542f529f1680dcf1908c7 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Tue, 9 Nov 2021 11:06:26 +0100 Subject: [PATCH] Updated home offsets, auto generation of tool actions --- rrf3.x/macros/Dock0 | 3 + rrf3.x/macros/Dock1 | 4 +- rrf3.x/macros/Dock2 | 4 +- rrf3.x/macros/Dock3 | 4 +- rrf3.x/macros/Dock4 | 3 - rrf3.x/sys/home_positions | 4 ++ rrf3.x/sys/make_pre_post_free.py | 118 +++++++++++++++++++++++++++++++ rrf3.x/sys/tfree0.g | 16 ++--- rrf3.x/sys/tfree1.g | 15 ++-- rrf3.x/sys/tfree2.g | 17 ++--- rrf3.x/sys/tfree3.g | 15 ++-- rrf3.x/sys/tpost0.g | 7 +- rrf3.x/sys/tpost1.g | 7 +- rrf3.x/sys/tpost2.g | 7 +- rrf3.x/sys/tpost3.g | 7 +- rrf3.x/sys/tpre0.g | 40 +++++------ rrf3.x/sys/tpre1.g | 40 ++++++----- rrf3.x/sys/tpre2.g | 40 ++++++----- rrf3.x/sys/tpre3.g | 41 +++++------ 19 files changed, 256 insertions(+), 136 deletions(-) create mode 100644 rrf3.x/macros/Dock0 delete mode 100644 rrf3.x/macros/Dock4 create mode 100644 rrf3.x/sys/home_positions create mode 100755 rrf3.x/sys/make_pre_post_free.py diff --git a/rrf3.x/macros/Dock0 b/rrf3.x/macros/Dock0 new file mode 100644 index 0000000..0e24615 --- /dev/null +++ b/rrf3.x/macros/Dock0 @@ -0,0 +1,3 @@ +G1 Y 180 F5000 +G1 X -12.2 Y 180 F5000 +G1 X -12.2 Y 227.4 F5000 diff --git a/rrf3.x/macros/Dock1 b/rrf3.x/macros/Dock1 index 0e24615..0c600c7 100644 --- a/rrf3.x/macros/Dock1 +++ b/rrf3.x/macros/Dock1 @@ -1,3 +1,3 @@ G1 Y 180 F5000 -G1 X -12.2 Y 180 F5000 -G1 X -12.2 Y 227.4 F5000 +G1 X 77.8 Y 180 F5000 +G1 X 77.8 Y 227.4 F5000 diff --git a/rrf3.x/macros/Dock2 b/rrf3.x/macros/Dock2 index 211d480..fe163d6 100644 --- a/rrf3.x/macros/Dock2 +++ b/rrf3.x/macros/Dock2 @@ -1,3 +1,3 @@ G1 Y 180 F5000 -G1 X 77.2 Y 180 F5000 -G1 X 77.2 Y 227.4 F5000 +G1 X 211.8 Y 180 F5000 +G1 X 211.8 Y 226.9 F5000 diff --git a/rrf3.x/macros/Dock3 b/rrf3.x/macros/Dock3 index ef03cce..4c17f75 100644 --- a/rrf3.x/macros/Dock3 +++ b/rrf3.x/macros/Dock3 @@ -1,3 +1,3 @@ G1 Y 180 F5000 -G1 X 211.4 Y 180 F5000 -G1 X 211.4 Y 227.4 F5000 +G1 X 301.8 Y 180 F5000 +G1 X 301.8 Y 227.4 F5000 diff --git a/rrf3.x/macros/Dock4 b/rrf3.x/macros/Dock4 deleted file mode 100644 index e5c82a9..0000000 --- a/rrf3.x/macros/Dock4 +++ /dev/null @@ -1,3 +0,0 @@ -G1 Y 180 F5000 -G1 X 301.5 Y 180 F5000 -G1 X 301.5 Y 227.4 F5000 diff --git a/rrf3.x/sys/home_positions b/rrf3.x/sys/home_positions new file mode 100644 index 0000000..bdbe6f9 --- /dev/null +++ b/rrf3.x/sys/home_positions @@ -0,0 +1,4 @@ +0: X -12.2 Y 227.4 +1: X 77.8 Y 227.4 +2: X 211.8 Y 226.9 +3: X 301.8 Y 227.4 diff --git a/rrf3.x/sys/make_pre_post_free.py b/rrf3.x/sys/make_pre_post_free.py new file mode 100755 index 0000000..d85f66e --- /dev/null +++ b/rrf3.x/sys/make_pre_post_free.py @@ -0,0 +1,118 @@ +#!/usr/bin/python3 + +import re +import os + +PRE = """; %(filename)s +; called before tool %(tool)d is selected + +G91 +G1 Z10 F1000 ; Drop the bed +G90 + +; Move in +M98 P"/macros/Coupler - Unlock" +G1 Y%(y_safe)0.1f F20000 ; at safe Y distance +G1 X%(x_final)0.1f Y%(y_safe)0.1f F20000 ; X location at safe Y distance +G1 X%(x_final)0.1f Y%(y_near)0.1f F20000 +G1 X%(x_final)0.1f Y%(y_final)0.1f F4000 ; X location at final Y distance +M98 P"/macros/Coupler - Lock" + +; # # # ###### # # ### # # ##### ; +; # # # # # # # ## # # ## # # # ; +; # # # # # # # # # # # # # # # ; +; # # # # # ###### # # # # # # # # #### ; +; # # # ####### # # # # # # # # # # # ; +; # # # # # # # # ## # # ## # # ; +; ## ## # # # # # # ### # # ##### ; +;if you are using non-standard length hotends ensure the bed is +;lowered enough BEFORE undocking the tool! + +; Move out +G1 X%(x_final)0.1f Y%(y_work)0.1f F4000 ; Tool in active position +""" + +POST = """; %(filename)s +; called after tool %(tool)d has been selected + +M116 P%(tool)d ; heatup + + +;prime nozzle +;M98 P"prime.g" + +M106 R1 ; restore print cooling fan speed +""" + +FREE = """; %(filename)s +; called when tool %(tool)d is freed + +G91 +G1 Z4 F1000 ; Drop the bed +G90 + +;Purge nozzle +;M98 P"purge.g" + +;Move In +G53 G1 X%(x_final)0.1f Y%(y_work)0.1f F20000 ; X location at work Y distance +G53 G1 X%(x_final)0.1f Y%(y_safe)0.1f F20000 +G53 G1 X%(x_final)0.1f Y%(y_near)0.1f F20000 +G53 G1 X%(x_final)0.1f Y%(y_final)0.1f F2000 ; X location at final Y distance +M98 P"/macros/Coupler - Unlock" + +;fan off +M106 P%(fan)d S0 + +;Move Out +G53 G1 X%(x_final)0.1f Y%(y_safe)0.1f F20000 ; X location at safe Y distance +""" + +class Home: + + def __init__(self, line): + m = re.match('^([0-9]+)\s*:\s*X\s*([-0-9.]+)\s*Y\s*([-0-9.]+)\s*$', + line) + if m: + self.tool = int(m.group(1)) + self.x = float(m.group(2)) + self.y = float(m.group(3)) + pass + + def __repr__(self): + return 'Home(%d, %f, %f)' % (self.tool, self.x, self.y) + +if __name__ == '__main__': + home = {} + for h in [Home(l) for l in open('home_positions')]: + home[h.tool] = h + pass + for i in range(3): + # Expected if all tools the same: + # 90.0 0.0 + # 135.0 0.0 + # 90.0 0.0 + print(home[i+1].x - home[i].x, home[i+1].y - home[i].y) + pass + for i in range(4): + for path,template in (('tpre%d.g' % i, PRE), + ('tpost%d.g' % i, POST), + ('tfree%d.g' % i, FREE)): + with open(path, 'w') as f: + print(path) + print(template % + dict( + filename=os.path.basename(path), + tool=i, + fan=2+i*2, + x_final=home[i].x, + y_final=home[i].y, + y_safe=home[i].y-50, + y_near=home[i].y-15, + y_work=home[i].y-75 + ), + file=f) + pass + pass + pass + pass diff --git a/rrf3.x/sys/tfree0.g b/rrf3.x/sys/tfree0.g index 2939d2d..468fb1a 100644 --- a/rrf3.x/sys/tfree0.g +++ b/rrf3.x/sys/tfree0.g @@ -1,25 +1,23 @@ ; tfree0.g ; called when tool 0 is freed -;Drop the bed G91 -G1 Z4 F1000 +G1 Z4 F1000 ; Drop the bed G90 ;Purge nozzle ;M98 P"purge.g" ;Move In -G53 G1 X-10.5 Y150 F50000 -G53 G1 X-10.5 Y200 F50000 -G53 G1 X-10.5 Y220 F50000 -G53 G1 X-10.5 Y242 F5000 - -;Open Coupler +G53 G1 X-12.2 Y152.4 F20000 ; X location at work Y distance +G53 G1 X-12.2 Y177.4 F20000 +G53 G1 X-12.2 Y212.4 F20000 +G53 G1 X-12.2 Y227.4 F2000 ; X location at final Y distance M98 P"/macros/Coupler - Unlock" ;fan off M106 P2 S0 ;Move Out -G53 G1 X-10.5 Y175 F50000 +G53 G1 X-12.2 Y177.4 F20000 ; X location at safe Y distance + diff --git a/rrf3.x/sys/tfree1.g b/rrf3.x/sys/tfree1.g index cb2037b..abb383b 100644 --- a/rrf3.x/sys/tfree1.g +++ b/rrf3.x/sys/tfree1.g @@ -1,26 +1,23 @@ ; tfree1.g ; called when tool 1 is freed -;Drop the bed G91 -G1 Z4 F1000 +G1 Z4 F1000 ; Drop the bed G90 ;Purge nozzle ;M98 P"purge.g" ;Move In -G53 G1 X79.5 Y150 F50000 -G53 G1 X79.5 Y200 F50000 -G53 G1 X79.5 Y220 F50000 -G53 G1 X79.5 Y242 F5000 - -;Open Coupler +G53 G1 X77.8 Y152.4 F20000 ; X location at work Y distance +G53 G1 X77.8 Y177.4 F20000 +G53 G1 X77.8 Y212.4 F20000 +G53 G1 X77.8 Y227.4 F2000 ; X location at final Y distance M98 P"/macros/Coupler - Unlock" ;fan off M106 P4 S0 ;Move Out -G53 G1 X79.5 Y175 F50000 +G53 G1 X77.8 Y177.4 F20000 ; X location at safe Y distance diff --git a/rrf3.x/sys/tfree2.g b/rrf3.x/sys/tfree2.g index 588f0d5..c76561b 100644 --- a/rrf3.x/sys/tfree2.g +++ b/rrf3.x/sys/tfree2.g @@ -1,26 +1,23 @@ ; tfree2.g ; called when tool 2 is freed -;Drop the bed G91 -G1 Z4 F1000 +G1 Z4 F1000 ; Drop the bed G90 ;Purge nozzle ;M98 P"purge.g" ;Move In -G53 G1 X214.5 Y150 F50000 -G53 G1 X214.5 Y200 F50000 -G53 G1 X214.5 Y220 F50000 -G53 G1 X214.5 Y243 F5000 - -;Open Coupler -M98 P/macros/Coupler - Unlock +G53 G1 X211.8 Y151.9 F20000 ; X location at work Y distance +G53 G1 X211.8 Y176.9 F20000 +G53 G1 X211.8 Y211.9 F20000 +G53 G1 X211.8 Y226.9 F2000 ; X location at final Y distance +M98 P"/macros/Coupler - Unlock" ;fan off M106 P6 S0 ;Move Out -G53 G1 X214.5 Y175 F50000 +G53 G1 X211.8 Y176.9 F20000 ; X location at safe Y distance diff --git a/rrf3.x/sys/tfree3.g b/rrf3.x/sys/tfree3.g index b951dbe..731274e 100644 --- a/rrf3.x/sys/tfree3.g +++ b/rrf3.x/sys/tfree3.g @@ -1,26 +1,23 @@ ; tfree3.g ; called when tool 3 is freed -;Drop the bed G91 -G1 Z4 F1000 +G1 Z4 F1000 ; Drop the bed G90 ;Purge nozzle ;M98 P"purge.g" ;Move In -G53 G1 X304.5 Y150 F50000 -G53 G1 X304.5 Y200 F50000 -G53 G1 X304.5 Y220 F50000 -G53 G1 X304.5 Y243 F5000 - -;Open Coupler +G53 G1 X301.8 Y152.4 F20000 ; X location at work Y distance +G53 G1 X301.8 Y177.4 F20000 +G53 G1 X301.8 Y212.4 F20000 +G53 G1 X301.8 Y227.4 F2000 ; X location at final Y distance M98 P"/macros/Coupler - Unlock" ;fan off M106 P8 S0 ;Move Out -G53 G1 X304.5 Y175 F50000 +G53 G1 X301.8 Y177.4 F20000 ; X location at safe Y distance diff --git a/rrf3.x/sys/tpost0.g b/rrf3.x/sys/tpost0.g index a1a9888..289852c 100644 --- a/rrf3.x/sys/tpost0.g +++ b/rrf3.x/sys/tpost0.g @@ -1,10 +1,11 @@ ; tpost0.g ; called after tool 0 has been selected -;heatup -M116 P0 +M116 P0 ; heatup + ;prime nozzle ;M98 P"prime.g" -M106 R1 ; restore print cooling fan speed \ No newline at end of file +M106 R1 ; restore print cooling fan speed + diff --git a/rrf3.x/sys/tpost1.g b/rrf3.x/sys/tpost1.g index 6986d1f..5173c35 100644 --- a/rrf3.x/sys/tpost1.g +++ b/rrf3.x/sys/tpost1.g @@ -1,10 +1,11 @@ ; tpost1.g ; called after tool 1 has been selected -;heatup -M116 P1 +M116 P1 ; heatup + ;prime nozzle ;M98 P"prime.g" -M106 R1 ; restore print cooling fan speed \ No newline at end of file +M106 R1 ; restore print cooling fan speed + diff --git a/rrf3.x/sys/tpost2.g b/rrf3.x/sys/tpost2.g index d363043..29c52f0 100644 --- a/rrf3.x/sys/tpost2.g +++ b/rrf3.x/sys/tpost2.g @@ -1,10 +1,11 @@ ; tpost2.g ; called after tool 2 has been selected -;heatup -M116 P2 +M116 P2 ; heatup + ;prime nozzle ;M98 P"prime.g" -M106 R1 ; restore print cooling fan speed \ No newline at end of file +M106 R1 ; restore print cooling fan speed + diff --git a/rrf3.x/sys/tpost3.g b/rrf3.x/sys/tpost3.g index 4518723..f3e461d 100644 --- a/rrf3.x/sys/tpost3.g +++ b/rrf3.x/sys/tpost3.g @@ -1,10 +1,11 @@ ; tpost3.g ; called after tool 3 has been selected -;heatup -M116 P3 +M116 P3 ; heatup + ;prime nozzle ;M98 P"prime.g" -M106 R1 ; restore print cooling fan speed \ No newline at end of file +M106 R1 ; restore print cooling fan speed + diff --git a/rrf3.x/sys/tpre0.g b/rrf3.x/sys/tpre0.g index ddcc060..01b068e 100644 --- a/rrf3.x/sys/tpre0.g +++ b/rrf3.x/sys/tpre0.g @@ -1,28 +1,28 @@ ; tpre0.g ; called before tool 0 is selected -;Unlock Coupler -M98 P"/macros/Coupler - Unlock" - -;Move to location -G1 X-10.5 Y200 F50000 - -;Move in -G1 X-10.5 Y230 F50000 - -;Collect -G1 X-10.5 Y242 F2500 - -;Close Coupler -M98 P"/macros/Coupler - Lock" - -;WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! -;if you are using non-standard length hotends ensure the bed is lowered enough BEFORE undocking the tool! G91 -G1 Z10 F1000 +G1 Z10 F1000 ; Drop the bed G90 -;Move Out -G1 X-10.5 Y150 F4000 +; Move in +M98 P"/macros/Coupler - Unlock" +G1 Y177.4 F20000 ; at safe Y distance +G1 X-12.2 Y177.4 F20000 ; X location at safe Y distance +G1 X-12.2 Y212.4 F20000 +G1 X-12.2 Y227.4 F4000 ; X location at final Y distance +M98 P"/macros/Coupler - Lock" +; # # # ###### # # ### # # ##### ; +; # # # # # # # ## # # ## # # # ; +; # # # # # # # # # # # # # # # ; +; # # # # # ###### # # # # # # # # #### ; +; # # # ####### # # # # # # # # # # # ; +; # # # # # # # # ## # # ## # # ; +; ## ## # # # # # # ### # # ##### ; +;if you are using non-standard length hotends ensure the bed is +;lowered enough BEFORE undocking the tool! + +; Move out +G1 X-12.2 Y152.4 F4000 ; Tool in active position diff --git a/rrf3.x/sys/tpre1.g b/rrf3.x/sys/tpre1.g index ec74f96..d28f82e 100644 --- a/rrf3.x/sys/tpre1.g +++ b/rrf3.x/sys/tpre1.g @@ -1,26 +1,28 @@ ; tpre1.g ; called before tool 1 is selected -;Unlock Coupler -M98 P"/macros/Coupler - Unlock" - -;Move to location -G1 X79.5 Y200 F50000 - -;Move in -G1 X79.5 Y230 F50000 - -;Collect -G1 X79.5 Y242 F2500 +G91 +G1 Z10 F1000 ; Drop the bed +G90 -;Close Coupler +; Move in +M98 P"/macros/Coupler - Unlock" +G1 Y177.4 F20000 ; at safe Y distance +G1 X77.8 Y177.4 F20000 ; X location at safe Y distance +G1 X77.8 Y212.4 F20000 +G1 X77.8 Y227.4 F4000 ; X location at final Y distance M98 P"/macros/Coupler - Lock" -;WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! -;if you are using non-standard length hotends ensure the bed is lowered enough BEFORE undocking the tool! -G91 -G1 Z10 F1000 -G90 +; # # # ###### # # ### # # ##### ; +; # # # # # # # ## # # ## # # # ; +; # # # # # # # # # # # # # # # ; +; # # # # # ###### # # # # # # # # #### ; +; # # # ####### # # # # # # # # # # # ; +; # # # # # # # # ## # # ## # # ; +; ## ## # # # # # # ### # # ##### ; +;if you are using non-standard length hotends ensure the bed is +;lowered enough BEFORE undocking the tool! + +; Move out +G1 X77.8 Y152.4 F4000 ; Tool in active position -;Move Out -G1 X79.5 Y150 F4000 diff --git a/rrf3.x/sys/tpre2.g b/rrf3.x/sys/tpre2.g index 3318998..ad497be 100644 --- a/rrf3.x/sys/tpre2.g +++ b/rrf3.x/sys/tpre2.g @@ -1,26 +1,28 @@ ; tpre2.g ; called before tool 2 is selected -;Unlock Coupler -M98 P"/macros/Coupler - Unlock" - -;Move to location -G1 X214.5 Y200 F50000 - -;Move in -G1 X214.5 Y230 F50000 - -;Collect -G1 X214.5 Y243 F2500 +G91 +G1 Z10 F1000 ; Drop the bed +G90 -;Close Coupler +; Move in +M98 P"/macros/Coupler - Unlock" +G1 Y176.9 F20000 ; at safe Y distance +G1 X211.8 Y176.9 F20000 ; X location at safe Y distance +G1 X211.8 Y211.9 F20000 +G1 X211.8 Y226.9 F4000 ; X location at final Y distance M98 P"/macros/Coupler - Lock" -;WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! -;if you are using non-standard length hotends ensure the bed is lowered enough BEFORE undocking the tool! -G91 -G1 Z10 F1000 -G90 +; # # # ###### # # ### # # ##### ; +; # # # # # # # ## # # ## # # # ; +; # # # # # # # # # # # # # # # ; +; # # # # # ###### # # # # # # # # #### ; +; # # # ####### # # # # # # # # # # # ; +; # # # # # # # # ## # # ## # # ; +; ## ## # # # # # # ### # # ##### ; +;if you are using non-standard length hotends ensure the bed is +;lowered enough BEFORE undocking the tool! + +; Move out +G1 X211.8 Y151.9 F4000 ; Tool in active position -;Move Out -G1 X214.5 Y150 F4000 diff --git a/rrf3.x/sys/tpre3.g b/rrf3.x/sys/tpre3.g index b300f24..a5d7c7a 100644 --- a/rrf3.x/sys/tpre3.g +++ b/rrf3.x/sys/tpre3.g @@ -1,27 +1,28 @@ ; tpre3.g ; called before tool 3 is selected -;Unlock Coupler -M98 P"/macros/Coupler - Unlock" - -;Move to location -G1 X304.5 Y200 F50000 - -;Move in -G1 X304.5 Y230 F50000 - -;Collect -G1 X304.5 Y243 F2500 - -;Close Coupler -M98 P"/macros/Coupler - Lock" - -;WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! -;if you are using non-standard length hotends ensure the bed is lowered enough BEFORE undocking the tool! G91 -G1 Z10 F1000 +G1 Z10 F1000 ; Drop the bed G90 -;Move Out -G1 X304.5 Y150 F4000 +; Move in +M98 P"/macros/Coupler - Unlock" +G1 Y177.4 F20000 ; at safe Y distance +G1 X301.8 Y177.4 F20000 ; X location at safe Y distance +G1 X301.8 Y212.4 F20000 +G1 X301.8 Y227.4 F4000 ; X location at final Y distance +M98 P"/macros/Coupler - Lock" + +; # # # ###### # # ### # # ##### ; +; # # # # # # # ## # # ## # # # ; +; # # # # # # # # # # # # # # # ; +; # # # # # ###### # # # # # # # # #### ; +; # # # ####### # # # # # # # # # # # ; +; # # # # # # # # ## # # ## # # ; +; ## ## # # # # # # ### # # ##### ; +;if you are using non-standard length hotends ensure the bed is +;lowered enough BEFORE undocking the tool! + +; Move out +G1 X301.8 Y152.4 F4000 ; Tool in active position -- GitLab