Commit c5033fb0 authored by electrolab's avatar electrolab

continuing lathemacro

parent ad7cbb8c
......@@ -14,7 +14,7 @@
viewBox="0 0 888 686.00002"
height="686"
width="888"
inkscape:version="0.92.0 r15299"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="LatheMacro.svg">
<sodipodi:namedview
pagecolor="#ffffff"
......@@ -25,17 +25,17 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3440"
inkscape:window-height="1377"
inkscape:window-width="2560"
inkscape:window-height="1387"
id="namedview4713"
showgrid="false"
inkscape:zoom="2"
inkscape:cx="610.67797"
inkscape:cy="326.46346"
inkscape:cx="505.99024"
inkscape:cy="326.30433"
inkscape:window-x="1912"
inkscape:window-y="244"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g6995-7" />
inkscape:current-layer="layer1" />
<defs
id="defs3816">
<marker
......@@ -1775,7 +1775,7 @@
sodipodi:role="line"
id="tspan4424"
x="618.78241"
y="496.31708">Diamater</tspan></text>
y="496.31708">Diameter</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:26.66666603px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
......@@ -2681,7 +2681,7 @@
sodipodi:role="line"
id="tspan5347"
x="653.28717"
y="545.14081" /></text>
y="544.03821" /></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:26.66666603px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
......@@ -2815,22 +2815,6 @@
id="path6185"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
x="673.80573"
y="197.13933"
id="text4856"><tspan
sodipodi:role="line"
id="tspan4854"
x="673.80573"
y="197.13933">Zero</tspan></text>
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:1.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker24532-8-2)"
d="m 716.41532,210.71995 c -14.85759,-9.27147 -28.71078,38.81002 -78.13131,10.02162"
id="path4595-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
......@@ -2851,7 +2835,7 @@
sodipodi:role="line"
id="tspan4883"
x="460.74036"
y="585.67712" /></text>
y="584.57452" /></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:26.66666603px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
......@@ -2883,20 +2867,6 @@
x="277.9584"
y="589.41583">Feed</tspan></text>
</g>
<rect
id="rect4768"
width="150.5"
height="46"
x="662.5"
y="156"
style="fill:#000000;fill-opacity:0" />
<rect
style="fill:#848488;fill-opacity:1"
id="rect4770"
width="114"
height="66.5"
x="668.5"
y="137.5" />
</g>
</g>
<text
......
;boring
O<boring> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G8 ; Lathe radius Mode
G90 ; Absolute Distance
G91.1 ; but not for arcs
; #1 X coord
; #2 surface speed
; #3 cut size
; #4 feed/rpm
; #5 Z coord
; #6 radius
; #7 angle
; #8 tool number
; #9 coolant
O10 if [#9 EQ 1]
M8
O10 endif
;M6 T#8 G43
O100 if [#8 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#1 = [#1 / 2] ; because of radius mode
#14 = [#<_x>] (startinG X)
#13 = #<_z> (startinG Z)
#20 = [#6 * SIN[#7]]
#21 = [-#6 * COS[#7]]
#22 = [#6 / COS[#7]]
#23 = [#5 + #6 - #20]
#24 = [[#23 - #13] * TAN[#7]]
G96 D2500 S#2 ; Constant Surface Speed Mode
M3 ;Start Spindle
G95 F#4 ; Feed-Per-Rev Mode
G4P1 ; Wait to reach speed
(debuG, TurninG finish dia #1 start dia #14 start lenGth #13 finish lenGth #5)
O101 WHILE [#14 LT [#1 - #3]]
G0 X #14
#14=[#14 + #3]
G1 X #14
G1 Z #23 X[#14 + #24]
o102 IF [#6 GT 0]
G3 Z#5 X[#14 + #24 + #21] I#21 K#20
G1 X[#14 + #24 + #21 - #3]
o102 ELSE
G1 X[#14 + #24 - [#3 * 1.5]]
o102 ENDIF
G0 Z[#13]
O101 ENDWHILE
G0 X#1
G1 Z#23 X[#1 + #24]
O103 IF [#6 GT 0]
G3 Z#5 X[#1 + #24 + #21] I#21 K#20
G1 X[#1 + #24 + #21 - #3]
O103 ELSE
G1 X[#1 + #24 - #3]
O103 ENDIF
G0 Z#13
G0 X#1 ; For touch-off
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<boring> endsub
M2
%
;chamfer
O<chamfer> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G8 ; Lathe radius Mode
G90 ; Absolute Distance
; #1 X coord
; #2 feed/rpm
; #3 0.5 ?
; #4 0 ?
; #5 Z coord
; #6 tool number
; #7 0 ?
; #8 chamfer size
; #9 exterior front
; #10 interior
; #11 exterior rear
; #12 coolant
O10 if [#12 EQ 1]
M8
O10 endif
;M6 T#6 G43
O100 if [#6 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#1 = [#1 / 2] ; because of radius mode
#14 = [#<_x>] (starting X)
#13 = [#<_z>] (starting Z)
G96 D2500 S#2 ; Constant Surface Speed Mode
M3
G95 F0.1 ; Feed-Per-Rev Mode
#20 = 0
O101 if [#9 GT 0.5] ; front outside
o102 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 - #20] z#13
G1 z#5
G1 x#1 z[#5 - #20]
G1 x #14
G0 z#13
o102 endwhile
G0 x#14 z#13
G0 x[#1 - #8]
G1 z#5
G1 x#1 z[#5 - #8]
G1 x #14
G0 z#13
O101 elseif [#10 GT 0.5] ; front inside
o103 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 + #20] z#13
G1 z#5
G1 x#1 z[#5 - #20]
G1 x #14
G0 z#13
o103 endwhile
G0 x#14 z#13
G0 x[#1 + #8]
G1 z#5
G1 x#1 z[#5 - #8]
G1 x #14
G0 z#13
O101 elseif [#11 GT 0.5] ; back outside
o104 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 - #20] z#13
G1 z#5
G1 x#1 z[#5 + #20]
G1 x #14
G0 z#13
o104 endwhile
G0 x#14 z#13
G0 x[#1 - #8]
G1 z#5
G1 x#1 z[#5 + #8]
G1 x #14
G0 z#13
O101 endif
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<chamfer> endsub
M2
%
;drill
O<drill> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G7 ; diameter mode
G90 ; Absolute Distance
; #1 drill diameter
; #2 ydepth
; #3 speed
; #4 feed/rpm
; #5 tool number
; #6 peck amount
; #7 retract amount
; #8 coolant
O10 if [#8 EQ 1]
M8
O10 endif
#9 = #<_y> (starting Y)
;M6 T#5 G43
O100 if [#5 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#7 = [[1000 * #3] / [3.1415 * #1]] ; metric mode RPM
G97 S#7 ; Constant RPM mode
M3 ;Start Spindle
G95 F#4 ; Feed-Per-Rev Mode
G4 P1 ; Wait to reach speed
(debug, Drilling dia #1 depth #2 asked-speed #3 feed/rpm #4 tool #5 peck dist #6 calculated-rpm #7 start-Y #9)
(MSG, ERROR : TODO must retract the X axis to home position)
; G0 X0 ; TODO must retract the X axis to home position
;G0 Y#9
G98
G83 Y#2 R#9 Q#6
G80
;G0 Y#9
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<drill> endsub
M2
%
;Facing
O<facing> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G7 ; diameter mode
G90 ; Absolute Distance
; #1 X coord
; #2 surface speed
; #3 cut size
; #4 feed/rpm
; #5 Z coord
; #6 angles
; #7 tool number
; #8 coolant
O10 if [#8 EQ 1]
M8
O10 endif
O20 IF [#6 NE 0]
(MSG, Angled facing isn't supported yet)
O20 ENDIF
;M6 T#7 G43
O100 if [#7 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#14 = [#<_x> * 2] (starting X)
#13 = #<_z> (starting Z)
G96 D2500 S#2 ; Constant Surface Speed Mode
M3
G95 F#4 ; Feed-Per-Rev Mode
G4P1 ; Wait to reach speed
O200 WHILE [#13 GT #5 + #3]
#13=[#13-#3]
G1 Z#13
G1 X#1
G0 Z[#13+#3]
G0 X#14
G0 Z#13
O200 ENDWHILE
G1 Z#5
G1 X#1
G0 Z[#13+#3]
G0 X[#14+#3]
G0 Z#5 ; For touch-off
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<facing> endsub
M2
%
;radius
O<radius> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G7 ; diameter mode
G90 ; Absolute Distance
; #1 X coord
; #2 feed/rpm
; #3 0.5 ?
; #4 0 ?
; #5 Z coord
; #6 tool number
; #7 0 ?
; #8 radius size
; #9 exterior front
; #10 interior
; #11 exterior rear
; #12 coolant
O10 if [#12 EQ 1]
M8
O10 endif
;M6 T#6 G43
O100 if [#6 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#1 = [#1 / 2] ; because of radius mode
#14 = [#<_x>] (starting X)
#13 = [#<_z>] (starting Z)
G96 D2500 S#2 ; Constant Surface Speed Mode
M3
G95 F0.1 ; Feed-Per-Rev Mode
G4P1 ; Wait to reach speed
#20 = 0
O101 if [#9 GT 0.5] ; Front outside
o102 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 - #20] z#13
G1 z#5
G3 x#1 z[#5 - #20] K[-#20]
G1 x #14
G0 z#13
o102 endwhile
G0 x#14 z#13
G0 x[#1 - #8]
G1 z#5
G3 x#1 z[#5 - #8] K[-#8]
G1 x #14
G0 z#13
O101 elseif [#10 GT 0.5] ; front inside
o103 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 + #20] z#13
G1 z#5
G2 x#1 z[#5 - #20] K[-#20]
G1 x #14
G0 z#13
o103 endwhile
G0 x#14 z#13
G0 x[#1 + #8]
G1 z#5
G2 x#1 z[#5 - #8] K[-#8]
G1 x #14
G0 z#13
O101 elseif [#11 GT 0.5] ; back outside
o104 while [[#20 + #3] lt #8]
#20 = [#20 + #3]
G0 x[#1 - #20] z#13
G1 z#5
G2 x#1 z[#5 + #20] K#20
G1 x #14
G0 z#13
o104 endwhile
G0 x#14 z#13
G0 x[#1 - #8]
G1 z#5
G2 x#1 z[#5 + #8] K#8
G1 x #14
G0 z#13
O101 endif
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<radius> endsub
M2
%
; restore metric/inch absolute/relative, feed as per paramter values
; call as 'O<restore> call [originalmetric] [originalabs] [originalfeed] [originalcomp]
;
;[#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
;
O<restore> sub
O100 if [#1 NE #<_metric>]
O200 if [#1]
G21
O200 else
G20
O200 endif
O100 endif
O300 if [#2 NE #<_absolute>]
O400 if [#2]
G90
O400 else
G91
O400 endif
O300 endif
O500 if [#3 NE #<_feed>]
F[#3]
O500 endif
O600 if [#4 NE #<_ccomp>]
O601 if [#4 EQ 400]
G40
O601 endif
O602 if [#4 EQ 411]
G41.1
O602 endif
O603 if [#4 EQ 420]
G42
O603 endif
O604 if [#4 EQ 421]
G42.1
O604 endif
O600 endif
O700 if [#5 NE #<_coord_system>]
O701 if [#5 EQ 540]
G54
O701 endif
O702 if [#5 EQ 550]
G55
O702 endif
O703 if [#5 EQ 560]
G56
O703 endif
O704 if [#5 EQ 570]
G57
O704 endif
O705 if [#5 EQ 580]
G58
O705 endif
O706 if [#5 EQ 590]
G59
O706 endif
O707 if [#5 EQ 591]
G59.1
O707 endif
O708 if [#5 EQ 592]
G59.2
O708 endif
O709 if [#5 EQ 593]
G59.3
O709 endif
O700 endif
O800 if [#6 NE #<_lathe_diameter_mode>]
O801 if [#6]
G7
O801 else
G8
O801 endif
O800 endif
O900 if [#7 NE #<_ijk_absolute_mode>]
O901 if [#7]
G90.1
O901 else
G91.1
O901 endif
O900 endif
O<restore> endsub
M2
;threading
O<threading> sub
; #1=thread.x, #2=thread.sf, #3=thread.tool-s, #4=thread.pitch-f, #5=thread.z-f, #6=thread.internal #7=thread.external
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G8 ; Lathe radius Mode
G90 ; Absolute Distance
; #1 X coord
; #2 feed/rpm
; #3 tool number
; #4 pitch
; #5 Z coord
; #6 interior
; #7 exterior
; #8 coolant
O10 if [#8 EQ 1]
M8
O10 endif
;M6 T#3 G43
O100 if [#3 NE #<_current_tool>]
(MSG, ERROR : Set tool before use macro)
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O100 return [-2] ; indicate failure to epilog
O100 endif
#1 = [#1 / 2.0]
#14 = [#<_x> * 2] (starting X)
#13 = #<_z> (starting Z)
G96 D2500 S#2 ; Constant Surface Speed Mode
M3
G4 P1 ; Wait to reach speed
#<height> = [0.86603 * #4]
#<majorflat> = [#<height> * 0.125]
#<minorflat> = [#<height> * 0.250]
#<threaddepth> = [#<height> * 0.625]
;(debug, #40 #<majorflat> #<minorflat> #<threaddepth>)
O101 IF [#<_metric>]
#<cutdepth> = 0.2
#<flatfeed> = 0.1
O101 ELSE
#<cutdepth> = 0.007
#<flatfeed> = 0.004
O101 ENDIF
G95 F#<flatfeed> ; Feed-Per-Rev Mode
;Threading
O102 IF [#6 GT 0.5] ;internal
;cut the minor flat diameter
;(debug, INTERNAL Threading thread dia-#1 start-#13 finish-#5 Pitch-#4 Depth-#3)
G0 Z #13
G0 X [#1 + #<minorflat> - #<height>]
G1 Z #5
G0 X [#1 - #<height>]
G0 Z #13
G96 D600 S#2 ; limit RPM in threading mode
G76 P#4 Z#5 i#<minorflat> j#<cutdepth> k#<threaddepth> H3 R1.5 Q29.5 E0 L0
G0 X [#1 - 0.5]
O102 ELSE ;external
; cut the major diameter
;(debug, EXTERNAL Threading thread dia-#1 start-#13 finish-#5 Pitch-#4 Depth-#3 MF #<majorflat>)
G0 Z #13
G0 X #1
G1 X [#1 - #<majorflat>]
G1 Z #5
G0 X #1
G0 Z #13
G96 D600 S#2 ; limit RPM in threading mode
G76 P#4 Z#5 i[-#<majorflat>] j#<cutdepth> k#<threaddepth> H3 R1.5 Q29.5 E0 L0
G0 X [#1 + 0.5]
O102 ENDIF
G0 Z#13
M5
M9
; restore g20/21, g90/g91, feed
O<restore> call [#<metric>] [#<absolute>] [#<feed>] [#<ccomp>] [#<coord_system>] [#<lathe_diameter_mode>] [#<ijk_absolute_mode>]
O<threading> endsub
M2
%
;Turning
O<turning> sub
#<ccomp> = #<_ccomp>
#<metric> = #<_metric>
#<absolute> = #<_absolute>
#<feed> = #<_feed>
#<coord_system> = #<_coord_system>
#<lathe_diameter_mode> = #<_lathe_diameter_mode>
#<ijk_absolute_mode> = #<_ijk_absolute_mode>
G8 ; Lathe radius Mode
G90 ; Absolute Distance
G91.1 ; but not for arcs
; #1 X coord
; #2 surface speed
; #3 cut size
; #4 feed/rpm
; #5 Z coord
; #6 radius
; #7 angle