Method for designing a control program based on a plc
By constructing a base class and state machine, combined with the POU inheritance mechanism, the problem of poor reusability and scalability of PLC programming in underground coal mines was solved, realizing the modularity and maintainability of PLC programs and simplifying the process of program expansion and modification.
Patent Information
- Application Number
- CN202411485094.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-10-23
AI Technical Summary
Existing PLC programming suffers from poor reusability and scalability in underground coal mine applications. Traditional ladder diagram programming is difficult to maintain and expand, and the program structure is chaotic, resulting in engineers needing a lot of on-site debugging and workload.
A PLC-based control program design method is adopted. By constructing a first base class FB_BaseAll and a second base class FB_Axis, and extending the device class, modularity and code reusability are achieved. Start-stop state machines and control flow state machines are used, combined with the POU inheritance mechanism for program extension and modification.
It improves the reusability and scalability of PLC programs, reduces redundancy and maintenance workload, simplifies the process of program expansion and modification, and improves the stability and maintainability of the system.
Smart Images

Figure CN119414770B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of PLC automatic control, and particularly relates to a control program design method based on PLC. BACKGROUND
[0002] PLC (Programmable Logic Controller) is a kind of controller which uses a kind of programmable memory to store programs, and executes user-oriented instructions such as logic operation, sequential control, timing, counting and arithmetic operation, and controls various types of mechanical equipment or production process through digital or analog input / output, which plays an important role in mine automation, and is mainly used for monitoring and controlling various equipment and processes in the mine. For example, various data (such as temperature, humidity, gas concentration, etc.) in the mine are collected through sensors, and then the devices such as motors, pumps and fans are started, stopped or adjusted according to the preset logic. At the same time, abnormal conditions of the devices are detected and alarms are sent to ensure the safety of the mine. PLC control system has many application scenarios in coal mine, such as automatically adjusting the ventilation system of the mine to maintain air quality, controlling the drainage pump and water treatment system to prevent water accumulation in the mine, and managing ore transportation equipment (such as belt conveyor, mine car, etc.). PLC programming technology supports the implementation and operation of control logic in modern industrial automation, and therefore a control program design method based on PLC is needed.
[0003] At present, the main forms of PLC programming language are Ladder Logic, Structured Text, Function Block Diagram, etc., each of which is suitable for different types of control tasks. Traditional PLC programming in coal mine usually uses ladder diagram (Ladder Logic) as the main programming language. Ladder diagram is similar to electrical control diagram, easy to understand and use, and is particularly suitable for expressing control logic, but its maintainability is poor, and as the complexity increases, the program structure is easy to become chaotic, difficult to maintain and expand, and the program reusability is poor, making it difficult to design function reuse and modularization, which is not conducive to the flexibility and scalability of the system (for example, in the belt control system, the number of belts controlled by different coal mine sites and the start-stop interfaces of each belt are not the same, and the control process flow of different sites is also different, so engineers need to write control programs from scratch according to the actual situation of the site, which requires a lot of time and effort for on-site debugging, and the workload is huge), and the device running process may have special needs such as device addition, function increase, etc., which requires tedious changes.
[0004] In addition, the traditional coal mine control system emphasizes the linear, sequential execution of the degree of design, the program structure is mainly composed of sequential, conditional and loop structure, using variables and functions for data processing and control flow, however, the traditional structure programming because of reusability, scalability and other reasons have cast can not meet the actual demand. SUMMARY
[0005] The technical problem solved by the present application is: in order to solve the poor reusability and scalability of the existing PLC programming, the present application provides a control program design method based on PLC, which can improve the reusability and scalability of the PLC control program through the improvement of the PLC control program.
[0006] The technical scheme adopted by the present application to solve its technical problem is: a control program design method based on PLC, comprising the following steps:
[0007] S1, constructing a PLC control program module, the PLC program control module comprises: an execution layer;
[0008] S2, obtaining the execution layer in step S1, and constructing a first base class FB_BaseAll and a second base class FB_Axis in the execution layer, and extending the device class of the first base class FB_BaseAll and the second base class FB_Axis;
[0009] 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.
[0010] 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.
[0011] Further, the step S2 comprises the following steps:
[0012] S2-1, obtaining the execution layer in step S1, and constructing a first base class FB_BaseAll in the execution layer;
[0013] S2-2, constructing a second base class FB_Axis in the execution layer in step S1;
[0014] S2-3, obtaining the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and extending the device class of the first base class FB_BaseAll and the second base class FB_Axis.
[0015] Further, in step S2-1, the first base class FB_BaseAll is used for encapsulation of basic function blocks for basic device start-stop control and protection.
[0016] The input of the first base class FB_BaseAll includes start-stop signal, reset signal, error signal and lock signal; the output of the first base class FB_BaseAll includes device running output, running state, error output and emergency stop; the control interface of the first base class FB_BaseAll encapsulation includes running state, fault state and start delay display of the first base class FB_BaseAll control.
[0017] Further, in step S2-1, the first base class FB_BaseAll is internally provided with a start-stop state machine.
[0018] Further, in step S2-1, the state transition of the start-stop state machine includes the following steps:
[0019] S2-1-1, when the system receives a start signal, the state is transferred to a ready-on state, the state flow code is 1xx, and one or a series of actions of the ready-on are performed, and if the start does not meet the on-object condition, the state is returned to a complete stop state;
[0020] S2-1-2, when the on-object condition is met, the state is transferred to an on-going state, the state flow code is 2xx, and an on-going on flow is performed;
[0021] S2-1-3, when the on flow is normal and a start success signal is returned, the state is transferred to a complete on state, the state flow code is 3xx, and a monitoring flow is performed;
[0022] S2-1-4, when the system meets a stop-object condition and receives a stop signal, the state is transferred to an on-going stop state, the state flow code is 4xx, and a stop flow is performed;
[0023] S2-1-5, when the stop actions are all completed and a stop success signal is returned, the state is transferred to a complete stop state, the state flow code is 0;
[0024] S2-1-6, when an exception occurs in the on-going on, on-going stop or complete on state, an exception signal is output, the state is transferred to an emergency stop state, the state flow code is 5xx, and an emergency stop flow is performed;
[0025] S2-1-7, when the system emergency stop is completed, the state is transferred to an error state, the state flow code is 9xx;
[0026] S2-1-8, when the system receives a reset signal and confirms, the reset action is performed, the state is transferred to the complete stop state, and the state flow code is 0.
[0027] Further, 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 zero reset function and axis initialization function; the control interface encapsulated by the second base class FB_Axis includes: jog control of the motor, micro-motion control, control speed setting window, home deceleration ratio setting window, micro-motion distance setting window and zero reset distance setting window.
[0028] Further, in step S2-2, the second base class FB_Axis is internally provided with a control flow state machine.
[0029] Further, in step S2-2, the state transition of the control flow state machine includes the following steps:
[0030] S2-2-1, when the motor is in the preparation state and receives AxAbs, AxRel, AxHome control instructions, the state is transferred to motion and the specific action of the control instruction is executed;
[0031] S2-2-2, when the motor is in the motion state, the specific action of the control instruction is being executed at this time, if the start exception is started, it returns to the Error state, and if the execution is completed, it returns to the preparation state;
[0032] S2-2-3, when the motor is in the preparation state and receives AxStop control instruction, 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 preparation state;
[0033] S2-2-4, when the motor is in the fault state and receives AxReInit control instruction, the state is transferred to the StandStill state, and the device initialization is completed.
[0034] Further, 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 POU inheritance function. Therefore, the subclass can override the methods and properties of the parent class, and the overall project can realize complex field requirements through reuse and extension of the encapsulated first base class FB_BaseAll and the second base class FB_Axis, at the same time, it can be customized according to special control process flow, greatly reducing the development workload.
[0035] Further, in step S1, the PLC program control module further comprises: a management layer, a perception layer and a driver layer; wherein: the management layer comprises: configuration management, information publishing and exception handling, used for processing host computer data issuing, controller data uploading and system exception conditions; the execution layer comprises: a motion control model, a control logic model and a collaborative watchdog; the perception layer comprises: port mapping, data analysis and CNC file analysis, used for processing device port mapping and device data analysis; the driver layer comprises: CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.
[0036] Compared with the prior art, the beneficial effects of the present application are:
[0037] 1、The PLC program control module is decomposed into multiple communication, control logic, motion control modules and the like, the actual application of the project can adapt to the required communication according to the first base class FB_BaseAll and the second base class FB_Axis, extend the required device object of the project, build the project system, improve the code reusability and modularity, and help to reduce redundancy and improve maintainability.
[0038] 2、The PLC program control module encapsulates data and operations inside the object, encapsulates the control process for the first base class FB_BaseAll, sets up a state machine for the start and stop of the device, and engineers can accurately change the process flow inside different states according to actual needs, which only modifies the control process of the device and does not affect the whole system, reduces the coupling between codes, and improves the stability and maintainability of the PLC program control module.
[0039] 3、The present application allows engineers to create new object classes through inheritance mechanism, so as to extend functions based on the first base class FB_BaseAll and the second base class FB_Axis to adapt to actual project requirements, and simplify the expansion and modification process of the program. BRIEF DESCRIPTION OF DRAWINGS
[0040] The present application will be further described below in combination with the drawings and examples.
[0041] Figure 1 The flowchart of the control program design method based on PLC of the present application;
[0042] Figure 2 The schematic diagram of the PLC program control module of the present application;
[0043] Figure 3 The flowchart of step S2 of the present application;
[0044] Figure 4Pin diagram for the first base class FB_BaseAll of the present application;
[0045] Figure 5 Pin diagram for the first base class FB_BaseAll of the present application;
[0046] Figure 6 Pin diagram for the first base class FB_BaseAll of the present application;
[0047] Figure 7 Pin diagram for the first base class FB_BaseAll of the present application;
[0048] Figure 8 Pin diagram for the first base class FB_BaseAll of the present application;
[0049] Figure 9 Object inheritance diagram of the present application. DETAILED DESCRIPTION
[0050] The present application will now be described in further detail by reference to the accompanying drawings. These drawings are simplified schematic diagrams which only show the basic structure of the present application in a schematic manner, and thus only show the components relevant to the present application.
[0051] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential", and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only used to facilitate the description of the present application and simplify the description, and thus cannot be understood as indicating or implying that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus cannot be understood as limiting the present application. In addition, features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified and limited, the term "mounting", "connection", "connection" should be understood broadly, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0052] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom" "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only used to facilitate the description of the present application and simplify the description, and thus cannot be understood as indicating or implying that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus cannot be understood as limiting the present application. In addition, features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified and limited, the term "mounting", "connection", "connection" should be understood broadly, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0053] As Figure 1As shown, it is the optimal embodiment of the application, the PLC-based control program design method of the embodiment comprises the following steps:
[0054] S1, constructing a PLC control program module, the PLC program control module comprises an execution layer;
[0055] S2, obtaining the execution layer in step S1, and constructing a first base class FB_BaseAll and a second base class FB_Axis in the execution layer, and then extending the device classes of the first base class FB_BaseAll and the second base class FB_Axis;
[0056] The first base class FB_BaseAll is used for logical control, and the second base class FB_Axis is used for servo motor control. Thus, by constructing the first base class FB_BaseAll and the second base class FB_Axis in the execution layer and extending the device classes based on the two base classes, the code reusability and modularity can be improved, which helps to reduce redundancy and improve maintainability.
[0057] In the embodiment, step S2 comprises the following steps:
[0058] S2-1, obtaining the execution layer in step S1, and constructing the first base class FB_BaseAll in the execution layer;
[0059] S2-2, constructing the second base class FB_Axis in the execution layer obtained in step S1;
[0060] S2-3, obtaining the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and extending the device classes of the first base class FB_BaseAll and the second base class FB_Axis.
[0061] In the embodiment, in step S2-1, the basic function block of the first base class FB_BaseAll is used for encapsulation of basic device start-stop control and protection; the inputs of the first base class FB_BaseAll basic function block include start-stop signals, reset signals, error signals, and locking signals; the outputs of the first base class FB_BaseAll basic function block include device running outputs, running states, error outputs, and emergency stops; the control interface encapsulated by the first base class FB_BaseAll includes the running state, fault state, and start delay display controlled by the first base class FB_BaseAll;
[0062] The first base class FB_BaseAll is internally provided with a start-stop state machine;
[0063] The state transition of the start-stop state machine comprises the following steps:
[0064] S2-1-1, when the system receives a start signal, state transition to the ready open state, state flow code is 1xx, and one or a series of actions of preparing to open are performed, if the start does not meet the open object condition, return to the completely stopped state;
[0065] S2-1-2, when the open object condition is met, the state transitions to the open state, the state flow code is 2xx, and the open flow of the open state is executed;
[0066] S2-1-3, when the open flow is normal and a start success signal is returned, the state transitions to the completely open state, the state flow code is 3xx, and the monitoring flow is executed;
[0067] S2-1-4, when the system meets the stop object condition and receives a stop signal, the state transitions to the stopping state, the state flow code is 4xx, and the stop flow is executed;
[0068] S2-1-5, when the stop action is completely executed and a stop success signal is returned, the state transitions to the completely stopped state, the state flow code is 0;
[0069] S2-1-6, when the open state, the stopping state or the completely open state appears an exception, an exception signal is output, the state transitions to the emergency stop state, the state flow code is 5xx, and the emergency stop flow is executed;
[0070] S2-1-7, when the system emergency stop is completed, the state transitions to the error state, the state flow code is 9xx;
[0071] S2-1-8, when the system receives a reset signal and confirms, the reset action is executed, the state transitions to the completely stopped state, the state flow code is 0. Specifically, based on the basic function block, a motor, a gate valve and other device function blocks can be packaged; there is a transition between states, and the transition is accompanied by a specific action, when the action is confirmed and a return signal is received, the next state is then transferred; the control interface of the first base class FB_BaseAll further includes: the control of the first base class FB_BaseAll; a user can debug and test through the control interface according to the process situation, simulate the fault condition in the debugging process through the enablement of the fault window and the lockout window, and actually control the process flow according to the situation and increase the control interface according to the demand.
[0072] Table 1: process start-stop state table
[0073]
[0074] For example: the fault code in the start-stop state machine is:
[0075] (ERR_NEED_URGENT: 3000; / / need emergency stop
[0076] ERR INPUT ERROR: 3001; / / input error
[0077] ERR INPUT NOT READY: 3002; / / not allowed to start
[0078] ERR INPUT RESET: 3003; / / input reset
[0079] ERR INPUT BISUODIAOXIAN: 3004; / / lock off-line
[0080] ERR INPUT OBJ BISUO: 3005; / / master device lock
[0081] ERR INPUT OBJ LIANSUO: 3006; / / other device lock
[0082] ERR START TIMEOUT: 3007; / / start timeout
[0083] ERR STOP TIMEOUT: 3008; / / stop timeout
[0084] ERR LOST RETURU: 3009; / / state loss
[0085] ERR INPUT IODIAOXIAN: 3010; / / IO off-line
[0086] ERR INPUT XUANNIU BISUO: 3011; / / knob lock
[0087] ERR START OFIEN: 3012; / / frequent start
[0088] In this embodiment, in step S2-2, the function modules of the second base class FB_Axis include: shaft absolute motion control function, shaft relative motion control function, shaft zero reset function and shaft initialization function; the control interface encapsulated by the second base class FB_Axis includes: jog control of the motor, micro-motion control, control speed setting window, home deceleration ratio setting window, micro-motion distance setting window and zero reset distance setting window;
[0089] The second base class FB_Axis is internally provided with a control flow state machine;
[0090] In step S2-2, the state transition of the control flow state machine includes the following steps:
[0091] S2-2-1, when the motor is in the preparation state, and receives the AxAbs, AxRel, AxHome control instruction, the state is transferred to the motion, and the specific action of the control instruction is executed;
[0092] S2-2-2, when the motor is in the motion state, at this time, the specific action of the control instruction is being executed, if the start-up is abnormal, the state is returned to the error state, if the execution is completed, the state is returned to the preparation state;
[0093] S2-2-3, when the motor is in the preparation state and receives the AxStop control instruction, the state is transferred to the stop state, at this time, the stop action is being executed, if the execution is completed, the state is returned to the preparation state;
[0094] S2-2-4, when the motor is in the fault state, and receives the AxReInit control instruction, the state is transferred to the standstill state, and the device initialization is completed. Specifically, the engineering debugging can perform a single cycle debugging according to the control interface of the second base class FB_Axis encapsulation according to the field situation.
[0095] Table two, the second base class FB_Axis axis control function table
[0096]
[0097] In the 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 by POU inheritance function. Thus, the subclass can rewrite the method and attribute of the parent class, and the overall project can realize the complex field requirement through reuse and extension of the encapsulated first base class FB_BaseAll and the second base class FB_Axis, at the same time, the customized development can be realized according to the special control process flow, which greatly reduces the development workload.
[0098] Specifically, all devices (for example: sensors, actuators) inherit the first base class FB_BaseAll and the second base class FB_Axis, and can share the basic functions and attributes.
[0099] For example: all devices FB_BaseDev, objects FB_BaseObj and subsystems FB_BaseSys inherit the first base class FB_BaseAll, and are extended on the basis of the first base class FB_BaseAll; the device FB_BaseDev can extend the specific device (for example: motor, gate and ball valve), the object FB_BaseObj extends the belt, pump suitable for a field, and the subsystem FB_BaseSys extends the belt system, water pump system.
[0100] In the embodiment, in step S1, the PLC program control module further comprises a management layer, a perception layer and a driving layer; the management layer comprises configuration management, information publishing and exception handling, and is configured to process host computer data issuing, controller data uploading and system exception; the execution layer comprises a motion control model (i.e., a second base class FB_Axis), a control logic model (i.e., a first base class FB_BaseAll) and a cooperative watchdog; the perception layer comprises port mapping, data analysis and CNC file analysis, and is configured to process port mapping of devices (e.g., a camera, a remote drive module, an audible and light alarm and a display board) and data analysis of the devices; and the driving layer comprises CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.
[0101] It should be noted that after the engineering is completed, the program is cycled according to the following steps: A, calling IO data update, B, judging trigger command, C, calling system function block, D, calling main object function block, and E, calling device function block, so as to establish a clear, flexible and maintainable object-oriented PLC program control module suitable for various industrial automation scenes.
[0102] To sum up, the PLC program control module is decomposed into multiple communication, control logic, motion control modules and the like, the first base class FB_BaseAll and the second base class FB_Axis are used to adapt to the required communication, the required device object of the project is expanded, the project system is built, the code reusability and modularity are improved, the redundancy is reduced, and the maintainability is improved; the PLC program control module encapsulates data and operation in the object, the control process is encapsulated for the first base class FB_BaseAll, the state machine is set for the start and stop of the device, the engineer can accurately change the process flow in different states according to actual needs, the operation only modifies the control process of the device and does not affect the whole system, the coupling between codes is reduced, and the stability and maintainability of the PLC program control module are improved; the inheritance mechanism allows the engineer to create a new object class, so that the function can be expanded based on the first base class FB_BaseAll and the second base class FB_Axis to adapt to the actual project demand, and the expansion and modification process of the program is simplified; these advantages make the application more efficient in the development of complex systems, finally improve the maintainability and scalability of the system, through the design of the class and the object, the logic structure of the control program is more clear, which is helpful to manage the complex control system, meanwhile, the encapsulation and modularization make the program easier to modify and debug (because modifying an object usually does not affect other objects), in addition, the object and the class can be reused in different projects or systems, reduce the repeated development work, the existing function is more easily expanded and the new demand is adapted through the inheritance, the modification amount of the code is reduced, these characteristics are helpful to solve the problems of code complexity, difficult to maintain and expand in the traditional way.
[0103] The above-mentioned ideal embodiments according to the application are for inspiration, and through the above description, relevant personnel can make various changes and modifications without deviating from the technical idea of the application. The technical scope of the application is not limited to the content in the specification, and must be determined by the scope of the claims.
Claims
1. A PLC-based control program design method characterized by comprising: The method comprises the following steps: S1, constructing a PLC program control module, wherein the PLC program control module comprises an execution layer; S2, obtaining the execution layer in step S1, and constructing a first base class FB_BaseAll and a second base class FB_Axis in the execution layer, and then extending device classes of the first base class FB_BaseAll and the second base class FB_Axis; The first base class FB_BaseAll is used for logical control, and the second base class FB_Axis is used for servo motor control; Step S2 comprises the following steps: S2-1, obtaining the execution layer in step S1, and constructing 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, obtaining the first base class FB_BaseAll constructed in step S2-1 and the second base class FB_Axis constructed in step S2-2, and extending device classes of the first base class FB_BaseAll and the second base class FB_Axis; In step S2-1, the first base class FB_BaseAll is internally provided with a start-stop state machine; State transition of the start-stop state machine comprises the following steps: S2-1-1, when the system receives a start signal, the state is transferred to a preparation start state, the state flow code is 1xx, and one or a series of actions of preparation start are performed, if the start does not satisfy an open object condition, the state is returned to a complete stop state; S2-1-2, when the open object condition is satisfied, the state is transferred to an open state, the state flow code is 2xx, and an open flow of the open state is performed; S2-1-3, when the open flow is normal and a start success signal is returned, the state is transferred to a complete open state, the state flow code is 3xx, and a monitoring flow is performed; S2-1-4, when the system satisfies a stop object condition and receives a stop signal, the state is transferred to a stop state, the state flow code is 4xx, and a stop flow is performed; 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, the state flow code is 0; S2-1-6, when an exception occurs in the open state, the stop state or the complete open state, an exception signal is output, the state is transferred to an emergency stop state, the state flow code is 5xx, and an emergency stop flow is performed; S2-1-7, when the system is in the emergency stop state, the state is transferred to an error state, the state flow code is 9xx; S2-1-8, when the system receives a reset signal and confirms the reset signal, a reset action is performed, the state is transferred to the complete stop state, and the state flow code is 0.
2. The PLC-based control program design method according to claim 1, characterized by, In step S2-1, the first base class FB_BaseAll is used for encapsulation of basic device start-stop control and protection; The inputs of the first base class FB_BaseAll comprise: A start signal, a reset signal, an error signal and a lock signal; The outputs of the first base class FB_BaseAll comprise: A device running output, a running state, an error output and an emergency stop. The control interface of the first base class FB_BaseAll encapsulates includes: The first base class FB_BaseAll controls the running state, fault state and start delay display.
3. The PLC-based control program design method according to claim 1, characterized by, In step S2-2, the function modules of the second base class FB_Axis include: The absolute motion control function of the shaft, the relative motion control function of the shaft, the home function of the shaft and the initialization function of the shaft; The control interface of the second base class FB_Axis encapsulates includes: The inching control of the motor, the micro-motion control, the control speed setting window, the acceleration and deceleration ratio setting window, the micro-motion distance setting window and the zero return distance setting window.
4. The PLC-based control program design method according to claim 1, characterized by, In step S2-2, the second base class FB_Axis is internally provided with a control flow state machine.
5. The PLC-based control program design method according to claim 4, characterized by, In step S2-2, the state transition of the control flow state machine includes the following steps: S2-2-1, when the motor is in the preparation state, and the AxAbs, AxRel, AxHome control instructions are received, the state is transferred to the motion, and the specific action of the control instruction is executed; S2-2-2, when the motor is in the motion state, at this time, the specific action of the control instruction is being executed, if the start is abnormal, return to the Error state, if the execution is completed, return to the preparation state; S2-2-3, when the motor is in the preparation state and the AxStop control instruction is received, the state is transferred to the stop state, at this time, the Stop action is being executed, if the execution is completed, return to the preparation state; S2-2-4, when the motor is in the fault state, and the AxReInit control instruction is received, the state is transferred to the StandStill state, and the device initialization is completed.
6. The PLC-based control program design method according to claim 1, characterized by, 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.
7. The PLC-based control program design method according to claim 1, characterized by, In step S1, the PLC program control module further includes: The management layer, the perception layer and the drive layer; Among them: the management layer includes: configuration management, information publishing and exception handling, used for processing the upper computer data downlink, controller data uplink and system exception; The execution layer includes: motion control model, control logic model and collaborative watchdog; The perception layer includes: port mapping, data analysis and CNC file analysis, used for processing the port mapping of the device, the data analysis of the device; The drive layer includes: CAN, CAN Open, Modbus RTU, Modbus TCP and GPIO.