Most of the examples are taken from the standard postprocessors provided.
- MAJOR
-
Function: val = MAJOR( major )
Action:
Returns the word number of the keyword ‘major’, used with the SEARCH function.
Related variables: none
Example: Excerpt from the LOADTL file for HEIDENHAIN, searching for SPINDL
EOB
MCODE / 6
$$
$$ Search for SPINDL
$$
M_spindl = MAJOR("SPINDL") M_loadtl
= MAJOR("LOADTL") SEARCH / ON
SEARCH / M_spindl, M_loadtl
IF ( ( SARG.num = M_spindl ) & SARG("VALUE") ) SPINDL.val = SVAL("VALUE",1)
$$
plane = 16 + ETAT0.plane
GCODE / plane, 1
CODE / 13, VAL("VALUE",1) SCODE /
SPINDL.val, 1
EOB
- MATMAT
-
Function: mat = MATMAT(mat1, mat2)
Action:
Product of two 3x3 matrices: mat = mat1*mat2
Related variables: none
- MATREF
-
Function: mat = MATREF(ref, mat1)
Action:
Product of the 4x3 matrix mat1 and the inverse of the 4x3 matrix ref: mat =
inverse(ref)*mat1
Related variables: none
Examples: coordinate system correction for CATIA V5
$$
mat[1] = VEC(ARG1.val[1], ARG1.val[2], ARG1.val[3])
mat[4] = VEC(ARG1.val[5], ARG1.val[6], ARG1.val[7])
mat[7] = VEC(ARG1.val[9], ARG1.val[10], ARG1.val[11])
mat[10] = VEC(ARG1.val[4], ARG1.val[8], ARG1.val[12])
$$
IF ( nrepere = 0 ) THEN
ref = MATRIX / mat[1], mat[2], mat[3], mat[10] $
, mat[4], mat[5], mat[6], mat[11], mat[7], mat[8], mat[9], mat[12]
ELSE
loc = MATRIX / mat[1], mat[2], mat[3], mat[10] $
, mat[4], mat[5], mat[6], mat[11], mat[7], mat[8], mat[9], mat[12]
$$
$$ orientation matrix of loc relative to the ref coordinate system and
$$ position of the origin of loc relative to the origin of ref in the ref coordinate system
$$
mat = MATREF(ref,loc) LOOP(i,1,1,12)
DATUM[i] = mat[i]
ENDLOOP
ETAT1.pts[4] = VEC(DATUM[3], DATUM[6], DATUM[9]) ETAT0.pts[4]
= VEC(DATUM[3], DATUM[6], DATUM[9])
$$
ENDIF
nrepere = nrepere + 1
$$
- MATROT
-
Function: mat = MATROT( a , b , c )
Action:
Calculates the 3x3 matrix corresponding to a rotation around the Z axis by an angle
c, around the Y axis by an angle b, and around the X axis by an angle a; the angles
are expressed in degrees. (a, b, c) are also known as Euler angles.
mat = rotz(c) * roty(b) * rotx(a)
This function is often used to evaluate the inclined plane matrix TABLE[12] as a
based on the three calculated angles PLAN.abc[3].
Related variables: none
Example: Enabling/disabling the inclined plane for NUM760
IF ( ARG("ON") ) THEN
$$
text = "A=" FORMAT(1,ETAT0.xyzabc[4])
text = text + "B=" FORMAT(1,ETAT0.xyzabc[5])
text = text + "C=" FORMAT(1,ETAT0.xyzabc[6])
text = text + "U=" FORMAT(1,ETAT0.xyzabc[1])
text = text + "V=" FORMAT(1,ETAT0.xyzabc[2])
text = text + "W=" FORMAT(1,ETAT0.Xyzabc[3])
text = text + "D=" FORMAT(2,LOADTL.num) NWRITE
/ text
MCODE / 150
EOB
TABLE = MATROT(ETAT0.xyzabc[4],ETAT0.xyzabc[5],ETAT0.xyzabc[6])
TABLE[10] = VEC(ETAT0.xyzabc[1],ETAT0.xyzabc[2],ETAT0.xyzabc[3])
plan = 1
$$
ENDIF
$$
IF ( ARG("OFF") ) THEN
$$
IF ( plan = 0 ) RETURN
MCODE / 152
EOB
TABLE = MATROT(0.0, 0.0, 0.0)
TABLE[10] = VEC(0.0, 0.0, 0.0)
plan = 0
$$
ENDIF
$$
XCODE
YCODE
ZCODE
$$
- MCODE
-
Function: val2 = MCODE ( val1 )
Action:
Returns the generic code for the M code defined in the data file: mcode = val2,
val1
Related variables: MCODE.val[].
- MGET
-
Function: text = MGET(n)
Action:
Retrieves the text result from the nth field of the menu. This statement must appear
after the MENU / OFF statement. In the case of a checkbox (5MBOX), the result is
either ON or OFF.
Related variables: none
Example: see MENU
- MODULO
-
Function: remainder = MODULO(val,n)
Action:
Calculate the remainder of the division of val by
n. n and val must be integers.
Related variables: none
- NEXTABC
-
Function:
- No arguments
abc = NEXTABC()
- With 1 argument
abc = NEXTABC(axis)
- With 3 arguments
abc = NEXTABC(i,j,k)
Action:
No arguments: returns the next machine angles.
With 1 argument: searches for the position that allows for maximum travel to avoid
reversals. 4 <= axis <= 6: number of the axis to optimize.
With 3 arguments: returns the first machine angles following an orientation (i,j,k)
different from the current one, used to preposition one or more rotary axes. The
search stops at the next RAPID command preceded by a GOTO without RAPID.
Related variables:
STATE1.xyzabc
AXIS0
AXIS1
AXIS2
Example: Prepositioning of the C-axis for an AC spindle kinematics
$$ C-axis anticipation
$$
abc = NEXTABC(0.0, 0.0, 1.0)
$$
$$ C positioning
$$
abc[3] = LIMANGLE(abc[3], 6)
$$
$$ Rotate C if necessary
$$
IF ( ABS(abc[3] - abc0[3]) > 0.001 ) THEN
GCODE / 0.0
CCODE / abc[3], 1
UPDATE
ENDIF
$$
- NEXTDIR
-
Function: dir = NEXTDIR(x,y,z)
Action:
No arguments: returns the direction of the next movement; (x, y, z) = position of the
current point
Related variables: none
- NEXTDIR
-
Function: dir = NEXTDIR(x,y,z,opt)
Action:
Returns the direction of the next movement: (x, y, z) = the position of the current
point if opt = 0, and the 1st subsequent movement in feed direction if opt = 1.
If opt = 1 and the next movement is a rapid traverse, returns the previous
direction.
Related variables: none
- NEXTGOTO
-
Function: pts = NEXTGOTO()
Action:
Returns the xyz coordinates of the next GOTO. If at the end of the file, returns the
coordinates of the current or previous point.
Related variables: none
- NEXTIJK
-
Function: ijk = NEXTIJK()
Action:
Returns the next tool axis.
Related variables: none
- NEXTMOVE
-
Function: move = NEXTMOVE()
Action:
Retrieves the type of the next movement.
- 0 = fast movement
- 1 = linear movement
- 2 = circular movement
- <0 = end of program or tool change.
Related variables: none
- NVAL
-
Function: n = NVAL(minor)
Action:
Returns the number of numeric values following the minor.
Related variables: none
Example: For SPINDL / RPM, 1000 in the SPINDL macro, we have NVAL("RPM") = 1
IF ( ARG("RPM") ) THEN
GCODE / 97.0
SPINDL.on = 1
IF ( NVAL("RPM") ) val = VAL("RPM",1)
ELSE IF ( …
- PLANABC
-
Function:
- With 3 or 4
arguments:
abc = PLANABC(wx, wy, wz, mode)
- With 6 or 7
arguments:
abc = PLANABC(ux, uy, uz, vx, vy, vz, mode)
Action:
Returns the Euler angles of orientation for the coordinate system defined by the
vectors U, V, and W.
If there are 3 or 4 arguments, the function determines a possible solution with the
W-axis (wx, wy, wz) using the machine axes.
If 6 or 7 arguments are provided, the function determines a possible solution with
the U (ux, uy, uz) and V (vx, vy, vz) axes based on the Euler angles.
- If mode = 0, returns the angles corresponding to the transformation rot Z + rot
Y + rot X
- If mode = 1, returns the angles corresponding to the transformation rot X + rot
Y + rot Z
Related variables: AXE0, AXE1,
AXE2.
- POLAR
-
Function: Function abc = POLAR(x, y, z)
Action:
Calculates the polar angle in the XY, YZ, or ZX plane.
- POLAR MODE = 1 abc[1] = arctangent (z / y)
- POLAR MODE = 2 abc[2] = arctangent (x / z)
- POLAR MODE = 3 abc[3] = arctangent (y / x)
- POLAR_MODE = 4 the rotation axis and index are defined by the first rotation
axis AXE0.
Related variables:
AXE0
POLAR MODE: relevant axis POLAR
MODE.poldist: minimum calculation distance
MODE.polorg: angular origin of the rotary axis
Example: axial milling on a lathe
$$
IF ( mill ) THEN
IF ( STATUS0.tlaxis = 3 ) THEN
abc = POLAR(ARG1.val[1], ARG1.val[2], ARG1.val[3])
STATE1.xyzabc[6] = abc[3]
ENDIF
GOTO
ELSE
GOTO / ARG1.val[1], ARG1.val[2], ARG1.val[3], 0, 0, 1.0 ENDIF
$$
- PQR
-
Function: pqr = PQR( x , y , z , i , j , k ,opt)
Action:
Calculates the bisector formed by (x, y, z)—the previous point—and the next point
projected onto the plane defined by (i, j, k). This function is used to calculate the
3D correction factor for side milling.
The opt value is optional; it defines the context for calculating the pqr values
- -1: offset relative to the previous movement
- 0: offset relative to both the previous and next movements (default)
- 1: offset relative to the next movement
Related variables: none
Example: Excerpt from the COMP3D macro for a NUM postprocessor
$$
ELSE
pqr1 = PQR(ARG1.val[1],ARG1.val[2],ARG1.val[3] $
,ARG1.val[4],ARG1.val[5],ARG1.val[6])
dist = pqr1[1]*pqr1[1]+pqr1[2]*pqr1[2]+pqr1[3]*pqr1[3] dist
= SQRT(dist)
IF ( dist > 0.001 ) THEN
pqr[1] = 1000.0 * CUTCOM.direction *
pqr1[1] pqr[2] = 1000.0 * CUTCOM.direction
* pqr1[2] pqr[3] = 1000.0 *
CUTCOM.direction * pqr1[3] IF (
CUTCOM.out ) GCODE / 43 CUTCOM.out =
0
ENDIF
ENDIF
$$
IF ( CUTCOM.out = 0 ) THEN CODE
/ 16 , pqr[1]
CODE / 17, pqr[2]
CODE / 27, pqr[3]
STATE0.delete = 3
ENDIF
$$
- PTS
-
Function: pts = PTS( x , y , z )
Action:
Calculates the work piece coordinates from the machine coordinates (x, y, z) based on
the machine kinematics and the inclined plane matrix. This function is the inverse of
the XYZ() function.
Related variables:
|