Distributed PLC compiling method, system, device and medium
The compilation image service and runtime image built using Docker containers and virtualization technology solve the complexity of compiling and debugging PLC programs across different hardware platforms, realize an efficient and unified programming environment for cross-platform compilation and debugging, and improve PLC development efficiency.
Patent Information
- Application Number
- CN202511498381.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2026-02-13
AI Technical Summary
In the current PLC program development process, developers need to manually configure cross-compilation toolchains across different operating systems and hardware platforms, which is cumbersome, error-prone, and difficult to maintain consistency across multiple PLC models, affecting development efficiency and project progress.
It uses Docker containers to build compilation image services and runtime images, and uses Windows programming software to write PLC program files in the compilation image environment. It also uses virtualization technology to achieve cross-platform compilation, supporting programming and debugging on multiple hardware platforms without adjustment.
It achieves high compatibility and portability of PLC programs on different hardware platforms, reduces adaptation costs and complexity, improves programming and debugging efficiency, supports multi-platform debugging, and enables rapid response to field needs.
Smart Images

Figure CN121523685A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of industrial automatic control, and in particular relates to a distributed PLC compiling method, system, device and medium. BACKGROUND
[0002] In the field of industrial automation, PLC (Programmable Logic Controller) is widely used in automatic production, process control and device management due to its high stability and strong real-time performance, and is an important equipment for realizing industrial automatic production.
[0003] With the vigorous development of industrial technology, modern industry has put forward more stringent requirements for control systems, such as efficient distributed processing capability, real-time communication mechanism and flexible scalability. Under this background, PLC technology is accelerating the deep integration with cutting-edge technologies such as industrial Internet of Things, 5G network and edge computing, and is jointly injecting more powerful power into intelligent industrial control.
[0004] However, the current PLC program development practice is facing severe challenges: the industrial site environment is becoming more and more complex, and a single production line or system often integrates PLC devices from different manufacturers and uses multiple processor architectures (such as x86, ARM, PowerPC, etc.). Developers often need to program in the integrated development environment (IDE) of the Windows platform, but the final program needs to run on the specific hardware and operating system of the target embedded PLC. The significant difference between the development environment and the target running environment (different operating systems, different instruction sets) requires complex cross-compilation and remote debugging. The traditional way requires developers to manually configure and maintain a dedicated cross-compilation tool chain and debugging environment (such as multiple systems, virtual machines, etc.) for each target PLC on the local machine, which is tedious, prone to errors (such as dependency conflicts, version mismatches), and difficult to maintain consistency across different development machines. Especially when multiple PLC models need to be supported or the production line needs to be upgraded quickly, remote operation and debugging, the time-consuming and uncertainty of environment configuration become the main bottleneck for improving development efficiency and ensuring project progress. The complexity of cross-platform compilation and debugging seriously restricts the speed of engineers responding to field requirements and hinders the efficient deployment and verification of advanced control logic in heterogeneous industrial environments. SUMMARY
[0005] The present application aims to solve the problems of the prior art by providing a distributed PLC compiling method, system, device and medium.
[0006] The present application specifically provides the following technical solutions: a distributed PLC compiling method, comprising the following steps: selecting a PLC program file written in structured text ST language in the programming software of Windows; The programming software sends the PLC program file to the compilation image environment encapsulated by the Docker container, receives the compilation log of the compilation image environment, and receives the corresponding executable file returned by the compilation image environment according to the operation mode; The programming software sends the executable file to the Runtime image, and issues a start command or a stop command, receives the command confirmation information when the Runtime image successfully executes the command, and initiates an execution debugging command when the PLC program is in a running state.
[0007] Preferably, the Runtime image successfully executes the start command, and specifically: After receiving the start command, the Runtime image returns the current variable monitoring list and the running log to the programming software, and starts the internal processes of the Runtime image, including the Modbus monitoring service, the PLC main process, the IO cache flushing, and the communication thread in the Runtime image; The main service is the first process started by the Runtime, responsible for managing the Runtime state and managing other services or processes; the PLC main process is responsible for managing and controlling the running state of the PLC program generated by compilation, loading and executing the executable file; the IO cache is the internal mapping area of the hardware IO point, responsible for hardware IO read and write; the Modbus monitoring service is responsible for reading the internal variables of the executable file, used for external monitoring of the internal variable state of the program after compilation and running; the communication agent thread is responsible for interacting between the main service and the PLC program running at the time of the executable file, forwarding the commands of the main service to the actual execution of the PLC program.
[0008] Preferably, the loading and execution of the executable file are specifically: The PLC main process enters a loop execution period, continuously flushing the IO cache, structured text (ST) program logic operation, updating the IO cache, and communication task processing; the communication task includes: the programming software requests the running log through the communication thread, and the Runtime image returns the running log; the programming software reads or writes the variable value in the IO cache through the communication thread, and performs variable monitoring.
[0009] Preferably, the Runtime image successfully executes the stop command, and specifically: The programming software sends a stop instruction, which is transmitted to the main service of the Runtime image through the communication thread; The main service commands the PLC main process to stop execution, the PLC main process clears the IO cache to clean up the state, updates the stop state after confirming the process stop, and returns the stop state information to the programming software through the communication thread, the programming software sends a logout instruction to end the session with the Runtime image.
[0010] Preferably, before the programming software sends the start command or the stop command to the Runtime image, the programming software further comprises: The programming software initiates a login request containing identity authentication to the Runtime image. The Runtime image performs MD5 verification on the executable file, and when the MD5 verification is passed, the programming software sends the executable file to the Runtime image.
[0011] Preferably, the compiling image service and the Runtime image are built by a Docker container; wherein the compiling image service provides a compiling related environment, and performs the compiling of the structured text; and the Runtime image provides a PLC program running environment, and performs the running, stopping, state monitoring and debugging of the PLC program.
[0012] Preferably, when the programming software initiates the execution of the debugging command, the programming software and the Runtime image perform bidirectional communication, and send the commands for setting breakpoints and canceling breakpoints.
[0013] The present application provides a kind of distributed PLC compiling system, comprising: The selection module is used to select the PLC program file written in structured text ST language in the programming software of Windows; The compiling module is used for the programming software to send the PLC program file to the compiling image environment encapsulated by Docker container, and receives the compiling log of the compiling image environment and the corresponding executable file returned in the compiling image environment according to the operation mode; The command module is used for the programming software to send the executable file to the Runtime image, and issues the start command or the stop command, when the Runtime image successfully executes the command, the programming software receives the command confirmation information, and when the PLC program is in the running state, the programming software initiates the execution of the debugging command.
[0014] The present application provides a kind of computer equipment, comprising memory and processor, the memory has stored program, the program is executed by the processor when, make the processor execute the steps of above-mentioned one kind of distributed PLC compiling method.
[0015] The present application provides a kind of storage medium, which stores computer program, the computer program is executed by processor when realizes the steps of above-mentioned one kind of distributed PLC compiling method.
[0016] Compared with prior art, the present application has the following advantages: The programming software sends a PLC program file to a compiling image environment, compiles the received PLC program file in the compiling image environment, generates an executable file and a compiling log, returns the compiling log to the programming software, and returns a corresponding executable file according to an operation mode, successfully realizes effective decoupling of the PLC controller program and the device hardware platform by applying the virtualization technology to the compiling stage of the PLC controller program, and further greatly improves the compatibility and portability, and the programming software sends a start command or a stop command to the Runtime image, sends command confirmation information to the integrated development environment when the Runtime image successfully executes the command, and the PLC program can be in a running state, and can be assisted by the standardized and consistent running environment provided by the virtualization container, and the programming software can initiate an execution debugging command by the successful execution of the Runtime image, is successfully compiled on a plurality of different hardware platforms, does not need to be additionally adjusted and modified, greatly reduces the adaptation cost and complexity caused by the hardware difference, and provides strong technical support and convenient conditions for the development, application and popularization of the programming software service. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 A flowchart of the compiling process in the embodiment of the present application. DETAILED DESCRIPTION
[0018] The technical solutions of the embodiments of the present application will be described clearly and completely in combination with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the protection scope of the present application.
[0019] The virtualization compiler structure is innovatively developed in the present application, can perfectly adapt to the multi-platform compiling requirement, effectively breaks the limitation of the traditional compiler running platform, realizes one writing and multiple debugging, significantly improves the overall working efficiency of the PLC programming and debugging, and provides strong support for the continuous development and application of the PLC technology in the complex and changeable industrial environment.
[0020] The present application builds a compiling image service and a Runtime image through a Docker container; the compiling image service provides a compiling related environment and compiles a structured text, and the Runtime image provides a PLC program running environment and performs running, stopping, state monitoring and debugging of the PLC program.
[0021] As shown in Figure 1 A distributed PLC compiling method is provided in the present application, and specifically includes the following steps: Step S1: Select the PLC program file written in structured text ST language in the programming software of Windows.
[0022] Windows side operation (programming and compilation trigger): Action: The engineer operates on the Windows operating system using the programming software.
[0023] Key action: Select to debug or run a program file written in structured text ST language.
[0024] Result: The programming software will send the structured text ST file to the compilation image environment.
[0025] Step S2: The programming software sends the PLC program file to the compilation image environment encapsulated by the Docker container, and the programming software sends the PLC program file to the compilation image environment, receives the compilation log of the compilation image environment, and returns the corresponding executable file in the compilation image environment according to the operation mode.
[0026] Compilation image service (generate execution file): Receive: The compilation service in the compilation image receives the structured text ST file.
[0027] Core processing: The compilation service compiles the structured text ST file to generate an executable file and a compilation log.
[0028] If it is a debugging mode: An additional variable mapping file containing line number information will also be generated (convenient for tracking during debugging).
[0029] Return: Return the compilation log to the Windows programming software.
[0030] Runtime: Mainly return the executable file.
[0031] Debugging: In addition to the executable file, an additional line number variable file is returned.
[0032] Among them, Figure 1 The compilation image is shown to participate in the process at both ends, but usually the compilation environment can be completed after completing the compilation task, and the service is in standby state ready for the next compilation request.
[0033] Step S3: The programming software sends the executable file to the Runtime image, and issues a start command or a stop command. When the Runtime image successfully executes the command, the programming software receives the command confirmation information, and when the PLC program is in a running state, the programming software initiates an execution debugging command.
[0034] Runtime image operation (login, download and start): Before the programming software sends the start command or stop command to the Runtime image, it also includes: 1. Login request: The programming software initiates a login request to the Runtime image, which includes authentication, possibly including authentication.
[0035] 2. Security check: The Runtime image performs an MD5 check on the executable file (to verify the integrity and legality of the file).
[0036] 3. Download execution file: When the MD5 check passes, the programming software sends the executable file to the Runtime image.
[0037] 4. Incremental update (optional): Check if there is an incremental undisturbed download (i.e., update part of the program while the PLC is running without interrupting the current running logic).
[0038] 5. Start command: The programming software sends a start command to the Runtime image, which is: After the Runtime image receives the start command, it returns the current variable monitoring list and running log to the programming software; starts the internal process - starts the Modbus monitoring service, PLC main process, IO cache flushing, and communication thread through the main service, where the PLC main process loads and executes the executable file.
[0039] Among them, the instruction type of the start command includes: standard running (starting from the beginning); debugging (loading debugging information and preparing for monitoring); undisturbed download (if selected).
[0040] Among them, the main service is the first process started by the Runtime, responsible for managing the Runtime state and managing other services or processes; the PLC main process is responsible for managing and controlling the running state of the compiled PLC program, loading and executing the executable file; the IO cache is an internal mapping area of the hardware IO point, responsible for hardware IO read and write; the Modbus monitoring service is responsible for reading the internal variables of the executable file, used for external monitoring of the internal variable state of the program after compilation and running; the communication agent thread is responsible for interacting between the main service and the PLC program during the execution of the executable file, forwarding the commands of the main service to the actual execution of the PLC program.
[0041] 6. Initialization return: The Runtime returns the current variable monitoring list to the programming software (for monitoring real-time values) and the running log.
[0042] 7. Runtime internal startup process (managed by the main service): ① Start Modbus monitoring service (for external device communication).
[0043] 2) Start the PLC main process (load and execute the executable file).
[0044] 3) Flush the IO cache (empty or initialize the internal mapping area of the hardware I / O point).
[0045] 4) Start the communication thread (handle communication requests between the programming software and the PLC, such as logs, variables, stop commands, etc.).
[0046] PLC execution cycle (main process loop): The PLC main process loads and executes the executable file, specifically: Core operation: the PLC main process enters the loop execution cycle, which is the core of the PLC program, which continuously scans and executes: Continuous flushing of the IO cache (input reading), structured text (ST) program logic operation, updating of the IO cache (output writing), and communication task processing; communication tasks include: the programming software requests to run the log through the previously established communication thread, that is, to obtain real-time running state information, and the Runtime image returns the running log; the programming software reads or writes the variable value in the IO cache through the communication thread to monitor the variable.
[0047] Stop flow: the programming software sends a stop command to the Runtime image, specifically: Stop request: the engineer sends a stop command through the programming software.
[0048] Stop processing: communication request stop process: the stop command is transmitted to the main service of the Runtime image through the communication thread; the main service commands the PLC main process to stop execution, and the PLC main process clears the IO cache to clean up the state, confirms the process stop, and updates the stop state, and returns the stop state information to the programming software through the communication thread, and the programming software sends a logout instruction to end the session with the Runtime image.
[0049] When the programming software initiates an execution debugging command, bidirectional communication is performed between the programming software and the Runtime image to send commands to set breakpoints and cancel breakpoints.
[0050] The present application takes advantage of the cross-platform features of Docker, making the remote debugging method widely applicable to a variety of different operating systems and hardware platforms. Whether it is Linux, Windows or macOS system, as long as Docker is installed, GDB remote debugging can be performed according to a unified process and method, greatly expanding the application range of debugging technology and meeting the needs of debugging programs in different development and testing environments.
[0051] Based on the above method and statement, the application provides a distributed PLC compiling method system, comprising a selection module, a compiling module and a command module.
[0052] The selection module is used for selecting a PLC program file written in a structured text ST language in programming software of Windows; the compiling module is used for sending the PLC program file to a compiling image environment encapsulated by a Docker container by the programming software, receiving a compiling log of the compiling image environment, and returning a corresponding executable file in the compiling image environment according to an operation mode; and the command module is used for sending the executable file to a Runtime image by the programming software, issuing a start command or a stop command, receiving command confirmation information when the Runtime image successfully executes the command, and initiating an execution debugging command when the PLC program is in a running state.
[0053] The application further provides a computer device comprising a memory and a processor, and the memory stores a program, and the program is executed by the processor to enable the processor to execute the steps of the distributed PLC compiling method.
[0054] According to the disclosed embodiments, the computer device can communicate with one or more external devices (such as a keyboard, a pointing device, a Bluetooth communication, etc.), or communicate with any device (such as a router, a demodulator, etc.) that enables the computer device to communicate with one or more other computer devices.
[0055] The application further provides a storage medium having a computer program stored thereon, and the computer program is executed by the processor to implement the steps of the distributed PLC compiling method.
[0056] According to the disclosed embodiments, the storage medium can be a non-volatile computer readable storage medium, which can include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the application, the storage medium can be any tangible medium containing or storing a program, which can be used by or in conjunction with an instruction execution system, device or apparatus.
[0057] The above is a further detailed description of the application in combination with specific preferred embodiments, and for those skilled in the art to which the application belongs, a number of simple deductions or replacements can be made without departing from the concept of the application, and all should be considered to fall within the protection scope of the application.
Claims
1. A distributed PLC compilation method, characterized in that, include: In Windows programming software, select the PLC program file written in Structured Text ST language; The programming software sends the PLC program file to the compilation image environment packaged in the Docker container, and receives the compilation logs of the compilation image environment, as well as the corresponding executable file returned by the compilation image environment according to the operation mode; The programming software sends the executable file to the Runtime image and issues start or stop commands. When the Runtime image successfully executes the command, the programming software receives command confirmation information and initiates a debug command when the PLC program is running.
2. The distributed PLC compilation method as described in claim 1, characterized in that, The Runtime image successfully executed the startup command, specifically: After receiving the start command, the Runtime image returns the current variable monitoring list and running log to the programming software, and starts the internal process of the Runtime image, starting the Modbus monitoring service, PLC main process, IO cache refresh and communication thread with the main service in the Runtime image; Among them, the main service is the first process started by the Runtime, responsible for managing the Runtime state and managing other services or processes; the PLC main process is responsible for managing and controlling the running state of the compiled PLC program, loading and executing the executable file; the IO cache is the internal image area of the hardware IO points, responsible for hardware IO read and write; the Modbus monitoring service is responsible for reading the internal variables of the executable file, used for external monitoring of the internal variable state of the compiled and run program; the communication proxy thread is responsible for the interaction between the main service and the PLC program running the executable file, forwarding the commands of the main service to the PLC program for actual execution.
3. The distributed PLC compilation method as described in claim 2, characterized in that, The loading and execution of the executable file specifically involves: The PLC main process enters a loop execution cycle, continuously refreshing the IO cache, performing logical operations on the structured text ST program, updating the IO cache, and processing communication tasks. The communication tasks include: the programming software requests the running log through the communication thread, and the Runtime image returns the running log; the programming software reads or writes variable values in the IO cache through the communication thread to monitor variables.
4. The distributed PLC compilation method as described in claim 1, characterized in that, The stop command was successfully executed on the Runtime image, specifically: A stop command is sent via programming software, and the stop command is transmitted to the main service of the Runtime image via a communication thread. The main service command PLC main process stops execution, clears the IO cache to clean up the status, updates the stop status after confirming the process has stopped, and returns the stop status information to the programming software through the communication thread. The programming software sends a logout command to end the session with the Runtime image.
5. The distributed PLC compilation method as described in claim 1, characterized in that, Before the programming software sends a start command or stop command to the Runtime image, it also includes: The programming software sends a login request, which includes authentication, to the Runtime image; The Runtime image performs an MD5 checksum on the executable file, and if the MD5 checksum passes, the programming software sends the executable file to the Runtime image.
6. The distributed PLC compilation method as described in claim 1, characterized in that, The build image service and runtime image are built using Docker containers. The build image service provides the compilation environment for compiling structured text, while the runtime image provides the PLC program execution environment for running, stopping, monitoring the status of, and debugging the PLC program.
7. A distributed PLC compilation method as described in claim 1, characterized in that, When the programming software initiates a debugging command, it communicates bidirectionally with the Runtime image to send commands to set and cancel breakpoints.
8. A distributed PLC compilation system, characterized in that, include: The selection module is used to select PLC program files written in the Structured Text ST language in Windows programming software; The compilation module is used by the programming software to send the PLC program file to the compilation image environment packaged in the Docker container, and to receive the compilation logs of the compilation image environment, as well as the corresponding executable file returned by the compilation image environment according to the operation mode; The command module is used by the programming software to send executable files to the Runtime image and issue start or stop commands. When the Runtime image successfully executes the command, the programming software receives command confirmation information and initiates the execution of debugging commands when the PLC program is in running state.
9. A computer device, characterized in that, It includes a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor performs the steps of a distributed PLC compilation method as described in any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of a distributed PLC compilation method according to any one of claims 1 to 7.