Most of the examples are taken from the standard postprocessors provided.
- ABC
-
Function: abc = ABC ( val1 , val2 , val3 , val4 )
Action:
Calculates the ABC angles based on the tool orientation (val1, val2, val3) in the
workpiece coordinate system. The calculation of these angles takes into account the
kinematics defined in the data file. The result abc must be a 3-dimensional array.
Angles are calculated using the shortest path based on the following elements:
- The definition of the rotation axes: AXEn.ijk[3]
- Only non-fixed axes are calculated: AXEn.fixed = 0
- The preferred direction of rotation is defined by AXEn.direction
- The tool position on the spindle: ETAT0.tlaxis or SPINDL.ijk
- The reference position: ETAT1.xyzabc[4-6]
Selection of solutions using MODE.optim:
- If MODE.optim = 0: the shortest of the 2ndnon-fixed rotary axis
- If MODE.optim = 1: the shortest of the1stnon-fixed rotary axis
- If MODE.optim = 2: the shortest of the two non-fixed rotary axes
If val4 = 0, the angles are calculated assuming ETAT1.xyzabc[4-6] = (0,0,0) and
ETAT0.tlaxis = 3, that is, without taking into account the tool’s position on the
spindle or the current angles.
The AXEn.sens variables are initialized based on the machine travel
ranges, with the priority direction corresponding to the side with the maximum
travel
After calling the ABC function, you can access the two complementary solutions that
were calculated:
Related variables:
AXEn.ijk[3] with n = 0, 1, 2
AXEn.fixe with n = 0, 1, 2
AXEN.sens with n = 0, 1, 2
MODE.optim = 0, 1, 2
ETAT1.xyzabc
ETAT0.tlaxis = 1, 2, 3, -1, -2, -3: tool oriented along X, Y, Z,
-X, -Y, -Z
SPINDL.ijk = tool axis coordinate on the spindle
ABC.sol1[3]:1st solution
ABC.sol2[3]:2nd solution
Example: excerpt from a 5-axis GOTO file, spindle positioning test
$$
abc = ABC(ARG1.val[4],ARG1.val[5],ARG1.val[6])
IF ( abc[3] < LIMIT.min[6] ) THEN $$ C-axis overshoot test
IF ( ETAT0.move = 0 ) THEN
#lab1
STATE1.xyzabc[6] = abc[3] + 180.0
STATE1.xyzabc[4] = -1 * abc[1]
STATE1.xyzabc[5] = -1 * abc[2]
PRINT "position -- " abc[1] " " abc[3]
abc = ABC(ARG1.val[4],ARG1.val[5],ARG1.val[6])
IF ( abc[3] < LIMIT.min[6] ) JUMPTO lab1
ELSE IF ( ABS(abc[3] - ETAT1.xyzabc[6]) > 89.999 )
ETAT1.xyzabc[6] = abc[3] + 180.0
ETAT1.xyzabc[4] = -1 * abc[1]
ETAT1.xyzabc[5] = -1 * abc[2] PRINT "
position --- " abc[1] " " abc[3]
abc = ABC(ARG1.val[4],ARG1.val[5],ARG1.val[6])
ELSE
ERROR / "position C" FORMAT(1,abc[3])
EXIT
ENDIF
ENDIF
$$
- ABS
-
Function: val1 = ABS(val2)
Action:
Calculates the absolute value.
Related variables: none
Example: see ABC
- ACOS
-
Function: val1 = ACOS(val2)
Action:
Calculates the arc cosine of val2 in degrees.
Related variables: none
- AINT
-
Function: val1 = AINT(val2)
Action:
Calculates the integer part of val2.
Related variables: none
Example: GOCIR file for FANUC helical interpolation
$$
IF ( PLUNGE.on ) THEN
PLUNGE.on = 0
IF ( PLUNGE.step = 0.0 ) PLUNGE.step = 1.0
dz = PLUNGE.z - STATUS1.pts[3]
n = AINT( ABS( dz ) / PLUNGE.pas ) + 1 $$ number of full circles dz = dz /
n
i = 0
z = STATE1.pts[3]
#lab1 i = i + 1
z = z + dz
GOCIR / ARG1.val[1], ARG1.val[2], ARG1.val[3] $
, ARG1.val[4], ARG1.val[5], ARG1.val[6], ARG1.val[7] $
, ARG1.val[8], ARG1.val[9], z IF
( i < n ) JUMPTO lab1
GOCIR / ARG1.val[1], ARG1.val[2], ARG1.val[3] $
, ARG1.val[4], ARG1.val[5], ARG1.val[6], ARG1.val[7] $
, ARG1.val[8], ARG1.val[9], z ELSE
GOCIR / ARG1.val[1], ARG1.val[2], ARG1.val[3] $
, ARG1.val[4] , ARG1.val[5] , ARG1.val[6] , ARG1.val[7] $
, ARG1.val[8] , ARG1.val[9] , ARG1.val[10] ENDIF
$$
- ANGLE
-
Function: val = ANGLE(x, y, z)
Action:
Calculates the angle formed by the current point, the destination point (x, y, z),
and the next point; val is expressed in degrees.
Related variables: STATE1.pts[]
Example: excerpt from the GOTO to add a deceleration point
dist0 = DIST(0,tol)
angle = ANGLE( ARG1.val[1] , ARG1.val[2] , ARG1.val[3] )
$$
$$ maintain the angle
$$
IF ( ABS(angle) > tol ) THEN IF
( g201 = 0 ) THEN
IF ( g98 ) THEN
GCODE / 199 , 0 , 1
g98 = 0
FEDRAT.upm = fedrat IF
( dist0 < dist2 ) THEN
ERROR "Deceleration distance too short" ELSE
ratio = dist2 / dist0
IF ( ratio > 0.9 ) ratio = 0.9
x = ARG1.val[1] + ratio * ( ETAT1.pts[1] - ARG1.val[1] )
y = ARG1.val[2] + ratio * ( ETAT1.pts[2] - ARG1.val[2] )
z = ARG1.val[3] + ratio * ( ETAT1.pts[3] - ARG1.val[3] )
GOTO / x, y, z
ENDIF
ENDIF
EOB
GCODE / 201
EOB
g201 = 1
ENDIF
ELSE
- ARG
-
Function: val = ARG(minor)
Action:
Checks for the existence of the minor ‘minor’ when the macro is called.
Related variables: none
Example: COOLNT file
IF ( ARG("OFF") ) THEN
MCODE / 9.0 , 0.0
ELSE IF ( ARG("ON") )
MCODE / 8.0 , 0.0
ELSE IF ( ARG("MIST") )
MCODE / 7.0 , 0.0
ELSE IF ( ARG("FLOOD") ) MCODE
/ 8.0 , 0.0
ENDIF
- ASCII
-
Function: val = ASIN ( text )
Action:
Returns the decimal value of the first character in the text string, the inverse of
the CHAR() function.
Variables involved: none
- ASIN
-
Function: val1 = ASIN(val2)
Action:
Calculates the arc sine of val2 in degrees.
Variables involved: none
- ATAN
-
Function: val1 = ATAN(val2, val3)
Action:
Calculates the arctangent in degrees of val2 / val3.
Variables involved: none
Example: Calculating Q and R in the GOTO file for AGIE
IF ( ARG1.nval = 6 ) THEN SEARCH
/ ON
goto = MAJOR("GOTO")
SEARCH / goto
IF ( SARG.num = goto ) THEN
x = SARG1.val[1] - ARG1.val[1] y
= SARG1.val[2] - ARG1.val[2]
dist = SQRT( x*x + y*y )
sina = ( y * ARG1.val[4] - x * ARG1.val[5] ) / dist
angleq = ATAN( sina , ARG1.val[6] )
cosa = ( x * ARG1.val[4] + y * ARG1.val[5] ) / dist
angler = ATAN( cosa , ARG1.val[6] )
$$
CODE / 8, angleq
IF ( ABS(angler) > 0.0100 ) ERROR " R must be zero for this approach "
IF ( ABS(angler) > 0.0100 ) CODE / 9 , angler
ENDIF
ELSE
- AXIS
-
Function: axis = AXIS ( ijk[1] , ijk[2] , ijk[3] )
axis = AXIS ( ijk[1] , ijk[2] , ijk[3] , mode)
Action:
- If mode is omitted or equals 0: Returns the coordinates of a vector from the APT
part coordinate system in the machine’s local coordinate system based on the
positions of the rotary table axes and the active inclined plane.
- If mode = 1: Returns the coordinates of a vector from the machine’s local
coordinate system to the APT workpiece coordinate system based on the positions of
the rotary table axes and the active inclined plane.
- If mode = 2: Returns the coordinates of a vector from the machine coordinate
system to the APT part coordinate system based solely on the position of the
rotary table axes.
Related variables:
ETAT0.xyzabc[4-6]: positions of the rotary axes
-
AXE0
AXE1
AXE2
TABLE[12]: inclined plane matrix
Example: Analysis of the circle’s axis in GOCIR to verify whether the circle is in
G17
$$
axis = AXE(ARG1.val[4], ARG1.val[5], ARG1.val[6])
IF ( ABS(axis[3]) < 0.999 ) THEN
MODE.circle = 4
ELSE IF ( NVAL("TURN") )
CODE / 15 , VAL("TURN",1)
ENDIF
$$
GOCIR
MODE.circle = MODE.circle0
$$
- CBRT
-
Function: val1 = CBRT(val2)
Action:
Calculates the cube root of val2.
Related variables: none
- CENTER
-
Function: xyz = CENTER(center,axis,radius,end)
Action:
Exact calculation of the center of the circle based on APT data to avoid errors from
numerical approximations
Center: coordinate vector of the circle's center Axis:
- Axis vector of the circle
- Radius: radius of the circle
- End: Endpoint of the circle
Related variables: ETAT1.pts
Example: Excerpt from the GOCIR macro for HEIDENHAIN
$$
axis = 3
IF ( STATUS0.plane = 3 ) axis =
1 IF ( STATUS0.plane = 2 ) axis
= 2
$$
CODE / 3, 0.0
center = CENTER(ARG1.val[1],ARG1.val[4],ARG1.val[7],ARG1.val[8])
xyz = XYZ(center[1], center[2], center[3])
IF ( axis # 1 ) CODE / 8 , xyz[1]
IF ( axis # 2 ) CODE / 9 , xyz[2] IF
( axis # 3 ) CODE / 10 , xyz[3] IF
(axis = 1) XCODE / xyz[1], -1 IF
(axis = 2) YCODE / xyz[2], -1 IF
(axis = 3) ZCODE / xyz[3], -1 EOB
$$
- CHAR
-
Function: string[n] = CHAR(val)
Action:
Defines a character by its decimal value. Used when you want to write a specific
character such as $ or " or a non-ASCII character:
- CHAR(36) = $ character
- CHAR(35) = # character
- CHAR(34) = " character
- CHAR(19) = XOFF
Related variables: none
Example: NUM's PPRINT macro
$$
WRITE / CHAR(36) + ARG0
$$
- COMFMT
-
Function: string = COMFMT ( string1 )
string = COMFMT ( val1 , val2 )
string = COMFMT(string1, val1, val2)
Action:
Allows the comment to be customized based on the language used. Used in the
translation of HEIDENHAIN cycle comments.
Can also be used to customize a comment based on the specific situation. If only
string1, then string = COMMENT1.start string1 COMMENT1.end.
- If val1 and val2 are provided, then retrieve the comment stored in the file
“message_fmt.msg.” “message_fmt.msg” must be located in the SGPost execution
directory. If “message_fmt.msg” does not exist, the default SGPost comment in the
current language is retrieved. CAUTION: sgpost.exe only includes the main
HEIDENHAIN cycle comments.
- If string1 and val1 and val2, then the same process as for val1 and val2,
returning string1 if no translation is found.
- If val2 = 0, then the string is written without the comment characters. See the
GOCYCL file in the heiden.dat library
Example of the “message_fmt.msg” file:
* Message file for HEIDENHAIN cycle messages
* LINE FORMAT: cycle_number,parameter_number="parameter description"
* CYCLE DEF 200
200.0 ="DRILLING"
200.201="SETUP CLEARANCE"
200,202="DEPTH"
200,203="PLUNGING DEPTH"
200,204="2ND SETUP CLEARANCE"
200,206="FEED RATE FOR PLUNGING"
200,210="DWELL TIME AT TOP"
200,211="Dwell Time at Depth"
Example of use with GOCYCL from heiden.dat:
WRITE/" Q200="+FORMAT(1,CYCLE.rapto)+ COMFMT(200,200) " " CHAR(126)
WRITE/" Q201="+FORMAT(1,fedto)+ COMFMT(200,201) " " CHAR(126) WRITE/"
Q206="+FORMAT(2,fedval)+ COMFMT(200,206) " " CHAR(126)
WRITE/" Q202="+FORMAT(1,inc)+ COMFMT(200,202) " " CHAR(126)
WRITE/" Q210="+FORMAT(1,0.0)+ COMFMT(200,210) " " CHAR(126)
WRITE/" Q203="+FORMAT(1,xyz[z])+ COMFMT(200,203) " " CHAR(126)
IF ( data_q211 ) THEN
WRITE/" Q204="+FORMAT(1,rtrcto)+ COMFMT(200,204) " " CHAR(126)
WRITE/" Q211="+FORMAT(1,dwell)+ COMFMT(200,211)
ELSE
WRITE/" Q204="+FORMAT(1,rtrcto)+ COMFMT(200,204)
ENDIF
- COS
-
Function: val1 = COS(val2)
Action:
Calculates the cosine of val2 in degrees.
Variables involved: none
- DATE
-
Function: text = DATE ( mode )
Action:
Information about the current system date.
- If mode = 1, returns the day of the week.
- If mode = 2, returns the month as text; if mode = 3, returns the current date;
if mode = 4, returns the system time.
- If mode = 5, returns the system minute.
- If mode = 6, returns the system second.
- If mode = 7, returns the system year.
- If mode = 8, returns the month as a number.
- If mode = 9, returns the local time.
- If mode = 10, returns the month in the current language.
- If mode = 11, returns the millisecond.
Related variables: none
Example: Excerpt from an INIT macro
$$
WRITE / " G25XYZ G43Z"
WRITE / " G27C0 G00 G54 G90 G94 G97"
GCODE / 0.0 , -1
$$
date = "-" + DATE(3) + "-" + DATE(2) + "-" + DATE(7) NWRITE
/ " ( CREATION_DATE-:" + date + ")"
$$
NWRITE / " ( " PART.no " ) "
$$
NWRITE / " M00"
$$
- DEFCODE
-
Function: num = DEFCODE ( name , major )
Action:
Creates a new code, which is added to the end of the existing list; the function
returns the number of the newly created code. If the code already exists, it returns
the number of the existing code.
- Name: name of the code.
- Major: number of the associated major.
Related variables: none
Example: excerpt from the COMMENT5 macro called when SGPOST detects a GOTO
instruction during SIEMENS reverse decoding
$$
label = STRGET(ARG0,1)
IF( STRLEN(label) = 0 ) RETURN
label = label ":"
$$
code = DEFCODE(label, 0)
$$
IF ( ISODEF(61) ) THEN $$ IF val =
ISOVAL(61)
PRINT " GOTOF test " val " code " code IF
( val) ) LABEL / code , 0
ELSE
LABEL / code, 0
ENDIF
$$
- DIST
-
Function: val = DIST(mode, tol)
Action:
- If mode = 0, returns the distance of the current movement.
- If mode = 1, returns the distance of the next linear movement at the same feed
rate.
- If mode = 2, returns the distance of the subsequent movements at the same feed
rate for an angular tolerance less than
tol, expressed in degrees
between two movements.
Related variables:
ETAT0.pts
SLOWDN.dmin (if mode = 2)
SLOWDN.rmin (if mode = 1 or 2)
Example: Excerpt from the GOTO macro for high speed
$$
$$ High-speed parameters
$$
tol = 7.0 $$ angular tolerance in degrees
dist2 = 10.0 $$ maximum deceleration distance
coef = 20000000 $$ max feed rate = sqrt( rmin * coef )
$$
dist0 = DIST(0,tol)
…
$$
$$ high speed
$$
IF ( dist0 > dist2 ) THEN
dist1 = DIST(2,tol)
IF ( ( g98 = 0 ) & (dist1 > dist2) ) THEN fedval
= SQRT( SLOWDN.rmin * coef ) fedrat =
FEDRAT.upm
IF ( fedval < FEDRAT.upm ) FEDRAT.upm = fedval
GCODE / 198, 0, 1
g98 = 1
ELSE IF ( g98 & ( dist1 < dist2 ) )
FEDRAT.upm = fedrat
GCODE / 199, 0, 1
g98 = 0
ENDIF
ENDIF
|