Motion Axis Gear (MAG)

CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580,
Compact GuardLogix
5380, and
GuardLogix
5580 controllers
The Motion Axis Gear (MAG) instruction provides electronic gearing between any two axes in a specified direction and at a specified ratio. When called, the specified Slave Axis is geared to the Master Axis at the specified Ratio (for example, 1.345) or Slave Counts to Master Counts (for example, 1:3). The MAG instruction supports specification of the gear ratio in one of two different formats, Real or Fractional, as determined by the Ratio Format input selection. The direction of Slave Axis motion relative to the Master Axis is defined by a very flexible Direction input parameter. The gearing direction may be explicitly set as the Same or Opposite or set relative to the current gearing direction as Reverse or Unchanged.
TIP:
The value for Ratio is sign sensitive. The Master Reference selection allows gearing input to be derived from either the Actual or Command position of the Master Axis. When the instruction’s Clutch capability is activated the gearing instruction commands the slave axis to accelerate or decelerate at a controlled rate before Locking on to the master axis using the instructions Acceleration value much like the clutch of a car.
This is a transitional instruction. Follow these steps when using it:
  • In ladder logic, insert an instruction to toggle the rung-condition-in from false to true each time the instruction should execute.
  • In a Structured Text routine, insert a condition for the instruction to cause it to execute only on a transition.
Architecture and safety support
Architecture
Standard
Safety
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers
Yes
No
Compact GuardLogix 5380, CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, and GuardLogix 5580 controllers
Yes
No
Available Languages
Ladder Diagram
MAG_LD_avail_v31
Function Block
This instruction is not available in function block.
Structured Text
MAG(SlaveAxis,MasterAxis,MotionControl,Direction,Ratio,SlaveCounts,MasterCounts,MasterReference,RatioFormat,Clutch,AccelRate,AccelUnits);
Operands
Ladder Diagram and Structured Text
Operand
Type
Tip:
AXIS_CONSUMED is supported by
Compact GuardLogix
5580,
CompactLogix
5380, and
CompactLogix
5480 controllers only.
Type
Tip:
AXIS_GENERIC is supported by the
ControlLogix
5570 and the
GuardLogix
5570 controllers only.
Format
Description
Slave Axis
AXIS_CIP_DRIVE
AXIS_VIRTUAL
AXIS_CIP_DRIVE
AXIS_VIRTUAL
AXIS_GENERIC_DRIVE
AXIS_SERVO
AXIS_SERVO_DRIVE
Tag
Name of the axis on which to perform operation. For controllers that support the REF_TO motion data types, the supported axis operand type can be replaced by an equivalent REF_TO type.
Master Axis
AXIS_CONSUMED
AXIS_VIRTUAL
AXIS_CIP_DRIVE
CompactLogix
5370,
Compact GuardLogix
5370,
Compact GuardLogix
5380,
CompactLogix
5380,
CompactLogix
5480
AXIS_CONSUMED
AXIS_VIRTUAL
AXIS_CIP_DRIVE
Tag
The axis that the slave axis follows.
For controllers that support the REF_TO motion data types, the supported axis operand type can be replaced by an equivalent REF_TO type.
Motion Control
MOTION_INSTRUCTION
MOTION_INSTRUCTION
Tag
Structure used to access instruction status parameters.
Direction
SINT, INT, or DINT
SINT, INT, or DINT
Immediate
The relative direction that the Slave axis tracks the Master Axis.
Select one of following:
0 = slave axis moves in the same direction as the master axis
1 = slave axis moves in the opposite direction of its current direction
2 = slave axis reverses from current or previous
3 = slave axis to continue its current or previous direction.
Ratio
REAL
REAL
Immediate or Tag
Signed Real value establishing the gear ratio in Slave User Units per Master User Unit.
Slave Counts
SINT, INT, or DINT
SINT, INT, or DINT
Immediate or Tag
Integer value representing slave counts used in specifying a Fractional gear ratio.
Master Counts
SINT, INT, or DINT
SINT, INT, or DINT
Immediate or Tag
Integer value representing master counts used in specifying a Fractional gear ratio.
Master Reference
BOOLEAN
BOOLEAN
Immediate
Sets the master position reference to either Command position or Actual position.
0 = Actual – slave axis motion is generated from the current position of the master axis as measured by its encoder or other feedback device.
1 = Command – slave axis motion is generated from the desired or commanded position of the master axis.
Ratio Format
BOOLEAN
BOOLEAN
Immediate
The desired ratio specification format. Select either:
0 = real gear ratio
1 = integer fraction of slave encoder counts to master encoder counts.
Clutch
BOOLEAN
BOOLEAN
Immediate
When Clutch is enabled, motion control ramps the slave axis up to gearing speed at the instruction’s defined Acceleration value. If not enabled, the Slave axis immediately locks onto the Master axis. If the Master Axis is currently moving this condition results in an abrupt uncontrolled acceleration event of the Slave Axis which can cause the axis to fault. Select either:
0 = enabled
1 = disabled
Accel Rate
REAL
REAL
Immediate or Tag
Acceleration rate of the Slave Axis in % or Acceleration Units. It is applied when the Clutch feature is enabled.
Accel Units
DINT
DINT
Immediate
The units used to display the Acceleration value. Select either:
0 = units per sec
2
1 = % of maximum acceleration
See Structured Text Syntax for more information on the syntax of expressions within structured text.
For the operands that require you to select from available options, enter your selection as described below.
This Operand
Has These Options Which You
Enter as Text
Or Enter as a Number
MasterReference
actual
command
0
1
RatioFormat
real
fraction_slave_master_counts
0
1
Clutch
enabled
disabled
0
1
AccelUnits
unitspersec2
%ofmaximum
0
1
MOTION_INSTRUCTION Structure
Mnemonic
Description
.EN (Enable) Bit 31
It is set when the rung makes a false-to-true transition and remains set until the servo message transaction is completed and the rung goes false.
.DN (Done) Bit 29
It is set when axis gear has been successfully initiated.
.ER (Error) Bit 28
It is set to indicate that the instruction detected an error, such as if you specified an unconfigured axis.
.IP (In Process) Bit 26
It is set on positive rung transition and cleared if either superseded by another Motion Gear Axes command, or terminated by a stop command, merge, shutdown, or servo fault.
Description
The MAG instruction enables electronic gearing between two axes at a specified ratio. Electronic gearing allows any physical axis to be synchronized to the actual or command position of another physical axis at a precise ratio. It provides a direct edge-to-edge lock between the two axes—no maximum velocity, acceleration, or deceleration limits are used. The speed, acceleration, and deceleration of the slave axis is completely determined by the motion of the master axis and the specified gear ratio.
IMPORTANT:
The maximum velocity, acceleration, or deceleration limits established during axis configuration do not apply to electronic gearing.
Select or enter the desired Master Axis, Slave Axis, and Direction and enter a value or tag variable for the desired ratio. If an axis is dimmed (gray) or not shown in the Slave Axis pop-up menu, the physical axis is not defined for Servo operation.
If the targeted axis does not appear in the list of available axes, the axis has not been configured for servo operation. Use the Tag Editor to create and configure a new axis.
Electronic gearing remains active through any subsequent execution of jog, or move processes for the slave axis. This allows electronic gearing motions to be superimposed with jog, or move profiles to create complex motion and synchronization.
Slaving to the Actual Position When Actual Position is entered or selected as the Master Reference source, the slave axis motion is generated from the actual position of the master axis as shown below.
MAG_Master Axis Position_v31
Actual position is the current position of a physical axis as measured by the axis encoder. This is the only valid selection when the master axis’ Axis Type is configured as Feedback Only.
Slave to the Command Position
When Command Position is entered or selected as the Master Reference source, the slave axis motion is generated from the command position of the master axis as shown below.
MAG_Slave to command postion_v31
Command position (only valid when the master axis’ Axis Type is configured as Servo) is the current desired or commanded position for the master axis.
Since the command position does not incorporate any associated following error, external position disturbances, or quantization noise, it is a more accurate and stable reference for gearing. When gearing to the command position of the master, the master axis must be commanded to move to cause any motion on the slave axis.
Gear in the Same Direction
When Same is selected or entered as the Direction, the slave axis moves in its positive direction at the specified gear ratio when the master axis moves in its positive direction and vice-versa.
Gear in the Opposite Direction
When Opposite is selected or entered as the Direction, the slave axis moves in its negative direction at the specified gear ratio when the master axis moves in its positive direction and vice-versa.
Change the Gear Ratio
When Unchanged is selected or entered as the Direction, the gear ratio may be changed while preserving the current gearing direction (same or opposite). This is useful when the current direction is not known or not important.
Reverse the Gearing Direction
When Reverse is selected or entered as the Direction, the current direction of the electronic gearing is changed from same to opposite or from opposite to same. This is very useful for winding applications where the gear ratio must be reversed at each end of the wind.
Real Number Gear Ratio
When Ratio Format is selected or entered as Real, the gear ratio is specified as a real number or tag variable with a value between 0.00001 and 9.99999 (inclusive) representing the desired ratio of slave axis position units to master axis position units. A gear ratio expressed this way is easy to interpret since it is defined in the axes’ configured position units.
Fraction Gear Ratios
When Ratio Format is selected or entered as Fraction, the gear ratio is specified as a pair of integer numbers or tag variables representing the ratio between the number of slave axis feedback counts and the number of master axis feedback counts. See The Tag variable Builder earlier in this manual for information on tag variables.
IMPORTANT:
The Conversion Constant entered as part of the axis configuration procedure is not used when the Ratio Format for the MAG instruction is specified as a Fraction.
If your gear ratio cannot be exactly expressed as a real number with a maximum of five digits to the right of the decimal point, use Fraction as the Ratio Format.
Specifying the gear ratio as a fraction allows the direct implementation of irrational gear ratios (such as 1/3) with no accumulated positioning errors or round off. Since the master and slave count values do not use the axis conversion constants and because they are integers, the actual gear ratio relationship between the slave and master axes exactly match the specified ratio.
For example, the irrational gear ratio of 1/3 can be equivalently specified as 1 slave count to 3 master counts, 10 slave counts to 30 master counts, 3 slave counts to 9 master counts.
Clutch
When the Clutch check box is checked, the slave axis accelerates or decelerates to the speed that it would be moving if it were currently geared to the selected master axis at the specified gear ratio and direction using a trapezoidal velocity profile (linear acceleration or deceleration). Once the slave axis has reached the gearing speed, electronic gearing is automatically activated according to the other selections. Enter the desired Accel Rate as a percentage of the current configured maximum acceleration value or directly in the configured user units for acceleration.
This clutch function works much like the clutch in a car, allowing the slave axis to be smoothly engaged to the master axis as shown below.
RSL5K_MAG Clutch
Clutch Function
Using the clutch feature avoids the uncontrolled acceleration or deceleration that results when electronic gearing is enabled while the master axis is moving. The clutch feature can also be used to merge gear ratio changes on-the-fly, even changes in direction. The motion controller automatically ramps the slave axis to the speed implied by the master axis at the new ratio and/or direction.
The operation of the clutch ramp generator has no affect on jog or move processes that might be in progress on the slave axis.
Changing Master Axes
The master axis for electronic gearing can be changed at any time, even while gearing is currently enabled. However, since it is possible to have electronic gearing enabled on more than one axis at a time, if a Servo master axis and slave axis are reversed, the axes become cross-coupled and unexpected motion may result.
For example, if you are gearing Axis 0 to Axis 1 (defined as a Servo axis) and then want to change to gearing Axis 1 to Axis 0, you must first disable gearing on Axis 0 (see Disable Gearing later in this section). This is because specifying Axis 1 as the slave axis with Axis 0 as the master axis does not automatically disable Axis 0 from being a slave axis with Axis 1 as the master axis.
Move While Gearing
An incremental MAM instruction may be used for the slave axis (or master axis if the Axis Type is configured as Servo) while the electronic gearing is enabled. This is particularly useful to accomplish phase advance/retard control. The incremental move distance can be used to eliminate any phase error between the master and the slave, or to create an exact non-zero phase relationship. Incremental MAM instruction may also be used in conjunction with electronic gearing to compensate for material slip.
Normally a gear ratio of 1 is used with phase adjustment. A 1:1 ratio ensures that the computed phase error does not change before performing the move to correct it. Electronic gearing is not normally used with absolute moves, since the ultimate endpoint is not predictable.
To successfully execute a MAG instruction, the targeted axis must be configured as a Servo Axis Type and the axis must be in the Servo On state. If any of these conditions are not met than the instruction errors.
IMPORTANT:
The MAG instruction execution completes in a single scan, thus the Done (.DN) bit and the In Process (.IP) bit are set immediately. The In Process (.IP) bit remains set until the initiated Gear process is superseded by another MAG instruction, or terminated by a Motion Axis Stop command, Merge operation, or Servo Fault Action.
In this transitional instruction, the relay ladder, toggle the Rung-condition-in from cleared to set each time the instruction should execute.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. A major fault can occur if an uninitialized reference or a reference of incorrect type is passed to the Axis operand. See Common Attributes for operand-related faults
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
The .EN, .DN, .ER, and .IP bits are cleared to false.
Rung-condition-in is false
The .EN bit is cleared to false if either the .DN or .ER bit is true.
Rung-condition-in is true
The .EN bit is set to true and the instruction executes.
Postscan
N/A
Structured Text
Condition/State
Action Taken
Prescan
See Prescan in Ladder Diagram table
Normal execution
See Rung-condition-in is false, followed by rung is true in the Ladder Diagram table.
Postscan
See Postscan in Ladder Diagram table.
Extended Error Codes
Use Extended Error Codes (.EXERR) for more instructions about an error. See Motion Error Codes (.ERR).
If ERR is
And EXERR is
Then
Cause
Corrective Action
13
Varies
An operand is outside its range.
The EXERR is the number of the operand that is out of range. The first operand is 0.
For example, if EXERR = 4, then check the Decel Rate.
EXERR
Operand
10
Accel Rate
Examples
Example 1
MAG_LD_ex1_v31
Example 2
This example increases the number of operands that require data conversion.
MAG_LD_ex2_v31
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.