User's Manual

PMAC User Manual
230 Synchronizing PMAC to External Events
Disable all PLC programs using <CTRL-D. This will give the fastest possible response to a
command.
Set I8 to 0, which forces a real time interrupt every servo cycle. If not running a PLC 0, leave this at
zero permanently.
Begin the programs using R<CR> if @@ has been issued as in the simple case or use <CTRL-R>
which is the global run command.
To run a PLC 0, set I8 back to its original value (usually 2). Leaving I8 at 0 will probably cause PLC
0 to starve the background tasks for processor time, causing loss of communications or even a
watchdog timer failure.
Enable the PLC programs required. Have the first line of each motion program enable the PLC
programs for its respective PMAC card. For example:
OPEN PROG 1 CLEAR
ENA PLC 1..31
TM 1000
Position-Capture Functions
The position-capture function latches the current encoder position at the time of an external event into a
special register. It is executed totally in hardware, without the need for software intervention (although it is
set up, and later serviced, in software). This means that the only delays in the capture are the hardware gate
delays (negligible in any mechanical system), so this provides an incredibly accurate capture function.
Setting the Trigger Condition
The position capture register can be used both automatically, as in homing routines where the firmware
handles the register directly, and manually, where the user program must handle the register information.
Regardless of the mode, the event that causes the position capture is determined by Encoder I-variables 2
and 3 (I902 and I903 for Encoder 1). Encoder I-Variable 2 defines what combination of encoder third-
channel transition and encoder flag transition triggers the capture (it also allows software trigger). If it
says to use a flag, Encoder I-variable 3 determines which flag (almost always set to zero to specify the
home flag.)
Using for Homing
When using this feature for homing a motor, the motor flag address I-variable (Ix25 for motor x) must
point to the proper set of flags (this has to be done to address the limit flags properly). For instance, the
default value of I125 is 49152 ($C000), pointing to the first set of flags. Then Encoder/Flag I-variable 2
(e.g. I902) and Encoder/Flag I-variable 3 (e.g. I903) define the transition within this encoder and flags to
cause the position capture. Once these have been set up properly, the homing function will use the
position-capture feature automatically.
Using in User Program
If using the position-capture function in the own program, these two I-variables still control the capture
event. Access the captured position through a full word M-variable (M103 is the suggested M-variable
for the Encoder 1 capture register: M103->X:$C003,0,24,S). Use the position-captured flag bit (bit
17 of the control/status register). For example: M117->X:$C000,17,1. This bit goes true when the
trigger condition has gone true; it goes false when the capture register is read (when M103 is used in an
expression). As long as the bit is true, the capture function is disabled; read the capture register to re-
enable the capture function. The example program MOVTRIG.PMC shows how this function can be
used for precision registration.
Offset from Motor Position
Encoder position is referenced to the position at the most recent power-on or reset, regardless of any
homing moves or offset commands done since then. To relate this encoder position to motor position,
one must know the offset between encoder zero and the homing-zero positions.