Sunday 11 March 2018

Engraving a cylinder with graduations to be used as machine tool / lathe dial.


Using gcmc to generate the gcode, this becomes a trivial exercise in more modern programming techniques.

feedrate(400.0mm);

sf = 10.0mm;    /* Scaling factor */
diameter = 80.0mm;      /* Scaling factor */

n = 0;

for (c=0deg; c<360deg ; c=c+3.6deg ) {
// message(">>>> ", c, " ",c%36);

 if ( ( c % 36 ) == 0deg || ( c % 36 ) == 36deg) {
 message("--- ", n);
 vl  = typeset(to_string(n), FONT_HSANS_1);
 vl = scale(vl, [sf / (2.0*pi()), sf]);
 n = n + 10;
 goto([diameter/2,-,0.0mm,-,-,c]);
 move([-,-,14.0mm,-,-,-]);

 }
 elif ( ( c % 36 ) == 18deg ) {
 message("--  ", c);
 goto([diameter/2,-,0.0mm,-,-,c]);
 move([-,-,10.0mm,-,-,-]);
 }
 elif ( ( c % 36 ) != 0deg || ( c % 36 ) != 18deg  ) {
 message("-   ", c);
 goto([diameter/2,-,0.0mm,-,-,c]);
 move([-,-,7.0mm,-,-,-]);
 }
}

Interesting site with lathe dial reductions to suit different lead screws.
http://www.modelengineeringwebsite.com/Mini_handwheel_1.html

Typical operations implemented for the mini CNC Lathe


Linux CNC forum resource with  handy macros
https://forum.linuxcnc.org/41-guis/26550-lathe-macros

Threading
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Lathe_Code

 
Engraving numbers on cylinders
https://forum.linuxcnc.org/20-g-code/27169-g-code-to-engrave-numbers-on-cylinders?limitstart=0


Mini Lathe CNC Conversion

The requirements is simple, for my Deckel and Eagle restore I need to make new dials and dial fasteners. The dial fasteners are simple and a knurled part will probably do, but I want it to look as original as possible. These are plastic rings about 80mm diameter with formed surface resembling a toothed drive belt pulley. I need to make four of these, setup in the dividing head and mill all of them at once, then slice them up and cut the internal thread, was my initial thinking. 

But wait I have a ball screw, steppers and a  mini lathe, a small 7 x10 branded  Rotwerk.

This seemed like the ideal opportunity to finally convert the little lathe to CNC.

I need a fourth axis. So the spindle has to double as A Axis. This was done with big 120tooth HTD 3M pulley which is attached directly on the spindle.

Converting the Z axis or bed slide was simple, just replace the lead screw with the ball screw and stepper mount.

The A Axis is a bit more challenging, but also a fairly quick job.

Next configuring Linux CNC, wiring the parallel port and stepper drivers. all this was accomplished in less than two hours.

I will post some pictures shortly.

G-code for engraving 0 to 360 degrees on a cylinder


; Main routine for engraving 0 to 360 degrees on a cylinder
; Based on work done by Andy Pough, transposed to C and Z axis for my mini lathe conversion
; Subroutines not included as they are the same as in my previous post

 O100 while [#3 LT 360]
 #4 = [#3 * #<_scale>]
(DEBUG, #4)
 O101 if [#4 LT 10]
        G0 C#3 Z0 X[#<_dia> / 2 + 1]
        O[FIX[#4]] call
 O101 else if [#4 LT 100]
        G0 C[#3 - #42 * 0.5] Z0 X[#<_dia> / 2 + 1]
        O[FIX[#4 / 10]] call
        G0 C[#3 + #42 * 0.5] Z0
        O[FIX[#4 mod 10]] call
 O101 else if [#4 LT 1000]
        G0 C[#3 - #42 ] Z0 X[#<_dia> / 2 + 1]
        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
 O101 endif

 #3 = [#3 + #<_inc>]
 O100 endwhile

G-Code for Lathe Dial Rings 100 Increments

;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

Chipmaster Gear Cutting

  Calculate all the possible gear combinations for the gear selector to cut a 15TPI thread: Imperial TPI C 5 24 20 Imperial TPI ...