09 TPL Language
09 TPL Language
ARCHITETTURA E
PROGRAMMAZIONE SISTEMI PER
MOTION CONTROL
MARCO
SILVESTRI
LEZIONE 09
OTHER LANGUAGES FOR MOTION
CONTROL
▪ TPL
(https://tplang.org/)
2
TPL
▪ TPL or Tool Path Language is a programming language for creating
machine tool paths for CNCs. It is based on JavaScript and is a
powerful replacement for the venerable but horribly outdated
GCode language. However, TPL can output GCode so it remains
compatible with existing machine control software such as
LinuxCNC.
3
AN EXAMPLE
▪ feed(400); // Set the feed rate to 400 millimeters per minute
▪ tool(1); // Select tool 1
5
FUNCTIONS
▪ The above square example could be wrapped in a function like this:
▪ Note the square() function uses icut() the incremental version of cut(). 6
FOR LOOP
▪ Given the square() function you can now cut repeated squares
like this:
▪ Here is the result of running the square function as in the for loop
above.
7
ROTATE
▪ for (var i = 0; i < 4; i++) {
▪ squares(10, 5, -3, 5);
▪ rotate(Math.PI / 8); // Rotate clockwise 15 degrees
▪ }
8
TOOL MOVEMENT: RAPID
▪ rapid(x, y, z, a, b, c, u, v, w, incremental=false)
▪ Issue a linear motion at the rapid feed rate from the current
position to the new position defined by the provided axes
arguments.
▪ irapid(x, y, z, a, b, c, u, v, w, incremental=true)
9
TOOL MOVEMENT: CUT
▪ cut(x, y, z, a, b, c, u, v, w, incremental=false)
▪ The same as rapid() except moves are at the current feed rate set
by a call to feed().
▪ icut(x, y, z, a, b, c, u, v, w, incremental=true)
10
TOOL MOVEMENT: ARC
▪ arc(x, y, z, angle, plane)
▪ x, y and z specify the offset from the current position to the far
center of the helical move in the selected plane. If the z value is
zero then the move is a simple arc in the selected plane,
otherwise it is a true helical move with an axis of length equal to
the absolute value of the z value either above or below the
selected plane through the current control point depending on
the sign.
▪ It is an error if:
12
TOOL MOVEMENT: DWELL
▪ probe() will return the coordinates of the position at the time
the probe changed state. If the programmed point was reached
before the state changed then the programmed point will be
returned instead.
▪ It is an error if:
13
TOOL MOVEMENT: DWELL
▪ dwell(seconds)
▪ seconds indicate the time in seconds that all axes will remain
unmoving. Fractions of a second may be used.
14
MACHINE STATE
▪ feed(rate, mode = FEED_UNITS_PER_MIN)
▪ rate indicates the units per minute in the XYZ Cartesian system of all
subsequent non-rapid moves until the feed rate is changed.
▪ mode may be one of the following:
▪ FEED_UNITS_PER_MIN - The feed rate is in units per minute. The unit
may be inches, millimeters or degrees depending on the current unit of
length and which axes are moving.
▪ FEED_INVERSE_TIME - Indicates that moves should be completed in
one divided by rate minutes. For example, if rate is 2.0, moves should be
completed in half a minute.
▪ FEED_UNITS_PER_REV - Means that the controlled point should move a
certain number of units per revolution.
▪ If no arguments are given, returns the current feed rate and mode.
▪ feed(4); // Move at 4 units per minute
▪ rate = feed()[0]; // Get the current feed rate
15
SPEED
▪ speed(rate, surface, max)
16
TOOL
▪ tool(number)
▪ Make tool number the current tool.
▪ tool(1); // Select tool 1
18
SPEED
▪ speed(rate, surface, max)
19
ESERCIZIO
▪ Modificare il programma d’esempio precedente per realizzare
una traiettoria ottagonale.
20