Servoworks CNC Macro Programming Manual: Revision 1.94 © 2011 Soft Servo Systems, Inc
Servoworks CNC Macro Programming Manual: Revision 1.94 © 2011 Soft Servo Systems, Inc
Programming Manual
Revision 1.94
© 2011 Soft Servo Systems, Inc.
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Warning / Important Notice
Warning
The product described herein has the potential – through misuse, inattention, or lack of understanding – to create
conditions that could result in personal injury, damage to equipment, or damage to the product(s) described herein.
Machinery in motion and high-power, high-current servo drives can be dangerous; potentially hazardous situations
such as runaway motors could result in death; burning or other serious personal injury to personnel; damage to
equipment or machinery; or economic loss if procedures aren’t followed properly. Soft Servo Systems, Inc. assumes
no liability for any personal injury, property damage, losses or claims arising from misapplication of its products. In
no event shall Soft Servo Systems, Inc. or its suppliers be liable to you or any other person for any incidental
collateral, special or consequential damages to machines or products, including without limitation, property damage,
damages for loss of profits, loss of customers, loss of goodwill, work stoppage, data loss, computer failure or
malfunction claims by any party other than you, or any and all similar damages or loss even if Soft Servo Systems,
Inc., its suppliers, or its agent has been advised of the possibility of such damages.
It is therefore necessary for any and all personnel involved in the installation, maintenance, or use of these products
to thoroughly read this manual and related manuals and understand their contents. Soft Servo Systems, Inc. stands
ready to answer any questions or clarify any confusion related to these products in as timely a manner as possible.
The selection and application of Soft Servo Systems, Inc.’s products remain the responsibility of the equipment
designer or end user. Soft Servo Systems, Inc. accepts no responsibility for the way its controls are incorporated
into a machine tool or factory automation setting. Any documentation and warnings provided by Soft Servo
Systems, Inc. must be promptly provided to any end users.
This document is based on information that was available at the time of publication. All efforts have been made to
ensure that this document is accurate and complete. However, due to the widely varying uses of this product, and
the variety of software and hardware configurations possible in connection with these uses, the information
contained in this manual does not purport to cover every possible situation, contingency or variation in hardware or
software configuration that could possibly arise in connection with the installation, maintenance, and use of the
products described herein. Soft Servo Systems, Inc. assumes no obligations of notice to holders of this document
with respect to changes subsequently made. Under no circumstances will Soft Servo Systems, Inc. be liable for any
damages or injuries resulting from any defect or omission in this manual.
Soft Servo Systems, Inc. makes no representation or warranty, expressed, implied, or statutory with respect to, and
assumes no responsibility for the accuracy, completeness, sufficiency, or usefulness of the information contained
herein. NO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS OF PURPOSE SHALL APPLY.
_____________________________________________________________________________________
i
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Warning / Important Notice
Important Notice
The information contained in this manual is intended to be used only for the purposes agreed upon in the related
contract with Soft Servo Systems, Inc. All material contained herein is subject to restricted rights and restrictions
set forth in the contract between the parties.
These manuals contain confidential and proprietary information that is not to be shared with, nor distributed to, third
parties by any means without the prior express, written permission of Soft Servo Systems, Inc. No materials
contained herein are to be duplicated or reproduced in whole or in part without the express, written permission of
Soft Servo Systems, Inc.
Although every effort and precaution has been taken in preparing this manual, the information contained herein is
subject to change without notice. This is because Soft Servo Systems, Inc. is constantly striving to improve its
products. Soft Servo Systems, Inc. assumes no responsibility for errors or omissions.
All rights reserved. Any violations of contractual agreements pertaining to the materials herein will be prosecuted to
the full extent of the law.
! CAUTION
Due to the preread/block buffering aspect of macro statement execution, it is possible
that macro statements using system variables may be evaluated, parsed, and delivered
to the block buffer BEFORE the previous lines have been executed, and before the
relevant system parameters have been updated. Therefore, the evaluation of a macro
statement containing a system variable may not evaluate as expected.
For more information, see Section 7.1: Preread Function/Block Buffering – Problems
and Workaround.
_____________________________________________________________________________________
ii
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Contents
Table of Contents
Warning ............................................................................................................................................................................................ i
Important Notice ............................................................................................................................................................................. ii
Table of Contents .......................................................................................................................................................................... iii
List of Tables.................................................................................................................................................................................. iv
List of Figures ................................................................................................................................................................................. v
List of Figures ................................................................................................................................................................................. v
Chapter 1: Overview .................................................................................................................................................................... 1-1
1.1 What Is A Macro Program? ............................................................................................................................ 1-1
1.2 Differences Between Simple (Non-Macro) Subprograms And Macros.......................................................... 1-1
1.3 Differences Between Macro Statements and NC Statements ......................................................................... 1-2
1.4 General Format Requirements ........................................................................................................................ 1-2
Chapter 2: Variables .................................................................................................................................................................... 2-1
2.1 Overview of Variables .................................................................................................................................... 2-1
2.2 Types of Variables .......................................................................................................................................... 2-1
2.3 Specifying and Referencing Variables ............................................................................................................ 2-2
2.3.1 Specifying a Variable .............................................................................................................................. 2-2
2.3.2 Referencing a Variable ............................................................................................................................ 2-3
2.4 Variable Values............................................................................................................................................... 2-4
2.4.1 Allowable Values for Variables .............................................................................................................. 2-4
2.4.2 Rounding of Referenced Variables ......................................................................................................... 2-4
2.5 Processing Null and Uninitialized Variables .................................................................................................. 2-4
2.5.1 Uninitialized Variables in a Mathematical Formula ............................................................................... 2-4
2.5.2 Uninitialized Variables in a Movement Command ................................................................................. 2-5
2.5.3 Uninitialized Variables in a Conditional Expression .............................................................................. 2-5
Chapter 3: System Variables ...................................................................................................................................................... 3-1
3.1 Overview of System Variables ....................................................................................................................... 3-1
3.2 System Variables for Interfacing with the PLC .............................................................................................. 3-2
3.3 System Variables for Tool Compensation ...................................................................................................... 3-4
3.4 System Variables for Timers .......................................................................................................................... 3-4
3.5 System Variables for Modal Information ....................................................................................................... 3-5
3.6 System Variables for Position Information ..................................................................................................... 3-7
3.7 System Variables for Workpiece Coordinates ................................................................................................ 3-9
Chapter 4: Mathematical Operations and Logical Operations ................................................................................................ 4-1
4.1 Summary of Mathematical and Logical Operations ....................................................................................... 4-1
4.2 Format of Mathematical and Logical Operations ........................................................................................... 4-3
4.3 Order of Operations ........................................................................................................................................ 4-4
4.3.1 Nesting .................................................................................................................................................... 4-4
4.3.2 Priority of Operations .............................................................................................................................. 4-4
4.4 Precision and Errors ........................................................................................................................................ 4-4
4.4.1 Precision and Errors Related to Mathematical and Logical Operations .................................................. 4-4
4.4.2 Precision and Errors Related to Conditional Expressions ....................................................................... 4-6
4.4.3 Errors Related to Null Variables or Uninitialized Variables ................................................................... 4-6
Chapter 5: Flow of Control – Branching and Repetition .......................................................................................................... 5-1
5.1 Overview of Flow Control .............................................................................................................................. 5-1
5.2 GOTO Statement (Unconditional Branching) ................................................................................................ 5-1
5.3 Conditional Statements and Comparison Operators ....................................................................................... 5-2
5.4 IF Statement .................................................................................................................................................... 5-3
5.4.1 IF GOTO (Conditional Branching) ......................................................................................................... 5-3
5.4.2 IF THEN (Conditional Execution) .......................................................................................................... 5-4
5.4.3 IF ELSE ENDIF (Conditional Execution with Branching) ..................................................................... 5-4
5.5 WHILE DO END Statement (Conditional Looping) ...................................................................................... 5-4
5.6 Nesting ............................................................................................................................................................ 5-5
5.6.1 Acceptable Nesting ................................................................................................................................. 5-5
_____________________________________________________________________________________
iii
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Contents
List of Tables
_____________________________________________________________________________________
iv
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Contents
List of Figures
_____________________________________________________________________________________
v
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 1: Overview
Chapter 1: Overview
Macros significantly simplify part programming and reduce part programming time by allowing reuse of
programming pieces such as user-defined canned cycles. The extensive macro programming capabilities available
with ServoWorks CNC systems will save time and reduce operator errors.
Macros are written in the ServoWorks macro programming language, which is similar to the BASIC programming
language. You will find it easy to learn to program macros for ServoWorks CNC systems.
Macros can be used as subroutines, contained in the same file as the main program (and called using the G65 simple
macro call). Or, macros can be used as separate macro subprograms, either residing in the same folder as the main
program (and called using an M98 subprogram call), or residing anywhere, even on a network (using custom G, M,
S or T macro calls).
Using macro subroutines (or macro subprograms) is very similar to calling a simple NC subprogram from a main
part program, except with the added advantage that you can use variables, control structures and mathematical and
logical operations in macros. This means that macros are much more powerful, more versatile and more reusable
than simple NC subprograms. For instance, you can have one macro for a bolt hole, and just change the variables
(arguments) you assign when you call the macro (with macro instructions). If you were using a simple (non-macro)
subprogram for programming a bolt hole, you would need a different subprogram for each size bolt hole.
_____________________________________________________________________________________
1-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 1: Overview
·
·
G65 Macro number main
· program
·
%
O Macro number
·
·
· body of macro
· subroutine
·
M99 – returns the flow of control to the calling program
%
NOTES:
1) Using M99 in the main part program returns the flow of control to the beginning of that main part program,
resulting in an infinite loop.
2) Either the “%” symbol or a carriage return is required at the end of all NC and macro files.
1) Contains an arithmetic or logical operation (see Chapter 4: Mathematical Operations and Logical
Operations)
2) Contains a control statement (see Chapter 5: Flow of Control – Branching and Repetition)
3) Contains a macro call command (see Chapter 6: Calling Macro Programs from Within Part Programs)
Any statement (block of code) not meeting the above criteria is considered to be an NC statement.
When a macro statement is executed, single block mode does not apply; i.e., the machine does not stop execution.
For instance:
GOTO99 Æ INVALID
GOTO 99 Æ VALID
[#11GT0] Æ INVALID
[#11 GT 0] Æ VALID
_____________________________________________________________________________________
1-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 1: Overview
2) Brackets “[ ]”must be used around conditional expressions and in mathematical and logical operations.
Parentheses “( )”are invalid in these cases, and are used only for comments in the code.
For instance:
(#11 GT 0) Æ INVALID
[#11 GT 0] Æ VALID
_____________________________________________________________________________________
1-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 2: Variables
Chapter 2: Variables
The ServoWorks macro programming language allows you to specify either a numeric value or a variable number.
When a variable number is used, the variable value can be assigned when the macro program is called from the part
program, or the variable value can be calculated within the macro program, based on other numeric values or
variables.
1) The Null Variable (#0). The value of this variable is always null. You cannot assign a value to this
variable.
! CAUTION
DO NOT USE A NULL VARIABLE.
Using a null variable (#0) in any line of code (in mathematical formulas, movement
commands or conditional expressions) will cause an error, or unintended results.
2) Local Variables (#1-#99). Local variables are used within a local program scope, which may be a macro
program, a subprogram or the main program. Local values are only held as long as the local scope exists.
For example, both the main program and a macro program called from the main program can have a local
variable #1, but they are separate variables with separate values that exist only within their scope. The
value of local variables within a macro program is lost (initialized to null) when the macro program returns
to the part program.
You can assign values to local variables when you call a macro program from within a part program, or you
can use local variables to hold the results of logical or mathematical operations.
3) Numbered Global Variables (#100-#499). Numbered global variables are used by the ServoWorks CNC
system and are shared across multiple macro programs. The value is saved in the ServoWorks CNC system
after a macro program (which may have assigned or changed the value of the global variable) returns to the
part program. These variables lose their values when the control is completely shut down (powered off).
Numbered global variables have file scope – that is, if a global variable is defined in a file (whether it is the
main program, a subprogram, or a macro program; whether or not it is defined inside a subroutine), its
value is only visible in that file.
_____________________________________________________________________________________
2-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 2: Variables
4) Symbolic Global Variables (#axxx - #zxxx) . The ServoWorks CNC system allows the use of symbolic
variables, with meaningful variable naming (such as #position), for the convenience of the user. These
symbolic variables must be all lower case, preceded by a “#” sign, and contain no numbers.
Symbolic global variables, like numbered global variables, are used by the ServoWorks CNC system and
are shared across multiple macro programs. The value is saved in the ServoWorks CNC system after a
macro program (which may have assigned or changed the value of the global variable) returns to the part
program. These variables lose their values when the control is completely shut down (powered off).
Symbolic global variables also have file scope.
! CAUTION
You will get unpredictable results if you specify a symbolic global variable that does
not begin with “#,” or that uses upper case letters or mixes upper and lower case
letters, or that includes numbers in the name. Either the variable will be ignored or
there will be an error, depending on whether or not the variable name conflicts with
keywords.
5) Numbered Permanent Variables (#500-#999). Permanent variables are used by the ServoWorks CNC
system and are shared across multiple macro programs. These variables keep their value in the
ServoWorks CNC system after a macro program (which may have assigned or changed the value of the
global variable) returns to the part program. They even keep their values even when the control is
completely shut down (powered off), because the values are saved in the Windows registry. [NOTE:
ServoWorks S-100T is the exception; the values of all numbered permanent variables are lost when the
control is completely shut down (powered off).]
6) System Variables (#3000 - #13999). System variables are used for holding data/values related to NC
operations, such as positions, feedrates, tool compensation values, workpiece coordinate offsets, etc. For
more information, see Chapter 3: System Variables.
All variables except symbolic variables must be assigned a number. Symbolic variables should have lower case
names.
All variables except symbolic variables must be specified with a number sign (“#”) followed by the variable
number. The correct format is:
where “n” is the variable index number. For instance, to specify the variable #1 and give it the value of 500, the line
of code would simply be:
#1 = 500
To specify the symbolic variable #position and give it the value of 23.0, the line of code would simply be:
#position = 23.0
_____________________________________________________________________________________
2-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 2: Variables
! CAUTION
Parentheses are invalid for specifying a variable number with an expression, and
would result in an error or in unpredictable results.
You can reference a local, global, permanent or system variable in one of two ways:
1) If you want to directly use the value of a variable, put the variable number after a word address, such as
“X#4”. The value of variable #4 is used for the value of the part programming parameter “X.”
For example:
#1 = 20
#2 = 40
#position = 23.5
G01 X#1 Y#2 Z#position Æ this is interpreted as “G01 X20 Y40 Z23.5”
2) If you want to use the value of a variable in an expression, enclose the expression in brackets (“[]”) and put
the expression after a word address, such as “X[#4+#5].” The value of variables #4 and #5 are added
together, and used for the value of the part programming parameter “X.”
You can reverse the sign of a variable value by referencing it with a minus sign (–) before the “#,” such as “X–#4.”
As an example, the following line in a macro program demonstrates several ways of referencing local, global or
system variables:
#position = 100
G00 X#position Z#position
These lines would have the same effect as “G00 X100 Z100”.
! CAUTION
You cannot reference any variable with subprogram name calls (a “P” word address)
or block/sequence numbers (an “N” word address).
_____________________________________________________________________________________
2-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 2: Variables
! CAUTION
VARIABLES MUST BE DEFINED/INITIALIZED BEFORE USE.
Using a null variable (#0) or an uninitialized variable in any line of code (in
mathematical formulas, movement commands or conditional expressions) will cause
an error, or unintended results.
Local and global variables are stored as double-precision floating-point values. A double-precision floating-point
number is a 64-bit approximation of a real number. The number can be zero or can range from -
1.7976931348623157E+308 to -2.2250738585072014E-307 (-1.7976931348623157 x 10308 to –
2.2250738585072014 x 10-307), or from 2.2250738585072014E-307 to 1.7976931348623157E+308
(2.2250738585072014 x 10-307 to 1.7976931348623157 x 10308).
Values in ranges other than these will trigger an alarm in the ServoWorks CNC system.
When you assign a value without a decimal point, the value of the variable is assigned as a double-precision
floating-point value with the maximum precision possible, approximately 15 digits of precision.
When a variable is referenced and its value assigned to an address, the value is automatically rounded according to
the maximum accuracy of double-precision floating-point numbers. A floating-point calculation is an arithmetic
calculation done with floating-point numbers and often involves some approximation or rounding because the result
of an operation may not be exactly representable.
Floating-point values are limited to a finite precision. For the purposes of the machine tool and factory automation
industries, this highly accurate representation of values is more than adequate, and rounding of referenced values is
undetectable. For a more complete explanation, see Section 4.4: Precision and Errors.
Using the null variable (#0) in any line of code will result in an error.
If a variable has the value of null and is used in a mathematical formula, the entire line of code is ignored, causing
unintended results.
_____________________________________________________________________________________
2-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 2: Variables
! CAUTION
Using a null variable (#0) or an uninitialized variable in a mathematical formula will
cause unintended results, and should be avoided.
If a variable has the value of null and is used in a movement command, both the variable and the word address being
referenced will be ignored, probably causing unintended results. For example:
#1 = 10
#2 = #0
G01 X#1 Y#2
“G01 X10” is the movement command that will be executed. The “Y” address will be ignored, because the value
assigned to that address is undefined.
! CAUTION
Using a null variable (#0) or an uninitialized variable in a movement command will
be ignored, causing unintended results, and should be avoided.
If a variable has the value of null and is used in a conditional expression, it will cause a syntax error.
! CAUTION
Using a null variable (#0) or an uninitialized variable in a conditional expression will
cause an error, and should be avoided.
_____________________________________________________________________________________
2-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
_____________________________________________________________________________________
3-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
System variables for interfacing with the PLC are broken down as follows:
SYSTEM
VARIABLE CORRESPONDING PLC ADDRESS INTERFACE WITH PLC
NUMBER
#1000 G54.0
#1001 G54.1
#1002 G54.2
#1003 G54.3
#1004 G54.4
#1005 G54.5
#1006 G54.6
#1007 G54.7 16-bit signal from PLC to macro. The
signal is read bit by bit.
#1008 G55.0
#1009 G55.1
#1010 G55.2
#1011 G55.3
#1012 G55.4
#1013 G55.5
#1014 G55.6
#1015 G55.7
The 16-bit binary value of byte G54 16-bit signal from PLC to macro. All
#1032 and G55, G54 being the least 16 bits of the signal are read at one
significant byte. time.
_____________________________________________________________________________________
3-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
SYSTEM
VARIABLE CORRESPONDING PLC ADDRESS INTERFACE WITH PLC
NUMBER
#1100 F54.0
#1101 F54.1
#1102 F54.2
#1103 F54.3
#1104 F54.4
#1105 F54.5
#1106 F54.6
#1107 F54.7 16-bit signal from macro to PLC. The
signal is read bit by bit.
#1108 F55.0
#1109 F55.1
#1110 F55.2
#1111 F55.3
#1112 F55.4
#1113 F55.5
#1114 F55.6
#1115 F55.7
The 16-bit binary value of byte F54 16-bit signal from macro to PLC. All
#1132 and F55, F54 being the least 16 bits of the signal are read at one
significant byte. time.
32-bit signal from macro to PLC. All
The 32-bit binary value of byte 32 bits of the signal are read at one
#1133 F56, F57, F58 and F59, F56 being time.
the least significant byte. Acceptable values range from –
2,147,483,648 to +2,147,483,648.
_____________________________________________________________________________________
3-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
System variable numbers for tool compensation values are available for ServoWorks MC-Quad, ServoWorks
S-100M, ServoWorks S-120M and ServoWorks S-140M, and are broken down as follows:
· · · · ·
· · · · ·
· · · · ·
· · · · ·
· · · · ·
· · · · ·
SYSTEM
VARIABLE TIMER DESCRIPTION
NUMBER
_____________________________________________________________________________________
3-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
! CAUTION
If you try to write to a system variable for modal information, you will get an error.
This variable is write-protected.
System variables for modal information for ServoWorks S-100T, ServoWorks MC-Quad, ServoWorks S-100M,
ServoWorks S-120M and ServoWorks S-140M are explained as follows:
SYSTEM
MODAL
VARIABLE FUNCTION
GROUP
NUMBER
One shot G codes: G04, G09, G27, G28, G29, G30, G50, G52,
#4000 00
G70~G76, G107
#4001 Movement commands: G00, G01, G02, G03, G32, G90, G92, G94 01
#4010 Canned cycle: G80, G83, G84, G85, G87, G88, G89 10
#4015 Exact stop check mode and cutting mode: G61, G64 15
_____________________________________________________________________________________
3-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
SYSTEM
MODAL
VARIABLE FUNCTION
GROUP
NUMBER
One shot G codes: G04, G05, G08, G09, G10, G27, G28, G29, G30,
#4001 00
G31, G53, G65, G92
#4002 Movement commands: G00, G00.1, G01, G02, G03, G02.3, G03.3 01
Table 3-7: System Variables for ServoWorks MC-Quad, S-100M, S-120M, and S-140M Modal Information
As an example, the line of code “#5=#4006,” the value of variable #5 would be either 20 or 21, depending upon
whether G20 or G21 was active.
_____________________________________________________________________________________
3-6
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
! CAUTION
If you specify a system variable to read modal information that corresponds to a G
code modal group that cannot be used (i.e. a G code related to ServoWorks S-100T
functions when you’re using ServoWorks MC-Quad), that system variable will be
assigned a value of zero.
! CAUTION
If you try to write to a system variable for position information, you will get an error.
This variable is write-protected.
SYSTEM
VARIABLE POSITION INFORMATION NOTES
NUMBER
Block end point (the program position • Tool compensation value not
#5001 – #5008 at the completion of the current block) included
(for axes 1-8) in the current workpiece coordinate • System variable can be read during
system1 movement
_____________________________________________________________________________________
3-7
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
NOTES:
1) If no G54, G55, G56, G57, G58 or G59 code has been programmed, the workpiece coordinate system will
be the same as the machine coordinate system.
2) See Section 7.1: Preread Function / Block Buffering – Problems and Workaround.
An example follows, where X is Axis #1, Y is Axis #2, and the G54 workpiece coordinates are X=100 and Y=100.
At the completion of the execution of the above code, the value of #1 would be 10.000 (the program position
relative to the G54 workpiece coordinate system). The value of #2 would be 110.000 (the machine position relative
to the machine coordinate system). The value of #3 would be 10.000 mm (the program position relative to the G54
workpiece coordinate system).
_____________________________________________________________________________________
3-8
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 3: System Variables
System variables for workpiece coordinates in various workpiece coordinate systems are explained as follows:
SYSTEM
VARIABLE EXPLANATION
NUMBER
#5201 – #5208
External workpiece coordinates
(for axes 1-8)
#5221 – #5228
G54 workpiece coordinates for workpiece coordinate system #1
(for axes 1-8)
#5241 – #5248
G55 workpiece coordinates for workpiece coordinate system #2
(for axes 1-8)
#5261 – #5268
G56 workpiece coordinates for workpiece coordinate system #3
(for axes 1-8)
#5281 – #5288
G57 workpiece coordinates for workpiece coordinate system #4
(for axes 1-8)
#5301 – #5308
G58 workpiece coordinates for workpiece coordinate system #5
(for axes 1-8)
#5321 – #5328
G59 workpiece coordinates for workpiece coordinate system #6
(for axes 1-8)
_____________________________________________________________________________________
3-9
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
Tables 4-1, 4-2 and 4-3 summarize the mathematical and logical operations can be performed on variables. In the
tables, the expression to the right of the operator (“=”) can contain constants, variables, or an expression containing
constants and/or variables. Variables to the left of the operator (“=”) can also be replaced with an expression. #A,
#B and #C represent local, global, permanent, system or symbolic variables, unless noted otherwise.
Assignment #A = #B
Sum #A = #B + #C
Difference #A = #B - #C
Product #A = #B * #C
Quotient #A = #B / #C
Exponent #A = #B ^ #C
_____________________________________________________________________________________
4-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
! CAUTION
If you input data in radians instead of degrees for trigonometric functions you will get
an error.
_____________________________________________________________________________________
4-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
Natural
#A = ln [#B]
Logarithm
2) Brackets must be used: sin [#B]. The use of parenthesis (i.e. “sin (#B)”) would result in an error.
3) To include comments in mathematical and logical operations, use parenthesis (“( )”).
_____________________________________________________________________________________
4-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
4.3.1 Nesting
In addition to using brackets as part of functions, you can use brackets to specify a certain order of operations.
There is no limit to the number of folds for nested brackets. For equations with brackets, expressions and functions
within brackets are executed from the innermost to the outermost pairs of brackets.
For instance:
4
4.3.2 Priority of Operations
Commands including mathematical and logical operations are executed in a predictable order, as follows:
3) Addition and subtraction operations (+, –, or, xor) (from left to right)
There is always some level of error in the execution of mathematical and logical operations. However, all
ServoWorks CNC systems use highly precise double-precision floating-point variables, so the level of error is quite
small, approximately 15 digits.
The 64-bit double-precision floating point standard is described by IEEE. A double-precision floating-point word
has the following internal format:
_____________________________________________________________________________________
4-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F'.
A number n is expressed in floating point format as:
n = (-1)s * m * 2e
where “s” is the value of the sign bit, “m” is the mantissa, and “e” is the exponent.
The mantissa m is "normalized," which means that it is always scaled such that it is greater than or equal to 1, and
less than 2. Therefore, the ones bit (20) is always set, and is not present in the actual number. This is called an
implied bit. Since the mantissa is 52 bits, plus the implied ones bit, the precision of the number is stored to 53 bits,
or 253 = 900,719,925,474,100, approximately 15 digits of precision (2.2250738585072014E-307, or
2.2250738585072014 x 10-307).
The effective range (excluding infinite values) of IEEE double-precision floating-point numbers is:
• Binary: ± (2-2-52)1023
308.25
• Decimal: ~ ± 10 (This value is the end point of the range with the IEEE-754 round-to-nearest
value mode applied.)
Floating-point numbers usually behave very similarly to the real numbers they are used to approximate. However,
there are some cases where floating-point numbers do not model real numbers well because most floating-point
values can't be precisely represented as a finite binary value. For example 0.1 is .0001100110011... in binary (it
repeats forever), so it can't be represented with complete accuracy on a computer using binary arithmetic, which
includes all PCs. Similarly, the result of arithmetic operations may need to be rounded. For example, 2/3 might
yield 0.666666666666667.
Because of this, you can’t assume that a result is accurate to the last decimal place. There are always small
differences between the "true" answer and what can be calculated with the finite precision of any floating point
processing unit. Cumulative rounding errors are possible, but are unlikely to ever be problematic.
! CAUTION
Any time you specify division by zero, you will get an error.
_____________________________________________________________________________________
4-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 4: Mathematical and Logical Operations
Conditional expressions using EQ (equal to), NE (not equal to), GE (greater than or equal to), GT (greater than), LE
(less than or equal to) or LT (less than), can also result in errors.
As an example, if you are using the expression “IF [#10 EQ #20],” if there are small errors in how variables #10
and #20 have been calculated, you may get a FALSE evaluation when a TRUE evaluation would have been
expected. Also, consider that both variables #10 and #20 may have been rounded off slightly, which could also
affect the evaluation.
To avoid this problem, you could replace the expression “IF [#10 EQ #20]” with “IF [abs [#10 – #20] LT
0.00001,” thus assuming that two values are considered to be equal if their difference does not exceed some
allowable limit (0.00001 in this case)
Any time you use a null variable or an uninitialized variable, you will get an error or unintended results.
.
_____________________________________________________________________________________
4-6
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
5) The WHILE DO END statement (conditional loop: repetition while certain conditions are met).
These branching and repetition statements are case insensitive: they can be both lower case or upper case (“IF ELSE
ENDIF” or “if else endif.”
GOTO n Å NOTE: a space is required between “GOTO” and “n,” the sequence number
“n” refers to the sequence number. It can be specified in one of two ways:
! CAUTION
It is strongly recommended that you use GOTO statements to branch to sequence
numbers that occur later in the macro program, rather than a sequence number that
comes BEFORE the GOTO statement. In other words, the flow of control should
always be in the forward direction, not in the reverse direction, or it will impact
processing time.
! CAUTION
If you specify a sequence number outside the range of 1 to 99,999, you will get an
error.
_____________________________________________________________________________________
5-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
! CAUTION
It is invalid to use a variable or an expression as a sequence number. The following
lines of code would each result in an error:
GOTO #1
GOTO [#1 + #2]
#1 = 100
#2 = 0
IF [#1] Å evaluates as TRUE
IF [#2] Å evaluates as FALSE
[#A EQ #B]
EQ = Equal to
[#A = #B]
[#A GT #B]
GT > Greater than
[#A > #B]
[#A GE #B]
GE ≥ Greater than or equal to
[#A >= #B]
[#A LT #B]
LT < Less than
[#A < #B]
[#A LE #B]
LE ≤ Less than or equal to
[#A <= #B]
_____________________________________________________________________________________
5-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
! CAUTION
Conditional statements that include the null variable (#0) will result in a syntax error.
! CAUTION
Brackets must be used: [#A EQ #B]. The use of parenthesis (i.e. “(#A EQ #B)”)
would result in an error.
5.4 IF Statement
The IF statement specifies some conditional expression. It may be followed by a GOTO statement, a THEN
statement, or an ELSE…ENDIF structure.
If that conditional expression is satisfied, program execution branches to sequence number n. If that conditional
expression is not satisfied, program execution continues with the execution of the statement following the IF GOTO
statement.
As noted previously, “n” refers to the sequence number, and can be specified in one of two ways:
! CAUTION
If you specify a sequence number outside the range of 1 to 99,999, you will get an
error.
! CAUTION
It is invalid to use a variable or an expression as a sequence number. The following
lines of code would each result in an error:
GOTO #1
GOTO [#1 + #2]
_____________________________________________________________________________________
5-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
If that conditional expression is satisfied, the program executes the macro statement following the “THEN.” If that
conditional expression is not satisfied, program execution continues with the execution of the statement following
the IF THEN statement (and the macro statement following the “THEN” is not executed).
! CAUTION
The macro statement needs to be in the same line as the IF THEN statement, or you
will get an error.
IF [<conditional expression>]
<macro statement(s)>
ELSE
<macro statement(s)>
ENDIF
If the first conditional expression is satisfied, the program executes the macro statement(s) following “IF” (and the
macro statement(s) following the “ELSE” are not executed). If that first conditional expression is not satisfied, then
program execution continues with the execution of the second macro statement or set of macro statements following
“ELSE” (and the macro statement(s) following the “IF” are not executed). Program execution then continues with
the execution of the statement following the ENDIF statement.
Only one of the two sets of macro statements in an IF ELSE ENDIF structure is executed.
_____________________________________________________________________________________
5-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
! CAUTION
If you specify an “m” number outside the range of 1 to 99,999, you will get an error.
WHILE/DO/END statements can be consecutive, or can be nested inside of each other. See Section 5.6: Nesting for
examples.
5.6 Nesting
Conditional statements and repetition statements can be nested within each other, with certain logical restrictions.
IF ELSE ENDIF and WHILE DO END statements can be nested with no limit to the depth of nesting.
_____________________________________________________________________________________
5-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
The flow of control can be directed to outside of the WHILE DO END loop, an example of which follows:
IF [<conditional expression>]
<macro statement(s)>
ELSE
IF [<conditional expression>]
<macro statement(s)>
ELSE
IF [<conditional expression>]
<macro statement(s)>
ELSE
<macro statement(s)>
ENDIF
ENDIF
ENDIF
There are several nesting conditions that that would cause an error in the execution of your macro program:
2) GOTO statements that branch the flow of control within a DO/END Loop of a WHILE statement
3) Infinite loops
_____________________________________________________________________________________
5-6
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 5: Flow of Control – Branching and Repetition
5.6.2.2 GOTO Statements That Branch The Flow Of Control Within A DO END Loop Of A
WHILE Statement
DO/END loops cannot be entered except from the while statement. If you attempt to use a GOTO statement to send
the flow of control to within a DO/END loop, you will get an error, as this cannot logically be executed (the
evaluation of the conditional statement of the WHILE loop is skipped).
An example of a GOTO statement that branches the flow of control within a DO/END loop follows:
• The conditional expression for a WHILE statement is always true – none of the variables within the
conditional expression are modified by statements within the DO END loop
_____________________________________________________________________________________
5-7
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
Macro subprograms can be called using custom G, M, S or T codes, or by using the M98 subprogram call, in the
format:
M98 P R where P is the subprogram name, and R specifies the number of times the subprogram
should be executed.
Calls to macro subprograms using M98 have the disadvantage of not allowing the passing of variables.
For example, “M98 PTest_1 R3” calls subprogram OTest_1.dat in the same folder as the parent program, and
repeats it three times. The subprogram must be in a separate file from the part program file in which the M98
subprogram call appears. The subprogram file must be in the same folder as the part program file.
Macro programs can be called from within part programs with any of the following methods:
1) A subprogram macro call (M98) Macro programs must be in the same folder as the part program file.
2) A simple macro call (G65) Macro subroutines must be in the same file as the main program
The differences between an M98 subprogram call and other macro calls are summarized in the following table:
Arguments
can be
NO YES YES YES
specified (data
passed)
Table 6-1: Summary of Differences Between M98 Subprogram Call and Macro Calls
_____________________________________________________________________________________
6-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
For example, the statement “G65 P9000 A10. B20. C30.” assigns the value of “10” to #1, the value of “20” to #2
and the value of “30” to #3. In other words, addresses A, B and C are used to pass arguments, which are assigned
to local variables #1, #2 and #3.
The argument assignment protocol for ServoWorks CNC macros uses all of the letters of the alphabet (once each)
except G, L, N, O and P.
! CAUTION
If you specify a G, L, N, O or P in your argument assignments, you will get an error.
Addresses that need not be specified (that won’t be used by the macro program) can be omitted from the argument
assignments. The values of local variables corresponding to omitted addresses are set to null.
The letters and the local variables to which the letters are assigned are summarized in the following table:
A #1
B #2
C #3
D #7
E #8
F #9
H #11
I #4
J #5
K #6
M #13
Q #17
R #18
S #19
T #20
U #21
V #22
W #23
X #24
Y #25
Z #26
Table 6-2: Summary of Argument Assignment Protocol for ServoWorks CNC Macros
_____________________________________________________________________________________
6-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
An example follows: the statement “G65 P9000 A10. B20. F2. S100.” assigns the value of “10” to #1, the value
of “20” to #2, the value of “2” to #9 and the value of “100” to #19. In other words, addresses A, B, F and S are
used to pass arguments, which are assigned to local variables #1, #2, #9 and #19. The values of local variables #3,
#4, #5, #6, #7, #8, #11, #13, #17, #18, #20, #21, #22, #23, #24, #25 and #26 are set to null because the addresses
that correspond with them were omitted from the argument assignment statement.
Required Format
In addition to these two parameters, the macros are called with argument assignments, which are not considered to
be parameters.
Example 1
G65 P100 L3 Z20.0 R2.5 F500 – calls macro program O100.dat, which will be repeated 3 times, and assigns
the value 20.0 to address Z, 2.5 to address R and 500 to address F
O100.dat – this line indicates the macro program O100.dat, which is in the same file,
and which precedes the subroutine code
_____________________________________________________________________________________
6-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
Example 2
G28
G50 X0 Z0
G65 P1 Z-5 R.5 Q1 D0.3 F20.0
main program
M30
%
O1
IF [#26-#18>0] GOTO 100
IF [#17<=0] GOTO 100
IF [#7<0] GOTO 100
IF [#9<=0] GOTO 100
#50 = #18
G00 X0
G00 Z#50
WHILE [#50-#17 > #26] DO 1
#50 = #50 - #17
macro subroutine
G01 Z#50 F#9
#50 = #50 + #7
G00 Z#50
#50 = #50 - #7
END 1
G01 Z#26 F#9
G00 Z#18
N100
M99
%
Limitations
• G65 must be specified before any argument.
• The macro program (the subroutine) must be in the same file as the part program file that calls the macro
program.
There are local variable levels (0 to 4) pertaining to nesting. The level of the main program is level 0. Each time a
macro is called, the level of the local variable is incremented by one, and the values of the local variables at the
previous level are saved in the ServoWorks CNC system.
When M99 is executed in a macro program (indicating the end of the macro program), control returns to the calling
program, the local variable level is decremented by one, and the values of the local variables that existed when the
macro was called are restored.
! CAUTION
When M99 is executed in a main program, it results in an infinite loop.
_____________________________________________________________________________________
6-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
6.5.1 Overview
You can create customized G, M, S or T codes to call macro programs, using Configuration Mode of one of the
ServoWorks S-100M series (S-100M, S-120M and S-140M). This is very similar to the G65 simple macro call.
Essentially, you can use this capability to create your own special, user-defined G, M, S or T code functions (written
as customized macro programs) and call them using your own G, M, S or T code number.
You can define G, M, S or T codes as specialized codes by using macro parameters to associate these codes with
specific macro programs. For S and T codes, the specified macro program applies to ALL S and T codes. For G
and M codes, you define specific G and M codes (up to ten of each) that you associate with different macro
programs.
When the “Enable Custom G/M/S/T Macro Calls” parameter (set in Configuration Mode of ServoWorks S-100M,
S-120M or S-140M) is set to “Enabled,” the ServoWorks RealTime DLL searches part program files before starting
G code execution and generates (creates) a temporary file (with a user-defined file name and location), in which
every special G, M, S and T code (defined by the Macro function parameters) is replaced with a G65 simple macro
call to the specified macro program, and each macro program is appended to this temporary file as a subroutine. S
and T codes are kept as parameters (arguments) in any new line involving special S or T codes that invoke a macro
program.
NOTE: When the “Enable Custom G/M/S/T Macro Calls” parameter is set to “Enabled,” the temporary file is
created and executed even if there are no special G, M, S or T codes in the part program.
6.5.2 Macro Call Function Parameters for Custom G Codes, M Codes, S Codes or T
Codes
_____________________________________________________________________________________
6-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
_____________________________________________________________________________________
6-6
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
• All lines of code that contain special G, M, S or T codes are replaced with G65 simple macro calls to the
corresponding user-defined macro programs
• These user-defined macro programs are appended to this temporary part program file as macro subroutines
Required Format
You must include the full path for this file, including the drive.
Example
C:\Program Files\SoftServo\S-100M\ncdata\Macro\tempdata.dat
Limitations
• The location for this temporary file must be in a local folder, not on a network or a non-system drive.
• This folder must already exist. If you type the path of a folder that does not exist, you will get an error
message similar to the following:
Notes
• When the “Enable Custom G/M/S/T Macro Calls” is set to “Enabled,” this temporary file is created
whether or not there are any special G, M, S or T codes.
• Because this temporary part program file is executed by the ServoWorks G-Code parser and not the
original part program file, M98 blocks will look for subprograms in the folder containing the temporary file
and not the original part program file. To have M98 blocks look for subprograms in the folder containing
the original part program file, set the output file to be in the same folder as the original part program file.
_____________________________________________________________________________________
6-7
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
For example, if S1000 is defined as a custom S code macro call to O1234.dat, if “S500” appears in
O1234.dat, it will NOT be treated as a macro call.
• No nesting of calls using S codes is allowed. In other words, if S codes are defined to call a macro
program, any S codes in that macro program (subroutine) will be treated as ordinary S codes, and will not
call that macro program again.
• All S codes in subprograms called with M98 are treated as ordinary S codes.
Notes
The S code is kept as a parameter (argument) in the new line that invokes the macro program. For example, the line
of code “S10” would be replaced with “G65 P3333 S10.”
_____________________________________________________________________________________
6-8
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
For example, if T1000 is defined as a custom T code macro call to O1234.dat, if “T500” appears in
O1234.dat, it will NOT be treated as a macro call.
• No nesting of calls using T codes is allowed. In other words, if T codes are defined to call a macro
program, any T codes in that macro program (subroutine) will be treated as ordinary T codes, and will not
call that macro program again.
• All T codes in subprograms called with M98 are treated as ordinary T codes.
Notes
The T code is kept as a parameter (argument) in the new line that invokes the macro program. For example, the line
of code “T10” in the original NC part program would be replaced with “G65 P3333 T10.”
In the O3333.dat macro program, the code should be written using the variable “T#20,” because “#20” is the
variable number that corresponds to address letter T (see Table 6-2). When the parameter “T10” is passed into the
O3333.dat macro program as an argument, T#20 will be replaced with T10. In this way, the O3333.dat macro
program can support all T codes, with the T codes defined by the tool number called in the original NC program.
_____________________________________________________________________________________
6-9
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
1) The name of the M code that invokes a macro program file (that defines this custom M code).
2) The name of the macro program to be called for each instance of that specific M code in the user’s part
program.
Required Format
The format for an M code can be an integer, or an integer with one digit after the decimal point. This is helpful,
since you can name special M codes as non-integer numbers to set them apart from normal, predefined M codes
which are always an integer value.
The name of the macro program should be an integer between 1 and 999999999 (with no commas).
Example
The name of the M code could be “3” (which defines “M03” as a customized M code), or could be “3.1” (which
defines “M03.1” or “M3.1” as a customized M code).
The name of the macro program could be “3333” (which would cause the special M code to invoke a macro
program file named “O3333.dat”)
Limitations
• No nesting of calls using any specially defined M codes is allowed. In other words, if a special M code is
defined to call a macro program, any instances of that same M code in that macro program (subroutine) will
be treated as an ordinary M code, and will not call that macro program again.
However, if a DIFFERENT special M code is used in a macro program (different than the special M code
that called that macro program), then it WILL call its associated macro program from within the macro
program.
For example, if M3.1 is defined as a custom M code macro call to O3131.dat, if “M3.1” appears in
O3131.dat, it will NOT be treated as a macro call. But if M4.1 is defined as a custom M code macro call to
O4141.dat, and M4.1 appears in O3131.dat, it WILL call O4141.dat from O3131.dat.
• All M codes in subprograms called with M98 are treated as ordinary M codes.
_____________________________________________________________________________________
6-10
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 6: Calling Macro Programs
1) The name of the G code that invokes a macro program file (that defines this custom G code).
2) The name of the macro program to be called for each instance of that specific G code in the user’s part
program.
Required Format
The format for a G code can be an integer, or an integer with one digit after the decimal point. This is helpful, since
you can name special M codes as non-integer numbers to set them apart from normal, predefined M codes which are
always an integer value.
The name of the macro program should be an integer between 1 and 999999999 (with no commas).
Example
The name of the G code could be “23” (which defines “G23” as a customized G code), or could be “23.1” (which
defines “G23.1” as a customized G code).
The name of the macro program could be “3333” (which would cause the special G code to invoke a macro program
file named “O3333.dat”)
Limitations
• No nesting of calls using any specially defined G codes is allowed. In other words, if a special G code is
defined to call a macro program, any instances of that same G code in that macro program (subroutine) will
be treated as an ordinary G code, and will not call that macro program again.
However, if a DIFFERENT special G code is used in a macro program (different than the special G code
that called that macro program), then it WILL call its associated macro program from within the macro
program.
For example, if G23.1 is defined as a custom G code macro call to O231.dat, if “G23.1” appears in
O231.dat, it will NOT be treated as a macro call. But if G24.1 is defined as a custom G code macro call to
O241.dat, and G24.1 appears in O231.dat, it WILL call O241.dat from O231.dat.
• All G codes in subprograms called with M98 are treated as ordinary G codes.
_____________________________________________________________________________________
6-11
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 7: Macro Statement Processing
There are occasions where macro statements using system variables are evaluated, parsed, and delivered to the block
buffer BEFORE the previous lines have been executed, and the relevant system parameters have been updated.
Therefore, the evaluation of a macro statement containing a system variable may not evaluate as expected.
For example, let’s say the current position of the X axis is 0.0, and then the following five blocks of code are each
parsed and sent to the block buffer as a group:
G01 X10
G01 X20
G01 X30
G01 X40
IF [#5021 LT 20.0] then <macro statement> This fifth statement is evaluated based upon the
position of X as 0.0, because the previous 4 lines of
system variable for the current code have been preread and placed in the buffer, but
position of Axis 1 in the machine have not yet been executed. The system variable for
coordinate system the current position of the X axis will not be updated
until these lines of code have been executed, which is
too late for the fifth line of code to evaluate as the
programmer intended.
There is a workaround to this problem that avoids this problem. Simply program five “dummy” blocks of code
before any macro statements involving system variables. Typically, we recommend the following for block delays:
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
This only delays code execution by 50 milliseconds, but avoids any problems caused by a delay in system variable
value updating.
! CAUTION
IF YOU DO NOT PROGRAM IN BLOCK DELAYS BEFORE STATEMENTS
INVOLVING SYSTEM VARIABLES, YOU WILL GET UNEXPECTED
RESULTS IN THE EXECUTION OF YOUR MACRO PROGRAMS.
_____________________________________________________________________________________
7-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 7: Macro Statement Processing
_____________________________________________________________________________________
7-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
8.1 Overview
The following are examples of macros for automatic tool change (ATC) functions for ServoWorks S-100T,
ServoWorks S-100M, ServoWorks S-120M or ServoWorks S-140M.
NOTE: ATC achieved with a macro program is different than the GE Fanuc way. Fanuc supports the M06 code
(Tool Change). Any time a tool change is required, an “M06T__” command is given inside a part program. This
“M06T__” command activates either a macro program or a PLC sequence program, or both.
First, write a macro program or a subprogram for tool change. This macro or subprogram includes motion
commands, M codes and T codes.
Then, in the part program, call that macro or subprogram each time you require a tool change. (Instead of just
writing “M06T__” in the part program, as you would do with Fanuc.)
#520=3
M98 P9006 Å Calls the tool change macro program
G04 P1500
#520=5
M98 P9006 Å Calls the tool change macro program
M02
Figure 8-1: Part Program That Calls the Macro Program O9006.dat
_____________________________________________________________________________________
8-1
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
M50
M5
G04 P1000
G20
N10
M10
G04 P2000 (Open Collet)
G00 G53 Z0.
_____________________________________________________________________________________
8-2
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
Then, for each customized G, M, S or T code, you must write a customized macro program (.dat file) that resides in
the macro program folder (C:\Program Files\SoftServo\S-100M\ncdata\Macro\ in this case). In this example, the
customized macro programs are as follows:
_____________________________________________________________________________________
8-3
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
Write a part program file that uses these specialized S, T, M and G codes (G21.2, M03 and T20, in this example).
One such example part program follows:
_____________________________________________________________________________________
8-4
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
When the “Enable Custom G/M/S/T Macro Calls” parameter is set to “Enabled,” the ServoWorks G-Code Parser
searches the ATCTest.dat file before starting G code execution. It generates (creates) a temporary file (with the
“Output File Name”, in this case C:\Program Files\SoftServo\S-100M\ncdata\Macro\tempdata.dat), in which every
special S, T, M or G code is replaced with a G65 simple macro call to the specified macro program, and each macro
program is appended to the “tempdata.dat” file as a subroutine, as shown:
O1111
G90
G1 X-50.0 Y100.0 F2000
X-50.00 Y-200.0 F4000
M99
%
O3333
G90
M03 S1000
M99
%
O2222
G90
X100.0 Y-200.0
X0.0 Y0.0
M99
%
ATCTest.dat tempdata.dat
Figure 8-8: Example of ATC: Transformation of ATCTest.dat into the tempdata.dat File
The tempdata.dat file becomes the file actually executed by the ServoWorks G-Code Parser, NOT the ATCTest.dat
file.
_____________________________________________________________________________________
8-5
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
8.5 ATC Example #3: ATC for a Rotary Tool Changer Using PLC, Standard
G Codes, and a Customized T Code
Following is another example of an ATC function that uses predefined M codes and a customized T code to trigger
tool changes in the executing part program.
The rotary tool changer has 13 tool positions, and is shown in the following figure:
Home sensor –
Tool #1
Tool present sensor
Spindle
NOTES:
1) BEFORE USING A T CODE TO INVOKE THE ATC MACRO PROGRAM, YOU MUST FIRST SET
THE TOOL CHANGER TO ITS HOME POSITION USING M28, AND THEN USE MDI MODE TO
SET #600 (A NUMBERED PERMANENT VARIABLE) TO 1 BY TYPING “#600=1” IN MDI MODE.
2) Variable #20 is assigned to address “T” (see Table 6-2). In this case, #20 is the tool number to be placed in
the spindle. If “T7” was used to call the tool change macro program, then #20 = 7.
When you want to invoke a tool change as part of a part program, just use “T” followed by the tool number (i.e.
“T7”), and the O2004.dat tool change macro program will be invoked, and will pass the tool number to this macro
program.
The tool change procedure that is programmed in the macro program for custom T codes (in file O2004.dat) is
described in detail as follows:
_____________________________________________________________________________________
8-6
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
1) Check to see if the called tool number is equal to the current tool number (does #20 equal #600?) – if it is,
exit the macro program
2) Use the M12 code defined in the PLC sequence program to open the tool-changer cover
3) Check to make sure the tool-changer cover actually opened. Check the “tool change cover open sensor”
wired to X2.5 – if it is 0 (open), continue, otherwise generate an alarm and exit the macro program. [More
specifically, system variable #1005 is used in the macro program. #1005 corresponds to PLC address
G54.5, and the PLC sequence program reads the value of X2.5, which is wired to the tool changer cover
open sensor, and writes it to G54.5.]
4) Check the “tool present sensor” wired to X2.3 to see if there is a tool in the spindle – if it is 0 (no tool in the
current holder), skip the tool return step, and continue to step #12
5) Move the spindle to the spindle safe position (above the workspace, to move over the tool-changer)
6) Move the spindle to the XY tool change position for tool return
8) Move the tool-changer to return the current tool to the tool holder, moving at the low speed tool-changer
feedrate
9) Open the collet using the M10 code defined in the PLC sequence program
10) Check the “open collet check” sensor wired to X2.4 to make sure the collet opened (is set to 1) – if it
didn’t, generate an alarm and exit the macro program
11) Grab the tool in the current holder by bringing the spindle down to the ready-to-approach position, and then
retracting it back up to the safety position
12) Check to make sure the tool number isn’t zero (in which case, having returned the current tool, go directly
to step #24)
13) Calculate the difference between the current tool number and the called tool number, then calculate the
distance (number of steps required to be travelled – sum of sections where each is 1/13 of a circle) to reach
the called tool moving in each direction, to optimize the tool change operation
14) Check the “open collet check” sensor wired to X2.4 again, to make sure the collet is still open (is set to 1) –
if it isn’t, generate an alarm and exit the macro program
15) Rotate the carousel by the calculated angle to find the called tool and place it in the tool change position,
using M24 (one full motor revolution to rotate the carousel to the next closest tool, 13 revolutions for full
carousel revolution)
16) Move the spindle to the spindle safe position (above the workspace, to move over the tool-changer)
17) Move the spindle to the XY tool change position for tool return
18) Open the collet using the M10 code defined in the PLC sequence program
19) Check the “open collet check” sensor wired to X2.4 to make sure the collet opened – if it didn’t, generate
an alarm and exit the macro program
_____________________________________________________________________________________
8-7
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
20) Grab the new tool from the current holder by bringing the spindle down to the ready-to-approach position
(the grip position – the spindle clamps the tool with a spring), and then retracting it back up to the safety
position
21) Close the collet and lock the tool using the M11 code defined in the PLC sequence program
22) Check the “open collet check” sensor wired to X2.4 to make sure the collet closed (is set to 0) – if it didn’t,
generate an alarm and exit the macro program
23) Save the current tool number as #600 (a numbered permanent variable)
24) Reverse the tool-changer to bring it to the tool holder safe position
25) Move the spindle to the spindle safe position (above the workspace, to move over the tool-changer)
26) Close the tool-changer cover using the M13 code defined in the PLC sequence program
27) Check to make sure the tool-changer cover actually closed. Check the “tool change cover open sensor”
wired to X2.5 – if it is 1 (closed), continue, otherwise generate an alarm and exit the macro program.
28) Exit the tool change macro program, and return to the calling program.
_____________________________________________________________________________________
8-8
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
The macro function parameters must be set in Configuration Mode, Macro tab, as follows:
Location
of the
O2004.dat
file
Refers to
O2004.dat
Then, for the customized T code, the corresponding customized macro program (.dat file) for this example must
resides in the macro program folder (‘C:\Program Files\SoftServo’ in this case). In this example, the customized
macro program O2004.dat is as follows:
_____________________________________________________________________________________
8-9
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
(Homing-After set the tool changer to the home position, set #600=1
in MDI mode.)
(Participating I/O)
(Reached position switch for CW - input X2.0)
(Reached position switch for CCW - input X2.1)
(Tool present sensor - input X2.2)
(Open collet check - input X2.3)
(Tool changer cover open sensor X2.5)
(CW relay-output Y24.0)
(CCW relay-output Y24.1)
(M24 - one full motor revolution to rotate the carousel to the next
closest tool, 13 revolutions for full carousel revolution)
(Single or bi-directional)
_____________________________________________________________________________________
8-10
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
N10
IF [#1003 EQ 1] GOTO N40
(If there is no tool in the spindle, skip the tool return step,
otherwise continue)
IF [#1002 EQ 0] GOTO N20
(Check if the tool holder is empty for return - G54.2)
#1110=1 (Alarm message trigger F55.2)
M00
N20
G90G53 Z#59 (Safe spindle position)
G53 X#61 Y#81
(Place the spindle over the XY tool change position for tool return)
G90G53 Z[#58-#57]
(Place the spindle at the tool change Z axis position)
G91G01 X#55 Y#56 F#9
(Place the current tool in the tool holder)
M10 (Open the collet)
G04 P#50 (M-code time delay)
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
N30
G91G01 Z#57 (Spindle up to a ready-to-approach position)
G90G53 Z#59 (Spindle up to the safety position)
(Grab the new tools)
_____________________________________________________________________________________
8-11
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
N40
IF [#20 EQ 0] GOTO N80
(Return the current tool but do not grab another)
#91=#20-#600
(Difference between the current tool number and the called tool
number)
IF [#91 GT 0]
(Calculating distances to reach for both directions to optimize )
#90=#91
(Number of steps to travel (sum of sections where each is 1/13
of a circle ))
IF [#90 LT 7]
#1100=0
#1133=#90
ELSE
#1100=1
#1133=13-#90
ENDIF
ELSE
#90=-#91
(Number of steps to travel (sum of sections where each is 1/13
of a circle ))
IF [#90 LT 7]
#1100=1
#1133=#90
ELSE
#1100=0
#1133=13-#90
ENDIF
ENDIF
_____________________________________________________________________________________
8-12
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
N50
M24 (Rotate the carousel by given angle to find the
called tool and place it in the tool change
position)
G04 P#50
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
G90G53 Z#59 (Safe spindle position)
G90G53 X#61 Y#81 (Spindle above the called tool position)
M10 (Open the collet)
G04 P#50
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
N60
G90G53 Z#58
(Place the spindle at the ready-to-approach Z axis position)
G91G01 Z-#57 F#9
(Shift the spindle down on a spindle to the grip position)
M11 (Close the collet)
G04 P#50
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
_____________________________________________________________________________________
8-13
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
N70
#600=#20 (Save the current tool number)
N80
G91G01 X-#55 Y-#56 (Reverse the tool holder)
G90G53 Z#59 (Spindle up to the safety position)
M13 (Close the tool-changer cover)
G04 P#50 (M-code time delay)
G04 P#50 (M-code time delay)
G04 P#50 (M-code time delay)
G04 P10
G04 P10
G04 P10
G04 P10
G04 P10
M00
N90
M99
%
_____________________________________________________________________________________
8-14
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
The relevant part of the corresponding PLC sequence program that corresponds to the O2004.dat file is shown on
the following pages. This sequence program defines M03 – M06, M08 – M17, M19 – M41.
_____________________________________________________________________________________
8-15
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M10 - Y24.3
RD.NOT F10.0
AND F10.1
AND.NOT F10.2
AND F10.3
AND.NOT F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R4.2
// M12 - Y24.4
RD.NOT F10.0
AND.NOT F10.1
AND F10.2
AND F10.3
AND.NOT F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R4.4
_____________________________________________________________________________________
8-16
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M14 - Y24.5
RD.NOT F10.0
AND F10.1
AND F10.2
AND F10.3
AND.NOT F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R4.6
// M16 - Y24.6
RD.NOT F10.0
AND.NOT F10.1
AND.NOT F10.2
AND.NOT F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R5.0
_____________________________________________________________________________________
8-17
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M22 - Y24.7
RD.NOT F10.0
AND F10.1
AND F10.2
AND.NOT F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R5.6
// M24 - Y25.0
RD.NOT F10.0
AND.NOT F10.1
AND.NOT F10.2
AND F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R6.0
_____________________________________________________________________________________
8-18
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M26 - Y25.1
RD.NOT F10.0
AND F10.1
AND.NOT F10.2
AND F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R6.2
// M28
RD.NOT F10.0
AND.NOT F10.1
AND F10.2
AND F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R6.4
// M30 - Y25.2
RD.NOT F10.0
AND F10.1
AND F10.2
AND F10.3
AND F10.4
AND.NOT F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R6.6
_____________________________________________________________________________________
8-19
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M32 - Y25.3
RD.NOT F10.0
AND.NOT F10.1
AND.NOT F10.2
AND.NOT F10.3
AND.NOT F10.4
AND F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R7.0
// M34 - Y25.4
RD.NOT F10.0
AND F10.1
AND.NOT F10.2
AND.NOT F10.3
AND.NOT F10.4
AND F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R7.2
_____________________________________________________________________________________
8-20
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// M36 - Y25.5
RD.NOT F10.0
AND.NOT F10.1
AND F10.2
AND.NOT F10.3
AND.NOT F10.4
AND F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R7.4
// M38 - Y25.6
RD.NOT F10.0
AND F10.1
AND F10.2
AND.NOT F10.3
AND.NOT F10.4
AND F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R7.6
// M40 - Y25.7
RD.NOT F10.0
AND.NOT F10.1
AND.NOT F10.2
AND F10.3
AND.NOT F10.4
AND F10.5
AND.NOT F10.6
AND.NOT F10.7
WRT R8.0
_____________________________________________________________________________________
8-21
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// Spindle stop
RD.NOT F1.4
RD.STK Y0.0 // DC-120/DC-150 output bit 0
AND.NOT Y0.1
AND.NOT Y0.2
OR.STK
WRT Y0.0 // DC-120/DC-150 output bit 0
// Spindle CW
RD F7.0
AND R3.3
RD.STK Y0.1
AND F1.4
OR.STK
AND.NOT R3.4
WRT Y0.1
// Spindle CCW
RD F7.0
AND R3.4
RD.STK Y0.2
AND F1.4
OR.STK
AND.NOT R3.3
WRT Y0.2
// Spindle enable
RD R3.3
OR R3.4
RD.STK R2.0
AND.NOT R3.5
OR.STK
WRT R2.0 // Spindle enable relay
_____________________________________________________________________________________
8-22
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// Spindle Brake
RD.NOT R2.0
TMR 3
WRT Y1.3
// (M03/04/M05)
RD R3.3
RD.STK Y24.0
AND.NOT R3.4
AND.NOT R3.5
OR.STK
WRT Y24.0
RD R3.4
RD.STK Y24.1
AND.NOT R3.3
AND.NOT R3.5
OR.STK
WRT Y24.1
// (M10/M11)
RD R4.2
RD.STK Y24.3
AND.NOT R4.3
OR.STK
WRT Y24.3
// (M12/M13)
RD R4.4
RD.STK Y24.4
AND.NOT R4.5
OR.STK
WRT Y24.4
_____________________________________________________________________________________
8-23
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// (M14/M15)
RD R4.6
RD.STK Y24.5
AND.NOT R4.7
OR.STK
WRT Y24.5
// (M16/M17)
RD R5.0
RD.STK Y24.6
AND.NOT R5.1
OR.STK
WRT Y24.6
// (M22/M23)
RD R5.6
RD.STK Y24.7
AND.NOT R5.7
OR.STK
WRT Y24.7
// (M24/M25)
RD.NOT R200.0
AND R06.0
AND.NOT R6.1
WRT R200.7
//ROTATE
RD R200.7
AND F54.0
WRT Y25.0 //CW
RD R200.7
AND.NOT F54.0
WRT Y25.1 //CCW
// (M30/M31)
RD R6.6
RD.STK Y25.2
AND.NOT R6.7
OR.STK
WRT Y25.2
_____________________________________________________________________________________
8-24
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
// (M36/M37)
RD R7.4
RD.STK Y25.5
AND.NOT R7.5
OR.STK
WRT Y25.5
// (M38/M39)
RD R7.6
RD.STK Y25.6
AND.NOT R7.7
OR.STK
WRT Y25.6
// (M40/M41)
RD R8.0
RD.STK Y25.7
AND.NOT R8.1
OR.STK
WRT Y25.7
// MFIN (M00, M01, M02, M03, M04, M05, M06, M08, M09, M10,
M11, M12, M13, M14, M15, M16, M17, M19, M20, M22, M23, M24,
M25, M26, M27, M30, M31, M32, M33, M34, M35, M36, M37, M38,
M39, M40, M41)
RD R4.0
OR R4.1
OR R4.2
OR R4.3
OR R4.4
OR R4.5
OR R4.6
OR R4.7
WRT R0.2
RD R5.0
OR R5.1
OR R5.2
OR R5.3
OR R5.4
OR R5.5
OR R5.6
OR R5.7
WRT R0.3
_____________________________________________________________________________________
8-25
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
RD R200.2
OR R6.1
OR R6.3
OR R200.4
OR R6.5
OR R6.6
OR R6.7
WRT R0.4
RD R7.0
OR R7.1
OR R201.0
OR R201.1
OR R7.4
OR R7.5
OR R7.6
OR R7.7
WRT R0.5
RD R8.0
OR R8.1
WRT R0.6
_____________________________________________________________________________________
8-26
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Chapter 8: Macro Examples: Automatic Tool Change (ATC)
//Counter
RD R200.1
OR.NOT R200.1
WRT R200.1
RD R200.0
AND R06.0
WRT R200.2
//Alarm message
RD F55.2
WRT A0.2
RD F55.3
WRT A0.3
RD F55.4
WRT A0.4
_____________________________________________________________________________________
8-27
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Index
Index
A D
_____________________________________________________________________________________
I
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Index
_____________________________________________________________________________________
II
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Index
N Q
n 5-1 quotient.................................................................. 4-1
N codes .................................................................. 2-1
naming of variables ............................................... 2-2 R
natural logarithm ................................................... 4-3
NC statements........................................................ 1-2 R 6-1
radians ................................................................... 4-2
NE.......................................................................... 5-2
negative variable values......................................... 2-3 range of execution ................................................. 5-4
nesting ............................................................ 4-4, 5-5 referencing variables.............................................. 2-3
macro calls......................................................... 6-4 referencing variables in an expression................... 2-3
nesting depth.......................................................... 6-4 registry................................................................... 2-2
repetition statements .............................................. 5-1
nesting of calls.......................................6-8, 6-9, 6-10
nesting, unacceptable............................................. 5-6 requirements, formatting ....................................... 1-2
non-zero value ....................................................... 5-2 reversing the sign of a variable value .................... 2-3
rounding.......................................................... 4-2, 4-5
not.......................................................................... 4-3
not equal to ............................................................ 5-2 rounding of referenced variables ........................... 2-4
null variable .................................................... 2-1, 2-4
in a conditional expression ................................ 2-5 S
in a mathematical formula ................................. 2-4 S code setting......................................................... 6-8
in a movement command................................... 2-5 S codes................................................................... 2-1
number of times for execution............................... 6-1 S codes, customized............................................... 6-5
numbered global variables..................................... 2-1 S-100M/S-120M/S-140M............................... 3-4, 3-6
numbered permanent variables .............................. 2-2 S-100T ............................................................ 2-2, 3-5
numeric value ........................................................ 5-2 sequence number ................................................... 5-1
ServoWorks G-Code Parser................................... 7-2
O ServoWorks macro programming language ... 1-1, 2-1
Optional Skip......................................................... 7-2 ServoWorks MC-Quad ................................... 3-4, 3-6
ServoWorks part programming language .............. 2-1
or 4-3
order of operations................................................. 4-4 ServoWorks S-100M/S-120M/S-140M.......... 3-4, 3-6
Output File Name (Full Path) ................................ 6-7 ServoWorks S-100T ....................................... 2-2, 3-5
overlapping WHILE DO END ranges ............ 5-6, 5-7 sign ........................................................................ 4-1
simple macro call............................................ 6-1, 6-3
Single Block mode.......................................... 1-2, 7-2
P
space required between keywords and values ....... 1-2
parameter assignments........................................... 6-2 specifying variables ............................................... 2-2
parentheses ............................................................ 1-3 specifying variables in an expression .................... 2-3
part programming language................................... 2-1 square root ............................................................. 4-2
permanent scope .................................................... 2-2 storage of variable values ...................................... 2-4
permanent variables............................................... 2-2 subprogram name calls .......................................... 2-3
PLC interface with system variables .............. 3-2, 3-3 subprograms .......................................................... 1-1
position .................................................................. 2-1 calling ................................................................ 6-1
position information with system variables ........... 3-7 location of file.................................................... 6-1
power ..................................................................... 4-1 subtraction ............................................................. 4-1
powering off ................................................... 2-1, 2-2 sum ........................................................................ 4-1
precision ......................................................... 2-4, 4-4 symbolic global variables ...................................... 2-2
preread function..........................................ii, 3-7, 7-1 system variable evaluation................................. ii, 7-1
priority of operations ............................................. 4-4 system variables.............................................. 2-2, 3-1
processing a null variable ...................................... 2-4 for interfacing with the PLC ....................... 3-2, 3-3
processing an uninitialized variable....................... 2-4 for position information..................................... 3-7
processing of macro statements ............................. 7-1 for timers ........................................................... 3-4
_____________________________________________________________________________________
III
SERVOWORKS CNC MACRO PROGRAMMING MANUAL
Index
_____________________________________________________________________________________
IV