Control program design method based on PLC

By building base classes and extended device classes in the PLC control program module, the problem of poor reusability and expansion of PLC programming technology is solved, and higher code reusability and modularity are achieved, and the system maintainability and capability are improved. Extensibility.

CN119414770AActive Publication Date: 2025-02-11TIANDI CHANGZHOU AUTOMATION +1
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202411485094.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-11
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The existing PLC programming technology has poor reusability and poor scalability, making it difficult to meet the flexibility and scalability requirements of complex systems.

Method used

By building PLC control program modules, including execution layer, management layer, perception layer and driver layer, and building base classes FB_BaseAll and FB_Axis within the execution layer, the device classes are extended to improve code reusability and modularity.

Benefits of technology

It improves the reusability and scalability of PLC control programs, reduces redundancy and improves maintenance, simplifies the program expansion and modification process, and improves the system maintainability and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119414770A_ABST
    Figure CN119414770A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of PLC automatic control, in particular to a PLC-based control program design method which comprises the following steps: S1, constructing a PLC control program module which comprises an execution layer; and S2, obtaining the execution layer in the step S1, constructing a first base class FBBaseAll and a second base class FBAXis in the execution layer, and then expanding the equipment classes of the first base class FBBaseAll and the second base class FBAXis. According to the method, the first base class FBBaseAll and the second base class FBAxis are constructed in the execution layer, and the equipment class is expanded based on the two base classes, so that the reusability and modularization of codes can be improved, and the redundancy can be reduced and the maintainability can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of PLC automatic control, and in particular to a control program design method based on PLC. Background Art

[0002] PLC (Programmable Logic Controller) is a controller that uses a type of programmable memory to store programs internally, execute user-oriented instructions such as logical operations, sequential control, timing, counting and arithmetic operations, and control various types of mechanical equipment or production processes through digital or analog input / output. It plays an important role in mining automation and is mainly used to monitor and control various equipment and processes in mines. For example, various data in the mine (such as temperature, humidity, gas concentration, etc.) are collected through sensors, and then motors, pumps, fans and other equipment are started, stopped or adjusted according to preset logic. At the same time, abnormal conditions of equipment are detected and alarms are issued to ensure mine safety. PLC control systems have many application scenarios in coal mines, such as automatically adjusting the ventilation system of the mine to maintain air quality; controlling drainage pumps and water treatment systems to prevent water accumulation in the mine and managing ore transportation equipment (such as belt conveyors, mine cars, etc.). PLC programming technology supports the implementation and operation of control logic in modern industrial automation. For this reason, we need to provide a control program design method based on PLC.

[0003] At present, the main forms of PLC programming languages ​​are: Ladder Logic, Structured Text, FunctionBlock Diagram, etc. Each language is suitable for different types of control tasks. Traditional coal mine underground PLC programming usually uses ladder logic as the main programming language. Ladder logic is similar to electrical control diagrams, easy to understand and use, and particularly suitable for the expression of control logic. However, its maintainability is poor. With the increase of degree of complexity, the program structure tends to become chaotic, difficult to maintain and expand, and the program reusability is poor. Function reuse and modular design are difficult, which is not conducive to the flexibility and scalability of the system (for example: belt control system, the number of belts controlled at different coal mine sites and the start and stop interfaces of each belt are different. Outside, the control process flow at different sites is also different. Engineers need to write the control program from scratch according to the actual situation on site. On-site debugging requires a lot of time and workload). During the operation of the equipment, there are often special needs such as equipment increase and decrease, function increase, etc., and the workload of this method is cumbersome.

[0004] In addition, traditional coal mine control systems emphasize linear, sequential execution design methods. The program structure is mainly composed of sequence, conditional and loop structures, using variables and functions for data processing and control flow. However, traditional structured programming can no longer meet actual needs due to reusability, scalability and other reasons. Summary of the invention

[0005] The technical problem to be solved by the present invention is: in order to solve the technical problems of poor reusability and poor scalability of existing PLC programming, the present invention provides a control program design method based on PLC, which can improve the reusability and scalability of the PLC control program by improving the PLC control program.

[0006] The technical solution adopted by the present invention to solve the technical problem is: a control program design method based on PLC, comprising the following steps: S1, constructing a PLC control program module, wherein the PLC program control module comprises: an execution layer; S2, obtaining the execution layer in step S1, and constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer, and then expanding the device class of the first base class FB_BaseAll and the second base class FB_Axis; Among them: the first base class FB_BaseAll is used for logic control, and the second base class FB_Axis is used for servo motor control.

[0007] Therefore, by constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer and extending the device class based on the two base classes, the reusability and modularity of the code can be improved, which helps to reduce redundancy and improve maintainability.

[0008] Furthermore, the step S2 comprises the following steps: S2-1, obtain the execution layer in step S1, and construct the first base class FB_BaseAll in the execution layer; S2-2, constructing the second base class FB_Axis in the execution layer obtained in step S1; S2-3. Obtain the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and expand the device class of the first base class FB_BaseAll and the second base class FB_Axis.

[0009] Further, in step S2-1, the basic function block of the first base class FB_BaseAll is used for encapsulation of basic equipment start / stop control and protection; The inputs of the basic function blocks of the first base class FB_BaseAll include: start / stop signals, reset signals, error signals and lock signals; the outputs of the basic function blocks of the first base class FB_BaseAll include: equipment operation output, operation status, error output and emergency stop; the control interface encapsulated by the first base class FB_BaseAll includes: operation status, fault status and start delay display controlled by the first base class FB_BaseAll.

[0010] Furthermore, in step S2-1, a start-stop state machine is provided inside the first base class FB_BaseAll.

[0011] Further, in step S2-1, the state transition of the start-stop state machine includes the following steps: S2-1-1, when the system receives the start signal, the state is transferred to the ready-to-start state, the state flow code is 1xx, and one or a series of actions of ready-to-start are executed. If the start does not meet the start object conditions, it returns to the completely stopped state; S2-1-2, when the opening object conditions are met, the state is transferred to the opening state, the state flow code is 2xx, and the opening flow is executed; S2-1-3, when the opening process is normal and the start-up success signal is returned, the state is transferred to the fully open state, the state process code is 3xx, and the monitoring process is executed; S2-1-4, when the system meets the stop object conditions and receives the stop signal, the state is transferred to the stopping state, the state flow code is 4xx, and the stop flow is executed; S2-1-5, when all stop actions are completed and a stop success signal is returned, the state is transferred to the complete stop state, and the state flow code is 0; S2-1-6, when an abnormality occurs in the opening, stopping or fully opening state, an abnormal signal is output. At this time, the state is transferred to the emergency stop state, the state flow code is 5xx, and the emergency stop process is executed; S2-1-7, when the system emergency stop is completed, the state is transferred to the error state, and the state flow code is 9xx; S2-1-8. When the system receives the reset signal and confirms it, it executes the reset action and the state is transferred to the completely stopped state. The state flow code is 0.

[0012] Further, in step S2-2, the functional modules of the second base class FB_Axis include: axis absolute motion control function, axis relative motion control function, axis return to zero function and axis initialization function; the control interface encapsulated by the second base class FB_Axis includes: motor inching control, micro-motion control, control speed setting window, deceleration ratio setting window, micro-motion distance setting window and return to zero distance setting window.

[0013] Furthermore, in step S2-2, a control flow state machine is provided inside the second base class FB_Axis.

[0014] Furthermore, in step S2-2, the state transfer of the control flow state machine includes the following steps: S2-2-1, when the motor is in the ready state and receives the AxAbs, AxRel, AxHome control instructions, the state is transferred to the motion state and the specific action of the control instruction is executed; S2-2-2, when the motor is in motion, it is executing the specific action of the control instruction. If the start is abnormal, it returns to the Error state. If the execution is completed, it returns to the ready state. S2-2-3, when the motor is in the ready state and receives the AxStop control command, the state is transferred to the stop state. At this time, the Stop action is being executed. If the execution is completed, it returns to the ready state; S2-2-4. When the motor is in a fault state and receives the AxReInit control command, the state is transferred to the StandStill state to complete the device initialization.

[0015] Furthermore, in step S2-3, the reuse and inheritance of the first base class FB_BaseAll and the second base class FB_Axis are realized through the POU inheritance function. Thus, the subclass can rewrite the methods and properties of the parent class, and the overall project can realize complex on-site requirements by reusing and extending the encapsulated first base class FB_BaseAll and the second base class FB_Axis. At the same time, customized development can be carried out according to special control process flow, which greatly reduces the workload of development.

[0016] Further, in step S1, the PLC program control module also includes: a management layer, a perception layer and a driver layer; wherein: the management layer includes: configuration management, information release and exception handling, which are used to handle the upper computer data sending, controller data uploading and system abnormalities; the execution layer includes: motion control model, control logic model and collaborative watchdog; the perception layer includes: port mapping, data parsing and CNC file parsing, which are used to handle the port mapping of the device and the data parsing of the device; the driver layer includes: CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.

[0017] Compared with the prior art, the present invention has the following beneficial effects: 1. The present invention decomposes the PLC program control module into multiple modules such as communication, control logic, motion control module, etc. The actual application of the project can adapt the required communication according to the first base class FB_BaseAll and the second base class FB_Axis, expand the device objects required by the project, build the project system, improve the reusability and modularity of the code, help reduce redundancy and improve maintainability.

[0018] 2. The PLC program control module of the present invention encapsulates data and operations inside the object, encapsulates the control process flow for the first base class FB_BaseAll, and sets a state machine for the start and stop of the equipment. Engineers can accurately change the process flow inside different states according to actual needs. This operation will only modify the control process flow of this type of equipment without affecting the overall system, reducing the coupling between codes and improving the stability and maintainability of the PLC program control module.

[0019] 3. The present invention allows engineers to create new object classes through an inheritance mechanism, so that they can adapt to actual project requirements based on the extended functions of the first base class FB_BaseAll and the second base class FB_Axis, simplifying the expansion and modification process of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0021] Figure 1 It is a flow chart of the control program design method based on PLC of the present invention; Figure 2 It is a schematic diagram of a PLC program control module of the present invention; Figure 3 is a flow chart of step S2 of the present invention; Figure 4 This is a pin diagram of the first base class FB_BaseAll of the present invention; Figure 5 It is a schematic diagram of the first base class FB_BaseAll control state machine of the present invention; Figure 6 It is the control interface of the first base class FB_BaseAll of the present invention; Figure 7 It is a schematic diagram of the second base class FB_Axis control state machine of the present invention; Figure 8 The control interface of the second base class FB_Axis of the present invention; Fig. 9 It is the object inheritance relationship diagram of the present invention. DETAILED DESCRIPTION

[0022] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0023] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0024] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0025] like Figure 1 As shown, it is the best embodiment of the present invention. The control program design method based on PLC in this embodiment includes the following steps: S1. Construct a PLC control program module. The PLC program control module includes: an execution layer; S2, obtaining the execution layer in step S1, and constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer, and then extending the device class of the first base class FB_BaseAll and the second base class FB_Axis; Among them: the first base class FB_BaseAll is used for logic control, and the second base class FB_Axis is used for servo motor control. Therefore, by constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer and extending the device class based on the two base classes, the code reusability and modularity can be improved, which helps to reduce redundancy and improve maintainability.

[0026] In this embodiment, step S2 includes the following steps: S2-1, obtain the execution layer in step S1, and construct the first base class FB_BaseAll in the execution layer; S2-2, constructing the second base class FB_Axis in the execution layer obtained in step S1; S2-3. Obtain the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and expand the device class of the first base class FB_BaseAll and the second base class FB_Axis.

[0027] In this embodiment, in step S2-1, the basic function block of the first base class FB_BaseAll is used for encapsulation of start-stop control and protection of basic equipment; the input of the basic function block of the first base class FB_BaseAll includes: start-stop signal, reset signal, error signal and lock signal; the output of the basic function block of the first base class FB_BaseAll includes: equipment operation output, operation status, error output and emergency stop; the control interface encapsulated by the first base class FB_BaseAll includes: operation status, fault status and start delay display controlled by the first base class FB_BaseAll; The first base class FB_BaseAll has a start-stop state machine set inside; The state transition of the start-stop state machine includes the following steps: S2-1-1, when the system receives the start signal, the state is transferred to the ready-to-start state, the state flow code is 1xx, and one or a series of actions of ready-to-start are executed. If the start does not meet the start object conditions, it returns to the completely stopped state; S2-1-2, when the opening object conditions are met, the state is transferred to the opening state, the state flow code is 2xx, and the opening flow is executed; S2-1-3, when the opening process is normal and the start-up success signal is returned, the state is transferred to the fully open state, the state process code is 3xx, and the monitoring process is executed; S2-1-4, when the system meets the stop object conditions and receives the stop signal, the state is transferred to the stopping state, the state flow code is 4xx, and the stop flow is executed; S2-1-5, when all stop actions are completed and a stop success signal is returned, the state is transferred to the complete stop state, and the state flow code is 0; S2-1-6, when an abnormality occurs in the opening, stopping or fully opening state, an abnormal signal is output. At this time, the state is transferred to the emergency stop state, the state flow code is 5xx, and the emergency stop process is executed; S2-1-7, when the system emergency stop is completed, the state is transferred to the error state, and the state flow code is 9xx; S2-1-8, when the system receives the reset signal and confirms it, it executes the reset action, the state is transferred to the completely stopped state, and the state flow code is 0. Specifically, based on this basic function block, the function blocks of equipment such as motors and gate valves can be encapsulated; there are transfers between states, and the transfers are accompanied by specific actions. When the action is confirmed and the return signal is received, it will then transfer to the next state; the control interface encapsulated by the first base class FB_BaseAll also includes: the control of the first base class FB_BaseAll; the user performs debugging and testing through the control interface according to the process conditions, simulates the fault conditions in the debugging process by enabling the fault window and the lock window, and inherits the control interface according to the actual control process flow and adds control interfaces in combination with the needs.

[0028] Table 1 Process start and stop status table

[0029] For example: The fault code in the start-stop state machine is: (ERR_NEED_URGENT: 3000; / / Emergency stop required ERR_INPUT_ERROR: 3001; / / Input failure ERR_INPUT_NOT_READY: 3002; / / Startup not allowed ERR_INPUT_RESET: 3003; / / Input reset ERR_INPUT_BISUODIAOXIAN: 3004; / / Locked and disconnected ERR_INPUT_OBJ_BISUO: 3005; / / Master device locked ERR_INPUT_OBJ_LIANSUO: 3006; / / Other devices are locked ERR_START_TIMEOUT: 3007; / / Start timeout ERR_STOP_TIMEOUT: 3008; / / Stop timeout ERR_LOST_RETURU: 3009; / / status lost ERR_INPUT_IODIAOXIAN: 3010; / / IO disconnected ERR_INPUT_XUANNIU_BISUO: 3011; / / Knob locked ERR_START_OFIEN: 3012; / / Frequent start).

[0030] In this embodiment, in step S2-2, the function modules of the second base class FB_Axis include: axis absolute motion control function, axis relative motion control function, axis return to zero function and axis initialization function; the control interface encapsulated by the second base class FB_Axis includes: motor inching control, micro-motion control, control speed setting window, home deceleration ratio setting window, micro-motion distance setting window and return to zero distance setting window; The second base class FB_Axis has a control flow state machine set inside; In step S2-2, the state transfer of the control flow state machine includes the following steps: S2-2-1, when the motor is in the ready state and receives the AxAbs, AxRel, AxHome control instructions, the state is transferred to the motion state and the specific action of the control instruction is executed; S2-2-2, when the motor is in motion, it is executing the specific action of the control instruction. If the start is abnormal, it returns to the Error state. If the execution is completed, it returns to the ready state. S2-2-3, when the motor is in the ready state and receives the AxStop control command, the state is transferred to the stop state. At this time, the Stop action is being executed. If the execution is completed, it returns to the ready state; S2-2-4, when the motor is in a fault state and receives the AxReInit control command, the state is transferred to the StandStill state to complete the device initialization. Specifically, the engineering debugging can be performed in a single week according to the control interface encapsulated by the second base class FB_Axis according to the on-site situation.

[0031] Table 2 The second base class FB_Axis axis control function table

[0032] In this embodiment, in step S2-3, the reuse and inheritance of the first base class FB_BaseAll and the second base class FB_Axis are realized through the POU inheritance function. Thus, the subclass can rewrite the methods and properties of the parent class, and the overall project can realize complex field requirements by reusing and extending the encapsulated first base class FB_BaseAll and the second base class FB_Axis. At the same time, customized development can be carried out according to special control process flow, which greatly reduces the workload of development.

[0033] Specifically, all devices (such as sensors and actuators) inherit the first base class FB_BaseAll and the second base class FB_Axis and can share basic functions and properties.

[0034] For example: all devices FB_BaseDev, objects FB_BaseObj and subsystems FB_BaseSys inherit from the first base class FB_BaseAll and are extended on the basis of the first base class FB_BaseAll; the device FB_BaseDev can be extended to specific equipment (such as motors, gates and ball valves), the object FB_BaseObj can be extended to belts and pumps suitable for a certain site, and the subsystem FB_BaseSys can be extended to belt systems and water pump systems.

[0035] In this embodiment, in step S1, the PLC program control module also includes: a management layer, a perception layer and a driver layer; wherein: the management layer includes: configuration management, information release and exception handling, which are used to handle the upper computer data sending, controller data uploading and system abnormalities; the execution layer includes: motion control model (i.e., the second base class FB_Axis), control logic model (i.e., the first base class FB_BaseAll) and collaborative watchdog; the perception layer includes: port mapping, data parsing and CNC file parsing, which are used to process port mapping of equipment (e.g., cameras, remote drive modules, sound and light alarms and display boards) and data parsing of equipment; the driver layer includes: CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.

[0036] It should be noted that after completing the program initialization, the project performs the program loop according to the following steps: A. Call IO data update, B. Determine the trigger command, C. Call the system function block, D. Call the main object function block, E. Call the device function block. By establishing a clearly structured, flexible and maintainable object-oriented PLC program control module, it is suitable for various industrial automation scenarios.

[0037] In summary, the present invention decomposes the PLC program control module into multiple modules such as communication, control logic, motion control module, etc. The actual application of the project can adapt the required communication according to the first base class FB_BaseAll and the second base class FB_Axis, expand the equipment objects required for the project, build the project system, improve the reusability and modularity of the code, and help reduce redundancy and improve maintainability; the PLC program control module encapsulates data and operations inside the object, encapsulates the control process flow for the first base class FB_BaseAll, and sets the state machine for the start and stop of the equipment. Engineers can accurately change the process flow inside different states according to actual needs. This operation will only modify the control process flow of this type of equipment without affecting the overall system, reducing the coupling between codes and improving the stability and maintainability of the PLC program control module; the inheritance mechanism allows engineers to Engineers often use new object classes, so that they can adapt to actual project requirements based on the extended functions of the first base class FB_BaseAll and the second base class FB_Axis, simplifying the expansion and modification process of the program; these advantages make the present invention more efficient in the development of complex systems, and ultimately improve the maintainability and scalability of the system. Through the design of classes and objects, the logical structure of the control program is clearer, which helps to manage complex control systems. At the same time, encapsulation and modularization make the program easier to modify and debug (because modifying one object usually does not affect other objects). In addition, objects and classes can be reused in different projects or systems, reducing repetitive development work. Through inheritance, it is easier to expand existing functions and adapt to new needs, reducing the amount of code modification. These features help solve the problems of complex code, difficult maintenance and expansion that may occur in traditional methods.

[0038] The above description is based on the ideal embodiment of the present invention. Through the above description, relevant personnel can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A control program design method based on PLC, characterized in that: The following steps are involved: S1, constructing a PLC control program module, wherein the PLC program control module comprises: an execution layer; S2, obtaining the execution layer in step S1, and constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer, and then extending the device class of the first base class FB_BaseAll and the second base class FB_Axis; Among them: the first base class FB_BaseAll is used for logic control, and the second base class FB_Axis is used for servo motor control.

2. The PLC-based control program design method according to claim 1, characterized in that: The step S2 comprises the following steps: S2-1, obtain the execution layer in step S1, and construct the first base class FB_BaseAll in the execution layer; S2-2, constructing the second base class FB_Axis in the execution layer obtained in step S1; S2-3. Obtain the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and expand the device class of the first base class FB_BaseAll and the second base class FB_Axis.

3. The PLC-based control program design method according to claim 1, characterized in that: In step S2-1, the basic function block of the first base class FB_BaseAll is used for encapsulation of basic equipment start / stop control and protection; The inputs of the first base class FB_BaseAll basic function block include: Start / stop signal, reset signal, error signal and lock signal; The outputs of the first base class FB_BaseAll basic function block include: Equipment operation output, operation status, error output and emergency stop; The control interface encapsulated by the first base class FB_BaseAll includes: The first base class FB_BaseAll controls the running status, fault status and startup delay display.

4. The PLC-based control program design method according to claim 1, characterized in that: In step S2-1, a start-stop state machine is provided inside the first base class FB_BaseAll.

5. The PLC-based control program design method according to claim 1, characterized in that: In step S2-1, the state transition of the start-stop state machine includes the following steps: S2-1-1, when the system receives the start signal, the state is transferred to the ready-to-start state, the state flow code is 1xx, and one or a series of actions of ready-to-start are executed. If the start does not meet the start object conditions, it returns to the completely stopped state; S2-1-2, when the opening object conditions are met, the state is transferred to the opening state, the state flow code is 2xx, and the opening flow is executed; S2-1-3, when the opening process is normal and the start-up success signal is returned, the state is transferred to the fully open state, the state process code is 3xx, and the monitoring process is executed; S2-1-4, when the system meets the stop object conditions and receives the stop signal, the state is transferred to the stopping state, the state flow code is 4xx, and the stop flow is executed; S2-1-5, when all stop actions are completed and a stop success signal is returned, the state is transferred to the complete stop state, and the state flow code is 0; S2-1-6, when an abnormality occurs in the opening, stopping or fully opening state, an abnormal signal is output. At this time, the state is transferred to the emergency stop state, the state flow code is 5xx, and the emergency stop process is executed; S2-1-7, when the system emergency stop is completed, the state is transferred to the error state, and the state flow code is 9xx; S2-1-8. When the system receives the reset signal and confirms it, it executes the reset action and the state is transferred to the completely stopped state. The state flow code is 0.

6. The PLC-based control program design method according to claim 1, characterized in that: In step S2-2, the functional modules of the second base class FB_Axis include: Axis absolute motion control function, axis relative motion control function, axis zero return function and axis initialization function; The control interface encapsulated by the second base class FB_Axis includes: The motor's inching control, micro-motion control, control speed setting window, home deceleration ratio setting window, micro-motion distance setting window and return to zero distance setting window.

7. The PLC-based control program design method according to claim 1, characterized in that: In step S2-2, a control flow state machine is provided inside the second base class FB_Axis.

8. The PLC-based control program design method according to claim 1, characterized in that: In step S2-2, the state transfer of the control flow state machine includes the following steps: S2-2-1, when the motor is in the ready state and receives the AxAbs, AxRel, AxHome control instructions, the state is transferred to the motion state and the specific action of the control instruction is executed; S2-2-2, when the motor is in motion, it is executing the specific action of the control instruction. If the start is abnormal, it returns to the Error state. If the execution is completed, it returns to the ready state. S2-2-3, when the motor is in the ready state and receives the AxStop control command, the state is transferred to the stop state. At this time, the Stop action is being executed. If the execution is completed, it returns to the ready state; S2-2-4. When the motor is in a fault state and receives the AxReInit control command, the state is transferred to the StandStill state to complete the device initialization.

9. The PLC-based control program design method according to claim 1, characterized in that: In step S2 - 3 , the reuse and inheritance of the first base class FB_BaseAll and the second base class FB_Axis are implemented through the POU inheritance function.

10. The PLC-based control program design method according to claim 1, characterized in that: In step S1, the PLC program control module further includes: Management layer, perception layer and driving layer; The management team includes: Configuration management, information release and exception handling, used to handle the sending of host computer data, uploading of controller data and system abnormalities; The execution layer includes: Motion control model, control logic model and cooperative watchdog; The perception layer includes: Port mapping, data analysis and CNC file analysis, used to process device port mapping and device data analysis; The driver layer includes: CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.

Citation Information

Patent Citations

  • Control program modularization system for numerical control machine

    CN102221828A

  • Controller support device, simulation method of control program, support program of controller and computer-readable storage medium storing support program of controller

    CN102804087A

  • PLC program design method and system

    CN104142649A

  • Object-oriented automation logistics control program design method

    CN105302053A

  • Industrial process control management method and device

    CN112965438A