Graphical automatic programming of CNC wire EDM instructions
2026-04-06 05:57:41··#1
CNC wire EDM machines are machine tools that use a moving molybdenum wire to perform electrical discharge cutting on metal. Over the decades, many series of wire EDM machines have emerged worldwide, and their corresponding machining instructions have been standardized by international ISO and EIA standards. Domestically produced wire EDM machines are widely used throughout China due to their low price, ease of maintenance, high reliability, and availability of skilled operators. However, domestically produced machine tools widely use 3B format machining instructions. General graphical programming systems (such as UGⅡ and MasterCAM) can only generate machining codes conforming to ISO and EIA standards and are incapable of handling 3B format codes. In recent years, AutoCAD has been widely used in the domestic machinery industry. This paper develops a 3B instruction graphical automatic programming system on AutoCAD. It uses AutoLisp language to read entity group code data and convert it into 3B machining code. Practice has proven its accuracy, practicality, and high efficiency. 1 Principle 1.1 Format of 3B Instruction Code The format is: B XY B YY B J G Z Where, B is the separator. XY and YY: ① When machining a straight line, these are the coordinates of the line's endpoint (the origin is at the line's starting point); ② When machining an arc, these are the coordinates of its starting point (the origin is at the arc's center). J and G: G is the counting direction, with two directions, X and Y, which are Gx and Gy respectively, as shown in Figure 1. For a straight line, when the line is in the shaded area, G is Gy; otherwise, G is Gx. If the endpoint of the arc is in the shaded area, G is Gx; otherwise, Gy. J is the length of the projected line or the sum of the projected lengths of the machining trajectory (straight line or arc) in the counting direction. Z is the machining command, with 12 types (as shown in Figure 2). 1.2 AutoCAD Entity Selection Set and Entity Group Code In AutoCAD, each graphic element can be treated as an independent entity, and the ssget() function can be used to construct the required entity selection set. The data for each entity can be obtained by looking up its entity group code. Each entity has an entity name, represented by group code -1, and an entity type, such as Line, Arc, Pline, etc., represented by group code 0. Other group code relationships are shown in the table below. Figure 1 Counting direction selection (left is a straight line, right is an arc) Figure 2 Schematic diagram of machining instructions (left is a straight line, right is an arc) Below is the entity group code of a line segment: (-1.<Entity name: 60000014>) (0.”LINE”) (8.”0”) (10 1.0 2.0 0.0) (11 6.0 6.0 0.0) 2 Program design method The program first calls the gettfiled() function to create an NC file (the file has a .3B extension), and then uses the ssget() function to define the entity selection set (selected by the user according to the machining order). After being broken down, it becomes two types: "Line" and "Arc" (research has found that for v12.0, the graphic entities are all broken down into Line and Arc in the end, such as the pline fitted by Fit is broken down into Arc, the pline fitted by spline is broken down into line, etc.). Therefore, the core of the program is based on line and Arc as objects. The program loads the next entity, determines whether it is a line or an arc, splits the data, extracts the geometric data according to the group code of line or arc, performs calculations, and finally forms a string "B XX B YY B J G Z". This string is added to the NC file, and then another entity is loaded for loop calculation. In this way, the NC file is added line by line until the entity is edited. For a straight line, the starting and ending coordinates can be extracted using group codes 10 and 11. Then, the origin is moved to the starting point, and XX and YY are the ending coordinates. Let dx1 and dx2 be the absolute values of XX and YY, respectively. Then, when dx1 > dy1, G = Gx and J = dx1; otherwise, G = Gy and J = dy1. For an arc, the center, radius, starting angle, and ending angle can be extracted using group codes 10, 40, 50, and 51. One of the problems with arcs is the calculation of the projected length J, as shown in Figure 3. The calculation of arc J involves three cases (Figure 3). For ①, J = |Qx - Zhx| or J = |Qy - Zhy| (Q: starting point, Zh: ending point). For ②, the origin is moved to point Q, at which point J = |Qx + Zhx| or J = |Qy + Zhy|. For ③, the origin is moved to Q1 and Q2 respectively to calculate Q1A' and Q2B': Q1A' = |Qx| or |Qy|, Q2B' = |Zhx| or |Zhy|, then J = Q1A' + Q2B' + D. Figure 3. Calculation of the projected length J of the arc (left is when G=Gx, right is when G=Gy). Regarding the machining direction of the arc (clockwise or counterclockwise), since the grouping data for the arc in AutoCAD is all specified as counterclockwise, this program will retain the endpoint coordinates of the previous entity and assign them to the variable ZhD. If the next entity is an arc, ZhD will be compared with the starting coordinates Qx and y of the arc. If they are the same, the arc is counterclockwise; otherwise, the arc is clockwise, and the starting and ending points of the arc will be swapped. The program flowchart is shown in Figure 4. 3. Conclusion Practice has proven that the method described in this paper for compiling 3B machining codes is simple and quick to operate, accurate in calculation, intuitive and reliable, and yields significant results. It reduces the requirements for CNC programmers, alleviates the difficulty of labor, and achieves the goal of graphical automatic programming of 3B machining codes.