Motion Calculate Cam Profile (MCCP)
This information applies to the
CompactLogix
5370, ControlLogix
5570, Compact GuardLogix
5370, GuardLogix
5570, Compact GuardLogix
5380, CompactLogix
5380, CompactLogix
5480, ControlLogix
5580, and GuardLogix
5580 controllers.The Motion Calculate Cam Profile (MCCP) instruction calculates a cam profile based on an array of cam points. Establish an array of cam points programmatically or by using the Cam Profile Editor. Each cam point in the cam array consists of a slave position value, a master position (position cam) or time (time cam) value, and an interpolation type (linear or cubic). A Motion Axis Position Cam (MAPC) instruction or Motion Axis Time Cam (MATC) instruction can use the resulting cam profile to govern the motion of a slave axis according to master position or time.
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.
Available Languages
Ladder Diagram
Function Block
This instruction is not available in function block.
Structured Text
MCCP(MotionControl,Cam,Length,StartSlope,EndSlope,CamProfile);
Operands
Ladder Diagram
Operand | Type | Format | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Motion Control | MOTION_INSTRUCTION | Tag | Structure used to access block status parameters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Cam | CAM, CAM_EXTENDED | Array | Tag name of the cam array used to compute the cam profile. The numerical array index indicates the starting cam element in the array used in the cam profile calculation. Ellipsis launches Cam Profile Editor. Use the CAM_EXTENDED type for this operand to enable access to double-precision (64-bit LREAL) cam data members. If used, the Cam Profile operand must be of type CAM_PROFILE_EXTENDED. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Length | UINT | Immediate or Tag | Determines the number of cam elements in the array used in the cam profile calculation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Start Slope | REAL | Immediate or Tag | This is the boundary condition for the initial slope of the profile. It is valid only for a cubic first segment and specifiesa slope through the first point. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
End Slope | REAL | Immediate or Tag | This is the boundary condition for the ending slope of the profile. It is valid only for a cubic last segment and is used to specifies a slope through the last point. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Cam Profile | CAM_PROFILE, CAM_PROFILE_EXTENDED CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllersUse the Motion Redefine Position (MRP) instruction to change the command or actual position of an axis. The value specified by Position is used to update the Actual or Command position of Axis. The position redefinition can be calculated on an Absolute or Relative basis. If Absolute is selected the Position value is assigned to the current Actual or Command position. If Relative is selected the Position value is added as a displacement to the current Actual or Command position. The process of redefining the current axis position has no affect on motion in progress as the instruction preserves the current servo following error during the redefinition process. As a result, axis position can be redefined on-the-fly without disturbing axis motion. Architecture and Safety Support Available Languages
Ladder Diagram Function Block This instruction is not available in function block. Structured Text MRP(Axis,MotionControl,Type,PositionSelect,Position); Operands Ladder Diagram and Structured Text
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:
MOTION_INSTRUCTION Structure
Description The MRP instruction directly sets the actual or command position of the specified axis to the specified absolute or relative position. No motion is caused by this instruction—the current axis position is simply redefined. Select or enter the desired Axis, Type, Position Selection, and enter a value or tag variable for the desired New Position. If the targeted axis does not appear in the list of available axes, the axis has not been configured for operation. Use the Tag Editor to create and configure a new axis. The MRP instruction may be used while the axis is moving as well as when it is at rest. MRP is used to redefine position on-the-fly for certain registration, slip compensation, and re-calibration applications.
In this transitional instruction, the relay ladder, toggle the Rung-condition-in from cleared to set each time the instruction should execute. Master Driven Speed Control (MDSC) and the MRP Instruction You can execute an MRP on the Master or the Slave axes or coordinate system when an MDSC is active. The Master axis position is changed when an MRP is executed (goes IP) on the Master while it is moving in MDSC mode; the slave is not affected. 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
Structured Text
Error Codes See Error Codes (ERR) for Motion Instructions. Extended Error Codes Extended Error Codes provide additional instruction specific information for the Error Codes that are generic to many instructions. See Motion Error Codes (.ERR) for Motion Instructions. The following Extended Error codes help to pinpoint the problem when the MRP instruction receives a Servo Message Failure (12) error message.
Extended Error codes for the Parameter Out of Range (13) error code work a little differently. Rather than having a standard enumeration, the number that appears for the Extended Error code refers to the number of the operand as they are listed in the faceplate from top to bottom with the first operand being counted as zero. Therefore for the MRP instruction, an extended error code of 4 would refer to the Position operand’s value. You would then have to check your value with the accepted range of values for the instruction. MRP Changes to Single Axis Status Bits The AxisHomedStatus bit is not impacted by the execution of the MRP instruction. The status is the same before and after the MRP is execution. If the axis has been homed using the absolute home procedure, the AbsoluteReferenceStatus is set. AxisHomedStatus may also be set is the axis has not been subject to a power cycle. AbsoluteReferenceStatus is cleared when the MRP is executed and this is only true to Axis_Servo_Drive axis. This indicates the axis position is no longer referenced to the absolute home position. Examples Example 1 Ladder Diagram Example 2 Ladder Diagram | Array | Tag name of the calculated cam profile (Cam Profile) array used as input to MAPC and MATC instructions. Only the zero array element ([0]) is allowed for the Cam Profile array. Ellipsis launches Cam Profile Editor. Use the CAM_PROFILE_EXTENDED type for this operand to enable access to double-precision (64-bit LREAL) cam data members. If used, the Cam operand must be of type CAM_EXTENDED. |
Structured Text
Operand | Type | Format | Description |
---|---|---|---|
Source | SINT INT DINT REAL STRING structure | tag | Initial element to copy Important: The Source and Destination operands should be the same data type, or unexpected results may occur. |
Destination | SINT INT DINT REAL STRING LINT structure | tag | Initial element to be overwritten by the Source Important: The Source and Destination operands should be the same data type, or unexpected results may occur. |
Length | DINT | immediate tag | Number of Destination elements to copy. |
See Structured Text Syntax for more information on the syntax of expressions within structured text.
The operands are the same as those for the relay ladder MCCP instruction. For the array operands, you do not have to include the array index. If you do not include the index, the instruction starts with the first element in the array ([0]).
MOTION_INSTRUCTION Structure
Mnemonic | Description |
---|---|
.EN (Enable) Bit 31 | The Enable bit is set when the rung transitions from false-to-true and stays set until the done bit is set and the rung goes false. |
.DN (Done) Bit 29 | The Done bit is set when the calculate cam instruction has been executed and the Cam Profile array calculated. |
.ER (Error) Bit 28 | The error bit indicates when the instruction detects an error, such as if the cam array is of an illegal length. |
Description
The MCCP instruction computes a cam profile based on a given set of points in a specified cam array. Subsequent Motion Axis Position Cam (MAPC) or Motion Axis Time Cam (MATC) camming instructions can use the resultant cam profiles generated by the MCCP instruction to provide complex motion of a slave axis with respect to either a master axis position or with respect to time.
Because cam profiles can be directly calculated by the
Logix Designer
Cam Profile Editor, the main purpose of the MCCP instruction is to provide a method for calculating cam profiles in real-time based on programmatic changes to the corresponding cam arrays.Specifying a Cam Array
In order to execute an MCCP instruction, a Cam array tag must be created using the RSLogix Tag Editor or the Cam Profile Editor. The figure below illustrates how the Cam array tags are established and used as input to the MCCP instruction.
The Cam array elements consist of slave (yp) and master (xp) point pairs as well as an interpolation type. Since there is no association with a specific axis position or time, the x and y point values are unitless. The interpolation type may be specified for each point as either linear or cubic.
The MCCP instruction supports two types of Cam array: CAM and CAM_EXTENDED. Use CAM arrays to calculate cam profile tags of type CAM_PROFILE. Use CAM_EXTENDED arrays to calculate cam profile tags of type CAM_PROFILE_EXTENDED, which provide better precision.
Specifying the Cam Profile Tag
To execute a MAPC instruction, a Cam Profile array tag must also be created. Cam Profile array tags may be created by the
Logix Designer
tag editor or the MAPC/MATC instructions using the built-in Cam Profile Editor.The data within the Cam Profile array can be modified at compile time by using the Cam Profile Editor, or at run-time with the MCCP instruction. In the case of run-time changes, a Cam array must be created in order to use the MCCP instruction.
The status parameter is used to indicate that the Cam Profile array element has been calculated. If execution of a camming instruction is attempted using any uncalculated elements in a cam profile, the MAPC or MATC instructions error. The type parameter determines the type of interpolation applied between this cam array element and the next cam element.
The MCCP instruction supports two types of Cam Profile array: CAM_PROFILE and CAM_PROFILE_EXTENDED. CAM_PROFILE is calculated from a CAM array. CAM_PROFILE_EXTENDED is calculated from a CAM_EXTENDED array, which provides better precision.
Cam Profile Array Status Member
The Status member of the first element in the cam profile array is special and used for data integrity checks. For this reason, the MCCP must always specify the cam profile with the starting index set to 0. This first cam profile element Status member can have the following values.
Status Variables | Description |
---|---|
0 | Cam profile element has not been calculated. |
1 | Cam profile element is being calculated. |
2 | Cam profile element has been calculated. |
n | Cam profile element has been calculated and is currently being used by (n-2) or MATC instructions. |
Linear and Cubic Spline Interpolation
The resultant calculated cam profiles are fully interpolated. This means that if the current master position or time does not correspond exactly with a point in the cam array used to generate the cam profile, the slave axis position is determined by linear or cubic interpolation between adjacent points. In this way, the smoothest possible slave motion is provided. The MCCP instruction accomplishes this by calculating coefficients to a polynomial equation that determines slave position as a function of master position or time.
Calculating the Cam Profile
Before calculating a cam profile on a specified axis, the MCCP instructions first checks if the cam profile array has been calculated by checking the value of the first cam profile element’s Status member. If the Status value is either 0 or 2, the MCCP proceeds with the calculation of the cam profile. When the cam profile array has been completely calculated, the MCCP instruction sets the first cam profile element’s Status value to being calculated, or 1, and then sets the Status value of all other cam profile elements to being calculated. As the calculation proceeds, individual cam profile members’ Status values are set to calculated, or 2. When all elements in the cam profile array have been calculated, the first cam profile element’s Status value is also set to calculated.
However, if an MCCP instruction is executed with an initial cam profile Status value of 1, then the cam profile is currently being calculated by another MCCP instruction, and the MCCP instruction errors. If the Status value is >2, then the cam profile is being actively used by an MAPC or MATC instruction process, and the MCCP instruction errs.
Start Slope and End Slope
To facilitate a smooth entry into and exit from a cubic cam profile, slope control is provided. The Start Slope and End Slope parameters determine the initial rate of change of the slave relative to the master. These values are used in the cubic spline calculations performed on the cam array. The diagram below the master slave slope relationship.
The default values for Start Slope and End Slope are 0 to facilitate a smooth start and end to the cam profile from rest. However, if the axis is already camming, an appropriate non-zero Start Slope can be specified to match the End Slope of the currently executing cam, to seamlessly blend the two cam profiles together.
The Start Slope and End Slope values are not applicable when starting or ending the cam profile with linear interpolation.
IMPORTANT:
The MCCP instruction execution completes in a single scan. This instruction should therefore be placed in a separate task to avoid impacting user program scan time.
This is a transitional instruction:
- In relay ladder, toggle Rung-condition-in from false to true each time the instruction should execute.
- In structured text, condition the instruction so that it only executes on a transition.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. 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 the 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 the Ladder Diagram table. |
Extended Error Codes
Extended Error Codes provide additional instruction specific information for the Error Codes that are not specific enough to help pinpoint the problem. When the MCCP instruction receives an Illegal Cam Length (26) error message to let it know that the length input parameter does not correspond to what the instruction expects, the corresponding Extended Error code provides the number of cams in the Cam Tag provided to the instruction. When the MCCP instruction receives an Illegal Cam Profile Length (27) error message to let it know that the length input parameter does not correspond to what the instruction expects, the corresponding Extended Error code provides the number of cam points the instruction is attempting to generate. See Error Codes (ERR) for Motion Instructions.
MCCP Changes to Status Bits
No
Examples
Example 1
Ladder Diagram
Structured Text
MCCP(MCCP_1,Cam_1[0],30,1.0,1.0,Cam_pro1[0]);
Example 2
Ladder Diagram
Structured Text
MCCP(mccp_motion_ctrl,cam[0],2,2,10,cam_profile[0]);
Provide Feedback