User's Manual

Turbo PMAC User Manual
Synchronizing Turbo PMAC to External Events 361
Scaled properly, this value can be added to the whole-count capture register value, regardless of the
direction of motion at the trigger. To combine these into units of hardware counts (which are the same as
software counts in many cases), the following equation can be used:
EncCaptureHWPos = FractionCount/4096 + WholeCount
If the capture is done on an Acc-51 interpolated sinusoidal encoder, the following equation can be used to
calculate the captured position in the motor’s software counts:
EncCaptureSWPos = FractionCount/32 + WholeCount*32
Note that the net position must be stored in a floating-point variable to keep the fractional value, and that
these equations use the fractional count first because reading the whole-count register resets the trigger
logic. In Turbo PMAC code, this could be something like:
P103=M183/32+M103*32
Converting to Motor and Axis Coordinates
The capture registers are scaled in encoder counts, referenced to the position at the latest power-up/reset.
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 encoder position in software counts (which may be the same as
hardware counts) to motor position for capture calculations. First is the home capture position, the
encoder position captured at the home trigger, a value PMAC stores for future use. The second is the
home-offset variable Ixx26, which contains the difference between the trigger position and the home
position. The relationship is:
MotorCapturePos = EncCapturePos - HomeCapturePos- HomeOffset
The home capture position is a 24-bit signed integer, expressed in counts. It is best accessed with a 24-bit
signed M-variable. The register and suggested M-variable for Motor 1 is:
M173->Y:$0000CE,0,24,S ; #1 home capture position (cts)
The home offset I-variable Ixx26 is in units of 1/16 count, so it should be divided by 16 before adding to
the motor position. In Turbo PMAC code, this conversion could be done as:
P104=P103-M173-I126/16
The conversion from motor position to axis position involves a scale factor and an offset, with the
following equation:
AxisCapturePos = MotorCapturePos / ScaleFactor - Offset
The scale factor is specified in the axis definition statement in counts per engineering unit; it should be
constant for an application. The scale factor can be specified directly in the equation, or the actual
register that PMAC is using can be accessed with suggested M-variables:
Mxx91 ; Axis scale factor for X, U, A, B, or C assigned to Motor xx
Mxx92 ; Axis scale factor for Y or V assigned to Motor xx
Mxx93 ; Axis scale factor for Z or W assigned to Motor xx
The offset is the position bias term, with suggested M-variable Mx64, and units of 1/(Ixx08*32) counts.
It is set equal to the axis definition offset (usually 0) on power-up/reset and homing. It can be changed
after this with on-line command {axis}= or motion program command PSET.