A local circular arc interpolation control method for a plotter
Patent Information
- Application Number
- CN202611233800.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-10-23
AI Technical Summary
[0005]本发明的目的在于解决现有绘图机圆弧插补依赖上位机逐微段计算和下发所导致的通信负担大、插补连续性易受通信延迟影响,以及PLC圆弧坐标计算实时性不足、脉冲取整误差容易累积和微段执行状态难以可靠衔接的问题
1.本发明由PLC根据圆弧几何参数、圆弧运动方向及进给速度,在本地完成连续角度确定、微段目标坐标生成及运动参数转换,无需上位机逐微段计算并连续下发运动指令,能够减少插补过程中的通信数据量及通信等待时间,降低通信延迟或波动对圆弧运动连续性的影响。
Smart Images

Figure CN122963065A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of PLC motion control technology, specifically a PLC local circular interpolation control method for a plotter. Background Technology
[0002] In PLC-controlled plotters, drawing circular arc trajectories requires meeting trajectory accuracy requirements while ensuring long-term continuous operation and multi-axis motion coordination. Due to limitations in cyclic scanning cycle, floating-point arithmetic capability, and high-speed pulse output resources, low-cost PLCs are prone to coordinating trajectory subdivision accuracy and control resources when executing a large number of circular arc trajectories.
[0003] Existing technologies typically involve a host computer pre-discretizing the circular arc trajectory and sending the discrete trajectory coordinates to the PLC point by point; or calling the PLC's preset circular arc interpolation function to complete the trajectory control; for equipment with high requirements for trajectory accuracy and motion performance, a dedicated motion control card can also be configured to handle interpolation calculations and pulse output.
[0004] However, when the host computer sends data point by point, the finer the arc subdivision, the more trajectory data needs to be transmitted and scheduled. Long-term operation can easily increase the communication load and affect the stability of trajectory execution. The PLC's preset interpolation function has limited subdivision parameter adjustment capability, making it difficult to adapt to the accuracy requirements of different graphics. Further delegating the arc subdivision to the local low-cost PLC will increase the number of angle calculations and micro-segment executions, and also require handling cross-regional angle continuity and multi-axis motion coordination issues. Therefore, the existing solution is difficult to simultaneously achieve arc drawing accuracy, operating efficiency, and continuous drawing stability at a low hardware cost. Summary of the Invention
[0005] The purpose of this invention is to solve the problems of existing plotter circular interpolation relying on the host computer to calculate and send micro-segments one by one, resulting in a large communication burden, interpolation continuity being easily affected by communication delays, as well as the insufficient real-time performance of PLC circular coordinate calculation, easy accumulation of pulse rounding errors, and difficulty in reliably connecting micro-segment execution states.
[0006] To address the above problems, this invention proposes a PLC-based local circular interpolation control method for a plotter, comprising: Obtain the circular arc trajectory parameters, which include the circular arc geometric parameters, the circular arc motion direction, and the feed speed; The starting angle and target angle are determined based on the arc geometry parameters, and the angles are made continuous according to the arc movement direction to obtain continuous starting angles and continuous target angles. Using the continuous starting angle as the iteration starting point, the current micro-segment target coordinates and corresponding iteration states are generated iteratively according to the arc motion direction with a preset angular displacement step size. Control the drawing motion axis to execute the current micro-segment, and pre-generate the target coordinates and motion parameters of the next micro-segment based on the iterative state during execution, and write them into the preparation state of the next micro-segment; After the current micro-segment is confirmed to be completed, the current execution state is submitted, the preparation state of the next micro-segment is switched to the current execution state, the trajectory execution state is updated, and the drawing motion axis is controlled to obtain the circular interpolation control result.
[0007] Preferably, obtaining the circular arc trajectory parameters includes: Extract the current point position, target point position, and center parameters from the arc geometry parameters, and determine the center position and the coordinate increments of the current point position and target point position relative to the center position; The starting radius and the ending radius are determined based on two sets of coordinate increments. When the radius deviation between the two is not greater than a preset geometric error threshold, the starting radius is determined as the arc radius. Otherwise, an arc parameter abnormality flag is generated and the generation of micro-segments is stopped.
[0008] Preferably, the angle continuity processing includes: The coordinate increments of the current point position and the target point position relative to the center position are determined based on the arc geometry parameters. Zero-value judgment and arctangent operation are performed on the two sets of coordinate increments, and circumferential mapping is performed according to the sign relationship to obtain the initial circumferential angle and the target circumferential angle; The target circumferential angle is periodically expanded according to the direction of the arc motion. When the current point position is the same as the target point position and corresponds to the whole circle trajectory, the target circumferential angle is expanded along the direction of the arc motion for one angle period.
[0009] Preferably, the iterative generation of the micro-segment target coordinates and the corresponding iterative states includes: The preset angular displacement step size is determined and latched based on the radius of the arc, the allowable chord height error, the pulse equivalent of the drawing motion axis, and the shortest start-up time of the hardware motion resources. The sine and cosine states are initialized with continuous starting angles. The sine and cosine constants of the step length are determined according to the preset angular displacement step length and the direction of the circular motion. The micro-segment target coordinates and corresponding iterative states are generated recursively. When the remaining arc angle is not greater than the preset angular displacement step size, the target point position is determined as the target coordinate of the last micro-segment.
[0010] Preferably, the control of the drawing motion axis to execute the current micro-segment includes: The theoretical displacements of the two drawing motion axes are determined based on the starting and target coordinates of the current micro-segment. The theoretical displacements are then superimposed with the effective displacement residuals corresponding to the previous completed state. The displacements are converted into integer target pulse numbers according to the corresponding pulse equivalents, and candidate displacement residuals are generated based on the displacement difference before and after the conversion. The shared motion duration is determined based on the micro-segment length and feed rate, and the two drawing motion axes are controlled to output corresponding pulses using the same motion time base. After the current micro-segment is confirmed to be complete, the candidate displacement residual is updated to the effective displacement residual.
[0011] Preferably, when the number of integer target pulses for one drawing motion axis is zero, the drawing motion axis is kept stationary while the other drawing motion axis outputs pulses. When the number of integer target pulses for both drawing motion axes is zero and the current micro-segment target coordinate has not reached the target point position, the current micro-segment is not started, and the target coordinates of the next micro-segment are generated. The target coordinates of the current micro-segment are updated and the number of integer target pulses is recalculated until at least one drawing motion axis forms a target pulse or reaches the target point position. When the number of pulses is still zero after reaching the target point position, the final segment completion confirmation is generated and the corresponding iteration status and candidate displacement residual are submitted. The micro-segment completion count is not updated separately for the merged micro-segment target coordinates.
[0012] Preferably, the completed state records the target coordinates, confirmed completion position, effective iteration state, effective displacement residual, and micro-segment completion count of the completed micro-segment; the current execution state records the target coordinates, motion parameters, pending iteration state, and candidate displacement residual of the micro-segment being executed; the next micro-segment preparation state records the pre-generated target coordinates, motion parameters, candidate iteration state, and candidate displacement residual of the next micro-segment, and records the pre-calculated starting position and pre-calculated effective displacement residual used when generating the motion parameters.
[0013] Preferably, the next micro-segment preparation state is prohibited from being started during the current micro-segment execution; when the target pulse output is completed on both drawing motion axes and the effective edge of the segment completion flag is reached, the current execution state is submitted to the completed state; the confirmed completion position after submission is compared with the pre-calculated starting position, and the effective displacement residual is compared with the pre-calculated effective displacement residual. If the corresponding differences are not greater than the preset state consistency error threshold, the next micro-segment preparation state is switched to the current execution state; otherwise, it is set to invalid and regenerated according to the confirmed completion position after submission and the effective displacement residual.
[0014] Preferably, the action state control includes: In the event of a paused or recoverable execution anomaly, the permission to start subsequent micro-segments is revoked, the updating of candidate displacement residuals of incomplete micro-segments to valid displacement residuals is prohibited, and the confirmed stop position is determined. Upon receiving a recovery command or when the exception is resolved and the hardware motion resources meet the recovery conditions, the remaining motion parameters are re-determined based on the difference between the integer target pulse number and the number of output pulses, or based on the positional relationship between the confirmed stop position and the target coordinates of the unfinished micro-segment. The effective displacement residual before the start of the micro-segment is not superimposed repeatedly. After the remaining motion is completed, the execution of subsequent micro-segments is resumed.
[0015] Preferably, the arc trajectory parameters further include pen state information characterizing the pen-down drawing state or the pen-up idle state; before the first micro-segment of the current arc is started, the Z-axis is controlled to switch to the corresponding state according to the pen state information, and the drawing motion axis is allowed to start after obtaining confirmation of arrival; the Z-axis state switching is locked during the execution of the current arc; when the execution of the current arc is completed and the pen state corresponding to the next arc changes, the Z-axis is controlled to complete the corresponding switching before the first micro-segment of the next arc is started.
[0016] Compared with the prior art, the present invention has the following advantages: 1. This invention enables the PLC to determine continuous angles, generate micro-segment target coordinates, and convert motion parameters locally based on the arc geometry parameters, arc motion direction, and feed speed. This eliminates the need for the host computer to calculate micro-segments one by one and continuously issue motion commands, thereby reducing the amount of communication data and communication waiting time during the interpolation process and reducing the impact of communication delays or fluctuations on the continuity of the arc motion.
[0017] 2. This invention uses a preset angular displacement step size to recursively calculate the sine and cosine states to generate the target coordinates of each micro-segment. This avoids the PLC repeatedly performing trigonometric function calculations in each interpolation cycle, reduces the computational burden of circular interpolation, makes the micro-segment coordinate calculation more suitable for the PLC's periodic computational capabilities, and improves the real-time performance of circular interpolation.
[0018] 3. This invention converts the axial displacement between adjacent micro-segment target coordinates into micro-segment motion parameters in the form of integer pulses, and forms candidate displacement residuals from the unrealized displacements generated by pulse rounding, which are used for pulse calculation of subsequent micro-segments. This can compensate for the displacement error generated by discrete pulse conversion segment by segment, suppress the accumulation of rounding error along the circular arc trajectory, and improve the control accuracy of the circular arc trajectory and the target point position.
[0019] 4. This invention pre-generates the preparation state for the next micro-segment during the execution of the current micro-segment, and only submits the corresponding recursive state and candidate displacement residual and switches to the next micro-segment after the current micro-segment obtains a valid completion flag. This enables the micro-segment calculation to be connected with the motion execution, while avoiding premature updates of the valid state when paused, abnormal, or the micro-segment is not completed. This reduces the occurrence of state misalignment, repeated compensation, or trajectory discontinuity during the resumption of execution, and improves the continuity and reliability of circular interpolation control. By using the confirmation of Z-axis positioning as a prerequisite for starting the drawing motion axis, and locking the Z-axis state switching during the current circular arc execution, the pen-down action or pen-up action and the trajectory execution of the drawing motion axis are interlocked in time. This avoids trajectory breakage caused by starting drawing before the pen is in position, and trajectory trailing caused by starting idle movement before the pen is lifted. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation on the scope of this application.
[0021] Figure 1 This is an exemplary flowchart of the PLC local circular interpolation control method provided in an embodiment of the present invention; Figure 2 A schematic diagram of the counterclockwise circular interpolation control process of the PLC local circular interpolation control method provided in this embodiment of the invention; Figure 3 A schematic diagram of the clockwise circular interpolation control process of the PLC local circular interpolation control method provided in this embodiment of the invention; Figure 4 This is a schematic diagram of the overall architecture of the PLC local circular interpolation control method provided in an embodiment of the present invention. Detailed Implementation
[0022] To make the technical means, creative features, objectives, and effects of this invention easier to understand, the invention is further described below with reference to specific embodiments. However, the following embodiments are merely preferred embodiments of this invention and not all of them. Other embodiments obtained by those skilled in the art based on the embodiments described herein without creative effort are all within the protection scope of this invention.
[0023] A specific embodiment of the present invention discloses a PLC local circular interpolation control method for a plotter, such as... Figure 1 As shown, the method includes: S1. Obtain the arc trajectory parameters, which include the arc geometric parameters, the arc motion direction, and the feed speed.
[0024] First, the graphic data of the object to be drawn is acquired and imported into vector graphics processing software. The graphic or text outline is vectorized, and a G-code file containing motion information of each trajectory segment is generated according to the connection relationship of the outline path and the drawing order. The G-code file is input into the host computer, which uses MATLAB to read and parse each trajectory segment one by one according to the trajectory arrangement order. The current trajectory to be executed is determined according to the motion type recorded in the trajectory segment. When the current trajectory to be executed is determined to be an arc trajectory, the position, rotation direction and velocity information of the arc are read to obtain the target point position, center parameter, arc motion direction and feed speed. The trajectory segment motion information also includes pen status information for controlling pen action. The pen status information is determined by the Z-axis position parameter in the G-code or the pen lifting command. The Z-axis position parameter does not participate in the arc plane coordinate recursion, but is used to control the pen motion axis to switch between the pen lifting state and the pen falling state.
[0025] Furthermore, the position of the planar motion axis when the current arc begins execution is obtained and determined as the current point position; during continuous drawing, the position reached after the previous trajectory segment ends is taken as the current point position of the current arc, so that adjacent trajectory segments are continuous in position; the center parameter represents the positional offset relationship of the center relative to the current point in two planar motion directions, and the positional offset in the two directions is superimposed with the coordinates of the current point in the corresponding directions to determine the center position of the center in the drawing plane.
[0026] After determining the center position, the horizontal and vertical coordinate increments of the current point position and the target point position relative to the center position are obtained respectively. The starting radius is determined based on the horizontal and vertical coordinate increments corresponding to the current point position, and the ending radius is determined based on the horizontal and vertical coordinate increments corresponding to the target point position. The starting radius and the ending radius represent the distances between the current point position, the target point position and the center position, respectively.
[0027] The starting radius and the ending radius are compared to obtain the radius deviation. When the radius deviation is greater than a preset geometric error threshold, it is determined that the current arc geometric parameters do not meet the arc construction conditions, an arc parameter anomaly flag is generated, and the generation of the corresponding arc micro-segment is stopped. When the radius deviation is not greater than the preset geometric error threshold, the starting radius is determined as the arc radius, and the target coordinates of each micro-segment are generated based on the arc radius. Wherein, when the remaining arc angle is less than a preset angular displacement step, the target point position is determined as the target coordinates of the last micro-segment so that the generated arc trajectory reaches the target point position. The preset geometric error threshold is used to limit the allowable deviation between the starting radius and the ending radius, and is determined according to the coordinate resolution of the arc trajectory parameters and the preset allowable trajectory error. In this embodiment, it is set to 0.02mm.
[0028] The geometric parameters of the current arc are formed based on the current point position, the target point position, and the center position. Specifically, with the center position as a reference, the coordinate increments between the current point and the center and between the target point and the center are calculated in two planar motion directions. The coordinate increments corresponding to the current point represent the positional relationship between the starting position of the arc and the center, and the coordinate increments corresponding to the target point represent the positional relationship between the ending position of the arc and the center. The coordinate increments serve as the geometric input for subsequently determining the starting angle and the target angle.
[0029] The arc geometry parameters, arc motion direction, and feed speed are established according to the current arc to form a set of arc trajectory parameters corresponding to the arc. The host computer organizes the arc trajectory parameters according to the data address corresponding to each parameter and writes them into the data storage area of the PLC through the communication link, so that the PLC can obtain the geometric information, motion direction, and speed information corresponding to the current arc.
[0030] S2. Determine the starting angle and target angle based on the arc geometry parameters, and perform angle continuity processing according to the arc movement direction to obtain continuous starting angle and continuous target angle.
[0031] Using the center position of the circle as the reference for angle calculation, the coordinate differences between the current point position and the target point position and the center position are calculated to obtain the first horizontal coordinate increment and the first vertical coordinate increment corresponding to the current point, and the second horizontal coordinate increment and the second vertical coordinate increment corresponding to the target point. Specifically, the first horizontal coordinate increment and the first vertical coordinate increment are used to characterize the direction of the arc's starting position relative to the center, and the second horizontal coordinate increment and the second vertical coordinate increment are used to characterize the direction of the arc's ending position relative to the center.
[0032] Specifically, let the current position be... The target point location is The center position Then, the corresponding coordinate increments are determined according to the following formulas: , , , , Among them, the This represents the coordinate increment of the current point relative to the center of the circle in the X direction. This represents the coordinate increment of the current point relative to the center of the circle in the Y direction. Together, they are used to characterize the directional relationship between the starting position of the arc and the center of the circle. This represents the coordinate increment of the target point relative to the center of the circle in the X direction. This represents the coordinate increment of the target point relative to the center of the circle in the Y direction. Together, they are used to characterize the directional relationship between the arc's termination position and the center of the circle.
[0033] Furthermore, respectively with and As an object of angle calculation, for any set of coordinate increments First, the absolute value of the horizontal coordinate increment. The threshold value for comparison with the preset zero value In an alternative implementation, a comparison is made between the two methods. Set as It is used to treat the smallest horizontal coordinate increments caused by numerical calculation errors as zero values.
[0034] Specifically, when At that time, the ratio of the vertical coordinate increment to the horizontal coordinate increment is calculated, and the arctangent is performed to obtain the base angle. : , Since the fundamental angle is determined solely by the ratio of two coordinate increments, points in different quadrants may yield the same or similar arctangent results. Therefore, further calculations based on... and The sign relationship is used to perform a circular mapping of the basic angle; when and At that time, the basic angle remains unchanged; when At that time, add to the basic angle ;when and At that time, add to the basic angle This allows for a unified representation of the positions corresponding to different quadrants. Within the range of circumferential angles.
[0035] when When division is no longer performed, the corresponding circumferential angle is determined directly based on the vertical coordinate increment: when When, the circumferential angle is determined as ;when When, the circumferential angle is determined as .when and When the corresponding position coincides with the center of the circle and cannot form a valid circumferential direction, the subsequent angle processing for the current arc is stopped. By performing a zero value judgment before the arctangent operation, the vertical angle determination process is directly entered when the horizontal coordinate increment is close to zero, avoiding the abnormal angle result caused by the participation of a tiny number in the division.
[0036] Process the current point and the target point separately using the above method to obtain the starting circumferential angle corresponding to the current point. Target circumference angle corresponding to the target point ;at this time, and Both represent geometric angles of corresponding positions in the same circular coordinate system, but since circular angles are based on... As the period is defined, when the arc crosses the zero-angle position, the numerical relationship between the two circumferential angles may not be consistent with the actual direction of arc movement. Therefore, the obtained direction of arc movement is used to make the two continuous.
[0037] When the direction of the circular arc movement is counterclockwise, the initial circumferential angle will be... Determined as continuous starting angle If the target circumference angle Not less than the initial circumferential angle Then Directly determined as continuous target angles If the target circumference angle Less than the initial circumferential angle Then, the target circumferential angle is periodically expanded according to the following formula: , Thus satisfying the counterclockwise downward direction , will originally cross The arc at the 0 boundary is transformed into a continuously increasing angle range.
[0038] When the direction of the circular arc movement is clockwise, the initial circumferential angle will be... Determined as continuous starting angle If the target circumference angle Not greater than the initial circumferential angle Then Directly determined as continuous target angles If the target circumference angle Greater than the initial circumferential angle Then, the periodic expansion is performed according to the following formula: , Thus satisfying the clockwise downward direction The arc crossing the 0-angle boundary is converted into a continuously decreasing angle interval; for a complete circular trajectory where the current point and the target point coincide but the center points are different, the continuous target angles are determined according to the direction of the arc movement. or This ensures that the circular trajectory still has a defined range of angle iterations.
[0039] After the above processing, continuous starting angles are obtained. and continuous target angle The continuous processing does not change the actual geometric relationship between the current point, the target point, and the center of the circle. Instead, it expands the periodic circumferential angles according to the direction of the arc movement, so that the counterclockwise arc corresponds to a continuously increasing angle interval, and the clockwise arc corresponds to a continuously decreasing angle interval. As a result, subsequent iterations can be started with continuous starting angles and the continuous target angles can be used as iteration boundaries to continuously generate the positions of each micro-segment target according to the angular displacement consistent with the direction of the arc movement, without having to switch the iteration direction again when the angle crosses a quadrant or the zero angle position.
[0040] S3. Using the continuous starting angle as the iteration starting point, generate the current micro-segment target coordinates and corresponding iteration states iteratively according to the arc motion direction with a preset angular displacement step size.
[0041] The angular displacement step size for controlling the degree of arc subdivision is preset in the PLC. The angular displacement step size is positive, and the angular displacement increment used for this circular interpolation is determined according to the direction of the circular motion. When the direction of the circular arc movement is counterclockwise, let When the direction of the circular arc movement is clockwise, let Thus, the direction of the circular arc motion directly acts on the subsequent coordinate recursion direction, without having to re-determine the rotation direction in each micro-segment calculation. In one optional implementation, the angular displacement step size can be set to 0.01 rad, and the angular displacement step size can be pre-configured according to the drawing accuracy requirements.
[0042] Before generating the micro-segment target coordinates of the current arc, at the aforementioned continuous starting angle Initialize the circumferential position state, calculate the cosine and sine values corresponding to the continuous starting angles, and record them as the current cosine state. and the current sine state Where k is the current arc angle iteration index, and when k=0, the continuous starting angles are used as the initial state of the current angle: , , Simultaneously, based on the angular displacement increment Calculate the corresponding step size cosine constant. and step size sine constant : , , The and The angular displacement step size and direction of motion of the current arc only need to be determined once and stored in the data area of the PLC for repeated calls in subsequent micro-segment iterations. Therefore, when continuously generating the target coordinates of the micro-segments, it is not necessary to perform sine and cosine calculations for each new current angle.
[0043] For the k-th micro-segment iteration, based on the current cosine state Current sine wave state And the pre-stored step cosine constant and step size sine constant Determine the cosine and sine states corresponding to the next position on the circle based on the trigonometric sum and difference relationships: , , in, and These represent the cosine and sine values of the corresponding circumferential position after the current arc advances one step along the angular displacement increment. Since the clockwise direction... Take the negative value, the corresponding By changing the sign at the same time, the same set of recursive relations can be used to update the circumferential position in both clockwise and counterclockwise directions.
[0044] When performing the above recursion, first save the value at the beginning of the current iteration. and Calculate separately and Once both are calculated, the current circumferential position state is updated to avoid the other state incorrectly referencing the already updated result after updating one state variable first.
[0045] Based on this recursion... and Based on the center position and arc radius determined by S1, the coordinates of the micro-segment target corresponding to the current iteration are determined; let the center position be... If the radius of the arc is R, then the coordinates of the micro-segment target are... Determined according to the following formula: , , For the first iteration, the current point position of the current arc is used as the starting coordinate of the first micro-segment, and the target coordinate of the micro-segment obtained by the first recursion is used as the ending coordinate of the first micro-segment; for subsequent iterations, the target coordinate of the micro-segment generated in the previous iteration is used as the starting coordinate of the current micro-segment, and the target coordinate of the micro-segment generated in this recursion is used as the ending coordinate of the current micro-segment, thereby forming multiple micro-segments arranged along the current arc in sequence.
[0046] During the generation of micro-segment target coordinates, the recursive state used to calculate the target coordinates of subsequent micro-segments is determined as the calculation recursive state, and the recursive state corresponding to the micro-segment that has been confirmed as completed by the drawing motion axis is determined as the valid recursive state. The calculation recursive state includes the iteration angle, the current sine state, and the current cosine state used for calculation, which are used to generate candidate target coordinates for the current micro-segment or the next micro-segment. The valid recursive state includes the iteration angle, sine state, and cosine state corresponding to the last confirmed completed micro-segment, which are used to characterize the arc position that the drawing motion axis has completed.
[0047] For each micro-segment target coordinate generated, the iteration angle, sine state, and cosine state obtained in this recursion are associated to form the corresponding micro-segment's calculation recursion state, which is saved along with the micro-segment target coordinate. The generation of the micro-segment target coordinate only advances the calculation recursion state and does not directly update the valid recursion state. After the corresponding micro-segment obtains a valid completion flag, the calculation recursion state is updated to a new valid recursion state according to the state submission process described above. During the continuous generation of micro-segment target coordinates, the continuous change relationship between the current iteration angle and the continuous starting angle is maintained, and the current iteration angle is not re-converted to a single circumferential period. When continuous recursion makes the current sine state... When the current state and the current cosine state cause numerical drift, amplitude correction can be performed on both. However, the amplitude correction does not change the direction of increase or decrease of the corresponding iteration angle, nor does it change the continuous angle relationship between the continuous starting angle and the continuous target angle. At the same time, it is determined whether the next advance according to the preset angular displacement step size will reach or exceed the continuous target angle. If the continuous target angle has not been reached, the sine state and cosine state recursion continues based on the current calculation recursion state. When the remaining arc angle is less than a complete angular displacement step size, the continuous target angle is determined as the iteration angle of the last calculation, and the determined target point position is directly determined as the target coordinate of the last micro-segment.
[0048] like Figure 2 As shown, when the arc motion direction is counterclockwise, the PLC takes the continuous starting angle as the iteration starting point, advances the current iteration angle according to the preset angular displacement step size in the positive direction, determines the corresponding micro-segment target coordinates based on the advanced iteration angle, and judges whether the advanced iteration angle has reached the continuous target angle; if the continuous target angle has not been reached, the next angle advancement and micro-segment target coordinate generation are continued, and the generation of new conventional micro-segments is stopped when the continuous target angle is reached.
[0049] like Figure 3As shown, when the direction of the arc motion is clockwise, the PLC takes the continuous starting angle as the starting point of the iteration, advances the current iteration angle according to the negative preset angular displacement step size, determines the corresponding micro-segment target coordinates based on the advanced iteration angle, and judges whether the advanced iteration angle has reached the continuous target angle; if the continuous target angle has not been reached, the next angle advancement and micro-segment target coordinate generation are continued, and the generation of new conventional micro-segments is stopped when the continuous target angle is reached.
[0050] Figure 2 and Figure 3 The angular advancement process is shown in both counterclockwise and clockwise directions. The main difference between the two lies in the sign of the angular displacement step and the comparison direction when reaching the continuous target angle. To avoid establishing two separate recursive processes, this embodiment uses a direction symbol to uniformly represent the two circular motion directions. The direction symbol corresponding to the counterclockwise direction is positive, and the direction symbol corresponding to the clockwise direction is negative. The angular displacement step with direction is determined based on the direction symbol.
[0051] It should be noted that, Figure 2 and Figure 3 The 0.01 rad shown is an example of a preset angular displacement step size, not a fixed value. In an optional implementation, the selectable range of the angular displacement step size is first determined based on the arc radius and allowable chord height error. Then, the corresponding micro-segment motion duration is determined based on the target chord length and feed rate between adjacent micro-segment target coordinates. It is then determined whether the micro-segment motion duration can meet the processing time required for the PLC to complete the generation of the next micro-segment target coordinates, motion parameter configuration, and state switching. Simultaneously, the corresponding pulse output requirements are determined based on the axial displacement and pulse equivalent of each drawing motion axis, and it is determined whether the required pulse output frequency is within the allowable range of the PLC hardware pulse output resources. Based on the above judgment results, the angular displacement step size or feed rate is adjusted to obtain a target angular displacement step size that simultaneously meets the requirements of trajectory accuracy, PLC processing time, and hardware pulse output capability.
[0052] Through the above processing, the sine and cosine operations are mainly concentrated in the state initialization stage before the current arc begins to be executed. The circumferential position of each subsequent micro-segment is mainly obtained by multiplying and adding the pre-stored step size constant with the current circumferential position state. This allows the angular displacement step size, arc movement direction and micro-segment coordinate generation to work together in the same recursive process. While maintaining the continuity of the arc subdivision direction and position, this reduces the PLC from repeatedly executing trigonometric function operations during the generation of each micro-segment.
[0053] S4. Control the drawing motion axis to execute the current micro-segment. During execution, pre-generate the target coordinates and motion parameters of the next micro-segment based on the iterative state and write them into the preparation state of the next micro-segment.
[0054] The PLC establishes a completed state, a current execution state, and a next micro-segment preparation state for the software calculation progress and hardware execution progress of the arc micro-segment, respectively. The completed state is used to store the logical target coordinates of the last confirmed completed micro-segment, the confirmed completion position determined by position feedback or cumulative output pulses, the micro-segment completion count, the effective recursive state, and the effective displacement residual, serving as a valid benchmark for subsequent micro-segment generation and anomaly recovery. The current execution state is used to store the logical start position, confirmed start position, micro-segment target coordinates, micro-segment motion parameters, corresponding recursive state, candidate displacement residual, and end segment identifier of the current micro-segment that has been written into the hardware motion resources and started. The next micro-segment preparation state is used to store the candidate logical start position, candidate confirmed start position, candidate target coordinates, candidate motion parameters, candidate recursive state, candidate displacement residual, and candidate end segment identifier of the next micro-segment that has been generated by the PLC but has not yet been started. The logical target coordinates are used to represent the target position generated according to the arc geometry, and the confirmed completion position is used to represent the position that the drawing motion axis actually reaches according to integer pulses and is confirmed by the completion flag. The two are not treated as the same position state.
[0055] After obtaining the target coordinates of the current micro-segment, the PLC determines the coordinate differences between the logical target coordinates of the previously confirmed completed micro-segment and the target coordinates of the current micro-segment in the two drawing motion axes, thereby obtaining the theoretical axial displacements corresponding to the two drawing motion axes. At the same time, it reads the effective displacement residuals corresponding to the two drawing motion axes from the completed state. The effective displacement residuals are used to represent the axial displacements that have not yet been realized through pulse output after the integer pulse conversion of the previously confirmed completed micro-segment.
[0056] For any drawing motion axis, the corresponding theoretical axial displacement and effective displacement residual are superimposed to obtain the corrected axial displacement of the current micro-segment; according to the pulse equivalent of the drawing motion axis and the integer conversion rules actually used by the PLC program, the corrected axial displacement is converted into an integer target pulse number with direction; the corresponding pulse output displacement is determined according to the integer target pulse number and pulse equivalent, and the part of the corrected axial displacement that is not realized by integer pulses is determined as the candidate displacement residual of the current micro-segment.
[0057] The target chord length of the current micro-segment is determined based on the coordinate change between the logical target coordinates of two adjacent micro-segments. The shared motion duration of the two drawing motion axes is then determined based on the target chord length and feed rate. The pulse output direction, pulse output quantity, and pulse output frequency are determined based on the integer target pulse count corresponding to each drawing motion axis and the shared motion duration, forming the motion parameters of the current micro-segment. When the integer target pulse count corresponding to one of the drawing motion axes is zero, that drawing motion axis is set to a no-pulse output state, and its axis-side pulse output condition is determined to be satisfied. The other drawing motion axis continues to execute the corresponding pulse output according to the shared motion duration. When the integer target pulse counts corresponding to both drawing motion axes are zero, the current micro-segment is treated as a no-pulse micro-segment, but its candidate displacement residual is still retained, and the status is submitted according to the subsequent valid completion conditions. The PLC writes the current micro-segment motion parameters into the planar motion control module with two-axis coordinated output function and sends a start signal that lasts for one PLC scan cycle. The planar motion control module calls the hardware PTO output unit to output pulses of the corresponding number and frequency to the two motion axes using the same hardware motion time base. This allows the continuous pulse output during the micro-segment execution to be completed by the hardware motion resources, while the PLC is only responsible for motion target determination, parameter writing, and execution status detection, reducing the impact of PLC cycle scan time changes on the synchronization relationship between the two axes. After the current micro-segment starts, the PLC maintains its micro-segment target coordinates, motion parameters, and corresponding recursive state in the current execution state. The current execution state is not modified during the period when the planar motion control module returns to the execution status. At the same time, when the iteration angle corresponding to the current execution state has not yet reached the continuous target angle, the PLC continues to perform an angular displacement recursion along the arc motion direction according to the recursive state in the current execution state to obtain the candidate recursive state and candidate target coordinates of the next micro-segment. Then, according to the aforementioned displacement decomposition and pulse conversion process, candidate motion parameters are generated, and the candidate recursive state, candidate target coordinates, and candidate motion parameters are written into the preparation state of the next micro-segment.
[0058] Specifically, the pre-calculation utilizes the time that the current micro-segment is continuously executed by the hardware PTO to complete the coordinate generation and parameter configuration of the next micro-segment, which can reduce the pauses caused by recalculating coordinates and motion parameters between adjacent micro-segments; however, before the current micro-segment is confirmed to be completed, the preparation state of the next micro-segment is only saved as candidate data and is not used to overwrite the completed state or the current execution state, so as to distinguish the position already calculated by the PLC, the target position being executed, and the position that the drawing motion axis has been confirmed to be completed.
[0059] In one optional implementation, the plotter's Z-axis is used to control the pen's switching between a pen-lifting state and a pen-falling state. A time-sequenced interlock relationship is established between the Z-axis and the X and Y axes. Before each micro-segment is started, the PLC first determines the required pen state based on the pen state information in the arc trajectory parameters. If the pen state corresponding to the current micro-segment is a pen-falling drawing state, the PLC controls the Z-axis to perform a pen-falling action. Only after the pen-falling position is confirmed can the X and Y axes start the current micro-segment movement. If the pen state corresponding to the current micro-segment is a pen-lifting idle state, the PLC controls the Z-axis to perform a pen-lifting action. Only after the pen-lifting position is confirmed can the X and Y axes start the current micro-segment movement.
[0060] During the micro-segment motion on the X and Y axes, the PLC is prohibited from sending any state switching commands to the Z axis, so that the Z axis remains unchanged in the current pen state until the current micro-segment motion is completed and a valid completion flag is obtained. After the current micro-segment motion is completed and a valid completion flag is obtained, if the pen state corresponding to the next micro-segment is different from the current pen state, the PLC controls the Z axis to perform the corresponding state switch, such as lifting or lowering the pen, before switching the next micro-segment preparation state to the current execution state. After the Z axis is confirmed to be in position, the X and Y axis motion of the next micro-segment is started.
[0061] When the trajectory execution status is paused or abnormal, the PLC controls the X and Y axes to stop moving while keeping the current state of the Z axis unchanged and not performing any pen lifting or putting down actions. After the pause is resumed or the abnormality is cleared, the PLC first confirms whether the current state of the Z axis is consistent with the pen state required for the micro-segment to be executed. If they are inconsistent, the PLC first controls the Z axis to complete the state switch and then resumes the movement of the X and Y axes.
[0062] The PLC continuously reads the target pulse output status of the two drawing motion axes and the segment completion flag returned by the planar motion control module. When the target pulse output conditions of both drawing motion axes are met and the valid edge of the segment completion flag arrives, it determines that the current micro-segment has obtained a valid completion flag. Among them, the drawing motion axis with an integer target pulse count of zero is considered to have met its axis-side pulse output conditions, but it still needs to be judged in conjunction with the target pulse output status of the other drawing motion axis and the segment completion flag. The PLC performs edge detection on the segment completion flag so that when the same completion level remains valid in multiple scan cycles, it only triggers a status submission once.
[0063] After the current micro-segment obtains a valid completion flag, a new confirmed completion position is determined based on the previous confirmed completion position and the actual number of integer pulses output by the current micro-segment. The logical target coordinates, confirmed completion position, corresponding recursive state, and candidate displacement residuals in the current execution state are submitted to the completed state. The corresponding recursive state is updated to a valid recursive state, the candidate displacement residuals are updated to valid displacement residuals, and the micro-segment completion count is incremented by one. After the submission is completed, the submitted valid displacement residuals and confirmed completion positions are compared with the candidate displacement residuals and candidate confirmation start positions used when generating the next micro-segment preparation state. If they are consistent or the deviation is within the preset state consistency error range, the next micro-segment preparation state is switched to the current execution state, and the next micro-segment is started when the hardware motion resources meet the restart conditions. If they are inconsistent, the next micro-segment preparation state is set to invalid, and the motion parameters of the next micro-segment are regenerated based on the actually submitted valid displacement residuals and confirmed completion positions.
[0064] When the current micro-segment is paused or an execution exception occurs because it has not obtained a valid completion flag, the logical target coordinates, recursive state and candidate displacement residuals in the current execution state are not submitted, the micro-segment completion count is not increased, and the next micro-segment preparation state generated based on the above candidate states is set to invalid, so that the completed state continues to represent the last micro-segment that has been actually confirmed to be completed.
[0065] When the submitted current execution state corresponds to a continuous target angle, the micro-segment is determined to be the last micro-segment, and the next micro-segment preparation state is no longer generated or switched. After the target pulse output of the last micro-segment is completed, the trajectory execution state is determined to be completed. When any micro-segment is in hardware execution, the trajectory execution state is determined to be continuous execution. When a pause or motion abnormality occurs, the trajectory execution state is determined to be paused or abnormal, respectively, so that the trajectory execution state is consistent with the actual confirmed completed micro-segment position and completion count.
[0066] S5. After the current micro-segment is confirmed to be completed, submit the current execution state, switch the next micro-segment preparation state to the current execution state, update the trajectory execution state and control the drawing motion axis to obtain the circular interpolation control result.
[0067] The PLC uses the determined trajectory execution state as the control condition for switching the drawing motion axis actions, and establishes corresponding motion control branches for continuous execution, pause, execution exception, and execution completion. The action state is used to characterize whether the drawing motion axis is allowed to receive new micro-segment motion parameters, whether to continue outputting pulses, and whether to maintain the current position. The circular interpolation control result includes at least the final execution state of the circular trajectory, the actual completed position, and the micro-segment completion count.
[0068] When the trajectory execution state is continuous execution, the PLC keeps the planar motion control module and hardware PTO output unit enabled, allowing the next micro-segment preparation state to be switched to the current execution state according to the established state submission conditions, and the next micro-segment to be started after the current micro-segment is completed; when the current micro-segment has not yet returned a valid completion flag, new micro-segment start signals are prohibited from being written to the planar motion control module, so that the drawing motion axis keeps executing the current micro-segment, avoiding the same start command being sent repeatedly due to the PLC cyclic scanning.
[0069] When the trajectory execution status is paused, the PLC revokes the permission to start subsequent micro-segments, stops generating new candidate micro-segments, invalidates the next micro-segment preparation status, and prohibits the current execution status that has not yet obtained a valid completion flag from being submitted to the completed status. For the currently executing micro-segment, a stop command is sent to the hardware motion resources, and the confirmed stop position is determined based on the position feedback value or the number of output pulses recorded by the hardware pulse output resources. After pause, the last valid recursive state, valid displacement residual, micro-segment completion count, and confirmed completion position in the completed status are retained, as are the target coordinates, integer target pulse count, corresponding recursive state, and end-segment identifier of the uncompleted micro-segments. When a recovery command is received, the PLC can... If the number of output pulses is obtained, the remaining number of pulses is determined based on the difference between the original integer target number of pulses for the current micro-segment and the number of pulses already output, and the current micro-segment continues to be executed according to the remaining number of pulses. If position feedback is used to determine the confirmed stop position, the remaining number of pulses is directly re-determined based on the axial positional relationship between the target coordinates of the incomplete micro-segment and the confirmed stop position. During the recovery calculation, the effective displacement residual before the start of the current micro-segment is no longer repeatedly added to the remaining axial displacement. Only after the incomplete micro-segment has been completed and the effective completion flag has been obtained again, the corresponding target coordinates, recursive state and candidate displacement residual are submitted, and the preparation state for the next micro-segment is regenerated.
[0070] When the trajectory execution status is in an abnormal state, the PLC locks the new micro-segment start signal, invalidates the next micro-segment preparation state, and controls the drawing motion axis to stop according to the abnormality type. For abnormalities such as parameter out-of-bounds, state transition timeout, or missing completion flag but the drawing motion axis still has the conditions for controlled motion, the PLC controls both drawing motion axes to decelerate and stop, and records the confirmed stop position. For abnormalities such as drive failure, limit trigger, or pulse output out-of-control, the PLC immediately prohibits the hardware pulse output resources from continuing to output pulses and generates the corresponding abnormality flag. After the abnormality is resolved, the PLC determines whether the current micro-segment at the time of the abnormality has obtained a valid completion flag. If a valid completion flag has not been obtained, the PLC maintains the confirmed completion position, valid recursive state, and valid displacement residual in the completed state unchanged, and re-determines the remaining motion parameters of the incomplete micro-segment according to the pause recovery process, without directly using the next micro-segment preparation state generated before the abnormality occurred. After the incomplete micro-segment regains a valid completion flag, it resubmits its target coordinates, recursive state, and candidate displacement residual, and resumes the generation and execution of subsequent micro-segments.
[0071] When the trajectory execution status is "execution completed", the PLC further verifies that the iterative angle corresponding to the current execution status has reached the continuous target angle, the last micro-segment has returned a valid completion flag, and the micro-segment completion count is consistent with the submitted recursive status. After the verification is passed, the generation and initiation of the arc micro-segment are prohibited, the trajectory pulse output of the hardware PTO is stopped, and the two motion axes are controlled to maintain the target coordinates of the last micro-segment, while the arc completion flag is latched. It should be noted that using the completion status of the last micro-segment, the target angle arrival status, and the consistency of the recursive status as the arc termination condition can avoid stopping the motion prematurely based solely on the completion of the angle calculation, or mistakenly identifying the intermediate micro-segment as the last micro-segment based solely on the completion of the pulse output.
[0072] The PLC combines the latched final execution state, actual end position, micro-segment completion count, and abnormal flag to form the circular interpolation control result. After reading the confirmation signal of the circular interpolation control result, the completion flag is released, and the drawing motion axis is controlled to maintain the current position or enter the execution process of the next trajectory according to the subsequent trajectory instructions.
[0073] like Figure 4As shown, the plotter control system used in this embodiment includes a host computer, a PLC, an operation input unit, a status indicator unit, and a motion execution unit. The host computer is communicatively connected to the PLC and is used to acquire graphic data of the object to be drawn, generate or parse corresponding trajectory data, and send trajectory parameters of the current trajectory to be executed to the PLC. The operation input unit is connected to the input terminal of the PLC and is used to input start, pause, running mode switching, or manual control information to the PLC. The status indicator unit is connected to the output terminal of the PLC and is used to indicate the current running status of the plotter. The motion execution unit includes a stepper driver connected to the output terminal of the PLC and a stepper motor controlled by the stepper driver. The stepper motor is used to drive the corresponding drawing motion axis.
[0074] In this embodiment, the host computer writes the arc trajectory parameters into the data storage area of the PLC through the communication link. Based on the arc trajectory parameters, the PLC completes the arc angle processing, micro-segment target coordinate generation, micro-segment motion parameter calculation and motion execution state control locally. Figure 4 The host computer program, PLC model, and communication protocol shown are optional implementations and do not constitute a limitation on the present invention.
[0075] To verify the trajectory control accuracy of the above-mentioned PLC local circular interpolation control method, a plotter described in the above embodiment was used to test the circular trajectory. During the test, the two plotting motion axes were synchronously controlled using PLC hardware pulse output resources. The pulse equivalent of the plotting motion axis was 0.003125 mm / pulse, and the preset angular displacement step size was set to 0.01 rad. Standard circular trajectories with theoretical diameters of 20.0 mm, 40.0 mm, and 60.0 mm were generated respectively, and the feed speeds were set to 10 mm / s, 50 mm / s, and 100 mm / s respectively. The trajectory was drawn three times under each combination of theoretical diameter and feed speed, and the actual circular arc diameter obtained from each drawing was measured.
[0076] In this embodiment, the single diameter error refers to the absolute value of the difference between the measured diameter and the corresponding theoretical diameter; the average absolute error under the same test conditions refers to the arithmetic mean of the single diameter errors obtained from three tests, and the calculation relationship is as follows: , Where i represents the i-th test condition, and j represents the j-th repeated test under the same test condition. This represents the theoretical diameter corresponding to the i-th test condition. This represents the measured diameter obtained from the j-th test under the i-th test condition. The value represents the corresponding single diameter error. The test results are shown in Table 1.
[0077] Table 1. Circular interpolation diameter error at different feed rates
[0078] As shown in Table 1, each combination of feed rate and theoretical diameter is defined as a test condition. Under each test condition, the plotter structure, pulse equivalent, angular displacement step size, and control method remain unchanged. Three repeated tests are performed according to the corresponding theoretical diameter and feed rate, and the actual diameter of the resulting arc is measured. The three measurement results are recorded as the first measured diameter, the second measured diameter, and the third measured diameter, respectively. Under the nine test conditions with theoretical diameters ranging from 20.0 to 60.0 mm and feed rates ranging from 10 to 100 mm / s, the average absolute error for each test condition is 0 to 0.17 mm, and the overall average absolute error for all measured data is approximately 0.10 mm. Specifically, when the feed rates are 10 mm / s, 50 mm / s, and 100 mm / s, the average absolute errors for each speed group are approximately 0.11 mm, 0.07 mm, and 0.11 mm, respectively. As the feed rate increased from 10 mm / s to 100 mm / s, the mean absolute error did not show a trend of continuous increase with the increase of speed.
[0079] The above test results show that, under different arc sizes and feed speeds, the PLC can continuously generate micro-segment target coordinates locally according to the arc trajectory parameters, and control the two drawing motion axes to execute corresponding micro-segment movements through hardware pulse output resources, so that the diameter of the actual drawn arc remains within a relatively stable error range. This verifies that the control process described in this embodiment, which combines continuous angle processing, micro-segment coordinate generation, integer pulse conversion, and micro-segment completion feedback, is practically feasible and can adapt to trajectory drawing requirements under different arc sizes and feed speeds. The embodiments of the present invention described above are subject to modification and change of method by those skilled in the art without departing from the embodiments and broader aspects of the present invention. The appended claims are intended to include all such modifications and changes of method that do not depart from the present invention.
[0080] Although the embodiments of this application are described above, the content is merely an example adopted for the purpose of facilitating understanding of this application and is not intended to limit the scope and application scenarios of this application. Any person skilled in the art described in this application may make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in this application, but the scope of patent protection of this application shall still be determined by the scope defined in the appended claims.
Claims
1. A PLC-based local circular interpolation control method for a plotter, characterized in that, include: Obtain the circular arc trajectory parameters, which include the circular arc geometric parameters, the circular arc motion direction, and the feed speed; The starting angle and target angle are determined based on the arc geometry parameters, and the angles are made continuous according to the arc movement direction to obtain continuous starting angles and continuous target angles. Using the continuous starting angle as the iteration starting point, the current micro-segment target coordinates and corresponding iteration states are generated iteratively according to the arc motion direction with a preset angular displacement step size. Control the drawing motion axis to execute the current micro-segment, and pre-generate the target coordinates and motion parameters of the next micro-segment based on the iterative state during execution, and write them into the preparation state of the next micro-segment; After the current micro-segment is confirmed to be completed, the current execution state is submitted, the preparation state of the next micro-segment is switched to the current execution state, the trajectory execution state is updated, and the drawing motion axis is controlled to obtain the circular interpolation control result.
2. The PLC local circular interpolation control method according to claim 1, characterized in that, The acquisition of the circular arc trajectory parameters includes: Extract the current point position, target point position, and center parameters from the arc geometry parameters, and determine the center position and the coordinate increments of the current point position and target point position relative to the center position; The starting radius and the ending radius are determined based on two sets of coordinate increments. When the radius deviation between the two is not greater than a preset geometric error threshold, the starting radius is determined as the arc radius. Otherwise, an arc parameter abnormality flag is generated and the generation of micro-segments is stopped.
3. The PLC local circular interpolation control method according to claim 1, characterized in that, The angle continuity processing includes: The coordinate increments of the current point position and the target point position relative to the center position are determined based on the arc geometry parameters. Zero-value judgment and arctangent operation are performed on the two sets of coordinate increments, and circumferential mapping is performed according to the sign relationship to obtain the initial circumferential angle and the target circumferential angle; The target circumferential angle is periodically expanded according to the direction of the arc motion. When the current point position is the same as the target point position and corresponds to the whole circle trajectory, the target circumferential angle is expanded along the direction of the arc motion for one angle period.
4. The PLC local circular interpolation control method according to claim 1, characterized in that, The iterative generation of micro-segment target coordinates and corresponding iterative states includes: The preset angular displacement step size is determined and latched based on the radius of the arc, the allowable chord height error, the pulse equivalent of the drawing motion axis, and the shortest start-up time of the hardware motion resources. The sine and cosine states are initialized with continuous starting angles. The sine and cosine constants of the step length are determined according to the preset angular displacement step length and the direction of the circular motion. The micro-segment target coordinates and corresponding iterative states are generated recursively. When the remaining arc angle is not greater than the preset angular displacement step size, the target point position is determined as the target coordinate of the last micro-segment.
5. The PLC local circular interpolation control method according to claim 1, characterized in that, The control of the drawing motion axis to execute the current micro-segment includes: The theoretical displacements of the two drawing motion axes are determined based on the starting and target coordinates of the current micro-segment. The theoretical displacements are then superimposed with the effective displacement residuals corresponding to the previous completed state. The displacements are converted into integer target pulse numbers according to the corresponding pulse equivalents, and candidate displacement residuals are generated based on the displacement difference before and after the conversion. The shared motion duration is determined based on the micro-segment length and feed rate, and the two drawing motion axes are controlled to output corresponding pulses using the same motion time base. After the current micro-segment is confirmed to be complete, the candidate displacement residual is updated to the effective displacement residual.
6. The PLC local circular interpolation control method according to claim 5, characterized in that, When the number of integer target pulses for one drawing motion axis is zero, the drawing motion axis is kept stationary while the other drawing motion axis outputs pulses. When the number of integer target pulses for both drawing motion axes is zero and the current micro-segment target coordinate has not reached the target point, the current micro-segment is not started, and the target coordinates of the next micro-segment are generated. The target coordinates of the current micro-segment are updated and the number of integer target pulses is recalculated until at least one drawing motion axis forms a target pulse or reaches the target point. When the number of pulses is still zero after reaching the target point, the final segment completion confirmation is generated and the corresponding iteration status and candidate displacement residual are submitted. The micro-segment completion count is not updated separately for the target coordinates of the merged micro-segments.
7. The PLC local circular interpolation control method according to claim 5, characterized in that, The completed status record includes the target coordinates, confirmed completion position, effective iteration status, effective displacement residual, and micro-segment completion count of the completed micro-segment; the current execution status record includes the target coordinates, motion parameters, pending iteration status, and candidate displacement residual of the micro-segment being executed; the next micro-segment preparation status record includes the target coordinates, motion parameters, candidate iteration status, and candidate displacement residual of the pre-generated next micro-segment, and records the pre-calculated starting position and pre-calculated effective displacement residual used when generating the motion parameters.
8. The PLC local circular interpolation control method according to claim 7, characterized in that, The next micro-segment preparation state is prohibited from being started during the current micro-segment execution; when the target pulse output is completed on both drawing motion axes and the valid edge of the segment completion flag is reached, the current execution state is submitted to the completed state; The system compares the confirmed completion position after submission with the pre-calculated starting position and the effective displacement residual with the pre-calculated effective displacement residual. If the corresponding differences are not greater than the preset state consistency error threshold, the system switches the next micro-segment preparation state to the current execution state; otherwise, it sets the micro-segment to invalid and regenerates it based on the confirmed completion position after submission and the effective displacement residual.
9. The PLC local circular interpolation control method according to claim 5, characterized in that, The action state control includes: In the event of a paused or recoverable execution anomaly, the permission to start subsequent micro-segments is revoked, the updating of candidate displacement residuals of incomplete micro-segments to valid displacement residuals is prohibited, and the confirmed stop position is determined. Upon receiving a recovery command or when the exception is resolved and the hardware motion resources meet the recovery conditions, the remaining motion parameters are re-determined based on the difference between the integer target pulse number and the number of output pulses, or based on the positional relationship between the confirmed stop position and the target coordinates of the unfinished micro-segment. The effective displacement residual before the start of the micro-segment is not superimposed repeatedly. After the remaining motion is completed, the execution of subsequent micro-segments is resumed.
10. The PLC local circular interpolation control method according to claim 1, characterized in that, The arc trajectory parameters also include pen state information representing the pen-writing state or the pen-lifting and idling state; before the first micro-segment of the current arc is started, the Z-axis is controlled to switch to the corresponding state according to the pen state information, and the drawing motion axis is allowed to start after the position confirmation is obtained; the Z-axis state switching is locked during the execution of the current arc; when the execution of the current arc is completed and the pen state corresponding to the next arc changes, the Z-axis is controlled to complete the corresponding switching before the first micro-segment of the next arc is started.