Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions configs/sim/axis/vismach/twinspindle/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
A mill-turn with a tilting head between two spindles, on twinspindlekins.

The head carries the tool on X Y Z and tilts it on B, about Y. The main
spindle turns its part on C; the sub spindle faces it along Z, 500 away,
and turns its own part on W. W is an angle, so [AXIS_W] declares it
TYPE = ANGULAR, and both spindles are WRAPPED_ROTARY. The vismach window
draws the spindle line across the screen as on a lathe: main spindle on
the left, Z to the right, X up.

Kinematics type 0 works on the part in the main spindle and orients the
tool with C and B; type 1 works on the part in the sub spindle and orients
it with W and B. Each part's frame has its Z out of its own spindle's face,
so a program reads the same on either part. Type 2 is the identity, the
machine frame, which G13.1 selects.

The INI sets MACHINE_MOVES_IN_MACHINE_FRAME, so G53, G28 and G30 move
the slides in that machine frame whichever spindle's type is in force.

Demo program:

twin-spindle-holes.ngc -- one subroutine drills a ring of six holes,
each tilted 20 degrees out from the part axis,
into the face of the part the kinematics type
in force works on; the program runs it on the
main spindle (G12.1 P0, G54) and then on the
sub spindle (G12.1 P1, G55). The subroutine
names no rotary: G53.3 turns the ones the type
orients with, and the report on the terminal
reads them by number, #<_kins_orient_1> and
#<_kins_orient_2>, 5 and 4 (C and B) on the
main spindle, 8 and 4 (W and B) on the sub
spindle, with their angles #<_orient_rot1> and
#<_orient_rot2>.

The tool table provides tool 1, length 50. The drawing hands its pivot
length and spindle distance to the kinematics (twinspindle.hal), so the
two agree.
67 changes: 67 additions & 0 deletions configs/sim/axis/vismach/twinspindle/twin-spindle-holes.ngc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
; twin-spindle-holes.ngc - one subroutine drills the same ring of tilted
; holes into the part in the main spindle and into the part in the sub
; spindle.
;
; configs/sim/axis/vismach/twinspindle and tests/twinspindle each keep a
; copy of this program: change both, they are the same file.
;
; Kinematics type 0 works on the main spindle's part and orients the tool
; with C and B; type 1 works on the sub spindle's part and orients it with
; W and B. The subroutine names neither: G53.3 turns whatever rotaries the
; type in force orients with, and the report reads them by number,
; #<_kins_orient_1> and #<_kins_orient_2>, with their angles in the same
; order, #<_orient_rot1> and #<_orient_rot2>. Each part's frame has its Z
; out of its own spindle, so both faces are at Z60 and the offsets read
; the same.

o<ring> sub
#<n> = 6 ; holes
#<r> = 30 ; hole circle radius on the face
#<t> = 20 ; tilt of each hole out from the part axis
#<i> = 0
o101 while [#<i> lt #<n>]
#<a> = [#<i> * 360 / #<n>]
; the hole's plane: origin on the face, X along the hole circle,
; Z the hole axis
g68.2 p3 q1 x[#<r>*cos[#<a>]] y[#<r>*sin[#<a>]] z0 i[-sin[#<a>]] j[cos[#<a>]] k0
g68.2 p3 q2 i[sin[#<t>]*cos[#<a>]] j[sin[#<t>]*sin[#<a>]] k[cos[#<t>]]
g53.2 ; solve the pose, report it
(print, hole #<i>: axis #<_kins_orient_1> to #<_orient_rot1>, axis #<_kins_orient_2> to #<_orient_rot2>)
g53.3 x0 y0 z5 ; orient and go, 5 above the hole
g1 z-10
g0 z5
#<i> = [#<i> + 1]
o101 endwhile
g0 z40
g69
o<ring> endsub

; from one part to the other in the machine frame, the identity type:
; up, clear of both parts, and the head pointing down
o<park> sub
g13.1
g53 g0 x300
g53 g0 z50 b90
o<park> endsub

g21 g90 g94 g17 g40
t1 m6
g43
f300

g10 l2 p1 x0 y0 z60 c0 w0 ; G54, the main spindle's part
g10 l2 p2 x0 y0 z60 c0 w0 ; G55, the sub spindle's part

o<park> call
g12.1 p0 ; the main spindle's part
g54
o<ring> call

o<park> call
g12.1 p1 ; the sub spindle's part
g55
o<ring> call

o<park> call
g54
m2
15 changes: 15 additions & 0 deletions configs/sim/axis/vismach/twinspindle/twinspindle.hal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
loadusr -W ./twinspindlegui.py

net jx joint.0.pos-fb twinspindlegui.jx
net jy joint.1.pos-fb twinspindlegui.jy
net jz joint.2.pos-fb twinspindlegui.jz
net jb joint.3.pos-fb twinspindlegui.jb
net jc joint.4.pos-fb twinspindlegui.jc
net jw joint.5.pos-fb twinspindlegui.jw

# the drawing and the kinematics share the geometry
net pivot-len twinspindlegui.pivot_len twinspindlekins.pivot-length
net spindle-distance twinspindlegui.spindle_distance twinspindlekins.spindle-distance

net tool-len motion.tooloffset.z twinspindlegui.tool_length
net tool-diam halui.tool.diameter twinspindlegui.tool_diam
166 changes: 166 additions & 0 deletions configs/sim/axis/vismach/twinspindle/twinspindle.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
[EMC]
VERSION = 1.1
MACHINE = Sim-twinspindlekins (XYZBCW mill-turn, two spindles)
DEBUG = 0

[DISPLAY]
# X Y Z are already the tip in the frame of the part the type works on, so
# the plot takes them as they are: a rotary in GEOMETRY would turn them
# again, and W, a translation there, would draw as a move along Z
GEOMETRY = XYZ
DISPLAY = axis
OPEN_FILE = ./twin-spindle-holes.ngc
INCREMENTS = 10 mm, 1 mm, .1 mm
JOG_AXES = XYZ
CYCLE_TIME = 0.100
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.0
PROGRAM_PREFIX = ../../nc_files/
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 2
TOOL_EDITOR = tooledit z diam

[RS274NGC]
RS274NGC_STARTUP_CODE = G17 G21 G40 G49 G54 G80 G90 G94 G97
PARAMETER_FILE = twinspindle.var
# Off the machine frame kinematics (on either spindle's type), G53, G28 and
# G30 move the slides in the machine frame, as G53.5, G28.5 and G30.5 do,
# wherever the tool and the head point, and G28.1 and G30.1 store that
# position. Unset, they move in the world of the spindle's type. See
# MACHINE_MOVES_IN_MACHINE_FRAME in the INI file documentation.
MACHINE_MOVES_IN_MACHINE_FRAME = 1

[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
SERVO_PERIOD = 1000000

[TASK]
TASK = milltask
CYCLE_TIME = 0.010

[HAL]
HALUI = halui
HALFILE = LIB:basic_sim.tcl
HALFILE = twinspindle.hal

[TRAJ]
COORDINATES = XYZBCW
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 50.0
MAX_LINEAR_VELOCITY = 200.0
MAX_LINEAR_ACCELERATION = 800.0
DEFAULT_LINEAR_ACCELERATION = 800.0
MAX_ANGULAR_VELOCITY = 360.0

[EMCIO]
TOOL_TABLE = twinspindle.tbl

[KINS]
# type 0: the part in the main spindle, C and B orient
# type 1: the part in the sub spindle, W and B orient
# type 2: identity, the machine frame
KINEMATICS = twinspindlekins
JOINTS = 6

[AXIS_X]
MIN_LIMIT = -400
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800

[AXIS_Y]
MIN_LIMIT = -300
MAX_LIMIT = 300
MAX_VELOCITY = 200
MAX_ACCELERATION = 800

[AXIS_Z]
MIN_LIMIT = -300
MAX_LIMIT = 800
MAX_VELOCITY = 200
MAX_ACCELERATION = 800

[AXIS_B]
MIN_LIMIT = -30
MAX_LIMIT = 210
MAX_VELOCITY = 90
MAX_ACCELERATION = 400

# the main spindle
[AXIS_C]
WRAPPED_ROTARY = 1
MIN_LIMIT = -1e9
MAX_LIMIT = 1e9
MAX_VELOCITY = 180
MAX_ACCELERATION = 720

# the sub spindle: an angle, so ANGULAR, however the letter reads
[AXIS_W]
TYPE = ANGULAR
WRAPPED_ROTARY = 1
MIN_LIMIT = -1e9
MAX_LIMIT = 1e9
MAX_VELOCITY = 180
MAX_ACCELERATION = 720

# the joints home to the head over the middle, pointing down at the
# spindle line, clear of both parts
[JOINT_0]
TYPE = LINEAR
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MIN_LIMIT = -400
MAX_LIMIT = 500
HOME = 300
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_1]
TYPE = LINEAR
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MIN_LIMIT = -300
MAX_LIMIT = 300
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_2]
TYPE = LINEAR
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MIN_LIMIT = -300
MAX_LIMIT = 800
HOME = 50
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_3]
TYPE = ANGULAR
MAX_VELOCITY = 90
MAX_ACCELERATION = 400
MIN_LIMIT = -30
MAX_LIMIT = 210
HOME = 90
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_4]
TYPE = ANGULAR
MAX_VELOCITY = 180
MAX_ACCELERATION = 720
MIN_LIMIT = -1e9
MAX_LIMIT = 1e9
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_5]
TYPE = ANGULAR
MAX_VELOCITY = 180
MAX_ACCELERATION = 720
MIN_LIMIT = -1e9
MAX_LIMIT = 1e9
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0
1 change: 1 addition & 0 deletions configs/sim/axis/vismach/twinspindle/twinspindle.tbl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
T1 P1 Z50 D10 ;drill
104 changes: 104 additions & 0 deletions configs/sim/axis/vismach/twinspindle/twinspindlegui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env python3
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# The twinspindlekins machine: a B tilting head on X Y Z between a main
# spindle (C) and a sub spindle (W) that face each other along Z. The model
# is built in machine coordinates and turned at the end so that Z, the
# spindle line, runs across the screen as on a lathe: main spindle on the
# left, Z to the right, X up.
#
# pivot_len and spindle_distance are handed to the kinematics by
# twinspindle.hal, so the drawing and the maths agree; they can be set at
# invocation, example: twinspindlegui.py pivot_len=200

from vismach import *
import hal
import sys

pivot_len = 150 # gauge line to the B axis
spindle_distance = 500 # main spindle face to sub spindle face
lat, lon = -80, 0 # the starting view, from the front

for setting in sys.argv[1:]:
exec(setting)

c = hal.component("twinspindlegui")
for pin in ("jx", "jy", "jz", "jb", "jc", "jw", "tool_length", "tool_diam"):
c.newpin(pin, hal.Type.REAL, hal.Dir.IN)
c.newpin("pivot_len", hal.Type.REAL, hal.Dir.OUT)
c.newpin("spindle_distance", hal.Type.REAL, hal.Dir.OUT)
c["pivot_len"] = pivot_len
c["spindle_distance"] = spindle_distance
c.ready()

class HalToolCylinder(CylinderZ):
def __init__(self, comp, *args):
CylinderZ.__init__(self, *args)
self.comp = comp

def coords(self):
r = 5 # default if hal pin not set
if c.tool_diam > 0: r = c.tool_diam/2
return -self.comp.tool_length, r, 0, r

# a chuck and a part, face at z 0, the part standing on +z; the flat on
# the part shows the spindle turning
def spindle(work=None):
part = [CylinderZ(0, 50, 60, 50),
Color([1, 0.2, 0.2, 1], [Box(40, -8, 0, 52, 8, 60)])]
if work:
part.append(Translate([work], 0, 0, 60))
return Collection([Color([0.6, 0.6, 0.7, 1], [CylinderZ(-100, 90, 0, 90)]),
Color([0.9, 0.8, 0.5, 1], part)])

# the main spindle turns the work by -C: its frame is Rz(-C)
work = Capture()
main_spindle = HalRotate([spindle(work)], c, "jc", -1, 0, 0, 1)
main_spindle = Collection([main_spindle,
Box(-160, -160, -400, 160, 160, -100)])

# the sub spindle is the same, turned by -W, then half a turn about X to
# face the main spindle from spindle_distance
sub_spindle = HalRotate([spindle()], c, "jw", -1, 0, 0, 1)
sub_spindle = Collection([sub_spindle,
Box(-160, -160, -400, 160, 160, -100)])
sub_spindle = Rotate([sub_spindle], 180, 1, 0, 0)
sub_spindle = HalTranslate([sub_spindle], c, "spindle_distance", 0, 0, 1)

# the head, gauge line at z 0: the tool below it, the spindle motor above
# up to the B axis at pivot_len, which is then put at the origin
tooltip = Capture()
head = Collection([HalTranslate([tooltip], c, "tool_length", 0, 0, -1),
Color([0.9, 0.9, 0.2, 1], [HalToolCylinder(c)]),
CylinderZ(0, 30, 40, 45),
CylinderZ(40, 45, pivot_len - 45, 45),
Translate([CylinderY(-55, 55, 55, 55)], 0, 0, pivot_len)])
head = Translate([head], 0, 0, -pivot_len)
head = HalRotate([head], c, "jb", 1, 0, 1, 0)

# the ram carries the B axis from behind, along -Y, clear of the head
# whichever way it tilts; the slides read the gauge line at B 0, pivot_len
# below the B axis
head = Collection([head,
Box(-50, -700, -50, 50, -60, 50)])
head = Translate([head], 0, 0, pivot_len)
head = HalTranslate([head], c, "jx", 1, 0, 0)
head = HalTranslate([head], c, "jy", 0, 1, 0)
head = HalTranslate([head], c, "jz", 0, 0, 1)

bed = Box(-420, -900, -450, -400, 300, 1000)

model = Collection([bed, main_spindle, sub_spindle, head])
# Z across the screen to the right, X up, as on a lathe
model = Rotate([model], -90, 0, 1, 0)
model = Rotate([model], 180, 0, 0, 1)

main(model, tooltip, work, size=900, lat=lat, lon=lon)
Loading