Skip to content

Commit 63eb5c9

Browse files
committed
Lathe Macros: Convert to GTK3, add new cycles and new artwork
Signed-off-by: andypugh <andy@bodgesoc.org>
1 parent 80d399d commit 63eb5c9

16 files changed

Lines changed: 5536 additions & 27549 deletions

configs/sim/gmoccapy/lathe_configs/LatheMacro.svg

Lines changed: 2960 additions & 2038 deletions
Loading
Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,72 @@
11
This folder contains a number of simulated lathe configs.
22

33
the "lathemacro" config offers a number of simple macros to perform
4-
the most common lathe operations.
4+
the most common lathe operations.
55

66
The GUI that controls the macros can be viewed by clicking the "Cycles"
7-
tab top left of the graphical preview window.
7+
tab top left of the graphical preview window.
8+
9+
There are two load-time options to control the tab behaviour:
10+
1) norun will hide the action button, use this if you want to use only
11+
a physical button (connected to gladevcp.cycle-start) to start the macros
12+
(Strongly recommended, especially with Touchy)
13+
2) notouch will allow keyboard editing of the spinboxes. Otherwise the
14+
custom numeric keyboard will be shown.
15+
16+
An example loadrt line, as used here in the Gmoccapy demo is:
17+
18+
[DISPLAY]
19+
EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -U notouch=1 -U norun=0 -u lathehandler.py -x {XID} lathemacro.ui
20+
21+
The window will resize slowly if you grab the corner and move the mouse
22+
inside the window. It's not as bad as it was, but still needs work.
23+
You may need to click the unmaximise button in the toolbar to get a
24+
window border to be able to use the resize handles.
25+
26+
Notes on the keyboard:
27+
As well as the obvious functions and unit conversions, it can be used to
28+
enter fractions. For example if you type 1.1/2 it will automatically
29+
update to display 1.5000 and 16.17/64 will show 16.2656.
30+
This can be used in a limited way to halve the onscreen value eg for
31+
entering radius instead of diameter.
32+
However it only works for whole numbers: 100/2 will become 50 but
33+
3.14149/2 is interpreted as 3 and 14 thousand halves so won't work.
34+
35+
Notes on adding your own cycles:
36+
Greate a new G-code subroutine in the same format as the existing ones.
37+
In Glade add a new tab to the 'tabs1' notebook and give it a name matching
38+
the new cycle.
39+
Edit the action button (inside an eventbox) to call the new G-code sub.
40+
Rename the action button to match the tab name and append '.action' eg
41+
MyCycle.action
42+
43+
Create new artwork. I used Fusion360, the models are here:
44+
https://a360.co/3uFPZNv
45+
and the drawings are here:
46+
https://a360.co/3uFPZNv
47+
Esport the drawing page as PDF and import into the lathemacro.svg file in
48+
Inkscape. You will need to resize. Add your own arrows and annotations.
49+
50+
Save the new layer in a layer named "layerN" (lower case) where N is the
51+
tab number, starting at zero. You will need to invoke the XML editor for
52+
this (Shift-Cmd-X on Mac)
53+
54+
The entry boxes are positioned relative to a 1500 x 1000 image; the
55+
original size of the SVG. So you can hover your mouse over the image in
56+
Inkscape to determine the coordinates.
57+
In the in the case of on-drawing controls the coordinates are entered as
58+
an XML comment in the Tooltip for the control in x,y format (The surface speed,
59+
tool and coolant do not need this, they are in a fixed table)
60+
61+
An example:
62+
63+
<!--300,711->Peck distance
64+
65+
Make sure the comment has "use markup" selected for the tooltip.
66+
Also ensure that the control has the "show_keyb" function allocated for
67+
the Widget->button_press event. If you copy-paste a tab and copy-paste
68+
extra controls this should be automatic.
69+
_All_ your new spinboxes will need their own new Adjustment, or they will
70+
change value when you alter the original spinbox that they are a copy of.
71+
872

configs/sim/gmoccapy/lathe_configs/boring.ngc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ M6 T#8 G43
2222
#24 = [[#23 - #13] * TAN[#7]]
2323

2424

25-
G96 D1500 S#2 ; Constant Surface Speed Mode
25+
G96 D2500 S#2 ; Constant Surface Speed Mode
2626
m3 ;Start Spindle
2727
g95 F#4 ; Feed-Per-Rev Mode
2828

29+
O90 IF [#9 GT 0.5]
30+
M8
31+
O90 ENDIF
32+
2933
g4p1 ; Wait to reach speed
3034

31-
(debug, Turning finish dia #1 start dia #14 start length #13 finish length #5)
35+
(debug, Turning finish dia #1 start dia #14 start length #13 finish length #5 coolant #9)
3236
O100 WHILE [#14 LT [#1 - #3]]
3337
g0 X #14
3438
#14=[#14 + #3]
@@ -53,7 +57,7 @@ g4p1 ; Wait to reach speed
5357
O102 ENDIF
5458
G0 Z #13
5559
G0 X #1 ; For touch-off
56-
M5
60+
M5 M9
5761
G7
5862
O<boring> endsub
5963

configs/sim/gmoccapy/lathe_configs/chamfer.ngc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ G96 D1500 S#2 ; Constant Surface Speed Mode
1919
M3
2020
g95 F0.1 ; Feed-Per-Rev Mode
2121

22+
O90 IF [#12 GT 0.5]
23+
M8
24+
O90 ENDIF
25+
2226
#20 = 0
2327
O101 if [#9 GT 0.5] ; front outside
2428
o100 while [[#20 + #3] lt #8]
@@ -66,6 +70,7 @@ O101 elseif [#11 GT 0.5] ; back outside
6670
g1 x #14
6771
g0 z#13
6872
O101 endif
73+
M5 M9
6974
G7
7075
O<chamfer> endsub
7176
m2
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
;drilling
2+
3+
; Use T = 0 for tailstock drilling, then this just sets speed
4+
5+
O<drilling> SUB
6+
7+
G18 ; XZ Plane
8+
G21 ; Metric Units
9+
G90 ; Absolute Distance
10+
G91.1 ; but not for arcs
11+
12+
#10 = [#2 * 1000 / [ #1 * 3.141592]]
13+
(debug, #10)
14+
O90 IF [#7 GT 0.5]
15+
M8
16+
O90 ENDIF
17+
18+
O100 IF [#6 LT 0.5]
19+
G97 M3 S#10
20+
O<drilling> RETURN
21+
O100 ENDIF
22+
23+
M6 T#6 G43
24+
G0 X0
25+
26+
O83 IF [#5 GT 0] ; Pecking
27+
G17
28+
G95 F#3 ; Feed-Per-Rev Mode
29+
G97 M3 S#10
30+
G98
31+
G83 R#<_z> Q#5 Z#4
32+
M5 M9 G18
33+
O<drilling> RETURN
34+
O83 ENDIF
35+
36+
O82 IF [1]; not pecking
37+
G17
38+
G95 F#3 ; Feed-Per-Rev Mode
39+
G97 M3 S#10
40+
G98
41+
G82 R#<_z> P0.5 Z#4
42+
M5 M9 G18
43+
O82 ENDIF
44+
45+
O<drilling> ENDSUB
46+
47+
O<drilling> call [10] [100] [0.03] [0] [2] [0] [1]
48+
49+
M2

configs/sim/gmoccapy/lathe_configs/facing.ngc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ G90 ; Absolute Distance
88

99
M6 T#7 G43
1010

11+
O90 IF [#8 GT 0.5]
12+
M8
13+
O90 ENDIF
14+
1115
O10 IF [#6 NE 0]
1216
(MSG, Angled facing isn't supported yet)
1317
O10 ENDIF
1418

1519
#14 = [#<_x> * 2] (starting X)
1620
#13 = #<_z> (starting Z)
1721

18-
G96 D2400 S#2 ; Constant Surface Speed Mode
22+
G96 D2500 S#2 ; Constant Surface Speed Mode
1923
M3
2024
g95 F#4 ; Feed-Per-Rev Mode
2125

@@ -36,6 +40,6 @@ g4p1 ; Wait to reach speed
3640
G0 Z[#13+#3]
3741
G0 X[#14+#3]
3842
G0 Z#5 ; For touch-off
39-
M5
43+
M5 M9
4044
O<facing> endsub
4145
M2

configs/sim/gmoccapy/lathe_configs/gmoccapy_lathe.pref

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ show_preview_on_offset = False
6868
use_keyboard_shortcuts = True
6969
dro_digits = 3
7070
toggle_readout = True
71-
tool_in_spindle = 1
71+
tool_in_spindle = 3
7272
diameter offset_axis_x = 0
7373
offset_axis_x = 0.0
7474
offset_axis_z = 0.0
7575
offset_axis_r = 50.0
7676
radius offset_axis_x = 0
7777
use_toolmeasurement = False
78+
kbd_height = 250
79+
icon_theme = None
80+
hide_tooltips = False
7881

configs/sim/gmoccapy/lathe_configs/gmoccapy_postgui.hal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ net tool-changed gmoccapy.toolchange-changed <= iocontrol.0.tool-changed
2020
net tool-prep-number gmoccapy.toolchange-number <= iocontrol.0.tool-prep-number
2121

2222
net tooloffset-x gmoccapy.tooloffset-x <= motion.tooloffset.x
23-
net tooloffset-z gmoccapy.tooloffset-z <= motion.tooloffset.z
24-
23+
net tooloffset-z gmoccapy.tooloffset-z <= motion.tooloffset.z
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;grooving
2+
3+
O<grooving> sub
4+
5+
G8 ; Radius mode (easier maths)
6+
G18 ; XZ Plane
7+
G21 ; Metric Units
8+
G90 ; Absolute Distance
9+
G91.1 ; but not for arcs
10+
11+
M6 T#4 G43
12+
13+
#1 = [#1 / 2] ; because of radius mode
14+
15+
#14 = [#<_x>] (starting X)
16+
17+
G96 D1500 S#2 ; Constant Surface Speed Mode
18+
m3 ;Start Spindle
19+
g95 F#3 ; Feed-Per-Rev Mode
20+
21+
O90 IF [#5 GT 0.5]
22+
M8
23+
O90 ENDIF
24+
25+
g4p1 ; Wait to reach speed
26+
G1 F#3 X#1
27+
G0 X#14
28+
M5 M9
29+
G7
30+
O<grooving> endsub
31+
32+
M2

configs/sim/gmoccapy/lathe_configs/lathe_macros.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ INCREMENTS = 1.000 mm, 0.100 mm, 0.010 mm, 0.001 mm
3737
EMBED_TAB_NAME = Cycles
3838
EMBED_TAB_LOCATION = ntb_preview
3939
#EMBED_TAB_LOCATION = ntb_user_tabs
40-
EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -u lathehandler.py -x {XID} lathemacro.ui
40+
EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -U notouch=1 -U norun=0 -u lathehandler.py -x {XID} lathemacro.ui
4141

4242
[FILTER]
4343
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
@@ -72,7 +72,7 @@ HALFILE = spindle_sim.hal
7272
HALFILE = simulated_home_lathe.hal
7373

7474
# Single file that is executed after the GUI has started.
75-
POSTGUI_HALFILE = gmoccapy_postgui.hal
75+
#POSTGUI_HALFILE = gmoccapy_postgui.hal
7676

7777
HALUI = halui
7878

0 commit comments

Comments
 (0)