User's Manual

PMAC2 User Manual
Using the Position Compare Feature on PMAC2 89
M108=1000 ; Set front end compare in A
M109=1010 ; Set back end compare in B
M110=0 ; No auto-increment
M112=0 ; Prepare initial value of 0
M111=1 ; Enable direct write (resets immediately to zero)
{Command to start the move}
Setting Up for Multiple Pulse Outputs
By using the auto-increment feature, it is possible to create multiple compare pulses with a single
software setup operation. When the auto-increment register is a non-zero value, its value is automatically
added to or subtracted from one compare register’s value when the other compare value is matched.
PMAC keeps track of the direction of incrementing, so only positive values should be used in the auto-
increment register, even if the encoder will be counting in the negative direction.
The setup for multiple pulses is like the setup for a single pulse, except that a non-zero value must be
entered into the auto-increment register, and the value entered for the back edge must be that of the first
back edge minus the auto-increment if the move will be positive, or that of the first back edge plus the
auto-increment value if the move will be negative.
In other words, the starting values to the two compare registers must bracket the starting position. When
either compare value is matched by the encoder counter, the other compare value is incremented in the
direction of movement.
Starting Position
B
0
A
0
B
1
A
1
Auto-Increment
Figure 17 Setup For Multiple Pulses
Example
Starting from the above example, desiring the compare output on between 1000 and 1010 counts, but
adding an auto-increment value of 2000 counts, with a starting position of about 100 counts, program
code to start the sequence could be:
M110=2000 ; Auto-increment of 2000 encoder counts
M108=1000 ; First front edge at 1000 counts
M109=1010-M110 ; First back edge at 1010 counts
M112=0 ; Prepare initial value of 0
M111=1 ; Enable direct write (resets immediately to zero)
Converting from Motor and Axis Coordinates
The compare registers are scaled in encoder counts, referenced to the power-up position. Typically, the
user wants to work in either motor coordinates, still in counts and referenced to the home position, or in
axis coordinates, in engineering units (mm, inches, degrees) and referenced to a user-set origin.
Two values are needed to convert motor position to encoder position for compare calculations. First is
the home capture offset, the encoder position captured at the home trigger, a value PMAC stores for
future use. The second is the home offset variable Ix26, which contains the difference between the trigger
position and the home position. The relationship is:
EncoderPosition = MotorPosition + HomeCaptureOffset + HomeOffset