Skip to content

Commit

Permalink
Gtk3 - Python 3 version
Browse files Browse the repository at this point in the history
  • Loading branch information
andypugh committed Nov 13, 2022
1 parent a2bd669 commit fcdf6e1
Show file tree
Hide file tree
Showing 13 changed files with 6,916 additions and 0 deletions.
3,057 changes: 3,057 additions & 0 deletions LatheMacro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
This folder contains a number of simulated lathe configs.

the "lathemacro" config offers a number of simple macros to perform
the most common lathe operations.

The GUI that controls the macros can be viewed by clicking the "Cycles"
tab top left of the graphical preview window.

There are two load-time options to control the tab behaviour:
1) norun will hide the action button, use this if you want to use only
a physical button (connected to gladevcp.cycle-start) to start the macros
(Strongly recommended, especially with Touchy)
2) notouch will allow keyboard editing of the spinboxes. Otherwise the
custom numeric keyboard will be shown.

An example loadrt line, as used here in the Gmoccapy demo is:

[DISPLAY]
EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -U notouch=1 -U norun=0 -u lathehandler.py -x {XID} lathemacro.ui

The window will resize slowly if you grab the corner and move the mouse
inside the window. It's not as bad as it was, but still needs work.
You may need to click the unmaximise button in the toolbar to get a
window border to be able to use the resize handles.

Notes on the keyboard:
As well as the obvious functions and unit conversions, it can be used to
enter fractions. For example if you type 1.1/2 it will automatically
update to display 1.5000 and 16.17/64 will show 16.2656.
This can be used in a limited way to halve the onscreen value eg for
entering radius instead of diameter.
However it only works for whole numbers: 100/2 will become 50 but
3.14149/2 is interpreted as 3 and 14 thousand halves so won't work.

Notes on adding your own cycles:
Create a new G-code subroutine in the same format as the existing ones.
In Glade add a new tab to the 'tabs1' notebook and give it a name matching
the new cycle.
Edit the action button (inside an eventbox) to call the new G-code sub.
Rename the action button to match the tab name and append '.action' eg
MyCycle.action

Create new artwork. I used Fusion360, the models are here:
https://a360.co/3uFPZNv
and the drawings are here:
https://a360.co/3uFPZNv
Esport the drawing page as PDF and import into the lathemacro.svg file in
Inkscape. You will need to resize. Add your own arrows and annotations.

Save the new layer in a layer named "layerN" (lower case) where N is the
tab number, starting at zero. You will need to invoke the XML editor for
this (Shift-Cmd-X on Mac)

The entry boxes are positioned relative to a 1500 x 1000 image; the
original size of the SVG. So you can hover your mouse over the image in
Inkscape to determine the coordinates.
In the in the case of on-drawing controls the coordinates are entered as
an XML comment in the Tooltip for the control in x,y format (The surface speed,
tool and coolant do not need this, they are in a fixed table)

An example:

<!--300,711->Peck distance

Make sure the comment has "use markup" selected for the tooltip.
Also ensure that the control has the "show_keyb" function allocated for
the Widget->button_press event. If you copy-paste a tab and copy-paste
extra controls this should be automatic.
_All_ your new spinboxes will need their own new Adjustment, or they will
change value when you alter the original spinbox that they are a copy of.


64 changes: 64 additions & 0 deletions boring.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
;boring

O<boring> sub

G8 ; Radius mode (easier maths)
G18 ; XZ Plane
G21 ; Metric Units
G90 ; Absolute Distance
G91.1 ; but not for arcs

M6 T#8 G43

#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

O90 IF [#9 GT 0.5]
M8
O90 ENDIF

g4p1 ; Wait to reach speed

(debug, Turning finish dia #1 start dia #14 start length #13 finish length #5 coolant #9)
O100 WHILE [#14 LT [#1 - #3]]
g0 X #14
#14=[#14 + #3]
G1 X #14
G1 Z #23 X[#14 + #24]
O101 IF [#6 GT 0]
G3 Z#5 X[#14 + #24 + #21] I#21 K#20
G1 X[#14 + #24 + #21 - #3]
O101 ELSE
G1 X[#14 + #24 - [#3 * 1.5]]
O101 ENDIF
G0 Z[#13]
O100 ENDWHILE

G0 x#1
G1 Z #23 X[#1 + #24]
O102 IF [#6 GT 0]
G3 Z#5 X[#1 + #24 + #21] I#21 K#20
G1 X[#1 + #24 + #21 - #3]
O102 ELSE
G1 X[#1 + #24 - #3]
O102 ENDIF
G0 Z #13
G0 X #1 ; For touch-off
M5 M9
G7
O<boring> endsub

M2
77 changes: 77 additions & 0 deletions chamfer.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
;chamfer

O<chamfer> sub

G8 ; Lathe radius Mode
G18 ; XZ Plane
G21 ; Metric Units
G90 ; Absolute Distance


M6 T#6 G43

#1 = [#1 / 2] ; because of radius mode

#14 = [#<_x>] (starting X)
#13 = [#<_z>] (starting Z)

G96 D1500 S#2 ; Constant Surface Speed Mode
M3
g95 F0.1 ; Feed-Per-Rev Mode

O90 IF [#12 GT 0.5]
M8
O90 ENDIF

#20 = 0
O101 if [#9 GT 0.5] ; front outside
o100 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
o100 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
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 [#11 GT 0.5] ; back outside
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 endif
M5 M9
G7
O<chamfer> endsub
m2
%
49 changes: 49 additions & 0 deletions drilling.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
;drilling

; Use T = 0 for tailstock drilling, then this just sets speed

O<drilling> SUB

G18 ; XZ Plane
G21 ; Metric Units
G90 ; Absolute Distance
G91.1 ; but not for arcs

#10 = [#2 * 1000 / [ #1 * 3.141592]]
(debug, #10)
O90 IF [#7 GT 0.5]
M8
O90 ENDIF

O100 IF [#6 LT 0.5]
G97 M3 S#10
O<drilling> RETURN
O100 ENDIF

M6 T#6 G43
G0 X0

O83 IF [#5 GT 0] ; Pecking
G17
G95 F#3 ; Feed-Per-Rev Mode
G97 M3 S#10
G98
G83 R#<_z> Q#5 Z#4
M5 M9 G18
O<drilling> RETURN
O83 ENDIF

O82 IF [1]; not pecking
G17
G95 F#3 ; Feed-Per-Rev Mode
G97 M3 S#10
G98
G82 R#<_z> P0.5 Z#4
M5 M9 G18
O82 ENDIF

O<drilling> ENDSUB

O<drilling> call [10] [100] [0.03] [0] [2] [0] [1]

M2
45 changes: 45 additions & 0 deletions facing.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
;Facing
O<facing> sub

G7 ; Lathe Diameter Mode
G18 ; XZ Plane
G21 ; Metric Units
G90 ; Absolute Distance

M6 T#7 G43

O90 IF [#8 GT 0.5]
M8
O90 ENDIF

O10 IF [#6 NE 0]
(MSG, Angled facing isn't supported yet)
O10 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
O<facing> endsub
M2
32 changes: 32 additions & 0 deletions grooving.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;grooving

O<grooving> sub

G8 ; Radius mode (easier maths)
G18 ; XZ Plane
G21 ; Metric Units
G90 ; Absolute Distance
G91.1 ; but not for arcs

M6 T#4 G43

#1 = [#1 / 2] ; because of radius mode

#14 = [#<_x>] (starting X)

G96 D1500 S#2 ; Constant Surface Speed Mode
m3 ;Start Spindle
g95 F#3 ; Feed-Per-Rev Mode

O90 IF [#5 GT 0.5]
M8
O90 ENDIF

g4p1 ; Wait to reach speed
G1 F#3 X#1
G0 X#14
M5 M9
G7
O<grooving> endsub

M2
Loading

0 comments on commit fcdf6e1

Please sign in to comment.