G-code to engrave numbers on cylinders
I wrote this G-code to engrave angles on a lathe part. It might be handy for other things. It uses a sub for each digit, then computed-calls to call the right one.
;Attempt to engrave scale rings
;Engraving is done in the XA plane and in the postive direction from X =0
#<_dia> = 50 ; scale diamter
#<_depth> = 0.2 ; engraving depth
#<_height> = 2 ; character height
#<_scale> = 1 ; unit conversion
#<_inc> = 10 ; angle between marks
#<_feed> = 20
G21
F #<_feed>
#41 = [180 / [#<_dia> * 3.14159] * #<_height>]
#42 = #<_height>
(debug, #41 #42)
O0 sub
G92 A0 X0
G0 A0 X0 Z[#<_dia> / 2 + 1]
G1 Z[#<_dia> / 2 - #<_depth>]
A[0.2357 * #41] X[0.0976 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.3333 * #41] X[0.6667 * #42]
A[0.2357 * #41] X[0.9024 * #42]
A[0.0000 * #41] X[1.0000 * #42]
A[-0.2357 * #41] X[0.9024 * #42]
A[-0.3333 * #41] X[0.6667 * #42]
A[-0.3333 * #41] X[0.3333 * #42]
A[0.0000* #41] X[0.0000 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O0 endsub
O1 sub
G92 A0 X0
G1 Z[#<_dia> / 2 - #<_depth>]
A[0.0000 * #41] X[1.0000 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O1 endsub
O2 sub
G92 A0 X0
G0 A[0.3333 * #41] X[0.000 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[-.3333 * #41] X[0.0000 * #42]
A[0.0000 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.4310 * #42]
A[0.3333 * #41] X[0.6666 * #42]
A[0.2357 * #41] X[0.9024 * #42]
A[0.0000 * #41] X[1.0000 * #42]
A[-.2357 * #41] X[0.9024 * #42]
A[-.3333 * #41] X[0.6667 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O2 endsub
O3 sub
G92 A0 X0
G0 A[-.3333 * #41] X[0.3333 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[-.2357 * #41] X[0.0976 * #42]
A[0.0000 * #41] X[0.0000 * #42]
A[0.2357 * #41] X[0.0976 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.5690 * #42]
A[0.0000 * #41] X[0.6667 * #42]
A[0.3333 * #41] X[1.0000 * #42]
A[-.3333 * #41] X[1.0000 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O3 endsub
O4 sub
G92 A0 X0
G0 A[0.2357 * #41] X[0.000 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[0.2357 * #41] X[1.0000 * #42]
A[-.3333 * #41] X[0.3333 * #42]
A[0.3333 * #41] X[0.3333 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O4 endsub
O5 sub
G92 A0 X0
G0 A[-.3333 * #41] X[0.3333 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[-.2357 * #41] X[0.0976 * #42]
A[0.0000 * #41] X[0.0000 * #42]
A[0.2357 * #41] X[0.0976 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.5690 * #42]
A[0.0000 * #41] X[0.6667 * #42]
A[-.3333 * #41] X[0.6667 * #42]
A[-.3333 * #41] X[1.0000 * #42]
A[0.3333 * #41] X[1.0000 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O5 endsub
O6 sub
G92 A0 X0
G0 A[-.3333 * #41] X[0.0333 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia> / 2 - #<_depth>]
A[-.2357 * #41] X[0.5690 * #42]
A[0.0000 * #41] X[0.6667 * #42]
A[0.2357 * #41] X[0.5690 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.0976 * #42]
A[0.0000 * #41] X[0.0000 * #42]
A[-.2357 * #41] X[0.0967 * #42]
A[-.3333 * #41] X[0.3333 * #42]
A[-.2357 * #41] X[0.9024 * #42]
A[0.0000 * #41] X[1.0000 * #42]
A[0.2357 * #41] X[0.9024 * #42]
G0Z [#<_dia> / 2 + 1]
G92.1
O6 endsub
O7 sub
G92 A0 X0
G0 A[-.2357 * #41] X[0.0000 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[0.3333 * #41] X[1.0000 * #42]
A[-.3333 * #41] X[1.0000 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O7 endsub
O8 sub
G92 A0 X0
G0 A[0.2357 * #41] X[0.5690 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia> / 2 - #<_depth>]
A[-.2357 * #41] X[0.5690 * #42]
A[-.3333 * #41] X[0.3333 * #42]
A[-.2357 * #41] X[0.0976 * #42]
A[0.0000 * #41] X[0.0000 * #42]
A[0.2357 * #41] X[0.0976 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.5690 * #42]
A[0.3333 * #41] X[0.6667 * #42]
A[0.2357 * #41] X[0.9024 * #42]
A[0.0000 * #41] X[1.0000 * #42]
A[-.2357 * #41] X[0.9024 * #42]
A[-.3333 * #41] X[0.6667 * #42]
A[-.2357 * #41] X[0.5690 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O8 endsub
O9 sub
G92 A0 X0
G0 A[-.3333 * #41] X[0.3333 * #42] Z[#<_dia> / 2 + 1]
G1 Z[#<_dia>/2 - #<_depth>]
A[-.2357 * #41] X[0.0976 * #42]
A[0.0000 * #41] X[0.0000 * #42]
A[0.2357 * #41] X[0.0976 * #42]
A[0.3333 * #41] X[0.3333 * #42]
A[0.3333 * #41] X[0.6667 * #42]
A[0.2367 * #41] X[0.9024 * #42]
A[0.0000 * #41] X[1.0000 * #42]
A[-.2357 * #41] X[0.9024 * #42]
A[-.3333 * #41] X[0.6667 * #42]
A[-.2357 * #41] X[0.4310 * #42]
A[0.0000 * #41] X[0.3333 * #42]
A[0.2357 * #41] X[0.4310 * #42]
A[0.3333 * #41] X[0.6667 * #42]
G0 Z[#<_dia> / 2 + 1]
G92.1
O9 endsub
; Start Engraving
G92.1
#3 = 0
O100 while [#3 LT 360]
#4 = [#3 * #<_scale>]
(DEBUG, #4)
O101 if [#4 LT 10]
G0 A#3 X0 Z[#<_dia> / 2 + 1]
O[FIX[#4]] call
O101 else if [#4 LT 100]
G0 A[#3 - #42 * 0.5] X0 Z[#<_dia> / 2 + 1]
O[FIX[#4 / 10]] call
G0 A[#3 + #42 * 0.5] X0
O[FIX[#4 mod 10]] call
O101 else if [#4 LT 1000]
G0 A[#3 - #42 ] X0 Z[#<_dia> / 2 + 1]
O[FIX[#4 / 100]] call
G0 A#3 X0
O[FIX[[#4/10] mod 10]] call
G0 A[#3 + #42 ] X0
O[FIX[#4 mod 10]] call
O101 endif
#3 = [#3 + #<_inc>]
O100 endwhile
M2
Please Log in or Create an account to join the conversation.
JT
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Kirk_Wallace
- Offline
- Expert Boarder
- Posts: 81
- Karma: 5
- Thank you received: 7
Please Log in or Create an account to join the conversation.
Kirk_Wallace wrote: If it is convenient, could you let me know if you there are any configuration or other changes I should look at?
I just tried it in the stock sim/axis-9-axis config and it was as you describe.
I changed GEOMETRY to ABCXYZYVW and then on restart the display looked as-shown in the picture above.
Please Log in or Create an account to join the conversation.
- Kirk_Wallace
- Offline
- Expert Boarder
- Posts: 81
- Karma: 5
- Thank you received: 7
[TRAJ]
AXES = 9
COORDINATES = A B C X Y Z U V W
HOME = 0 0 0 0 0 0 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 1.0
DEFAULT_ANGULAR_VELOCITY = 45.0
POSITION_FILE = position9.txt
MAX_LINEAR_VELOCITY = 1.2
MAX_ANGULAR_VELOCITY = 90.0
No joy. (using LinuxCNC 2.6.5 on Wheezy)
Please Log in or Create an account to join the conversation.
Kirk_Wallace wrote: Crud, I tried:
[TRAJ]
AXES = 9
COORDINATES = A B C X Y Z U V W
[DISPLAY] GEOMETRY not [TRAJ] COORDINATES
Please Log in or Create an account to join the conversation.
- Kirk_Wallace
- Offline
- Expert Boarder
- Posts: 81
- Karma: 5
- Thank you received: 7
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I guess it might be possible have subs for each ASCII code, but I don't know how one would pass the strings to the G-code.
Please Log in or Create an account to join the conversation.