In industrial automated production, high-precision motion control is crucial for improving production efficiency and ensuring product quality. Taking a five-axis machining center as an example, the equipment needs to simultaneously control multiple motion axes to move precisely along complex curved paths. This is difficult to achieve the high precision and efficiency requirements of traditional point-to-point movement. Especially when machining curved workpieces, achieving smooth curve interpolation, multi-axis synchronous motion, and efficient transition control has become a common challenge for industrial control engineers.
This article takes LeadStudio, a PLC programming software platform independently developed by Leadsai, as an example to introduce in detail the practical application of axis interpolation function. Through linear interpolation and circular interpolation functions, it helps developers easily realize multi-axis collaborative motion control and solve the high-precision motion requirements under complex curved paths.
01. Introduction to Shaft Interpolation Function
LeadStudio supports linear interpolation and circular interpolation, with the interpolation function implemented using axis groups.
1) Each axis group can control up to 4 motion control axes, including three coordinate axes (X, Y, and Z) and one auxiliary axis;
2) Supports up to 8 axis groups, each of which can be set to 2 axes (XY axes), 3 axes (XYZ axes), or 4 axes (XYZ axes and auxiliary axes);
3) Linear interpolation and circular interpolation support buffered modes. Each axis group can buffer up to 8 curves, and the transition mode between curves can be set individually;
4) During linear interpolation, the motion control axis representing the three coordinate axes (x, y, z) moves along the coordinate axes, while the auxiliary axis moves from the starting position to the ending position along a straight line.
5) When performing circular interpolation, you can choose one of the xy-axis plane, yz-axis plane, or xz-axis plane to perform circular interpolation. If other axes are configured in the axis group, the other axes will move from the starting position to the ending position along a straight line.
The following is an application example of PLC axis group (interpolation).
02. Introduction to Shaft Group Commands
Function block MC_MoveLinear: Linear interpolation instructions
This function block is used to control the axis group to perform linear interpolation, and the rising edge is valid.
The function block MC_MoveLinear is shown in the figure below:
Notice:
1) This instruction can only be triggered when the MC_Power instruction is called to switch all axes in the axis group to StandStill state. Triggering this instruction during single-axis motion (e.g., during point-to-point movement, homing, or stopping) is invalid.
2) After this instruction is triggered, the single-axis PLCOpen state machine enters synchronous motion mode. During the motion, it cannot be interrupted by single-axis motion instructions. After the interpolation curve is completed, the single-axis PLCOpen state machine enters StandStill state, at which time single-axis motion instructions can be executed;
3) Position is used to set the target position or displacement. Position[0] represents the position displacement component of the x-axis, Position[1] represents the position displacement component of the y-axis, Position[2] represents the position displacement component of the z-axis, and Position[3] represents the position displacement component of the auxiliary axis. Velocity represents the target velocity of the interpolator, where the target velocity of the coordinate axis is decomposed according to formulas (1), (2), and (3).
4) The interpolation speed of the auxiliary axis can be divided into two cases:
① When a point on the coordinate axis remains stationary while the auxiliary axis moves independently, the auxiliary axis moves at the target speed set by Velocity;
② When a point on the coordinate axis moves, the auxiliary axis will reach the target position simultaneously with the point on the coordinate axis; assuming the length of the interpolation line is L1, the target displacement of the auxiliary axis is L2, and the speed of the interpolation line at a certain moment is V0, the speed Va of the auxiliary axis is calculated as follows:
Va = V0 * L2 / L1
5) MoveMode selection:
MoveMode=0 indicates absolute positioning mode. After this command is triggered, the three coordinate axes will eventually move to the positions specified by (Position[0], Position[1], Position[2]), and the auxiliary axis will move to the position specified by Position[3].
MoveMode=1 indicates relative positioning mode. Let the positions of the three coordinate axes of the axis group be (Px, Py, Pz), the current position of the auxiliary axis be Pa, and after triggering this command, the three coordinate axes will eventually move to (Px+Position[0], Py+Position[1], Pz+Position[2]), and the final position of the auxiliary axis will be Pa+Position[3].
6) Buffer Mode
When selecting one of the six buffering modes (1, 2, 3, 4, 5, or 10), the interpolation instruction can buffer a maximum of 8 curves. When an instruction enters the buffered state, the Busy signal is active; when the instruction begins execution, the Active output is active; and when the instruction completes execution, the Done signal is active. When a newly added interpolation instruction selects mode 0 (interrupt + no transition), this instruction will interrupt all currently executing and buffered interpolation instructions, and the CommandAborted output of the interrupted interpolation instruction will be active.
Buffering mode refers to the instruction execution process when multiple interpolation instructions are started simultaneously, while transition mode refers to the method when multiple curve segments switch between each other.
Function block MC_MoveCircular: Circular interpolation instruction
This function block is used to control the axis group to perform circular interpolation function, and the rising edge is valid.
The function block MC_MoveCircular is shown in the figure below:
Notice:
1) This instruction can only be triggered when the MC_Power instruction is called to switch all axes in the axis group to StandStill state. Triggering this instruction during single-axis motion (e.g., during point-to-point motion, homing, or stopping) is invalid; 2) After triggering this instruction, the PLCOpen state machine of the single axis enters synchronous motion mode. Single-axis motion instructions cannot interrupt the motion during this period. After the interpolation curve is completed, the PLCOpen state machine of the single axis enters StandStill state, at which point single-axis motion instructions can be executed; 3) Specifying the circular arc axis.
CircAxes specifies the coordinate axis plane, with the following meanings: CircAxes=0 means that the xy coordinate axis plane is selected, the motion axes specified by AxisID_x and AxisID_y perform circular interpolation, and the axes specified by AxisID_z and AxisID_a are auxiliary axes that perform follow motion, moving from the starting position to the ending position along a straight line;
4) Interpolation mode selection
①CircMode=0 means circular interpolation is performed based on the points through which the interpolation occurs:
Taking the xy plane as an example, the starting position of the x-axis is Px, and the starting position of the y-axis is Py. After the command is triggered, a circular interpolation will be performed with (Px, Py) as the starting point and (EndPoint[0], EndPoint[1]) as the ending point, passing through the points (AuxPoint[0], (AuxPoint[1]).
When the starting and ending points are the same, a perfect circle is drawn with the starting point (Px, Py) and the passing points (AuxPoint[0], (AuxPoint[1]) as diameters. In this case, the rotation direction of the arc is specified by PathChoice.
When the starting point, the intermediate point, and the ending point are on the same straight line, a circle cannot be formed. The instruction reports an error and stops executing the interpolation instruction.
When the endpoint and the point of passage are the same point, or the starting point and the point of passage are the same point, the instruction reports an error and stops executing the interpolation instruction;
②CircMode=1 represents circular interpolation based on the center point:
Taking the x-axis and z-axis as examples, the starting position of the x-axis is Px, and the starting position of the z-axis is Pz. After the command is triggered, a circular interpolation will be performed with (Px, Pz) as the starting point, (AuxPoint[0], (AuxPoint[2]) as the center, and (EndPoint[0], EndPoint[2]) as the ending point. The rotation direction of the drawn arc is determined by PathChoice.
③CircMode=2 means performing circular interpolation based on the specified radius:
Regardless of which plane is chosen, the radius of the arc is always determined by |AuxPoint[0]|;
Taking the y-axis and z-axis as examples, the starting position of the y-axis is Py, and the starting position of the z-axis is Pz. The y-axis and z-axis perform circular interpolation with (Py, Pz) as the starting point, |AuxPoint[0]| as the radius, and (EndPoint[1], EndPoint[2]) as the ending point.
A negative radius sign results in a longer arc; a positive radius sign results in a shorter arc; the direction of rotation of the arc is specified via PathChoice.
5) Selection of movement method
①MoveMode=0 indicates absolute positioning mode:
When selecting a transit point, the auxiliary point and the endpoint represent absolute points in the coordinate system;
When selecting a center point, both the center point and the endpoint represent absolute points in the coordinate system;
When selecting a radius, the endpoint represents an absolute point in the coordinate system;
②MoveMode=1 indicates relative positioning mode:
When selecting a transit point, the auxiliary point and the endpoint represent points relative to the starting point;
When selecting a center point, the center point and the endpoint represent points relative to the starting point;
When selecting a radius, the endpoint represents a point relative to the starting point;
6) Buffer Mode
Refer to the linear interpolation instruction buffer mode;
Function block MC_GroupStop: Command to stop the movement of the axis group
This function block is used to implement the motion stop function of the shaft assembly, and the rising edge is valid.
The function block MC_GroupStop is shown in the following figure:
Notice:
1) The MC_GroupStop instruction can only pause interpolation instructions (such as MC_MoveLinear), and cannot stop single-axis motion instructions (such as MC_MoveAbsolute); 2) State transitions
On the rising edge of Execute, the interpolator stops according to the stop mode set by StopMode, interrupting all interpolation instructions in the buffer state. After stopping, the Done signal is valid, and the single-axis PLCOpen state machine remains in the SynchronizedMotion state. During Execute=ON, the interpolator remains in a stopped state, and triggering new interpolation instructions during this time is invalid. On the falling edge of Execute, the interpolator switches to a non-stop state, and the single axis enters the StandStill state, at which point new interpolation instructions can be triggered.
3) Stop Mode
When StopMode is set to 0, the machine will decelerate and stop according to the deceleration rate set by Deceleration; when StopMode is set to 1, the machine will stop immediately without any deceleration process.
Function block MC_GroupPause: Command to pause motion of axis group
This function block is used to implement motion pause function for the axis assembly, and the rising edge is valid.
The function block MC_GroupPause is shown in the following figure:
Notice:
1) The MC_GroupPause instruction can only pause interpolation instructions (such as MC_MoveLinear), and cannot stop single-axis motion instructions (such as MC_MoveAbsolute); 2) State transitions
① When all shafts in the shaft group are in the StandStill state:
When Enable is set to ON, the axes within the axis group remain in StandStill state. If a linear or circular interpolation command is triggered at this time, the axes within the axis group will switch to SynchronizedMotion state, but will be paused and will not execute the interpolation algorithm. The interpolation algorithm will only begin execution when the Enable signal of the MC_GroupPause instruction is set to OFF.
② When all axes in the axis group are in the SynchronizedMotion state:
On the rising edge of Enable, the interpolator performs a deceleration process according to the deceleration set by Deceleration. After deceleration is complete, the Done signal is valid, and the single-axis PLCOpen state machine remains in the SynchronizedMotion state. During the pause, the Busy and Active signals of the interpolation instruction being executed remain valid. During Enable=ON, the interpolator remains in a paused state. When a new interpolation instruction is triggered, the new interpolation instruction is in a buffered state. On the falling edge of Enable, the interpolator resumes execution of the previously paused interpolation instruction.
03. Operating Procedures
The PC's IP address is 192.168.1.132 (it should be on the same network segment as the PLC).
The IP address of SC2-C is 192.168.1.3;
The operation steps are shown in the figure:
(1) New construction projects
Open LeadStudio software and create a new project named "Example_SC2C_AxisGroup", as shown in the image below:
(2) Axis Group Settings 1) For pulse axis creation and parameter configuration, please refer to "Local Pulse Axis_Example", which will not be repeated here; 2) Right-click on [Motion Control Axis Group Configuration] in the device tree on the left, select [Add Axis Group], create a new axis group [MC_Group0], double-click to open axis group [MC_Group0], set the axis composition and related parameters of the axis group, as shown in the figure below:
Notice:
Maximum speed: Linear interpolation mode represents the maximum interpolation speed of a straight line in space; circular interpolation mode represents the maximum linear speed of a circular arc.
Maximum acceleration: Linear interpolation mode represents the maximum acceleration interpolated along a straight line in space; circular interpolation mode represents the maximum linear acceleration along a circular arc.
Stopping method: refers to the stopping method when a shaft assembly malfunctions.
(3) Shaft group (interpolation) program writing
1) The variable definitions are shown in the following figure;
2) Write the program as shown in the figure below:
(4) Axis group (interpolation) function test
1) Open LeadStudio software, open the project "Example_SC2C_AxisGroup", compile it without errors, download the project to SC2-C, and click run, as shown in the following figure:
2) Double-click "Trace0" in the device tree on the left, select "Trace Configuration", add variables as shown in the image below, right-click in the blank area, and select "Download Trace";
3) Double-click to open the AxisGroup Demo program, set the "iState" value to 1, and start executing the "AxisGroup Demo program". This will trigger a linear interpolation motion followed by a buffered circular interpolation motion, as shown in the following figure:
4) Wait for the program to complete. The monitoring will show that the "iState" value is 5, indicating that the linear interpolation and circular interpolation movements are complete, as shown in the figure below:
5) Double-click "Trace0" in the device tree on the left to see the position and velocity change curves of the two axes in the axis group during linear and circular interpolation processes, as shown in the figure below: