Delta Tau GEO BRICK LV User Manual

Page of 440
 
Turbo PMAC User Manual 
368
 
Synchronizing Turbo PMAC to External Events
 
The auto-increment function is still available in extended-count mode, but the auto-increment value is 
limited to integer numbers of counts. 
In operation in this mode, you write to both the standard (integer) compare register and the fractional 
compare register.  In this mode, the integer value written to the compare register is offset by one count 
from the count value at which the compare output will toggle.  The direction of this offset is dependent on 
the direction of motion.  If a value of n counts is written to the integer compare register, the compare 
output will toggle at n+1 counts when moving in the positive direction, or n-1 counts when moving in the 
negative direction.  To compensate for this, simply add or subtract 1 count depending on the direction of 
motion.  For instance, to get a compare edge at 743.25 counts when moving in the positive direction, 
write 742 (=743-1) to the integer compare register, and write 1024 (=0.25*4096) to the fractional 
compare register. 
Example: P108 and P109 are floating-point variables representing the first count values at which the 
compare output is to be turned on, then off.  P110 is an integer value representing the auto-increment 
length in counts.  Motion is to be in the positive direction.  Program code to start the sequence could be: 
M110=P110 
; Auto-increment value 
M108=INT(P108)-1 
; Compare A integer component 
M188=(P108-(M108+1))*4096 
; Compare A fractional component 
M109=INT(P109)-1-M110 
; Compare B integer component 
M189=(P109-(M109+1+M110))*4096  ; Compare B fractional component 
M112=0 
; Prepare initial value of 0 
M111=1 
; Enable direct write 
Converting from Motor and Axis Coordinates 
The compare registers are scaled in encoder counts, referenced to the position at the latest power-up/reset.  
Typically, 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 Ixx26, which contains the difference between the 
trigger position and the home position.  The relationship is: 
EncoderPosition = MotorPosition + HomeCaptureOffset + HomeOffset 
The home capture offset 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 Encoder 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. 
For example, for Motor 1 using Encoder 1 in a PMAC2-style Servo IC, if you want to set the Compare 
1A register to trigger at motor position +1500 counts, you could use the following command, on-line, in a 
motion program, or in a PLC program: 
M108=1500+M173+I126/16 
If you also want to specify the fractional count value, you can initially calculate the compare position in 
counts as a floating-point value.  Then you can break this into the integer and fractional components.  
Modifying the above example: 
P108=P500+M173+I126/16   
; Compare position in counts 
M108=INT(P108) 
 
 
; Write whole-count value 
M188=(P108-INT(P108))*4096 
; Write fractional-count value