MELSEC iQ-R Series Motion Module (RD78G) - Interpolation of multiple axes from PLC side
It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide.
In this part you will learn how to:
- declare axes groups and operate on them,
- starting linear interpolation of several axes,
- starting circular interpolation of 2 axes
This article requires an established and pre-configured project. For a description of how to do this, see the first and second article in the Melsec
iQ-R Series Motion Module (RD78G) Quick Start Guide series - System start-up and Drives configuration and programming from the PLC side.
1. Procedure for interpolation control
2. Axes group declaration and operation
2.1 Declaration of the axes group
Enter Parameter → Module Information → 00n:RD78G4 → Module Extended Parameter
In order to perform interpolation operations on the servo drive axes, it is necessary to add a group of these axes to the Motion module settings in the Motion Control Setting Function window. To do this, select the Axes Group tab from the project tree. This will open the New Data window.
In the (Data Name) field of this window, set a name for the axis group. The group number is set in the Axes Group No. field. After entering this data, confirm it with OK. The axis group will be added to the project.
After adding the servo axis group, add the axes it will consist of to its configuration. In my case, all 3 axes that make up the workstation I am working on will be added.
In this window you can also set the axes group parameters such as Command In-position Width, Acceleration/ Deceleration/Jerk Limit Value, Deceleration at Stop, Stop selection, Position/Velocity Command Unit and Velocity Limit Value.
When all the parameters will be set confirm the changes by pressing Apply button.
Information about the added axes group is stored in the AXES_GROUP_REF structure of the Motion module. To operate it in the PLC program we have to enable Public Labels:
After that rebuild the project and reflect public labels.
Now write the parameters to the Motion Module.
2.2 Enabling and disabling axes group using MC_GroupEnable and MC_GroupDisable FB
To perform operations on an axis group, you must first activate it. While an axis group operation is activated, you cannot perform operations on the individual axes of which the group consists. To enable it again, you must first deactivate the group. The function blocks MC_GroupEnable (activate group) and MC_GroupDisable (deactivate) are used for this.
Description of the inputs of the MC_GroupEnable/Disable function blocks
On the input side:
- Execute - When this variable is TRUE, FB is executed (BOOL).
- AxesGroup - This variable sets the axes group from AxesGroup structure.
On the output side:
- Done - This variable becomes TRUE when the axes group status transits to "4: Standby (GroupStandby)" in case of MC_GroupEnable or to "0: Axes group disabled (Group Disables)" in case of MC_GroupDisable (BOOL).
- Busy - This variable becomes TRUE when the FBs are executed (BOOL).
- Error - This variable becomes TRUE when the error occurs (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of FBs with defined I/O
After G_bGroupEnableExecute is set axes group defined as Group0001 will be activate. Proper activation will be announced by G_bGroupEnableDone. In case error occurs G_bGroupEnableError will be set in high state. The error code will be returned on G_uGroupEnableErrorID.
Deactivation of axes group will be done with G_bGroupDisableExecute. The rest of the outputs has corresponding effects to the MC_GroupEnable ones.
For the details description of MC_GroupEnable/Disable FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
2.3 Axes group erros reset using MC_GroupReset FB
If an error occurs on an axis group, reset it to allow further operations. To do this, use the MC_GroupReset function block.
Description of the inputs of the MC_GroupEnable/Disable function blocks
On the input side:
- Execute - When this variable is TRUE, executes MC_GroupReset (Axes Group Error Reset) (BOOL).
- Options - Set this variable to "0H" (DWORD, Hex).
- AxesGroup - This variable sets the axes group from AxesGroup structure.
On the output side:
- Done - This variable becomes TRUE when the reset of all axes in the axes group has been completed (BOOL).
- Busy - This variable becomes TRUE when MC_GroupReset (Axes Group Error Reset) is executed (BOOL).
- Error - This variable becomes TRUE when MC_GroupReset (Axes Group Error Reset) has been aborted because of timeout. This variable becomes FALSE when Execute command (Execute) becomes FALSE (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of FBs with defined I/O
For the details description of MC_GroupReset FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
2.4 Axes group Forces Stop using MC_GroupStop
MC_GroupStop decelerates the specified axes group to a stop.
Description of the inputs of the MC_GroupStop function block
On the input side:
- Execute - When this variable is TRUE, executes MC_GroupStop (BOOL).
- Deceleration - This variable sets the decelaration during stop operation (LREAL).
- Jerk - Set this variable to "0.0" (LREAL).
- Options - Set this variable to "0H" (DWORD, Hex).
- AxesGroup - This variable sets the axes group from AxesGroup structure.
On the output side:
- Done - This variable becomes TRUE when the velocity reaches 0 (BOOL).
- Busy - This variable becomes TRUE when operating the velocity toward 0 (LREAL).
- Active - This variable becomes TRUE while MC_GroupStop is controlling the axes (BOOL).
- Error - This variable becomes TRUE when an error occurs (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of FB with defined I/O
When G_bGroupStopExt is activated the specified axes group will decelerate toward 0 velocity with deceleration set in G_leGroupStopDecc. When the 0 velocity is reached G_bGroupStop is set in a high state.
For the details description of MC_GroupStop FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
3. Linear interpolation of 3 axes using MCv_MoveLinearInterpolateAbsoulte and MCv_MoveLinearInterpolateRelative
Linear interpolation can be performed in two modes - incremental and absolute. In the incremental mode, interpolation is carried out over a specified distance, in the absolute mode to a specified position.
3.1 Incremental linear interpolation with MCv_MoveLinearInterpolateRelative
Description of the inputs of the FB
On the input side:
- Execute - When this variable is TRUE, FB is executed (BOOL).
- ContinuosUpdate - This variable sets wheter to enable or disable continuous change of Velocity, Acceleration and Deceleration. Continuous update re-imports input variables to the instance in execution without aborting the operation (BOOL).
- LinearAxes - This variable specifies the axes to be used in linear interpolation control from the structuring axes. Specifies the index No. (1 to 16) of the structuring axes in the array.
When VelocityMode is set to "2: Reference axis speed (ReferenceAxisSpeed)", the first element of the array is regarded as the reference axis (LREAL[0..15]).
The maximum number of interpolated axes is 4.
In linear interpolation control, linear interpolation is performed using arbitrary axes from the structuring axes set to the axes group.
Set structuring axes to perform linear interpolation by Linear interpolation axis (LinearAxes) from the structuring axes of the axes group. Linear interpolation axis (LinearAxes) has 16 array elements. For the arrays, first set only the index Nos. (1 to 16: structuring axis 1 to 16) of structuring axes to be used for interpolation control to the front, then set the rest of the arrays to "0". Arrays set to "0" can be omitted.
The setting number of the linear interpolation axes must be set to the maximum number of the interpolation axes for interpolation control (4 axes) or less.
The number of structuring axes to be used for interpolation control must be the number of axes registered to the structuring axes or less.
When Velocity mode (VelocityMode) is "2: Reference axis speed (ReferenceAxisSpeed)", the structuring axis of the first element in Linear interpolation axis (LinearAxes) becomes the reference axis.
When specifying the following, "Linear Interpolation Axis Setting Incorrect (error code: 1AB9H)" occurs and the axis will not start.
・When specifying an structuring axis where an axis is not set
・When the first element of Linear interpolation axis (LinearAxes) is "0"
・When specifying the same index No. to Linear interpolation axis (LinearAxes) in duplicate
・When the number of axes set in Linear interpolation axis (LinearAxes) exceeds the maximum number of interpolation axes
Example: When structuring axis 2, 3, and 4 are set to the linear interpolation axis
LinearAxes[0]:= 2;
LinearAxes[1]:= 3;
LinearAxes[2]:= 4;
LinearAxes[3]:= 0 ;*1
.
.
.
LinearAxes[15]:= 0; *1
*1"LinearAxes[3]:= 0; to LinearAxes[15]:= 0;" can be omitted.
- Distance - This variable sets the movement amount from the current position at start to the end point. The target position is set as 1-dimensional array data. This data is treated as the relative position for structuring axes 1 to 16 (LREAL[0..15]).
Sets the movement amount from the current position at start to the end point. Movement amount (Distance) has 16 array elements.
Distance[0..15] indicates the movement amount of structuring axis 1 to 16. Set the position in relation to the structuring axes set in Linear interpolation axis (LinearAxes).
Movement amount (Distance) of structuring axes not set to the linear interpolation axes is ignored.
Movement amount (Distance) of axes after all structuring axes set to the linear interpolation axes can be omitted.
Example: When setting structuring axis 2, 3, 4 to the linear interpolation axes, and setting the target positions of structuring axis 2, 3, and 4 to 2000.0, 3000.0, and 4000.0 respectively
LinearAxes[0]:= 2;
LinearAxes[1]:= 3;
LinearAxes[2]:= 4;
LinearAxes[3]:= 0; *1
.
.
.
LinearAxes[15]:= 0; *1
Position[0]:= 2000.0;
Position[1]:= 3000.0;
Position[2]:= 4000.0;
Position[3]:= 0.0; *1
Position[15]:= 0.0; *1
*1"LinearAxes[3]:= 0; to LinearAxes[15]:= 0;" and "Position[3]:= 0.0; to Position[15]:= 0.0;" can be omitted.
- Acceleration - It sets the acceleration (LREAL).
- Deceleration - It sets the deceleration (LREAL).
- Jerk - It sets the jerk (LREAL).
For the detailed description of Jerk functionality refer to last chapter of the second article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Programming from the PLC side.
- VelocityMode - This variable sets the speed mode for interpolation control (LREAL):
・0: Vector speed (VectorSpeed)
・1: Long axis speed (LongAxisSpeed)
・2: Reference axis speed (ReferenceAxisSpeed)
- BufferMode - This variable sets the buffer mode for interpolation control.
・0: Aborting (mcAborting)
・1: Buffered (mcBuffered)
・2: BlendingLow (mcBlendingLow)
・3: BlendingPrevious (mcBlendingPrevious)
・4: BlendingNext (mcBlendingNext)
・5: BlendingHigh (mcBlendingHigh)
For the detailed description of BufferMode functionality refer to chapter 3 of the article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Single-axis positioning from the PLC side.
- Options - This variable sets the function options for MCv_MoveLinearInterpolateRelative (DWORD, Hex).
- AxesGroup - This variable sets the axes group from AxesGroup structure.
On the output side:
- Done - This variable becomes TRUE when the control is completed (BOOL).
- Busy - This variable becomes TRUE when the FB is executed (BOOL).
- Active - This variable becomes TRUE when MCv_MoveLinearInterpolateRelative is executed (BOOL).
- CommandAborted - This variable becomes TRUE when execution of MCv_MoveLinearInterpolateRelative is aborted because of an error or multiple start (BOOL).
- Error - This variable becomes TRUE when the error occurs (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of MCv_MoveLinearInterpolateRelative execution
In example below 3 axes will be interpolated:
1st axis over distance 60 mm.
2nd axis over distance 100 mm.
3rd axis over distance 50 mm.
The value of axes to be interpolated are stored in the awAxes (WORD[0..15]) vector and the values of travelling distance are stored in the adDistance (DWORD[0..15) vector.
In the first part of the program numbers of interpolated axes (1, 2, 3) and values of distance each axes travels are moved to respective variables.
To execute the interpolation M100 has to be set in a high state. It will enable the axes group. After succesful axes group activation MCv_MoveLinearInterpolateRelative is started. The values of velocity, acceleration, deceleration and jerk are set as in the connected registers. Velocity Mode is set as VectorSpeed and the FB is not buffered.
After the succesful interpolation operation or in case of error axes group is disabled by MC_GroupDisable FB.
Schematic representation of program execution:
For the details description of MCv_MoveLinearInterpolateRelative FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
3.2 Absolute linear interpolation with MCv_MoveLinearInterpolationAbsoulte
Description of the inputs of the FB
The input/output majority is the same as in MCv_MoveLinearInterpolateRelative. Below are the I/Os that have not yet been described:
- Position - This variable sets the target position for linear interpolation. The target position is set as 1-dimensional array data. This data is treated as the absoulte position for structuring axes 1 to 16 (LREAL[0..15]).
Position[0..15] indicates the target position of structuring axis 1 to 16. Set the position in relation to the structuring axes set in Linear interpolation axis (LinearAxes).
Target position (Position) of structuring axes not set to the linear interpolation axes is ignored.
Target position (Position) of axes after all structuring axes set to the linear interpolation axes can be omitted.
Example: When setting structuring axis 2, 3, 4 to the linear interpolation axes, and setting the target positions of structuring axis 2, 3, and 4 to 2000.0, 3000.0, and 4000.0 respectively
LinearAxes[0]:= 2;
LinearAxes[1]:= 3;
LinearAxes[2]:= 4;
LinearAxes[3]:= 0; *1
LinearAxes[15]:= 0; *1
Position[0]:= 2000.0;
Position[1]:= 3000.0;
Position[2]:= 4000.0;
Position[3]:= 0.0; *1
Position[15]:= 0.0; *1
*1"LinearAxes[3]:=0; to LinearAxes[15]:=0;" and "Position[3]:=0.0; to Position[15]:=0.0;" can be omitted.
- Direction - this variable sets the selected direction. The direction selection is ser as 1-dimensional array data. This data is treated as the direction selection for structuring axes 1 to 16 (INT[0..15]).
The setting for Direction selection (Direction) is ignored when the software stroke limit is valid. Performs positioning control in a direction which does not cross over into the area outside the software stroke limit range. However, when the value does not cross over into the area outside the software stroke limit range both in the positive direction and the negative direction, positioning control is performed in the direction closest to the target position (the direction in which the absolute value of the movement amount is shortest) based on the current position. If the distance is the same in both the positive direction and the negative direction, control is performed using the current direction.
When the software stroke limit is invalid, the direction used to move from the current position to the target position can be set by selecting from "1: Positive direction (mcPositiveDirection)", "2: Negative direction (mcNegativeDirection)", or "3: Shortest path (mcShortestWay)" in Direction selection (Direction).
・1: Positive direction (mcPositiveDirection) - performs positioning from the current position to the target position in the positive direction (address increasing).
・2: Negative direction (mcNegativeDirection) - performs positioning in the negative direction (address decreasing) from the current position to the target position.
・3: Shortest path (mcShortestWay) - Basen on the current position, positionig control is performed in the direction closest to the target positon (the direction in which the absolute value of the movement amount is shortest). If the distance is the same in both the positive direction and the negative direction, control is performed using the current direction.
Example of MCv_MoveLinearInterpolateAbsoulute execution
In example below 3 axes will be interpolated:
1st axis to position 70 mm.
2nd axis to position 80 mm.
3rd axis to position 40 mm.
The value of axes to be interpolated are stored in the awAxes (WORD[0..15]) vector and the values of positions are stored in the adPosition (DWORD[0..15) vector.
In the first part of the program numbers of interpolated axes (1, 2, 3) and values of position each axes travels travels to are moved to respective variables. Also the values of direction for each axis is moved to the respective variable. The direction for each axis is set as "3: Shortest Path".
To execute the interpolation M300 has to be set in a high state. It will enable the axes group. After succesful axes group activation MCv_MoveLinearInterpolateAbsolute is started. The values of velocity, acceleration, deceleration and jerk are set as in the connected registers. Velocity Mode is set as VectorSpeed and the FB is not buffered.
After the succesful interpolation operation or in case of error axes group is disabled by MC_GroupDisable FB.
Schematic representation of program execution:
For the details description of MCv_MoveLinearInterpolateAbsolute FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
4. Circular interpolation of 2 axes by MCv_MoveCircularInterpolateAbsolute and MCv_MoveCircularInterpolateRelative
As in the linear interpolation, circular interpolation also can be performed in two modes - incremental and absolute. In the incremental mode, interpolation is carried out over a specified distance, in the absolute mode over a specified position.
4.1 Relative circular interpolation with MCv_MoveCircularInterpolateRelative
Description of inputs of the FB
On the inputs side:
- Execute - When this variable is TRUE, FB is executed (BOOL).
- ContinuousUpdate - This variable sets whether to enable or disable continuous change of velocity, acceleration and deceleration (BOOL).
- CircAxes - This variable specifies the axes to be used in circular interpolation control form the structuring axes. Specifies the index No. (1 to 16) of the structuring axes in the array. The first element of the arrat is regarded as the reference axis (INT[0..1]).
The maximum number of interpolated axes is 2.
In circular interpolation control, circular interpolation is performed by using two arbitrary axes from the structuring axes set to the axes group.
The axes used to perform circular interpolation are specified from the structuring axes in the axes group by using Circular interpolation axis (CircAxes). The Circular interpolation axis (CircAxes) has two array elements. For the arrays, specify the index Nos. (1 to 16: structuring axis 1 to 16) of structuring axes to be used for interpolation control.
The first element of the array is regarded as the reference axis.
If the structuring axis specified does not have an axis set, "Circular Interpolation Axis Unset (error code: 1A62H)" occurs.
Example: When setting structuring axis 2 and 3 as the circular interpolation axes
CircAxes[0]:= 2;
CircAxes[1]:= 3;
- CircMode - This variable sets the circular interpolation designation method (INT[0..2])
・0: Border point specification (mcBorder) - Sub point (AuxPoint) sets the border point on the arc connecting the start point and the end point. Positioning control with arc path that passes through the specified border point is performed using the two structuring axes set in Circular interpolation axis (CircAxes).
・1: Center point specification (mcCenter) - Sub point (AuxPoint) sets the center point of the arc. Positioning control with an arc path having the center point at its center is performed using the two structuring axes set in Circular interpolation axis (CircAxes).
・2: Radius specification (mcRadius) - Sub point (AuxPoint) sets the radius of the arc. Positioning control with an arc path having the specified radius is performed using the two structuring axes set in Circular interpolation axis (CircAxes).
- AuxPoint - Sets the relative position of the sub point (border point, center point, and radius) according to unit of the axis. The relative position is set as 1-dimensional array data. This data changes as shown below based on the setting of Circular interpolation mode (CircMode):
- When Circular interpolation mode (CircMode) is set to "0: Border point specification (mcBorder)" or "1: Center point specification (mcCenter)":
This data is treated as the relative position for structuring axes 1 to 16.
- When Circular interpolation mode (CircMode) is set to "2: Radius specification (mcRadius)":
Treats the first element as the radius and ignores the second and subsequent elements.
Example: When setting structuring axis 2 and 3 to the circular interpolation axes and setting the relative position of the sub point for structuring axis 2 and 3 as 2000.0 and 3000.0 respectively.
CircAxes[0]:= 2;
CircAxes[1]:= 3;
AuxPoint[0]:= 2000.0;
AuxPoint[1]:= 3000.0;
AuxPoint[2]:= 0.0; *1
AuxPoint[15]:= 0.0; *1
*1"AuxPoint[2]:= 0.0; to AuxPoint[15]:= 0.0;" can be omitted.
- EndPoint - This variable sets the position of the end point. The position is set as 1-dimensional array data. This data is treated as the relative position for structuring axes 1 to 16 (LREAL[0..15]).
EndPoint[0..15] indicates the end point position of structuring axis 1 to 16.
End point (EndPoint) for structuring axes which are not set to the circular interpolation axis are ignored.
End point (EndPoint) after all of the structuring axes which are set to the circular interpolation axis can be omitted.
- PathChoice - This variable sets the rotation direction of the circular interpolation (INT[0..5]).
・0: CW (mcCW)
・1: CCW (mcCCW)
・2: Shortcut (mcShortWay)
・3: Detour (mcLongWay)
・4: CW Detour (mcCWLongWay)
・5: CCW Detour (mcCCWLongWay)
*: When specifying "0: Border point specification (mcBorder)" in Circular interpolation mode (CircMode), the input is ignored.
*: When specifying "2: Radius specification (mcRadius)" in Circular interpolation mode (CircMode), "0: mcCW" means the CW shortcut and "1: mcCCW" means the CCW shortcut.
PathChoice sets the rotation direction for circular interpolation. For the rotation direction, the first element of the array set in Circular interpolation axis (CircAxes) is regarded as the reference axis. Path selection (PathChoice) is set when Circular interpolation mode (CircMode) is set to "1: Center point specification (mcCenter)" or "2: Radius specification (mcRadius)". When Circular interpolation mode (CircMode) is set to "0: Border point specification (mcBorder)", this input is omitted. The following shows the setting value, setting description, arc center angle that can be controlled, and path of Path selection (PathChoice) according to the setting of Circular interpolation mode (CircMode):
- Velocity - Sets the speed command value (LREAL).
- Acceleration - Sets the acceleration (LREAL).
- Deceleration - Sets the deceleration (LREAL).
- Jerk - Sets the jerk (LREAL).
- CircularErrorTolerance - this variable sets the allowable rande for circular interpolation errors (LREAL).
In circular interpolation control with center point specification, the arc path calculated from the start position and center position may deviate from the end position set in End point (EndPoint). Circular interpolation error tolerance (CircularErrorTolerance) sets the allowable width of errors between the calculated arc path and the end position.
- BufferMode - This variable sets the buffer mode.
・0: Aborting (mcAborting)
・1: Buffered (mcBuffered)
・2: BlendingLow (mcBlendingLow)
・3: BlendingPrevious (mcBlendingPrevious)
・4: BlendingNext (mcBlendingNext)
・5: BlendingHigh (mcBlendingHigh)
For the detailed description of BufferMode functionality refer to chapter 3 of the article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Single-axis positioning from the PLC side.
- Options - This variable sets the function options for MCv_MoveCircularInterpolateRelative by specifying the bit (DWORD, Hex).
- AxesGroup - This variable sets the axes group from AxesGroup structure.
On the output side:
- Done - This variable becomes TRUE when the control is completed (BOOL).
- Busy - This variable becomes TRUE when the FB is executed (BOOL).
- Active - This variable becomes TRUE when MCv_MoveCircularInterpolateRelative is executed (BOOL).
- CommandAborted - This variable becomes TRUE when execution of MCv_MoveLinearInterpolateRelative is aborted because of an error or multiple start (BOOL).
- Error - This variable becomes TRUE when the error occurs (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of MCv_MoveCircularInterpolateRelative execution
In example below 2 axes will be interpolated to interpolate full circle.
The value of axes to be interpolated are stored in the awAxes (WORD[0..1]) vector and the values of positions are stored in the adPosition (DWORD[0..15) vector.
To interpolate full circle the CircMode and PathChoice has to be set to "1" and EndPoint as "0.0". AuxPoint is then used as center point of the interpolated circle.
4.2 Absolute circular interpolation with MCv_MoveCircularInterpolateAbsolute
MCv_MoveCircularInterpolateAbsolute executes positioning with 2-axis circular interpolation using the structuring axes of the set axes group by setting the end point and sub point of the absolute position.
The inputs and outputs of this function block are the same as those of MCv_MoveCirculatInterpolateRelative. The difference is that the AuxPoint and EndPoint inputs refer to the absolute position of the axis and not the distance the axis is to travel.
Example of MCv_MoveCircularInterpolateAbsolute execution
In example below 2 axes will be interpolated to interpolate full circle.
The value of axes to be interpolated are stored in the awAxes (WORD[0..1]) vector and the values of positions are stored in the adPosition (DWORD[0..15) vector.
To interpolate full circle the CircMode and PathChoice has to be set to "1" and EndPoint as "0.0". AuxPoint is then used as center point of the interpolated circle.