Machine tending (bt.tending)¶
The machine's side of a tending handshake, authored as a program of its own — FANUC Robot Interface 2 signalling, or a machine with no interface worked through its panel. See Machine tending.
vmc = bt.parts.machine_tool(scene, "vmc", door="servo")
hs = bt.tending.fanuc_ri2(scene, vmc, cycle_s=42.0)
tl = scene.simulate_sequences(["tend", hs.program])
tending
¶
Machine tending: the machine's side of the handshake, authored as a program of its own (design/design-machine-tending.md §4).
A machine tool is not a device the robot commands — it runs a part
program and talks to the cell in a fixed vocabulary of signals. FANUC's
Robot Interface 2 says it in M-codes and I/O: M62 announces the end of
the cycle a few seconds early, M60 unclamps and opens the side door,
SERVICE REQUEST holds while the door is at its open end, the robot asks
for the work clamp and reports the exchange done, and the door closes
before the next cycle starts. Written out, that is one more PLC program
scanned beside the robot's — which is what these templates author:
vmc = bt.parts.machine_tool(scene, "vmc", door="servo")
hs = bt.tending.fanuc_ri2(scene, vmc, cycle_s=42.0)
tend = scene.sequence("tend") # the robot's program, by hand
tend.step("wait", transition=bt.seq.signal(hs.signal("notice")))
...
tl = scene.simulate_sequences(["tend", hs.program])
The templates put nothing in the scene but signals, a sequence and (by
default) the CNC as an I/O node hosting it — so the derived I/O list
shows the handshake as wires between two controllers, PLCopen export
carries the machine's POU on a resource of its own, and the interlock
table (scene.interlocks()) reads the guards below as rows. The door
enforces itself: a leaf the machine closes on an arm still inside stops
the bake at that tick, by name.
Three guards every template writes into the machine's program, the way ISO 16090-1 has a machining centre written:
- the side door opens only with the front door closed (the two are never open together — while the side door is open, the machine body is the fence);
- a cycle starts only with the side door at its closed end — the confirmation signal, not the command;
- nothing starts while the E-stop is pressed.
Four vocabularies: fanuc_ri2 (FANUC Robot Interface 2), haas_autodoor
(Haas M80/M81 auto door with a cell-safe input), generic (a
vendor-neutral request/acknowledge, its signal names yours to set) and
manual (no interface — the robot works the door and the panel).
In those four the machine's program is written here and machining is one
step of it. haas_mfin is the other way round, the way a Haas is
actually integrated: the part program runs the cell. One NC program
that keeps running (M99) opens the window (M180), unclamps and clamps
the vise (M71/M70), and calls the robot through a user relay (M21)
that waits for its M-FIN — and the machine's program is derived from that
text (bt.nc.sequence), so the interlock table, the handshake spec and
the bake all read the program the operator loads.
FANUC_RI2
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
GENERIC
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
HAAS_AUTODOOR
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
HAAS_MFIN
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
MANUAL
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
Handshake
¶
What a template authored: the machine program's name, the door axis
it drives (or None — also where what it drives is a front door's two
leaves, MachineTool.front_doors), the I/O node it lives on, and the
signals by role — signal("service_req") is the name the robot's
program waits on, whatever the machine is called.
mtconnect_items
¶
The machine's lanes as MTConnect data items, for
bt.trace.read_mtconnect / to_mtconnect: Execution is
running, DoorState the side door's two lanes, EmergencyStop
the E-stop, ChuckState the work clamp (the nearest standard type
a vise clamp reports as). Only the roles this machine has.
MachineTool
¶
Bases: botrail.parts.Built
What machine_tool built, plus the names a tending program
addresses: the side door's axis (door, None for a manual door or
none), what rides on that door (door_objects — the leaf and its
trim, for a robot that slides it by hand), its end-of-travel lanes
(door_lanes = closed, open — the axis's stop lanes, or two zone
sensors on a loose leaf), the stroke and the world direction it opens
along (door_travel, door_axis), the front door's closed switch and
the E-stop lane the machine's program is guarded by (front_door_lane,
estop), the operator panel's Built and the button sensors on it.
door_axis
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
door_travel
class-attribute
¶
Convert a string or number to a floating-point number, if possible.
front_closed
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
front_door_axes
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
front_door_objects
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
front_door_travel
class-attribute
¶
Convert a string or number to a floating-point number, if possible.
front_doors
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
front_open
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
head_link
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
table_link
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
fanuc_ri2
¶
fanuc_ri2(
scene,
machine: MachineTool,
*,
cycle_s: float = 42.0,
clamp_s: float = 0.8,
notice_s: float = 5.0,
part_program: Optional[str] = None,
program: Optional[str] = None,
node: bool = True,
) -> Handshake
The FANUC Robot Interface 2 cycle, as the machine runs it.
Signals (all under <machine>/): running (a cycle is in progress),
notice (M62 — complete notice, notice_s before the end),
service_req (SERVICE REQUEST: the door is at its open end and the
machine waits for the robot), clamp (the work clamp, SO25_2),
and two the robot's program writes — clamp_req (asks for the
clamp once the blank is in the jaws) and service_ok (the exchange
is done and the arm is out).
The program <machine> (or program=): machining for
cycle_s - notice_s, the notice, then unclamp (clamp_s), the side
door to its open end, SERVICE REQUEST until the robot asks for the
clamp, the clamp (clamp_s), then wait for service_ok, close the
door and start the next cycle. A machine without an automatic door
(door="manual" or none) skips the door steps — the interlock is
then the robot's, or nobody's.
The one thing to get right on the robot's side: service_ok goes up
after the arm has left the enclosure. Set it earlier and the door
closes on the arm — which the bake refuses at that instant, naming
the door, the leaf, the robot and the link (DeviceCollision).
generic
¶
generic(
scene,
machine: MachineTool,
*,
cycle_s: float = 42.0,
clamp_s: float = 0.8,
signals: Optional[dict[str, str]] = None,
part_program: Optional[str] = None,
parts: Optional[Sequence[str]] = None,
cycle: bool = False,
program: Optional[str] = None,
node: bool = True,
) -> Handshake
A vendor-neutral request/acknowledge handshake — the shape most integrators wire when the machine's interface is a handful of relays:
- the machine says
runningwhile a cycle runs andreadyonce the part is unclamped and the door (if driven) stands open; - the cell asks
clamp_reqwith the blank in the jaws and getsclampback, then reportsexchange_doneonce the arm is out; - the machine closes the door and starts the next cycle.
signals renames any role to the maker's tag ({"ready": "vmc/M_FIN",
...}) — a catalog pack's interface.signals slots in here — so the
I/O list and the handshake spec carry the names the electrician reads.
A machine without a driven door skips the door steps; one whose only
driven door is its front door (machine_tool(front_drive=), no
side door — a washer an arm loads from the front) has its two leaves
opened and closed in those steps instead. Guards: the side door opens
only with the front door closed; the next cycle starts only with the
door the arm came through confirmed closed and no E-stop. part_program
runs an NC program on the machine's axes in place of the cycle_s
timer, and parts names what the vise holds on a table that moves
(see haas_autodoor). With cycle the machine's program starts over
once the next cycle is under way — part after part, for a cell that
keeps feeding it (the bake then ends with the cell's own program).
haas_autodoor
¶
haas_autodoor(
scene,
machine: MachineTool,
*,
cycle_s: float = 42.0,
clamp_s: float = 0.8,
part_program: Optional[str] = None,
parts: Optional[Sequence[str]] = None,
program: Optional[str] = None,
node: bool = True,
) -> Handshake
The Haas auto-door cycle: M80 opens the door, M81 closes it, and
the door works only while the cell-safe input is on (a light
curtain clear, a cell fence shut); cycle start closes the door.
Signals (under <machine>/): running, part_done (the program has
ended and the part is unclamped — the M-code relay a robot cell wires
to), clamp (a user M-code relay, M21-style, with its M-Fin), and
three the cell writes — cell_safe (it is safe to move the
door), clamp_req (clamp the blank) and start_req (remote cycle
start, once the arm is out). A driven side door is required
(door="air" / "servo"): M80/M81 are auto-door codes.
The program: machining for cycle_s, unclamp (clamp_s) and raise
part_done, wait for cell_safe and the front door closed, open
the door, clamp on request, wait for start_req with no E-stop,
close the door, and start once it reads closed.
This is the machine's program written for it, started from the cell.
A Haas is more often integrated the other way round — one part
program that keeps running and works the door, the vise and a relay
with M-FIN itself, with no start from outside: that is haas_mfin,
which reads the machine's side off the program.
With part_program — an NC program added with bt.nc.program, on a
machine built with its axes — machining is that program run on the
axes instead of the cycle_s timer: the cycle is as long as the
program takes. It is read here once, as the control will read it, so
what it cannot read is refused now and by line — and so is a program
that does not end at the exchange position the machine was built at
(machine.park), where the arm is taught. Enter the work offsets and
the tools before calling this.
On such a machine the table moves, and what the vise holds moves with
it: parts = (unloaded, loaded) names the part clamped as the cycle
runs and the one the cell loads in its place. The first is taken onto
the table as the cycle begins and freed at the unclamp; the second is
taken as the door closes for the next cycle — once the arm has let go
of it.
haas_mfin
¶
haas_mfin(
scene,
machine: MachineTool,
part_program: str,
*,
parts: Sequence[str],
clamp_s: float = 0.8,
relays: Union[Sequence[int], Mapping[int, str]] = (21,),
door_codes: Optional[tuple[int, int]] = None,
front_codes: Optional[tuple[int, int]] = None,
reach: Optional[float] = None,
program: Optional[str] = None,
node: bool = True,
) -> Handshake
A Haas run by its part program: the program — added with
bt.nc.program, on a machine built with its axes — opens and closes
the door, works the vise and calls the cell, and this writes the
machine's side of it from the text (bt.nc.sequence). End the program
on M99 and it keeps running, cycle after cycle.
The M codes it answers (the machine's M-code table):
M80/M81— the auto door, or the codes the machine's pack names for its side door (M180/M181, a VF's auto window;door_codesoverrides). The door goes to its end and the program waits for that end's switch. Both need the cell safe — and opening needs the front door shut: without, the control alarms and the program stops there (a Haas reports alarm 548), it does not wait.- On a machine built with an automatic front door
(
machine_tool(front_drive=)),M80/M81are that door — both leaves, at once (front_codesoverrides) — and the side door's codes are the pack's, orM180/M181. The two doors are never open together: either's opening needs the other shut. M70/M71— the vise clamps / unclamps,clamp_seach.M21…M28(relays) — a user relay with M-FIN: the relay comes on, the program waits form_fin, drops the relay and waits form_finto go again. Each is called where the arm was taught: with the axes at the exchange position the machine was built at (machine.park), which is checked here. A mapping says what each asks of the cell ({21: "arm: part out, blank in"}) — the words its step, the interlock table and the setup sheet then carry.
A block that turns the spindle needs the doors' closed switches and no E-stop: an alarm otherwise, not a wait.
Signals (under <machine>/): running, alarm, clamp, one per
relay (m21), and two the cell writes — cell_safe and m_fin.
The control's own lanes are there without being asked for:
<axes>.spindle, .coolant, and the words .rpm, .tool and .line
(the source line running, 0 while the control waits).
The vise holds what stands in it. clamp is a coil the table's
grasp follows (scene.bind_grasp): on, the table takes whichever of
parts — every part this vise will hold, the one in it now first —
stands within reach of it, and off lets it go. So nothing is
attached by name, cycle after cycle; a blank the arm still holds as
the vise closes becomes the vise's the moment the arm lets go; and a
program that cuts without M70 leaves its part behind as the table
moves. The vise is clamped as the cell starts. reach defaults to
how high the first part stands over the table, and a little.
On the cell's side: hold cell_safe on from before the door is
commanded; answer a relay by doing the work and raising m_fin,
drop it once the relay has dropped.
manual
¶
manual(
scene,
machine: MachineTool,
*,
cycle_s: float = 42.0,
clamp_s: float = 0.8,
buttons: Sequence[str] = (
"unclamp",
"clamp",
"cycle_start",
),
part_program: Optional[str] = None,
parts: Optional[Sequence[str]] = None,
program: Optional[str] = None,
node: bool = True,
) -> Handshake
A machine with no robot interface, worked through its panel — the retrofit case: the robot pulls the door and presses the buttons an operator would.
buttons names the panel buttons for unclamp, clamp and cycle start,
in that order (they must exist on the machine's panel). Signals:
running and clamp, plus the buttons' own zone lanes. The program
<machine>: machining for cycle_s, then wait for UNCLAMP, release
the clamp (clamp_s), wait for CLAMP, clamp (clamp_s), then wait
for CYCLE START with the side door at its closed end — a start
pressed with the door open is ignored, the way a guard interlock
ignores it (ISO 16090-1), and the bake reports the deadlock naming
this step. part_program runs an NC program on the machine's axes in
place of the cycle_s timer, and parts names what the vise holds
on a table that moves (see haas_autodoor).