User's Manual

PMAC User Manual
Writing Programs for PMAC 209
If the spindle were to be controlled in open-loop fashion in CSS mode, it would be best to have a PLC
program modifying the output command (Mx25 or Ix29) as a function of tool radial position. The
structure of the PLC program would be like that of the closed-loop motion program example
SPINDLE.PMC, except no actual move command would be needed; once the math was processed, the
value would simply be assigned to the appropriate variable.
Standard M-Codes
The sections below detail what is involved in implementing the standard M-codes. It is important to
realize the difference between an M-code in a program and an M-variable. They may look the same, but
to be interpreted as an M-variable, it must be used in an equation or expression. For instance, M01=1
refers to M- variable number 1 (usually this sets Machine Output 1), whereas M01 by itself is the M-code
number 1.
M-codes are treated as subprogram calls to the appropriate line label of motion program 1001.
M00 — Programmed Stop
The routine to execute this code simply needs to contain the STOP command. This code is looking for
the line label N0 of PROG 1001, and the beginning of any program is always implicitly N0, so this must
be at the very top of PROG 1001. The part of the file to implement this could be:
CLOSE
OPEN PROG 1001 ; Buffer control command
CLEAR ; To erase old when sending new
STOP ; First line of actual program
RET ; Will jump back when restarted
M01 — Optional Stop
Typically this code is used to do a stop if the Optional Stop switch on the operator's panel is set.
Assuming this switch is wired into the PMAC Machine Input 1, and variable M11 has been assigned to
this input (this is the default), then the routine to execute this code could be:
N01000 IF (M11=1) STOP
RET
M02 — End of Program
Since PMAC recognizes the end of a program automatically, and resets the program pointer back to the
top of the program, the routine for this code could be empty (RET statement only). However, in many
systems, a lot of variables and modes get set to default values here. A typical end-of-program routine
might be:
N02000 M55=0 ; Turn off spindle
M7=0 ; Turn off coolant
M2=0 ; Turn off conveyor
LINEAR ; Make sure not in circular mode
RET
M03 — Spindle on Clockwise
If the spindle is simply doing constant speed moves, these routines can issue jog commands. For
instance:
M04 — Spindle on Counterclockwise
N03000 CMD "#4J+"
RET
N04000 CMD "#4J-"
M05 — Spindle Stop
RET
N05000 CMD "#4J/"
RET