;Attempt to engrave scale rings based on the work done by Andy Pugh at https://forum.linuxcnc.org/20-g-code/27169-g-code-to-engrave-numbers-on-cylinders?limitstart=0
;Engraving is done in the ZC plane
;Warning, this is work in progress
#<_dia> = 50 ; scale diamter
#<_depth> = 0.2 ; engraving depth
#<_height> = 2 ; character height
#<_scale> = 1 ; unit conversion
#<_inc> = 3.6 ; angle between marks
#<_feed_soll_wert> = 20 ;
G21
F #<_feed_soll_wert>
#41 = [180 / [#<_dia> * 3.14159] * #<_height>]
#42 = #<_height>
(debug, #41 #42)
;Subroutine for engraving # 0
O0 sub
G92 C0 Z0
G0 C0 Z0 X[#<_dia> / 2 + 1]
G1 X[#<_dia> / 2 - #<_depth>]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.3333 * #41] Z[0.6667 * #42]
C[0.2357 * #41] Z[0.9024 * #42]
C[0.0000 * #41] Z[1.0000 * #42]
C[-0.2357 * #41] Z[0.9024 * #42]
C[-0.3333 * #41] Z[0.6667 * #42]
C[-0.3333 * #41] Z[0.3333 * #42]
C[0.0000* #41] Z[0.0000 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O0 endsub
;Subroutine for engraving # 1
O1 sub
G92 C0 Z0
G1 X[#<_dia> / 2 - #<_depth>]
C[0.0000 * #41] Z[1.0000 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O1 endsub
;Subroutine for engraving storke
; Oline [length]
O100 sub
G92 C0 Z0
G1 X[#<_dia> / 2 - #<_depth>]
C[0.0000 * #41] Z[1.0000 * #1]
G0 X[#<_dia> / 2 + 1]
G92.1
O100 endsub
;Subroutine for engraving # 2
O2 sub
G92 C0 Z0
G0 C[0.3333 * #41] Z[0.000 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[-.3333 * #41] Z[0.0000 * #42]
C[0.0000 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.4310 * #42]
C[0.3333 * #41] Z[0.6666 * #42]
C[0.2357 * #41] Z[0.9024 * #42]
C[0.0000 * #41] Z[1.0000 * #42]
C[-.2357 * #41] Z[0.9024 * #42]
C[-.3333 * #41] Z[0.6667 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O2 endsub
;Subroutine for engraving # 3
O3 sub
G92 C0 Z0
G0 C[-.3333 * #41] Z[0.3333 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[-.2357 * #41] Z[0.0976 * #42]
C[0.0000 * #41] Z[0.0000 * #42]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.5690 * #42]
C[0.0000 * #41] Z[0.6667 * #42]
C[0.3333 * #41] Z[1.0000 * #42]
C[-.3333 * #41] Z[1.0000 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O3 endsub
;Subroutine for engraving # 4
O4 sub
G92 C0 Z0
G0 C[0.2357 * #41] Z[0.000 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[0.2357 * #41] Z[1.0000 * #42]
C[-.3333 * #41] Z[0.3333 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O4 endsub
;Subroutine for engraving # 5
O5 sub
G92 C0 Z0
G0 C[-.3333 * #41] Z[0.3333 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[-.2357 * #41] Z[0.0976 * #42]
C[0.0000 * #41] Z[0.0000 * #42]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.5690 * #42]
C[0.0000 * #41] Z[0.6667 * #42]
C[-.3333 * #41] Z[0.6667 * #42]
C[-.3333 * #41] Z[1.0000 * #42]
C[0.3333 * #41] Z[1.0000 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O5 endsub
;Subroutine for engraving # 6
O6 sub
G92 C0 Z0
G0 C[-.3333 * #41] Z[0.0333 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia> / 2 - #<_depth>]
C[-.2357 * #41] Z[0.5690 * #42]
C[0.0000 * #41] Z[0.6667 * #42]
C[0.2357 * #41] Z[0.5690 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.0000 * #41] Z[0.0000 * #42]
C[-.2357 * #41] Z[0.0967 * #42]
C[-.3333 * #41] Z[0.3333 * #42]
C[-.2357 * #41] Z[0.9024 * #42]
C[0.0000 * #41] Z[1.0000 * #42]
C[0.2357 * #41] Z[0.9024 * #42]
G0Z [#<_dia> / 2 + 1]
G92.1
O6 endsub
;Subroutine for engraving # 7
O7 sub
G92 C0 Z0
G0 C[-.2357 * #41] Z[0.0000 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[0.3333 * #41] Z[1.0000 * #42]
C[-.3333 * #41] Z[1.0000 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O7 endsub
;Subroutine for engraving # 8
O8 sub
G92 C0 Z0
G0 C[0.2357 * #41] Z[0.5690 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia> / 2 - #<_depth>]
C[-.2357 * #41] Z[0.5690 * #42]
C[-.3333 * #41] Z[0.3333 * #42]
C[-.2357 * #41] Z[0.0976 * #42]
C[0.0000 * #41] Z[0.0000 * #42]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.5690 * #42]
C[0.3333 * #41] Z[0.6667 * #42]
C[0.2357 * #41] Z[0.9024 * #42]
C[0.0000 * #41] Z[1.0000 * #42]
C[-.2357 * #41] Z[0.9024 * #42]
C[-.3333 * #41] Z[0.6667 * #42]
C[-.2357 * #41] Z[0.5690 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O8 endsub
;Subroutine for engraving # 9
O9 sub
G92 C0 Z0
G0 C[-.3333 * #41] Z[0.3333 * #42] X[#<_dia> / 2 + 1]
G1 X[#<_dia>/2 - #<_depth>]
C[-.2357 * #41] Z[0.0976 * #42]
C[0.0000 * #41] Z[0.0000 * #42]
C[0.2357 * #41] Z[0.0976 * #42]
C[0.3333 * #41] Z[0.3333 * #42]
C[0.3333 * #41] Z[0.6667 * #42]
C[0.2367 * #41] Z[0.9024 * #42]
C[0.0000 * #41] Z[1.0000 * #42]
C[-.2357 * #41] Z[0.9024 * #42]
C[-.3333 * #41] Z[0.6667 * #42]
C[-.2357 * #41] Z[0.4310 * #42]
C[0.0000 * #41] Z[0.3333 * #42]
C[0.2357 * #41] Z[0.4310 * #42]
C[0.3333 * #41] Z[0.6667 * #42]
G0 X[#<_dia> / 2 + 1]
G92.1
O9 endsub
; Start Engraving
G92.1
#3 = 0
O500 while [#3 LT 360] ; rotate through full 360 degrees
#4 = [#3 * #<_scale>]
(DEBUG, #4)
#5 = [#3 MOD 36]
O501 if [#5 EQ 0] ; marks at 10th increment
G0 C#3 Z0 X[#<_dia> / 2 + #<_depth>]
O100 call [8] ; engrave long line
; O[FIX[#4]] call
O0 call
; G0 C#3 Z0
O501 else if [#5 EQ 18] ; marks at 5th increment
;; G0 C[#3 - #42 * 0.5] Z0 X[#<_dia> / 2 + 1]
G0 C#3 Z0 X[#<_dia> / 2 + #<_depth>]
O100 call [6] ; engrave medium line
O5 call
; O[FIX[#4 / 10]] call
; G0 C[#3 + #42 * 0.5] Z0
; O[FIX[#4 mod 10]] call
; O501 else if [[#5 MOD 1 ] GT 0 ] ; minor ticks
; G0 C[#3 - #42 ] Z0 X[#<_dia> / 2 + 1]
G0 C#3 Z0 X[#<_dia> / 2 + #<_depth>]
; O100 call [4] ; engrave short line
; O[FIX[#4 / 100]] call
; G0 C#3 Z0
; O[FIX[[#4/10] mod 10]] call
; G0 C[#3 + #42 ] Z0
; O[FIX[#4 mod 10]] call
O501 endif
#3 = [#3 + #<_inc>] ; increment loop counter
O500 endwhile
M2
No comments:
Post a Comment