G-code to engrave numbers on cylinders

More
13 years 12 hours ago - 8 years 2 months ago #40497 by andypugh
[edit 30/8/18: I added tick marks, see forum.linuxcnc.org/20-g-code/27169-g-cod...ders?start=10#116888 ]

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.



Code:
;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
Last edit: 8 years 2 months ago by andypugh.
The following user(s) said Thank You: BigJohnT, Dimitrios, biqut2, RotarySMP, jo_key, clunc, Boltonbrass

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #40509 by BigJohnT
That's pretty slick Andy.

JT

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago - 12 years 11 months ago #41130 by andypugh
The fonts are based on two octagons, and straight lines, but the results don't show it.

Last edit: 12 years 11 months ago by andypugh.
The following user(s) said Thank You: jtc, cts1085

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #55453 by Kirk_Wallace
Andy, thank you for replying to my IRC query. My setup -- 10.04, 2.5, stock sim_axis9 and stock sim.ini and your g-code above --- produces a tool that only moves in X and Z. It appears that the DROs change appropriately, but not the display. If it is convenient, could you let me know if you there are any configuration or other changes I should look at?

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #55458 by andypugh

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.

More
11 years 9 months ago #55460 by Kirk_Wallace
Crud, I tried:
[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.

Time to create page: 0.111 seconds
Powered by Kunena Forum