A development environment and management development method for compiled programmable logic controller

By classifying ladder diagrams and designing translation templates and driver designs, directly translating them into C language programs and compiling them, the problem of efficient R&D and low management development efficiency in the PLC development environment is solved, and efficient PLC development and flexible functional module development are achieved. .

CN115248570BActive Publication Date: 2024-10-29SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210532348.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-09
Publication Date
2024-10-29
Estimated Expiration
2042-05-09

AI Technical Summary

Technical Problem

The existing compiled programmable logic controller (PLC) development environment has problems of high R&D efficiency and low efficiency of management and development operations. In particular, there is redundant work and poor portability when converting ladder diagrams into C language, and management and development operations are poor. Relying on interpreted execution results in high memory usage and inconvenient driver interface configuration.

Method used

By classifying the ladder diagram into basic instructions, functional module instructions, functional units and resource allocation units, and designing translation templates and driver designs, it is directly translated into C language programs, and then compiled into binary executable codes. A database is used to store hardware resource configurations. Improve efficiency.

Benefits of technology

It improves the execution efficiency and R&D efficiency of PLC, simplifies the programming process, reduces memory usage, and supports flexible functional module development and driver interface configuration to adapt to a variety of development scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115248570B_ABST
    Figure CN115248570B_ABST
Patent Text Reader

Abstract

A development environment for a compiled programmable logic controller includes: S1: classify ladder diagrams; S2: design translation templates; S3: drive design; S4: generate C language programs; S5: compile C language programs; S6: download executable files. The present invention is highly efficient, directly translates the graphics elements of the ladder diagram into C language, and then compiles and executes, which belongs to direct compilation execution, greatly improving the execution efficiency. To meet a variety of development scenarios, the present invention belongs to a form of low-code development, which is not only suitable for ladder diagrams, but also provides a technical idea for researchers of low-code development based on graphics. Therefore, it is easier to realize mixed programming of ladder diagrams and C language. Due to the flexibility of C language, it can meet the actual needs of engineering and technical personnel to the greatest extent, especially in situations where algorithm integration is required. Meet market application expectations: For PLC R&D personnel, the present invention makes it easier to add new functional instructions and quickly adapt to market application needs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a development environment and a management and development operation method of a compiled programmable logic controller, belonging to the technical field of automatic control or regulation systems. Background Art

[0002] There are two types of PLC execution modes: compiled and interpreted. The interpreted execution mode has the advantages of small code length, convenient breakpoint setting during debugging, and low efficiency; the compiled execution mode has the advantages of high execution efficiency and good real-time performance without the process of interpretation and execution, but poor portability. Although the industry proposed a solution to translate the statement table into C language in 2016, people in this field prefer to use the ladder diagram programming method. Therefore, the technical idea adopted at that time was: first convert the ladder diagram into a statement table, and then convert the statement table into C language, which caused redundant work and reduced the R&D efficiency of other functional modules of the programmable logic controller.

[0003] Although many solutions for translating statement lists into C language have been made public, they still cannot substantially solve the technical problem of efficient R&D of new functional modules of programmable logic controllers:

[0004] Chinese patent document CN113760298 discloses a method for embedding C language in a PLC ladder diagram in the field of PLC, including providing a C language function writing interface in configuration software, using a compilation tool to compile the C language into a machine language that can be used in an embedded system, and obtaining an entry address of the C function; using the configuration software to download the generated machine code and mapping relationship to the PLC; in the PLC, the machine code is placed in a corresponding physical address, and then loaded into the PLC by a distributed loading method; when a user program calls a C language function in the ladder diagram of the PLC, the PLC obtains the entry address of the C function through the downloaded mapping relationship, and converts the entry address into a function pointer, and jumps to the user's C function through the function pointer for execution. The method of embedding C language in the PLC ladder diagram enables users to perform complex algorithms through C language in the PLC system, with high operating efficiency, simplified programming, and no need to redevelop a compiler system or transplant an open source compiler. However, the patent document embeds C language in the ladder diagram, and the source ladder diagram program remains unchanged. The execution efficiency is not improved, but the flexibility of function implementation is improved. It still cannot solve the technical problem to be solved by the present invention, that is, there is no corresponding technical means to convert the graphical language from the root of the ladder diagram into C language.

[0005] Chinese patent document CN207488786 discloses an industrial automation controller that uses an ARM chip as a controller and Linux as a system environment to implement PLC control. In the document, the IEC2C parser parses the text configuration file (.ST suffix) describing the PLC control logic into a C language program, and then the PLC compiler compiles the C program into a PLC executable program based on the Linux system, and runs the PLC executable program to implement the PLC function on the ARM chip, thereby controlling the industrial equipment. However, the document only parses the text configuration file into C language, and does not explain too much about the parsing steps, so it still cannot achieve the technical problem proposed by the present invention.

[0006] Chinese patent document CN101587445 discloses a PLC compilation and execution method, in which a PLC application written in a programming language supported by IEC61131-3 is converted into a description in standard C language. In the last step, the standard C language description file is compiled by compilation technology to generate an application module that can be directly executed by PLC. This application module can be directly executed in the CPU of PLC, and there is no need to interpret and execute the program. However, the patent document converts the statement table, ladder diagram, function block diagram, etc. into an assembly intermediate language, and then parses the intermediate language into C language. Obviously, since the translation method has an intermediate process, it still cannot solve the technical problem proposed in the present invention.

[0007] In summary, in order to adapt to various scenarios of modern industrial control, a programmable logic controller development environment with high R&D efficiency is urgently needed.

[0008] In addition, the management and development operation method for the compiled programmable logic controller development environment is also a technical issue that has always been concerned in this technical field: in the prior art, the management and development operations are all implemented based on the interpreted programmable logic controller, that is, the hardware resource configuration parameters need to be downloaded to the PLC hardware FLASH in advance, and then interpreted and executed. Based on this, the main disadvantage of this technical idea is that it occupies memory space. At the same time, users cannot customize the driver interface in advance. Once the driver interface changes, the kernel driver program must be re-burned, which greatly reduces the development efficiency.

[0009] The traditional method of storing data in a file and then reading the file data will make it difficult to classify and manage the real-time data and call it in real time during user programming, which will ultimately greatly reduce the execution efficiency. Therefore, those skilled in the art have proposed the idea of ​​realizing efficient management of development operations of programmable logic controllers based on databases, but this is limited by the following technical reasons:

[0010] First, for the management and development of interpreted programmable logic controllers, it is difficult to integrate interpreted execution with database technology; second, as for the existing compiled programmable logic controllers mentioned above, because they convert statement tables into assembly language, they still cannot achieve efficient management and development by integrating database technology; finally, although there are ways to convert statement tables into C language interpreted execution in the prior art, this type of compiled programmable logic controller is not yet mature, so there is no precedent for integrating the database with the management and development operations of the programmable logic controller.

[0011] Furthermore, if only the pin parameters are configured without configuring the driver interface, the driver interface can be kept consistent for the same series and the same model of hardware. However, due to different circuit design principles of the hardware, different engineers design products with different hardware level signals. For example, whether the scan input is low level effective or high level effective, if the host computer cannot configure the driver interface, in this case, the underlying driver interface needs to be re-customized, which violates the principle of software consistency and the original intention of the design. The driver interface configuration is more efficient and easy to call only if it is configured through a database.

[0012] To this end, through the above research, the applicant believes that: although there are technical barriers to achieving the management and development of efficient programmable logic controllers based on database technology, this technical idea meets the design needs of designers, so the applicant has been working tirelessly to achieve technological breakthroughs. Summary of the invention

[0013] In view of the deficiencies of the prior art, the present invention discloses a development environment for a compiled programmable logic controller.

[0014] The invention also discloses a software interface framework design method for the development environment.

[0015] The invention also discloses a development environment management development operation method of a compiled programmable logic controller.

[0016] The invention also discloses an electronic device loaded with a development environment of a compiled programmable logic controller.

[0017] The invention also discloses a computer program product for realizing a development environment of a compiled programmable logic controller.

[0018] The detailed technical scheme of the present invention is as follows:

[0019] A development environment for a compiled programmable logic controller, characterized by comprising:

[0020] S1: Classify the ladder diagram:

[0021] It is initially divided into: basic instructions, functional module instructions, functional units, variable management units and resource configuration units;

[0022] The basic instructions include bit logic operation instructions, comparison operation instructions, arithmetic operation instructions, shift operation instructions and data block transfer instructions; the bit logic operation instructions include normally open contact LD, normally closed contact LDN, rising edge pulse LDP, falling edge pulse LDF, coil output =, coil set S and coil reset R; the comparison operation instructions include greater than GT, less than LT, greater than or equal to GE, less than or equal to LE, equal to EQ, not equal to NE; the arithmetic operation instructions include addition ADD, subtraction SUB, multiplication MUL, division DIV, remainder MOD; the shift instructions include left shift SHL, right shift SHR, circular left shift ROL, circular right shift ROR; the data block transfer instructions include assignment MOV;

[0023] The functional module instructions include timer instructions, counter instructions, pulse output instructions, serial port communication instructions, free protocol instructions, ModBusRTU protocol instructions and interrupt instructions; the timer instructions include ordinary timer TP, on-delay timer TON, on-delay timer TONR with memory, and off-delay timer TOF; the counter includes add counter CU, subtract counter CD and high-speed counter HSC; the pulse output includes pulse width modulation PWM and pulse train output PTO; the serial port communication instructions include serial port setting S_COM, serial port enable EN_COM, and serial port disable DIS_COM; the free protocol instructions include encapsulation and transmission SND and unpacking UPK; the ModBusRTU protocol instructions include modbus protocol encapsulation and transmission instructions MB_SND and modbus protocol unpacking instructions MB_UPK; the interrupt instructions include interrupt enable ENI and interrupt disable DISI;

[0024] The functional units include a subprogram unit, an interrupt program unit, a C language program unit, and a function link library unit;

[0025] The variable management unit is divided into I area, Q area, M area, SM area, V area, AI area, AQ area, T area, C area, HC area and S area according to the storage area; it is divided into global variables, local variables and power-off preservation variables according to the storage type; the I area refers to the switch input image area; the Q area refers to the switch output image area; the M area refers to the auxiliary register image area; the V area refers to the user-defined global variable image area; the AI ​​area refers to the analog input image area; the AQ area refers to the analog output image area; the T area refers to the timer variable image area; the C area is the counter variable image area; the HC is the high-speed counter variable image area; the S area refers to the sequential control relay image area;

[0026] The resource configuration unit includes pin definition, HSC definition, interrupt resource, communication port and compilation option; the pin definition configuration includes digital input and output pins, analog input and output pins, and high-speed pulse output pins; the HSC definition configuration refers to the high-speed pulse input function pin configuration; the interrupt resource configuration refers to the interrupt resource of the PLC, and the configurable interrupt types include rising edge, falling edge, HSC count completion, HSC direction change, HSC external reset, timed interrupt, timed to interrupt, PTO count completion, serial port receiving character, serial port receiving completion, and serial port sending; the communication port configuration includes serial port, network port, and CAN port; the configuration of the compilation option refers to the relevant configuration options required for compilation after the ladder diagram is translated into C language, including header file inclusion class interface, hardware initialization interface, scan input interface, scan output interface, coil setting interface, and coil reset interface;

[0027] Further divided into: basic instructions are divided into type 1 basic conditional type and type 2 basic output type; the basic conditional type refers to a type of instruction representing a condition in a logic line of the ladder diagram, including the open contact LD, normally closed contact LDN, rising edge pulse LDP, falling edge pulse LDF and comparison operation instructions of the bit logic operation instruction; the basic output type refers to a type of instruction representing output in a logic line of the ladder diagram, including the coil output =, coil set S, coil reset R of the bit logic operation instruction, arithmetic operation instructions, shift operation instructions and data block transfer instructions;

[0028] All the functional module instructions are used as type 3 functional instruction output type. The functional instruction output type means that an execution function is represented in a logic line of the ladder diagram. The function is not just a simple logical operation, but implements a functional module like a function. For example, the ordinary timer instruction TP can work normally when the timing time is configured during programming, but the C language driver part needs to do a lot of function implementation work; the functional instruction output type includes timer instructions, counter instructions, pulse output instructions and interrupt instructions;

[0029] The functional units are divided into type 4 subroutine type and type 5 link type; the subroutine type includes subroutine unit and interrupt program unit; the link type includes C language program unit and function link library unit;

[0030] All the variable management units are used as type 6 variable models, where the variable models refer to storage units used in ladder diagram programs, including global variables, local variables, and power-off save variables;

[0031] The resource configuration unit is divided into type 7 pin configuration model and type 8 driver interface type; the pin configuration model means that the configuration corresponds to the hardware port, including digital input and output pins, analog input and output pins, high-speed pulse input and output pins, serial ports, network ports, and CAN ports; the driver interface type refers to the function interface of each functional module encapsulated in C language;

[0032] S2: Design translation templates: According to the further classification of the ladder diagram in step S1, design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates respectively, for translating the ladder diagram into corresponding C language programs;

[0033] S3: Driver design: Implement C code for the functions involved in the working process of the programmable controller, including digital input data reading, digital output data writing, analog input data processing, analog output control, basic timer function implementation, basic counter function implementation, high-speed pulse input function implementation, high-speed pulse output function implementation, serial port driver and protocol encapsulation function implementation, network port driver and protocol encapsulation function implementation, CAN driver and protocol encapsulation function implementation;

[0034] S4: Generate C language program: translate the ladder diagram edited by the user into C language code according to the translation template described in step S2, that is, call the main program main after the ladder diagram is translated into C; then call the C code generated by the driver design described in step S3 in main, and then form a complete set of C language program;

[0035] S5: Compile C language program: compile the C language code program into binary executable code through a compiler;

[0036] The C language program is compiled by "GCC+Makefile" compilation; GCC is the abbreviation of GCC cross-compilation tool, which is a link library generated by cross-compilation of actual CPU products, such as STM32 using gcc-arm-none-eabi tool; Makefile is the abbreviation of the compilation process customized according to the CPU product; the compilation process includes: target variable definition, C source code file location, S startup file location, compilation tool association, special flag processing, H header file location, library generation processing and clearing function pseudo code;

[0037] S6: Download executable file: burn the binary executable code into the programmable controller.

[0038] Preferably according to the present invention, the basic conditional template is the "if (condition)" part in the "if (condition) {function body}" format, for example, the normally open contact of the switch key can be translated into "if (key_val == 1)", and the normally closed contact of the switch key can be translated into "if (key_val == 0)", and the value of the key_val is realized by writing a switch input driver; in particular, the rising edge and falling edge instructions need to consider the state memory problem on the basis of the above template, for example, the rising edge of the switch key can be translated into "if ((key_val_new == 1) && (key_val_old == 0)) key_val_old = key_val_new", and the falling edge of the switch key can be translated into "if ((key_val_new == 0) && (key_val_old == 1)) key_val_old = key_val_new", the key_val_new refers to the read value of the current switch quantity, and the key_val_old refers to the read value of the switch quantity in the previous scanning cycle.

[0039] Preferably, according to the present invention, the basic output type template is the "{function body}" part in the "if (condition) {function body}" format, for example, the coil setting of the indicator light Q can be translated into "{write_Q, out_val}", the operation of the write_Q is implemented by writing a switch output driver, and the out_val is obtained by writing a switch input driver; for example, the add instruction can be translated into "{C=A+B}", the C must be a variable, and the A and B can be variables or values; in particular, the coil output instruction needs to consider the double coil output problem on the basis of the above template, specifically, on the basis of the coil setting, a reverse judgment is added, for example, the coil output of the indicator light Q can be translated into "{write_Q, out_val, temp_out_val; if (!temp_out_val)!write_Q,!out_val; temp_out_val=0;}"; the temp_out_val is the auxiliary memory value of out_val, and the "!+variable" means to invert the value of the variable.

[0040] Preferably, according to the present invention, the functional instruction output template includes: (1) structure definition, wherein the structure refers to the variables required for the corresponding function being encapsulated in a structure, for example, the structure content of the timer-related instruction includes the start / stop flag, time base, counter type, stop flag, load flag, timing flag, count variable and pre-loaded value variable; (2) structure array and structure array length definition, wherein the structure array definition refers to making a global definition in the C file of the timer driver program first, and the structure array length definition refers to making a global definition in the C file of the timer driver program first; (3) structure array and structure array length declaration, wherein the structure array length declaration refers to making a global declaration in the H file of the timer driver program first, and the structure array declaration refers to making a global declaration in the H file of the timer driver program first; (4) defining and implementing an interface function, wherein the interface function is an interface function called in the main loop body when the ladder diagram is translated into C language; in particular, for functions that need to be completed in an interrupt, it is not necessary to design an interface function.

[0041] Preferably, according to the present invention, the subroutine type template refers to generating a function interface of a C language program from a ladder diagram subroutine for calling by a main function or a function associated therewith; in particular, an interrupt subroutine needs to generate an interrupt function interface of a C language program, which can be executed without calling.

[0042] Preferably, according to the present invention, the link type template refers to encapsulating a function into a link port, and other functions directly call the link port; in particular, the link port in the link library unit is already encapsulated and does not need to be encapsulated again and can be directly called.

[0043] Preferably, according to the present invention, the variable model template refers to defining the user's variable definition according to the variable definition rules of the C language, and at the same time translating the PLC variable type into the C language data type one by one, for example, the PLC's "signed integer" is translated into the C language as "int"; in particular, power-off preservation of variables requires that data be saved in flash to prevent power loss.

[0044] Preferably according to the present invention, the pin configuration model template refers to a configuration that corresponds the hardware pins of the PLC to the pins of the CPU one by one, such as the digital input pin I0.0, and the corresponding CPU pin is P1.0; in particular, the encoder mode of the high-speed counter instruction requires 2 or 3 pins, so 2 or 3 pins need to be configured.

[0045] Preferably according to the present invention, the driver interface type template refers to directly configuring and calling the driver interface of the bottom layer encapsulation according to the reference format, such as scanning the input interface as read(%gpioPort%, %gpioPin%, 0), wherein the variable between the two percent signs belongs to the pin configuration configured by the user in the reference database.

[0046] Preferably, according to the present invention, in step S6, the downloading method of downloading the executable file includes a wireless method or a wired method; the wireless method refers to an OTA download method; the wired method refers to a Jlink download method, specifically implemented by using the syntax instructions of the JLINK-Commander.

[0047] The software interface framework design method of the development environment is characterized by comprising:

[0048] Menu bar, toolbar, tree window on the left, tree window on the right, ladder diagram editing area in the middle, such as Figure 2 As shown;

[0049] The menu bar includes a project menu, an edit menu, a compile menu and a help menu; the project menu includes new, open, save and print; the edit menu includes undo and restore; wherein the compile menu includes a build function and a download function, wherein the build function is used to convert the target ladder diagram to C language and compile the C language into binary executable code;

[0050] The toolbar includes engineering tools, editing tools and compiling tools; the engineering tools include new, open, save and print; the editing tools include undo and restore; the compiling tools include build and download functions; the toolbar functions are consistent with the menu functions;

[0051] The tree window on the left includes a first-level branch ladder program and a component box; the first-level ladder program includes a second-level branch main program, a subprogram, an interrupt program and a quick index; the main program is used to: when the middle ladder editing area is in the subprogram or interrupt program interface, by clicking the "main program" editing area to switch to the main program editing interface; the subprogram is used to: when adding a subprogram, create a subprogram, when the user needs to add a subprogram, right-click "Add" to pop up a dialog box for creating a subprogram, the dialog box for creating a subprogram includes a name, author, date, remarks, and a confirmation button, see the attached Figure 3, the created subroutine names are listed below the subroutine secondary branch, belonging to the third-level branch, and the main interface can be switched to the corresponding subroutine interface by clicking the subroutine index name, or the subroutine can be called by dragging the subroutine name; the interrupt program is used to: when an interrupt program needs to be added, create an interrupt program dialog box, right-click "Add" to pop up the create interrupt program dialog box, the create interrupt program dialog box includes name, interrupt resource, description, author, date, remarks and OK button, see attached Figure 4 The names of interrupt programs created by the user are listed below the secondary branch of the interrupt program, belonging to the third-level branch, and the main interface can be switched to the corresponding interrupt program interface by clicking the interrupt program index name; the quick index is used to: list the program function index directory of the main program, subprogram or interrupt program displayed on the current main interface, see the attached Figure 5 ; The component box is used to: list the instruction graphic elements used in the ladder diagram, including bit logic operation instructions, comparison operation instructions, arithmetic operation instructions, shift operation instructions, data block transfer instructions, timers, pulse outputs, serial port communications, ModbusRTU protocols and interrupt instructions; and is also used to drag the instruction graphic element corresponding to the instruction to the editing interface area through the signal input hardware for placement;

[0052] The tree form on the right includes a global variable table, a local variable table, a timer list, a counter list, PWM, COM, system variables, an IO variable table and a PLC resource configuration button; the global variable table includes user-defined global variables and power-off save variables, and is also used to click on the global variable table to create a new global variable, for example, by clicking the "+" button of the row to create a new global variable; the local variable table is used to list the local variables defined by the current main interface program, and the table changes with the switching of the main interface program, and is also used to create a new local variable by clicking on the local variable table, and clicking the "+" button of the row to create a new local variable; the timer list is used to list the timer type variables defined in the program; the counter list is used to list the counter type variables defined by the program; the PWM list is used to list the PWM type variables defined by the program; the COM list is used to list the COM type variables defined by the program; the system variables are used to list the global available variables that the system has defined and can be used without program definition; the IO variable table is used to: list the IO pins owned by the PLC hardware supported by the current project, including symbol names and pin names; the PLC resource configuration button is used for PLC hardware configuration, see Appendix Figure 6, after clicking, a PLC hardware configuration dialog box pops up, the PLC hardware configuration dialog box includes a PLC type list part, a "Use this PLC" button, a "Rename" button, a "Delete this PLC" button, a "Add PLC" button, a pin definition list, an HSC definition list, an interrupt resource list, a communication port list and a compilation option interface; the pin definition list header includes a serial number, a type, a display name, a PLC variable name, a CPU pin, a remark, a CPU port number and a CPU pin number; the HSC definition list header includes a name, pin1, pin2, a direction pin, a reset pin and a description; the interrupt resource list header includes an event number, a type, a PLC pin, a CPU pin, a description, a gpioPort and a gpioPin; the communication port list header includes a port name, a type, a sending pin, a receiving pin and a control pin; the compilation option interface includes a header file include, a hardware initialization interface function, a scan input interface function, a scan output interface function, a coil set interface function and a coil reset interface function;

[0053] The intermediate ladder diagram editing area is shown in the attached Figure 7 , including a program name display switching area, a program description, a label definition, a logic line comment and a logic line edit; the program name display switching area is used to: display the opened main program, subroutine or interrupt program, and click the program name to switch to the corresponding program interface, or right-click to hide the program; the program description is used to: annotate the currently edited program, and the fields include program name, author, date, and comment, which are displayed in the top line of the edit area; the label definition is used to: display a brief overview of the ladder diagram function on one side of the logic line in the edit area, and is also used to automatically generate a label under the quick index. Specifically, on the left side of the logic line in the edit area, it is a brief overview of a more complete function. The label will be automatically generated under the quick index and can be quickly located; the logic line comment is used to: annotate the program of the current logic line, and is designed at the top of each logic line; the logic line edit is used to: perform ladder diagram programming in this area, and the variables of each instruction are displayed below the corresponding instruction, and the multivariate operation instructions are displayed in the form of mathematical calculation formulas.

[0054] In the tree window on the left, subroutines and interrupt programs can be created and called by right-clicking and dragging in the tree structure, which is more intuitive and easier to learn than the conventional calling in the menu;

[0055] In the tree window on the right, the variable display and definition functions are designed. Compared with the conventional definition through the menu to call the variable dialog box, the user programming is more convenient and more intuitive to read; the PLC hardware configuration entry is designed in the IO pin list, which makes it easier for users to associate with this function and makes it easier for beginners to get started;

[0056] In the middle ladder diagram editing area, the designed variable display method and graphic element design method are different from conventional ladder diagram programming. Traditional graphic element instructions are mostly function block diagrams, which makes the overall layout messy. This patent uses the same basic graphic elements to express the relationship between multiple variables by displaying formulas below the instruction graphic elements, which is more intuitive and easier to understand.

[0057] An electronic device loaded with a development environment of a compiled programmable logic controller, characterized in that:

[0058] at least one processor; and a memory coupled to the at least one processor, the memory having instructions stored therein, the instructions, when executed by the at least one processor, causing the electronic device to perform actions for managing development jobs in a development environment, the actions comprising:

[0059] Classify the ladder diagram; design translation templates: design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates according to the classification of the ladder diagram, so as to translate the ladder diagram into corresponding C language programs; drive design: implement the functions involved in the working process of the programmable controller in C code respectively; generate C language program: translate the ladder diagram edited by the user into a C language program according to the translation template described in step S2, and then integrate it with the drive design described in step S3 into a complete C language program; compile the C language program: compile the C language program into a binary executable code through a compiler; download the executable file: burn the binary executable code into the programmable controller.

[0060] A computer program product for implementing a development environment for a compiled programmable logic controller, characterized in that the computer program product is tangibly stored on a non-transitory computer-readable medium and includes machine executable instructions, wherein the machine executable instructions are used to execute the above method.

[0061] The development environment management development operation method of the compiled programmable logic controller is characterized by comprising:

[0062] T1: Designing the database structure includes dividing the PLC configurable hardware resources into the following database entities and associated database entities;

[0063] like Fig.12 The database structure shown in Chen's diagram, according to the principle that the same entity in the database has the same entity attributes, divides the PLC configurable hardware resources into the following database entities, including: PLC model, general IO pin configuration, HSC pin configuration, communication resource pin, interrupt source configuration and driver interface configuration;

[0064] The PLC model refers to the series model name of the PLC hardware, which is visible when the user selects the model; the configuration attributes include the CPU type and the PLC model; the CPU type is STM32F103VET6; the PLC model is SK2109;

[0065] The general IO pin configuration includes configuring switch IO pins, analog IO pins, and high-speed pulse output pins; the common configuration attributes include IO type, symbol name, PLC variable name, CPU pin, CPU port number, CPU pin number, and description; the IO type includes switch input type DI, switch output type DO, analog input type AI, analog output type AQ, and high-speed pulse output type PWM; the symbol name is an alias given to the pin by the user and can be called in programming; the PLC variable names such as I0.0, Q2.1, and PWM0 can be directly called by the user; the CPU pins such as PA6 and P3.5 have different naming rules for different CPU types; the CPU port number and CPU pin number are parsed according to the CPU pin. If the CPU pin is PA6, the CPU port number is 1 and the CPU pin number is 6. If the CPU pin is P3.5, the CPU port number is 3 and the CPU pin number is 5; the description refers to the functional description of the configured pin;

[0066] The HSC pin configuration refers to the high-speed pulse input pin configuration, and has common configuration attributes including HSC name, pin 1, pin 2, direction pin, reset pin, and description; the HSC name is such as HSC0; the pin 1 refers to the first high-speed pulse input port, such as I0.3 / PC6; the pin 2 refers to the second high-speed pulse input port, such as I0.4 / PC7; the direction pin refers to the external direction control pin in the working mode of the HSC with the direction control function, which can be shared with pin 2 but is not compatible; the reset pin refers to the external reset pin in the working mode of the HSC with the external reset function; the description refers to the functional description of the HSC configuration pin;

[0067] The communication resource pins are used for serial communication, network communication and CAN communication, and have common configuration attributes including communication name, communication protocol, PLC pin, CPU pin, CPU port number, CPU pin number, and description; the communication name is an alias given to the communication configuration, which can be called by the user; the communication protocol is different for different communication port protocols, the serial communication protocol includes free protocol and Modbus protocol, the network communication protocol includes ProfiNet and EtherCat, and the CAN communication includes CANopen and standard CAN protocol;

[0068] The interrupt source configuration has common attributes including interrupt number, interrupt type, PLC pin, CPU pin, CPU port number, CPU pin number, and description; the interrupt number is the unique code of the interrupt source, such as INT0; the interrupt types include rising edge, falling edge, serial port receiving character, serial port receiving completion, serial port sending, timed interrupt for controlling time interval, timed interrupt for current time equal to preset value, high-speed counting interrupt for current value equal to preset value, high-speed counting interrupt for direction change, high-speed counting interrupt for external reset, and PTO pulse counting completion interrupt;

[0069] The driver interface configuration, configuration attributes include including header files, hardware initialization interface, scan input interface, scan output interface, coil set interface, coil reset interface; the included header file, such as #include "main.h"; the hardware initialization interface, such as PlcInit(); the scan input interface, such as readDIO (% gpioPort%, % gpioPin%, 0), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 0 represents low level valid; the scan output interface readDIO (% gpioPort%, %gpioPin%,1), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 1 represents high level valid; the coil setting interface is such as write(%gpioPort%, %gpioPin%,1), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 1 represents setting; the coil reset interface is such as write(%gpioPort%, %gpioPin%,0), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 0 represents reset;

[0070] The associated database entity includes: the PLC model and the IO pin configuration, HSC pin configuration, communication resource pin and interrupt source configuration are respectively in a 1-to-n association relationship, the PLC model and the drive interface configuration are in a 1-to-1 association relationship, and the interrupt source configuration and the general IO pin configuration and the HSC pin configuration are respectively in an m-to-n association relationship. Specifically, the PLC model and the general IO pin configuration are in a 1-to-n association relationship, that is, one-to-many, and a PLC model can be configured with multiple general IO pin configurations; the PLC model and the HSC pin configuration are in a 1-to-n association relationship, that is, one-to-many, and a PLC model can be configured with multiple HSC pin configurations; the PLC model and the communication resource pin are in a 1-to-n association relationship, that is, one-to-many, and a PLC model Multiple communication resource pins can be configured; the PLC model and interrupt source configuration are in a 1-to-n relationship, that is, one-to-many relationship. A PLC model can be configured with multiple interrupt source configurations; the PLC model and drive interface configuration are in a 1-to-1 relationship, that is, a PLC model can only correspond to one set of drive interfaces, and each drive interface is unique; the interrupt source configuration and general IO pin configuration are in an m-to-n relationship, that is, many-to-many relationship. There are multiple entries in an interrupt source configuration list that reference the configuration of the general IO port, and a general IO port configuration may be called in multiple interrupt sources; the interrupt source configuration and HSC pin configuration are in an m-to-n relationship, that is, many-to-many relationship. There are multiple entries in an interrupt source configuration list that reference the HSC pin configuration, and a HSC pin configuration may be called in multiple interrupt sources;

[0071] T2: Versatility-driven design

[0072] After configuring the hardware resources of the PLC, the database parameters are called during programming. Before forming the PLC user main program, a driver needs to be designed to identify the above configuration parameters; the universal driver design includes: universal IO driver design, universal functional instruction driver design, universal interrupt function design; the IO includes DI and DO; the functional instructions include timer instructions, counter instructions, PWM, PTO, HSC, and communication.

[0073] Preferably, according to the present invention, the universal IO driver design includes:

[0074] (1-1) Define an IO pin structure: The IO pin structure refers to a structure variable defined based on C language, and the IO port information is encapsulated in the structure. The IO pin structure is defined as tPin_IO, and the pin structure includes two members, one member is an unsigned 8-bit integer variable gpioPort, and the other member is an unsigned 8-bit integer variable gpioPin; tPin_IO is the name of the IO pin structure; gpioPort is the port number of the CPU pin; gpioPin is the pin number of the CPU pin;

[0075] (1-2) Instantiate the IO pin structure variable and define the number of members of the instantiated variable. According to the IO pin structure defined in step (1-1), instantiate a structure pointer variable named ioConf; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named ioCnt;

[0076] (1-3) Initialize the variables and structure pointer variables for the number of structure pointer variables. First, initialize the variable ioCnt for the number of structure pointer variables defined in step (1-2) according to the number of IO variables configured by the user; then, allocate space for the structure pointer variable ioConf through the malloc keyword according to the value of ioCnt and the memory size of the structure tPin_IO; finally, initialize the member variables gpioPort and gpioPin of the structure pointer variable ioConf according to the IO pin configuration parameters configured by the user;

[0077] (1-4) Design and implement the IO pin configuration interface and the read-write IO driver interface. According to the gpioPort, gpioPin and ioCnt initialized in step (1-3), design the IO pin configuration interface and the read-write IO driver interface.

[0078] The IO pin configuration interface process is: in the loop from 0 to ioCnt, a CPU pin is configured, and the configuration content includes configuring the pin clock, configuring the corresponding pin register and configuring the pin port register; the read-write IO driver interface finds the corresponding port according to gpioPort, and then calls the read-write register to perform the corresponding function operation;

[0079] Generally, the value of the CPU pin-related driver register can be inferred based on the port value port and pin value pin of the CPU pin, and the CPU port value port is gpioPort, and the CPU pin value pin is gpioPin. The values ​​of gpioPort and gpioPin are actually obtained by initializing the parameters configured by the user in step (1-3), so a universal IO pin configuration interface and read-write IO driver interface can be encapsulated; the calculation rules vary depending on the CPU, and need to be summarized and summarized according to the CPU chip user manual.

[0080] Preferably, according to the present invention, the general functional instruction driven design includes:

[0081] (2-1) defining a functional instruction structure, wherein the functional instruction structure refers to defining a structure variable based on C language, encapsulating the parameters involved in the functional instruction in a structure for easy management and calling, and the structure is named tFunc;

[0082] (2-2) Instantiate a functional instruction structure variable and define the number of members of the instantiated variable. According to the functional instruction structure defined in step (2-1), instantiate a structure pointer variable named pFunc; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named cntFunc;

[0083] (2-3) Initializing the variables and structure pointer variables for the number of structure pointer variables, firstly, according to the number of function instruction variables called in the user programming, initialize the variable cntFunc for the number of structure pointer variables defined in step (2-2); then, according to the value of cntFunc and the memory size of the structure tFunc, allocate space for the structure pointer variable pFunc through the malloc keyword; finally, initialize the member variables of the structure pFunc according to the configuration of the function instruction parameters called in the user programming; preferably, if there are parameters related to hardware port information in the functional instruction structure, call the relevant configuration data to initialize the member variables related to the hardware configuration of pFunc;

[0084] (2-4) Design and implement a functional instruction initialization interface and a driver interface. According to the pFunc and cntFunc initialized in step (2-3), design a functional instruction initialization interface and a driver interface; initialize corresponding function registers according to the different types of CPU pins used for different functions; the driver interface is called when the user configures the driver interface.

[0085] Preferably, according to the present invention, the universal interrupt function design includes:

[0086] (3-1) Interrupt function macro definition. When a user calls an interrupt interface, an interrupt macro is first defined. The interrupt interface called by the user must be defined in the above interrupt resource configuration before it can be called. The interrupt macro refers to the macro definition representing a certain interrupt, such as the macro of the timer interrupt is named USE_PLCINT_T0_TIM.

[0087] (3-2) Define the interrupt service function. When the user calls the interrupt interface, define another interrupt service function. For example, the interrupt service function of the timer interrupt is named PLCINT_T0_IRQHandler(). The interrupt program written by the user in the ladder diagram programming is converted from the ladder diagram language to C language to generate a C language interrupt program, and this C language interrupt program is encapsulated in the above interrupt service function;

[0088] (3-3) Predeclare the interrupt service function. According to the interrupt macro in step (3-1), the interrupt service function is predeclared using the conditional compilation method to facilitate the interrupt service function to be called in other files;

[0089] (3-4) Preprocessing the basic functions of interrupt service. Each interrupt function needs to do some basic function processing in advance to pave the way for user interrupt service functions, such as clock initialization of timing interrupt. In order to facilitate the implementation of the basic functions, combined with the interrupt macro in step (3-1), conditional compilation is used for preprocessing. The conditions of the conditional compilation described here are all the middle macros in (3-1), which is just a conditional compilation to pre-declare the interrupt service function and a conditional compilation to preprocess the basic functions of the interrupt service.

[0090] The technical advantages of the present invention are:

[0091] 1. Regarding the development environment of the compiled programmable logic controller of the present invention:

[0092] High efficiency, the ladder diagram elements are directly translated into C language, and then compiled and executed. It belongs to direct compilation and execution, which greatly improves the execution efficiency.

[0093] Meeting a variety of development scenarios, the present invention is a form of low-code development, which is not only suitable for ladder diagrams, but also provides a technical idea for researchers of low-code development based on graphics. Therefore, it is easier to realize mixed programming of ladder diagrams and C language. Due to the flexibility of C language, it can meet the actual needs of engineering and technical personnel to the greatest extent, especially in situations where algorithm integration is required.

[0094] Meeting market application expectations: The present invention makes it easier for PLC developers to add new functional instructions and quickly adapt to market application needs.

[0095] 2. For the software interface framework design method of the development environment:

[0096] The present invention places the operation buttons for creating new subroutines and new interrupt programs together with the index directory, rather than in the menu bar and toolbar, which makes it easier for programmers to learn and operate; similarly, the PLC resource configuration button is placed together with the IO list to facilitate programmers to find and use functions. The program description information is placed at the top of the editing area, rather than in the form of a commonly used technical dialog box, which is easier to read; the variable display is placed in the tree form on the right, rather than in the conventional pop-up dialog box, which is more convenient for users to consult; there are multiple ways to define the variable position. Click "+" in the variable display bar on the right to add a new variable, or double-click the primitive to add related variables during ladder diagram programming, which is more convenient for users to operate.

[0097] The present invention designs a universal adaptive dialog box template, so that one design can be used in any occasion; the present invention adopts a database storage method, which is easier to call, store and manage than conventional file storage; the interrupt program function of the present invention, compared with the design of conventional PLC, abandons the instruction association method, but associates by creating an interrupt program dialog box, which is more intuitive and easier to understand.

[0098] 3. The development environment management development operation method according to the present invention:

[0099] The present invention stores the hardware resource information configured by the programming software end in a database, and calls the corresponding configuration information in the database when the user is programming, generates PLC execution code, downloads it, and executes it, without downloading all parameters to the memory of the PLC, thus saving memory space and improving work efficiency.

[0100] The database-based hardware resource configuration method of the present invention adds interrupt resource configuration and driver interface configuration, solves the problem of inconsistent driver interfaces for the same function of different CPUs, and is more convenient for rapid construction of PLC.

[0101] The present invention is designed from three perspectives: universal IO drive design, universal functional instruction drive design, and universal interrupt function design, and adopts a process-based design concept. The process-based design can realize rapid customization of PLC kernel drive. BRIEF DESCRIPTION OF THE DRAWINGS

[0102] Figure 1 is the basic flow chart of the present invention;

[0103] Figure 2 Schematic diagram of the main interface of the development environment of the present invention, S1 is the menu bar, S2 is the tool bar, S3 is the tree form on the left, S4 is the tree form on the right, and S5 is the ladder diagram editing area in the middle;

[0104] Figure 3 It is the dialog box for creating a subroutine;

[0105] Figure 4 It is to create the interrupt procedure dialog box;

[0106] Figure 5 It is a quick index diagram;

[0107] Figure 6 It is the PLC hardware configuration dialog box, S6 is the main interface of the PLC hardware configuration dialog box, S7 is the pin definition configuration part, S8 is the interrupt resource configuration part, S9 is the communication port configuration part, and S10 is the compilation option configuration part;

[0108] Figure 7 It is a schematic diagram of the ladder diagram editing area, S11 is the program name display switching area, S12 is the program description, S13 is the logic line comment, S14 is the label definition, and S15 is the logic line editing area;

[0109] Figure 8 It is the ladder diagram design of the test program of "Example 2", S16 is the main program, S17 is the subroutine, and S18 is the interrupt program;

[0110] Fig. 9 It is a schematic diagram of the key code of the ladder diagram to C code of the test program of "Example 2"; S19 is the header file, function declaration and global variable definition code, wherein S19-1 is the header file, S19-2 is the sub-function declaration, S19-3 is the digital input and output global variable definition, and S19-4 is the coil output memory variable global declaration; S20 is the main function content, wherein S20-1 is the external interrupt pin initialization, S20-2 is the space allocation, array length initialization and structure body variable initialization of the switch input and output data structure array, S20-3 is the PLC other drive initialization, S20-4 is the main loop area, wherein S20-4-1 is the scan input variable, and S20-4-2, S20-4-3 and S20-4-4 realize the coil output function;

[0111] Fig.10 This is a schematic diagram of the test program compilation process of "Example 2";

[0112] Fig.11 This is a schematic diagram of the test program download process of "Example 2";

[0113] Fig.12 It is Chen's diagram of database structure;

[0114] Fig.13 It is a schematic diagram of key codes of steps (1-1), (1-2) and (1-3) of a general IO driver design implementation example;

[0115] Fig.14 It is the IO configuration workflow diagram in steps (1-4) of the general IO driver design embodiment;

[0116] Fig.15 It is a flowchart of the reading IO workflow in steps (1-4) of the general IO driver design embodiment;

[0117] Fig.16 It is a schematic diagram of key codes of a general functional instruction-driven design implementation example;

[0118] Fig.17 It is a schematic diagram of the key codes of a general interrupt function design implementation example.

[0119] Fig.18 This is the ladder diagram based on GX Works2 in step U1 of the "Comparison Test";

[0120] Fig.19 This is the operation result diagram based on the interpretive PLC in step U1 of the "comparative test";

[0121] Fig. 20 It is a ladder diagram based on the newlad of the present invention in the "comparative test" step U2;

[0122] Fig.21 It is a diagram of the operation result of the compiled PLC based on the present invention in the "comparative test" step U2;

[0123] Fig. 22 It is the ladder diagram based on GX Works2 in step U3 of the "Comparison Test";

[0124] Fig.23 This is the operation result diagram based on the interpretive PLC in step U3 of the "comparative test";

[0125] Fig.24 It is a ladder diagram based on the newlad of the present invention in the "comparative test" step U4;

[0126] Fig.25 It is a diagram of the operation result of the compiled PLC based on the present invention in the "comparative test" step U4;

[0127] Fig.26 It is the ladder diagram based on GX Works2 in step U5 of the "Comparison Test";

[0128] Fig. 27 This is the operation result diagram based on the interpretive PLC in step U5 of the "comparative test";

[0129] Fig.28 It is a ladder diagram based on the newlad of the present invention in the "comparative test" step U6;

[0130] Fig.29 It is a diagram of the operation result of the compiled PLC based on the present invention in the "comparative test" step U6;

[0131] Fig.30 This is a comparison chart of the single instruction result analysis in step U7 of the "Comparative Test". DETAILED DESCRIPTION

[0132] The present invention will be described in detail below with reference to the embodiments and the accompanying drawings, but is not limited thereto.

[0133] Embodiment 1,

[0134] A development environment for a compiled programmable logic controller, comprising:

[0135] like Figure 1 As shown,

[0136] S1: Classify the ladder diagram:

[0137] It is initially divided into: basic instructions, functional module instructions, functional units, variable management units and resource configuration units;

[0138] The basic instructions include bit logic operation instructions, comparison operation instructions, arithmetic operation instructions, shift operation instructions and data block transfer instructions; the bit logic operation instructions include normally open contact LD, normally closed contact LDN, rising edge pulse LDP, falling edge pulse LDF, coil output =, coil set S and coil reset R; the comparison operation instructions include greater than GT, less than LT, greater than or equal to GE, less than or equal to LE, equal to EQ, not equal to NE; the arithmetic operation instructions include addition ADD, subtraction SUB, multiplication MUL, division DIV, remainder MOD; the shift instructions include left shift SHL, right shift SHR, circular left shift ROL, circular right shift ROR; the data block transfer instructions include assignment MOV;

[0139] The functional module instructions include timer instructions, counter instructions, pulse output instructions, serial port communication instructions, free protocol instructions, ModBusRTU protocol instructions and interrupt instructions; the timer instructions include ordinary timer TP, on-delay timer TON, on-delay timer TONR with memory, and off-delay timer TOF; the counter includes add counter CU, subtract counter CD and high-speed counter HSC; the pulse output includes pulse width modulation PWM and pulse train output PTO; the serial port communication instructions include serial port setting S_COM, serial port enable EN_COM, and serial port disable DIS_COM; the free protocol instructions include encapsulation and transmission SND and unpacking UPK; the ModBusRTU protocol instructions include modbus protocol encapsulation and transmission instructions MB_SND and modbus protocol unpacking instructions MB_UPK; the interrupt instructions include interrupt enable ENI and interrupt disable DISI;

[0140] The functional units include a subprogram unit, an interrupt program unit, a C language program unit, and a function link library unit;

[0141] The variable management unit is divided into I area, Q area, M area, SM area, V area, AI area, AQ area, T area, C area, HC area and S area according to the storage area; it is divided into global variables, local variables and power-off preservation variables according to the storage type; the I area refers to the switch input image area; the Q area refers to the switch output image area; the M area refers to the auxiliary register image area; the V area refers to the user-defined global variable image area; the AI ​​area refers to the analog input image area; the AQ area refers to the analog output image area; the T area refers to the timer variable image area; the C area is the counter variable image area; the HC is the high-speed counter variable image area; the S area refers to the sequential control relay image area;

[0142] The resource configuration unit includes pin definition, HSC definition, interrupt resource, communication port and compilation option; the pin definition configuration includes digital input and output pins, analog input and output pins, and high-speed pulse output pins; the HSC definition configuration refers to the high-speed pulse input function pin configuration; the interrupt resource configuration refers to the interrupt resource of the PLC, and the configurable interrupt types include rising edge, falling edge, HSC count completion, HSC direction change, HSC external reset, timed interrupt, timed to interrupt, PTO count completion, serial port receiving character, serial port receiving completion, and serial port sending; the communication port configuration includes serial port, network port, and CAN port; the configuration of the compilation option refers to the relevant configuration options required for compilation after the ladder diagram is translated into C language, including header file inclusion class interface, hardware initialization interface, scan input interface, scan output interface, coil setting interface, and coil reset interface;

[0143] Further divided into: basic instructions are divided into type 1 basic conditional type and type 2 basic output type; the basic conditional type refers to a type of instruction representing a condition in a logic line of the ladder diagram, including the open contact LD, normally closed contact LDN, rising edge pulse LDP, falling edge pulse LDF and comparison operation instructions of the bit logic operation instruction; the basic output type refers to a type of instruction representing output in a logic line of the ladder diagram, including the coil output =, coil set S, coil reset R of the bit logic operation instruction, arithmetic operation instructions, shift operation instructions and data block transfer instructions;

[0144] All the functional module instructions are used as type 3 functional instruction output type. The functional instruction output type means that an execution function is represented in a logic line of the ladder diagram. The function is not just a simple logical operation, but implements a functional module like a function. For example, the ordinary timer instruction TP can work normally when the timing time is configured during programming, but the C language driver part needs to do a lot of function implementation work; the functional instruction output type includes timer instructions, counter instructions, pulse output instructions and interrupt instructions;

[0145] The functional units are divided into type 4 subroutine type and type 5 link type; the subroutine type includes subroutine unit and interrupt program unit; the link type includes C language program unit and function link library unit;

[0146] All the variable management units are used as type 6 variable models, where the variable models refer to storage units used in ladder diagram programs, including global variables, local variables, and power-off save variables;

[0147] The resource configuration unit is divided into type 7 pin configuration model and type 8 driver interface type; the pin configuration model means that the configuration corresponds to the hardware port, including digital input and output pins, analog input and output pins, high-speed pulse input and output pins, serial ports, network ports, and CAN ports; the driver interface type refers to the function interface of each functional module encapsulated in C language;

[0148] S2: Design translation templates: According to the further classification of the ladder diagram in step S1, design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates respectively, for translating the ladder diagram into corresponding C language programs;

[0149] S3: Driver design: Implement C code for the functions involved in the working process of the programmable controller, including digital input data reading, digital output data writing, analog input data processing, analog output control, basic timer function implementation, basic counter function implementation, high-speed pulse input function implementation, high-speed pulse output function implementation, serial port driver and protocol encapsulation function implementation, network port driver and protocol encapsulation function implementation, CAN driver and protocol encapsulation function implementation;

[0150] S4: Generate C language program: translate the ladder diagram edited by the user into C language code according to the translation template described in step S2, that is, call the main program main after the ladder diagram is translated into C; then call the C code generated by the driver design described in step S3 in main, and then form a complete set of C language program;

[0151] S5: Compile C language program: compile the C language code program into binary executable code through a compiler;

[0152] The C language program is compiled by "GCC+Makefile" compilation; GCC is the abbreviation of GCC cross-compilation tool, which is a link library generated by cross-compilation of actual CPU products, such as STM32 using gcc-arm-none-eabi tool; Makefile is the abbreviation of the compilation process customized according to the CPU product; the compilation process includes: target variable definition, C source code file location, S startup file location, compilation tool association, special flag processing, H header file location, library generation processing and clearing function pseudo code;

[0153] S6: Download executable file: burn the binary executable code into the programmable controller.

[0154] Preferably according to the present invention, the basic conditional template is the "if (condition)" part in the "if (condition) {function body}" format, for example, the normally open contact of the switch key can be translated into "if (key_val == 1)", and the normally closed contact of the switch key can be translated into "if (key_val == 0)", and the value of the key_val is realized by writing a switch input driver; in particular, the rising edge and falling edge instructions need to consider the state memory problem on the basis of the above template, for example, the rising edge of the switch key can be translated into "if ((key_val_new == 1) && (key_val_old == 0)) key_val_old = key_val_new", and the falling edge of the switch key can be translated into "if ((key_val_new == 0) && (key_val_old == 1)) key_val_old = key_val_new", the key_val_new refers to the read value of the current switch quantity, and the key_val_old refers to the read value of the switch quantity in the previous scanning cycle.

[0155] The basic output template is the "{function body}" part in the "if (condition) {function body}" format. For example, the coil setting of the indicator light Q can be translated into "{write_Q, out_val}", and the operation of write_Q is implemented by writing a switch output driver, and the out_val is obtained by writing a switch input driver; for example, the addition instruction can be translated into "{C=A+B}", and C must be a variable, and A and B can be variables or values; in particular, the coil output instruction needs to consider the double coil output problem based on the above template, specifically, on the basis of the coil setting, a reverse judgment is added, for example, the coil output of the indicator light Q can be translated into "{write_Q, out_val, temp_out_val; if (!temp_out_val)!write_Q,!out_val; temp_out_val=0;}"; the temp_out_val is the auxiliary memory value of out_val, and the "!+variable" means to invert the value of the variable.

[0156] The functional instruction output template includes: (1) structure definition, wherein the structure refers to the variables required by the corresponding function being encapsulated in a structure, for example, the structure content of the timer-related instruction includes the start / stop flag, time base, counter type, stop flag, load flag, timing flag, count variable and pre-loaded value variable; (2) structure array and structure array length definition, wherein the structure array definition refers to making a global definition in the C file of the timer driver program first, and the structure array length definition refers to making a global definition in the C file of the timer driver program first; (3) structure array and structure array length declaration, wherein the structure array length declaration refers to making a global declaration in the H file of the timer driver program first, and the structure array declaration refers to making a global declaration in the H file of the timer driver program first; (4) defining and implementing an interface function, wherein the interface function is an interface function called in the main loop body when the ladder diagram is translated into C language; in particular, for functions that need to be completed in an interrupt, it is not necessary to design an interface function.

[0157] The subroutine type template refers to generating a function interface of a C language program from a ladder diagram subroutine for calling by a main function or a function associated therewith; in particular, an interrupt subroutine needs to generate an interrupt function interface of a C language program, which can be executed without calling.

[0158] The link type template refers to encapsulating a function into a link port, and other functions directly call the link port; in particular, the link port in the link library unit is already encapsulated and does not need to be encapsulated again, and can be directly called.

[0159] The variable model template refers to defining the user's variable definition according to the variable definition rules of C language, and translating the PLC variable type into the C language data type one by one, such as the PLC's "signed integer" is translated into C language as "int"; in particular, power-off preservation variables need to save data in flash to prevent power loss.

[0160] The pin configuration model template refers to the configuration of one-to-one correspondence between the hardware pins of the PLC and the pins of the CPU, such as the digital input pin I0.0, the corresponding CPU pin is P1.0; in particular, the encoder mode of the high-speed counter instruction requires 2 or 3 pins, so 2 or 3 pins need to be configured.

[0161] The driver interface type template refers to directly configuring and calling the driver interface of the bottom layer encapsulation according to the reference format, such as scanning the input interface as read(%gpioPort%, %gpioPin%, 0), where the variable between the two percent signs belongs to the pin configuration configured by the user in the reference database.

[0162] In the step S6, the downloading method of the executable file includes a wireless method or a wired method; the wireless method refers to the OTA download method; the wired method refers to the Jlink download method, specifically, it is implemented by using the syntax instructions of the JLINK-Commander.

[0163] Embodiment 2,

[0164] The software interface framework design method of the development environment as described in Example 1 includes:

[0165] Menu bar, toolbar, tree window on the left, tree window on the right, ladder diagram editing area in the middle, such as Figure 2 As shown;

[0166] The menu bar includes a project menu, an edit menu, a compile menu and a help menu; the project menu includes new, open, save and print; the edit menu includes undo and restore; wherein the compile menu includes a build function and a download function, wherein the build function is used to convert the target ladder diagram to C language and compile the C language into binary executable code;

[0167] The toolbar includes engineering tools, editing tools and compiling tools; the engineering tools include new, open, save and print; the editing tools include undo and restore; the compiling tools include build and download functions; the toolbar functions are consistent with the menu functions;

[0168] The tree window on the left includes a first-level branch ladder program and a component box; the first-level ladder program includes a second-level branch main program, a subprogram, an interrupt program and a quick index; the main program is used to: when the middle ladder editing area is in the subprogram or interrupt program interface, by clicking the "main program" editing area to switch to the main program editing interface; the subprogram is used to: when adding a subprogram, create a subprogram, when the user needs to add a subprogram, right-click "Add" to pop up a dialog box for creating a subprogram, the dialog box for creating a subprogram includes a name, author, date, remarks, and a confirmation button, see the attached Figure 3 , the created subroutine names are listed below the subroutine secondary branch, belonging to the third-level branch, and the main interface can be switched to the corresponding subroutine interface by clicking the subroutine index name, or the subroutine can be called by dragging the subroutine name; the interrupt program is used to: when an interrupt program needs to be added, create an interrupt program dialog box, right-click "Add" to pop up the create interrupt program dialog box, the create interrupt program dialog box includes name, interrupt resource, description, author, date, remarks and OK button, see attached Figure 4The names of interrupt programs created by the user are listed below the secondary branch of the interrupt program, belonging to the third-level branch, and the main interface can be switched to the corresponding interrupt program interface by clicking the interrupt program index name; the quick index is used to: list the program function index directory of the main program, subprogram or interrupt program displayed on the current main interface, see the attached Figure 5 ; The component box is used to: list the instruction graphic elements used in the ladder diagram, including bit logic operation instructions, comparison operation instructions, arithmetic operation instructions, shift operation instructions, data block transfer instructions, timers, pulse outputs, serial port communications, ModbusRTU protocols and interrupt instructions; and is also used to drag the instruction graphic element corresponding to the instruction to the editing interface area through the signal input hardware for placement;

[0169] The tree form on the right includes a global variable table, a local variable table, a timer list, a counter list, PWM, COM, system variables, an IO variable table and a PLC resource configuration button; the global variable table includes user-defined global variables and power-off save variables, and is also used to click on the global variable table to create a new global variable, for example, by clicking the "+" button of the row to create a new global variable; the local variable table is used to list the local variables defined by the current main interface program, and the table changes with the switching of the main interface program, and is also used to create a new local variable by clicking on the local variable table, and clicking the "+" button of the row to create a new local variable; the timer list is used to list the timer type variables defined in the program; the counter list is used to list the counter type variables defined by the program; the PWM list is used to list the PWM type variables defined by the program; the COM list is used to list the COM type variables defined by the program; the system variables are used to list the global available variables that the system has defined and can be used without program definition; the IO variable table is used to: list the IO pins owned by the PLC hardware supported by the current project, including symbol names and pin names; the PLC resource configuration button is used for PLC hardware configuration, see Appendix Figure 6, after clicking, a PLC hardware configuration dialog box pops up, the PLC hardware configuration dialog box includes a PLC type list part, a "Use this PLC" button, a "Rename" button, a "Delete this PLC" button, a "Add PLC" button, a pin definition list, an HSC definition list, an interrupt resource list, a communication port list and a compilation option interface; the pin definition list header includes a serial number, a type, a display name, a PLC variable name, a CPU pin, a remark, a CPU port number and a CPU pin number; the HSC definition list header includes a name, pin1, pin2, a direction pin, a reset pin and a description; the interrupt resource list header includes an event number, a type, a PLC pin, a CPU pin, a description, a gpioPort and a gpioPin; the communication port list header includes a port name, a type, a sending pin, a receiving pin and a control pin; the compilation option interface includes a header file include, a hardware initialization interface function, a scan input interface function, a scan output interface function, a coil set interface function and a coil reset interface function;

[0170] The intermediate ladder diagram editing area is shown in the attached Figure 7 , including program name display switching area, program description, label definition, logic line comment and logic line editing; the program name display switching area is used to display the opened main program subroutine or interrupt program, and click the program name to switch to the corresponding program interface, or right-click to hide the program; the program description is used to annotate the currently edited program, and the fields include program name, author, date, and comment, which are displayed in the top line of the editing area; the label definition is used to display a brief overview of the ladder diagram function on one side of the logic line in the editing area, and is also used to automatically generate a label under the quick index. Specifically, on the left side of the logic line in the editing area, it is a brief overview of a more complete function. The label will be automatically generated under the quick index and can be quickly located; the logic line comment is used to annotate the program of the current logic line, and is designed at the top of each logic line. The logic line editing is used to perform ladder diagram programming in this area, and the variables of each instruction are displayed below the corresponding instruction, and the multivariate operation instructions are displayed in the form of mathematical calculation formulas.

[0171] like Figure 8-11 , the technical solutions described in Examples 1 and 2 are used to demonstrate the implementation process of the entire compilation as follows: Figure 8 It is the ladder diagram design of the test program, S16 is the main program, S17 is the subroutine, and S18 is the interrupt program; Fig. 9It is a key code diagram for converting the ladder diagram of the test program to C code; S19 is the header file, function declaration and global variable definition code, among which S19-1 is the header file, S19-2 is the sub-function declaration, S19-3 is the digital input and output global variable definition, and S19-4 is the coil output memory variable global declaration; S20 is the main function content, among which S20-1 is the external interrupt pin initialization, S20-2 is the space allocation, array length initialization and structure body variable initialization of the switch input and output data structure array, S20-3 is the PLC other driver initialization, S20-4 is the main loop area, among which S20-4-1 is the scan input variable, S20-4-2, S20-4-3 and S20-4-4 realize the coil output function; Fig.10 It is a schematic diagram of the test program compilation process; Fig.11 This is a schematic diagram of the test program download process.

[0172] Embodiment 3,

[0173] An electronic device loaded with a development environment of a compiled programmable logic controller, at least one processor; and a memory coupled to the at least one processor, the memory having instructions stored therein, the instructions when executed by the at least one processor causing the electronic device to perform actions for managing development jobs in the development environment, the actions comprising:

[0174] Classify the ladder diagram; design translation templates: design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates according to the classification of the ladder diagram, so as to translate the ladder diagram into corresponding C language programs; drive design: implement the functions involved in the working process of the programmable controller in C code respectively; generate C language program: translate the ladder diagram edited by the user into a C language program according to the translation template described in step S2, and then integrate it with the drive design described in step S3 into a complete C language program; compile the C language program: compile the C language program into a binary executable code through a compiler; download the executable file: burn the binary executable code into the programmable controller.

[0175] Embodiment 4,

[0176] A computer program product implementing a development environment for a compiled programmable logic controller is tangibly stored on a non-transitory computer-readable medium and includes machine executable instructions for executing the above method.

[0177] Embodiment 5,

[0178] The development environment management development operation method of the compiled programmable logic controller as described in Example 1-2 includes:

[0179] T1: Designing the database structure includes dividing the PLC configurable hardware resources into the following database entities and associated database entities;

[0180] like Fig.12 The database structure shown in Chen's diagram, according to the principle that the same entity in the database has the same entity attributes, divides the PLC configurable hardware resources into the following database entities, including: PLC model, general IO pin configuration, HSC pin configuration, communication resource pin, interrupt source configuration and driver interface configuration;

[0181] The PLC model refers to the series model name of the PLC hardware, which is visible when the user selects the model; the configuration attributes include the CPU type and the PLC model; the CPU type is STM32F103VET6; the PLC model is SK2109;

[0182] The general IO pin configuration includes but is not limited to configuring switch IO pins, analog IO pins, and high-speed pulse output pins; the common configuration attributes include IO type, symbol name, PLC variable name, CPU pin, CPU port number, CPU pin number, and description; the IO type includes but is not limited to switch input type DI, switch output type DO, analog input type AI, analog output type AQ, and high-speed pulse output type PWM; the symbol name is an alias given to the pin by the user and can be called in programming; the PLC variable names such as I0.0, Q2.1, and PWM0 can be directly called by the user; the CPU pins such as PA6 and P3.5 have different naming rules for different CPU types; the CPU port number and CPU pin number are parsed according to the CPU pin. If the CPU pin is PA6, the CPU port number is 1 and the CPU pin number is 6. If the CPU pin is P3.5, the CPU port number is 3 and the CPU pin number is 5; the description refers to the functional description of the configured pin;

[0183] The HSC pin configuration refers to the high-speed pulse input pin configuration, and has common configuration attributes including HSC name, pin 1, pin 2, direction pin, reset pin, and description; the HSC name is such as HSC0; the pin 1 refers to the first high-speed pulse input port, such as I0.3 / PC6; the pin 2 refers to the second high-speed pulse input port, such as I0.4 / PC7; the direction pin refers to the external direction control pin in the working mode of the HSC with the direction control function, which can be shared with pin 2 but is not compatible; the reset pin refers to the external reset pin in the working mode of the HSC with the external reset function; the description refers to the functional description of the HSC configuration pin;

[0184] The communication resource pins are used for serial port communication, network port communication and CAN communication, and have common configuration attributes including communication name, communication protocol, PLC pin, CPU pin, CPU port number, CPU pin number, and description; the communication name is an alias given to the communication configuration, which can be called by the user; the communication protocol is different for different communication port protocols, the serial port communication protocol includes but is not limited to the free protocol and Modbus protocol, the network port communication protocol includes but is not limited to ProfiNet and EtherCat, and the CAN communication includes but is not limited to CANopen and standard CAN protocol;

[0185] The interrupt source configuration has common attributes including interrupt number, interrupt type, PLC pin, CPU pin, CPU port number, CPU pin number, and description; the interrupt number is the unique code of the interrupt source, such as INT0; the interrupt type includes but is not limited to rising edge, falling edge, serial port receiving character, serial port receiving completion, serial port sending, timed interrupt for controlling time interval, timed interrupt for current time equal to preset value, high-speed counting interrupt for current value equal to preset value, high-speed counting interrupt for direction change, high-speed counting interrupt for external reset, and PTO pulse counting completion interrupt;

[0186] The driver interface configuration, configuration attributes include but are not limited to include header files, hardware initialization interface, scan input interface, scan output interface, coil set interface, coil reset interface; the included header file, such as #include "main.h"; the hardware initialization interface, such as PlcInit(); the scan input interface, such as readDIO (% gpioPort%, % gpioPin%, 0), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 0 represents low level valid; the scan output interface readDIO (% gpioPort %, %gpioPin%, 1), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 1 represents high level valid; the coil setting interface is such as write(%gpioPort%, %gpioPin%, 1), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 1 represents setting; the coil reset interface is such as write(%gpioPort%, %gpioPin%, 0), where gpioPort represents the CPU port number, gpioPin represents the CPU pin number, and 0 represents reset;

[0187] The associated database entity includes: the PLC model and the IO pin configuration, HSC pin configuration, communication resource pin and interrupt source configuration are respectively in a 1-to-n association relationship, the PLC model and the drive interface configuration are in a 1-to-1 association relationship, and the interrupt source configuration and the general IO pin configuration and the HSC pin configuration are respectively in an m-to-n association relationship. Specifically, the PLC model and the general IO pin configuration are in a 1-to-n association relationship, that is, one-to-many, and a PLC model can be configured with multiple general IO pin configurations; the PLC model and the HSC pin configuration are in a 1-to-n association relationship, that is, one-to-many, and a PLC model can be configured with multiple HSC pin configurations; the PLC model and the communication resource pin are in a 1-to-n association relationship, that is, one-to-many, and a PLC model Multiple communication resource pins can be configured; the PLC model and interrupt source configuration are in a 1-to-n relationship, that is, one-to-many relationship. A PLC model can be configured with multiple interrupt source configurations; the PLC model and drive interface configuration are in a 1-to-1 relationship, that is, a PLC model can only correspond to one set of drive interfaces, and each drive interface is unique; the interrupt source configuration and general IO pin configuration are in an m-to-n relationship, that is, many-to-many relationship. There are multiple entries in an interrupt source configuration list that reference the configuration of the general IO port, and a general IO port configuration may be called in multiple interrupt sources; the interrupt source configuration and HSC pin configuration are in an m-to-n relationship, that is, many-to-many relationship. There are multiple entries in an interrupt source configuration list that reference the HSC pin configuration, and a HSC pin configuration may be called in multiple interrupt sources;

[0188] T2: Versatility-driven design

[0189] After configuring the hardware resources of the PLC, the database parameters are called during programming. Before forming the PLC user main program, a driver needs to be designed to identify the above configuration parameters; the universal driver design includes: universal IO driver design, universal functional instruction driver design, universal interrupt function design; the IO includes but is not limited to DI and DO; the functional instructions include but are not limited to timer instructions, counter instructions, PWM, PTO, HSC, and communication.

[0190] The general IO driver design includes:

[0191] (1-1) Fig.13As shown, define the IO pin structure: the IO pin structure refers to defining a structure variable based on C language, encapsulating the IO port information in the structure, and the IO pin structure is defined as tPin_IO, which includes two members, one member is an unsigned 8-bit integer variable gpioPort, and the other member is an unsigned 8-bit integer variable gpioPin; tPin_IO is the name of the IO pin structure; gpioPort is the port number of the CPU pin; gpioPin is the pin number of the CPU pin;

[0192] (1-2) Instantiate the IO pin structure variable and define the number of members of the instantiated variable. According to the IO pin structure defined in step (1-1), instantiate a structure pointer variable named ioConf; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named ioCnt; Fig.13 As shown in L2 and L3;

[0193] (1-3) Initialize the variables and structure pointer variables for the number of structure pointer variables. First, initialize the variable ioCnt for the number of structure pointer variables defined in step (1-2) according to the number of IO variables configured by the user; Fig.13 As shown in L4 in the figure; then according to the value of ioCnt and the memory size of the structure tPin_IO, the malloc keyword is used to allocate space for the structure pointer variable ioConf, as shown in Fig.13 As shown in L5 in the figure; finally, the member variables gpioPort and gpioPin of the structure pointer variable ioConf are initialized according to the IO pin configuration parameters configured by the user, as shown in Fig.13 As shown in L6;

[0194] (1-4) Design and implement the IO pin configuration interface and the read-write IO driver interface. According to the gpioPort, gpioPin and ioCnt initialized in step (1-3), design the IO pin configuration interface and the read-write IO driver interface.

[0195] The IO pin configuration interface process is: in the loop from 0 to ioCnt, a CPU pin is configured, and the configuration content includes configuring the pin clock, configuring the corresponding pin register and configuring the pin port register; the read-write IO driver interface finds the corresponding port according to gpioPort, and then calls the read-write register to perform the corresponding function operation;

[0196] like Fig.14The figure shows a configuration workflow diagram using the STM32F103 series CPU as an example; the read-write IO driver interface finds the corresponding port according to the gpioPort, and then calls the read-write register to perform the corresponding function operation, such as Fig.15 The following is a flowchart of the read IO workflow using the STM32F103 series CPU as an example; Fig.15 The input parameter flag indicates the effective level value. If flag is equal to 0, it indicates that the low level is effective, that is, when the scan input function pin register reads the value of 0, it returns 1, and when the scan input function pin register reads the value of 1, it returns 0; if flag is equal to 1, it indicates that the high level is effective, that is, when the scan input function pin register reads the value of 1, it returns 1, and when the scan input function pin register reads the value of 0, it returns 0; since the input parameters of the scan input function are obtained by the user through hardware resource configuration, the driver interface is a general scan input driver interface based on the STM32F103 series CPU;

[0197] Design the IO pin configuration interface and read / write IO driver interface according to the gpioPort, gpioPin and ioCnt initialized in S3;

[0198] Generally, the value of the CPU pin-related driver register can be inferred based on the port value port and pin value pin of the CPU pin, and the CPU port value port is gpioPort, and the CPU pin value pin is gpioPin. The values ​​of gpioPort and gpioPin are obtained by initializing the parameters configured by the user in step (1-3), so a universal IO pin configuration interface and read-write IO driver interface can be encapsulated; the calculation rules vary from CPU to CPU, and need to be summarized and summarized according to the CPU chip user manual. Fig.14 The clock value of the pin can be obtained by shifting "1" left by "gpioPort plus 1" bits; the value of the pin register is obtained by shifting "1" left by "gpioPin" bits; the port register value is the value of the external time base 2 "APB2PERIPH_BASE" plus "gpioPort plus 1", and then shifting it left by 10 bits.

[0199] like Fig.16 As shown, taking the PWM function instruction as an example, the general functional instruction drive design includes:

[0200] (2-1) Define a functional instruction structure. The functional instruction structure refers to defining a structure variable based on C language, encapsulating the parameters involved in the functional instruction in a structure for easy management and calling. The structure is named tFunc; Fig.16 As shown in L7, the structure name is PWM;

[0201] (2-2) Instantiate a functional instruction structure variable and define the number of members of the instantiated variable. According to the functional instruction structure defined in step (2-1), instantiate a structure pointer variable named pFunc; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named cntFunc; Fig.16 As shown in L8, the structure pointer is named tPwm, and the number variable is pwmCnt;

[0202] (2-3) Initializing the variables and structure pointer variables for the number of structure pointer variables, firstly, according to the number of function instruction variables called in the user programming, initialize the variable cntFunc for the number of structure pointer variables defined in step (2-2); then, according to the value of cntFunc and the memory size of the structure tFunc, allocate space for the structure pointer variable pFunc through the malloc keyword; finally, initialize the member variables of the structure pFunc according to the configuration of the function instruction parameters called in the user programming; preferably, if there are parameters related to hardware port information in the functional instruction structure, call the relevant configuration data to initialize the member variables related to the hardware configuration of pFunc;

[0203] like Fig.16 As shown in L9:

[0204] First, according to the number of PWM function instruction variables called in user programming, initialize the variable pwmCnt of the number of loading structure pointer variables defined in step (2-2) to 1;

[0205] Then, according to the value of pwmCnt and the memory size of the structure PWM, the malloc keyword is used to allocate space for the structure pointer variable tPwm;

[0206] Finally, the member variables of the structure tPwm are initialized according to the configuration of the function instruction parameters called in the user programming, such as Fig.16 As shown in L9, the initialization PWM period is 100 milliseconds, the duty cycle is 60%, the port pin gpioPort is 1, and gpioPin is 0;

[0207] (2-4) Design and implement a functional instruction initialization interface and a driver interface. According to the pFunc and cntFunc initialized in step (2-3), design a functional instruction initialization interface and a driver interface; initialize corresponding function registers according to the different types of CPU pins used for different functions; the driver interface is called when the user configures the driver interface.

[0208] According to the tPwm and pwmCnt initialized in step (2-3), design the functional instruction initialization interface and the driver interface. Since the PWM function is a high-speed pulse output, only the register parameters need to be initialized, and the corresponding PWM port will automatically output pulses. Therefore, the PWM initialization interface and the driver interface are the same, such as Fig.16 As shown in L10, it is named PWM_Config(), and this interface can be called by the user after being configured in the database driver interface.

[0209] The general interrupt function design includes:

[0210] (3-1) Interrupt function macro definition. When a user calls an interrupt interface, an interrupt macro is first defined. The interrupt interface called by the user must be defined in the above interrupt resource configuration before it can be called. The interrupt macro refers to the macro definition representing a certain interrupt. For example, the macro of the timer interrupt is named USE_PLCINT_T0_TIM. Fig.17 As shown in L11;

[0211] (3-2) Define the interrupt service function. When the user calls the interrupt interface, define another interrupt service function, such as Fig.17 As shown in L12, if the interrupt service function of the timer interrupt is named PLCINT_T0_IRQHandler(), the interrupt program written by the user in the ladder diagram programming is converted from the ladder diagram language to C language to generate a C language interrupt program, and the C language interrupt program is encapsulated in the above interrupt service function;

[0212] (3-3) Predeclare the interrupt service function. According to the interrupt macro in step (3-1), the conditional compilation method is used to predeclare the interrupt service function, which is convenient for the interrupt service function to be called in other files, such as Fig.17 As shown in L13;

[0213] (3-4) Preprocessing the basic interrupt service functions. Each interrupt function needs to perform some basic function processing in advance to pave the way for the user interrupt service function, such as clock initialization of the timing interrupt. In order to facilitate the implementation of the basic functions, combined with the interrupt macro in step (3-1), conditional compilation is used for preprocessing, such as Fig.17 As shown in L14.

[0214] Comparative test:

[0215] In order to demonstrate the technical advantages of the present invention, the compiling development environment and the interpreting development environment of the present invention are compared under the same operating hardware:

[0216] The experimental conditions are shown in Table 1;

[0217] Table 1: Specific operating environments of the compiled development environment and the interpreted development environment of the present invention

[0218]

[0219] The comparative experimental scheme is as follows:

[0220] By writing PLC code with the same function, and then using an oscilloscope to measure the DO output time difference of SK2109 to calculate the PLC program scan cycle, the detailed test steps are as follows:

[0221] U1: First, write the basic code in GX Works2 software. The ladder diagram is as follows Fig.18 As shown; by measuring the output level state and time of the Y001 port, it can be seen that the code execution cycle of the three-interpretation PLC is approximately equal to 75us. The measurement results are as follows Fig.19 As shown, the period is named T0_GX, that is, T0_GX≈75μs;

[0222] U2: Then write the code with the same function in Newlad, the ladder diagram is as follows Fig. 20 As shown; by measuring the output level state and time of Q2 port, it can be seen that the code execution cycle of newlad PLC is approximately equal to 3.3μs. The measurement results are as follows Fig.21 As shown, the period is named T0_newlad, that is, T0_newlad≈3.3μs;

[0223] U3: Based on step U1, 20 interpreted PLC instructions are added, including 10 ADD instructions and 10 SUB instructions. The local ladder diagram is as follows: Fig. 22 As shown; the test output level time is approximately equal to 292μs, and the measurement results are as follows Fig.23 As shown, the time is named T1_GX, that is, T1_GX≈292μs;

[0224] U4: Based on step U2, add 20 newlad compiled PLC instructions, including 10 ADD instructions and 10 SUB instructions. The local ladder diagram is as follows: Fig.24 As shown; the test output level time is approximately equal to 4.5μs, and the measurement results are as follows Fig.25 As shown, the time is named T1_newlad, that is, T1_newlad≈4.5μs;

[0225] U5: Based on step U1, add 20 bit logic instructions, including 10 SET instructions and 10 RESET instructions, and write the ladder diagram as follows: Fig.26 As shown; the test output level time is approximately equal to 130μs, the test results are as follows Fig. 27As shown, the time is named T2_GX, that is, T2_GX≈130μs;

[0226] U6: Based on step U2, add 20 bit logic instructions, including 10 SET instructions and 10 RESET instructions, and write the ladder diagram as follows: Fig.28 As shown; the test output level time is approximately equal to 17μs, the test results are as follows Fig.29 As shown, the time is named T2_newlad, that is, T2_newlad≈17μs;

[0227] U7: Through steps U1 and U3, the ADD and SUB single instruction cycles of the interpreted PLC are obtained as T_GX_ADD; through steps U1 and U4, the ADD and SUB single instruction cycles of the compiled PLC of the present invention are obtained as T_newlad_ADD; through steps U1 and U5, the bit logic single instruction cycle of the interpreted PLC is obtained as T_GX_bit; through steps U1 and U6, the bit logic single instruction cycle of the compiled PLC of the present invention is obtained as T_newlad_bit;

[0228] T_GX_ADD=(T1_GX-T0_GX) / 20=(292-75) / 20=10.85μs;

[0229] T_newlad_ADD=(T1_newlad-T0_newlad) / 20=(4.5-3.3) / 20=0.06μs;

[0230] T_GX_bit=(T2_GX-T0_GX) / 20=(130-75) / 20=2.75μs;

[0231] T_newlad_bit=(T2_newlad-T0_newlad) / 20=(17-3.3) / 20=0.685μs;

[0232] Test result analysis and comparison chart Fig.30 As shown, through Fig.30 The recorded single instruction cycle proves that, compared with the interpreted PLC, the compiled PLC designed by the present invention has a much higher execution efficiency than the interpreted PLC under basically the same technical conditions.

Claims

1. A design method for a compiled programmable logic controller based on a development environment, characterized in that: The software interface framework of the development environment includes: Menu bar, toolbar, tree window on the left, tree window on the right, ladder diagram editing area in the middle; The menu bar includes a project menu, an edit menu, a compile menu and a help menu; wherein the compile menu includes a build function and a download function, and the build function is used to convert the target ladder diagram into C language and compile the C language into a binary executable code; The toolbar includes engineering tools, editing tools and compiling tools; the compiling tools include building functions and downloading functions; the toolbar functions are consistent with the menu functions; The tree window on the left side includes a first-level branch ladder diagram program and a component box; the first-level branch ladder diagram program includes a second-level branch main program, a subroutine, an interrupt program and a quick index; the main program is used to: when the middle ladder diagram editing area is in the subroutine or interrupt program interface, switch to the main program editing interface by clicking the "main program" editing area; the subroutine is used to: when adding a subroutine, create a subroutine, switch the main interface to the corresponding subroutine interface by clicking the subroutine index name, and call the subroutine by dragging the subroutine name; the interrupt program is used to: when it is necessary to add an interrupt program, create an interrupt program dialog box, and switch the main interface to the corresponding interrupt program interface by clicking the interrupt program index name; the quick index is used to: list the program function index directory of the main program, subroutine or interrupt program displayed on the current main interface; the component box is used to: list the list of instruction graphics used by the ladder diagram; and is also used to drag the instruction graphics corresponding to the instruction to the editing interface area through the signal input hardware for placement; The tree form on the right includes a global variable table, a local variable table, a timer list, a counter list, PWM, COM, a system variable, an IO variable table and a PLC resource configuration button; the global variable table includes user-defined global variables and power-off save variables, and is also used to click on the global variable table to create a new global variable; the local variable table is used to list the local variables defined by the current main interface program, and is also used to create a new local variable by clicking on the local variable table; the timer list is used to list the timer type variables defined in the program; the counter list is used to list the counter type variables defined by the program; the PWM is used to list the PWM type variables defined by the program; the COM is used to list the COM type variables defined by the program; the system variables are used to list the global usable variables that the system has defined and can be used without program definition; the IO variable table is used to: list the IO pins owned by the PLC hardware supported by the current project, including symbol names and pin names; the PLC resource configuration button is used for PLC hardware configuration; The middle ladder diagram editing area includes a program name display switching area, a program description, a label definition, a logic line comment and a logic line editing area; the program name display switching area is used to display the opened main program subroutine or interrupt program, and a single click on the program name can switch to the corresponding program interface, and the program can also be hidden by right clicking; the program description is used to annotate the currently edited program; the label definition is used to display a brief overview of the ladder diagram function on one side of the logic line of the editing area, and is also used to automatically generate labels under the quick index; the logic line comment is used to annotate the program of the current logic line; the logic line editing is used to perform ladder diagram programming in this area, and the variables of each instruction are displayed below the corresponding instruction, and the multivariate operation instructions are displayed in the form of mathematical calculation formulas; The steps of the design method include: S1: Classify the ladder diagram: It is initially divided into: basic instructions, functional module instructions, functional units, variable management units and resource configuration units; Further divided into: basic instructions are divided into type 1 basic conditional type and type 2 basic output type; the basic conditional type refers to a type of instruction representing a condition in a logic line of the ladder diagram; the basic output type refers to a type of instruction representing an output in a logic line of the ladder diagram; All the functional module instructions are output as type 3 functional instructions; The functional units are divided into type 4 subroutine type and type 5 link type; the subroutine type includes subroutine unit and interrupt program unit; the link type includes C language program unit and function link library unit; All the variable management units are used as type 6 variable models; The resource configuration unit is divided into a type 7 pin configuration model and a type 8 driver interface type; the driver interface type refers to the function interface of each functional module encapsulated in C language; S2: Design translation templates: According to the further classification of the ladder diagram in step S1, design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates respectively, for translating the ladder diagram into corresponding C language programs; S3: Driver design: Implement the functions involved in the working process of the programmable controller with C code; S4: Generate C language program: translate the ladder diagram edited by the user into C language code according to the translation template described in step S2, that is, call the main program main after the ladder diagram is translated into C; then call the C code generated by the driver design described in step S3 in main, and then form a complete set of C language program; S5: Compile C language program: compile the C language code program into binary executable code through a compiler; S6: Download executable file: burn the binary executable code into the programmable controller.

2. The design method of a compiled programmable logic controller based on a development environment according to claim 1, characterized in that: The basic conditional template is the "if (condition)" part in the "if (condition) {function body}" format; The basic output template is the "{function body}" part in the "if (condition) {function body}" format; The functional instruction output template includes: (1) structure definition, wherein the structure refers to variables required by the corresponding function encapsulated in a structure; (2) structure array and structure array length definition, wherein the structure array definition refers to making a global definition in the C file of the timer driver program first, and the structure array length definition refers to making a global definition in the C file of the timer driver program first; (3) structure array and structure array length declaration, wherein the structure array length declaration refers to making a global declaration in the H file of the timer driver program first, and the structure array declaration refers to making a global declaration in the H file of the timer driver program first; (4) defining and implementing an interface function, wherein the interface function is an interface function called in the main loop body when the ladder diagram is translated into C language.

3. The design method of a compiled programmable logic controller based on a development environment according to claim 1, characterized in that: The subroutine type template refers to a function interface that generates a C language program from a ladder diagram subroutine for the main function or an associated function to call; The link type template refers to encapsulating a function into a link port, and other functions directly call the link port; The variable model template refers to defining the user's variable definition according to the variable definition rules of the C language, and translating the PLC variable type into the C language data type one by one; The pin configuration model template refers to a configuration that matches the hardware pins of the PLC with the pins of the CPU one by one; The driver interface type template refers to directly configuring and calling the driver interface of the bottom layer encapsulation according to the reference format.

4. The design method of a compiled programmable logic controller based on a development environment according to claim 1, characterized in that: In the step S6, the downloading method of the executable file includes a wireless method or a wired method; the wireless method refers to the OTA download method; the wired method refers to the Jlink download method, specifically, it is implemented by using the syntax instructions of the JLINK-Commander.

5. An electronic device loaded with the design method of a compiled programmable logic controller based on a development environment as claimed in any one of claims 1 to 4, characterized in that: at least one processor; and a memory coupled to the at least one processor, the memory having instructions stored therein, the instructions, when executed by the at least one processor, causing the electronic device to perform actions for managing development jobs in a development environment, the actions comprising: Classify the ladder diagram; design translation templates: design basic condition type templates, basic output type templates, function instruction output type templates, subroutine type templates, link type templates, variable model templates, pin configuration model templates and drive interface type templates according to the classification of the ladder diagram, so as to translate the ladder diagram into corresponding C language programs; drive design: implement the functions involved in the working process of the programmable controller in C code respectively; generate C language program: translate the ladder diagram edited by the user into a C language program according to the translation template described in step S2, and then integrate it with the drive design described in step S3 into a complete C language program; compile the C language program: compile the C language program into a binary executable code through a compiler; download the executable file: burn the binary executable code into the programmable controller.

6. A computer program product for implementing the design method of a compiled programmable logic controller based on a development environment as claimed in any one of claims 1 to 4, characterized in that: The computer program product is tangibly stored on a non-transitory computer readable medium and includes machine executable instructions for performing the above-described method.

7. The development operation method in the design method of a compiled programmable logic controller based on a development environment as claimed in any one of claims 1 to 4, characterized in that: include: T1: Designing the database structure includes dividing the PLC configurable hardware resources into the following database entities and associated database entities; Divide the PLC configurable hardware resources into the following database entities, including: PLC model, general IO pin configuration, HSC pin configuration, communication resource pin, interrupt source configuration and driver interface configuration; The association database entity includes: the PLC model and the IO pin configuration, HSC pin configuration, communication resource pin and interrupt source configuration are all in a 1-to-n association relationship, the PLC model and the drive interface configuration are in a 1-to-1 association relationship, and the interrupt source configuration and the general IO pin configuration and the HSC pin configuration are in an m-to-n association relationship; T2: Versatility-driven design After configuring the hardware resources of the PLC, the database parameters are called during programming. Before forming the PLC user main program, a driver needs to be designed to identify the above configuration parameters; the universal driver design includes: universal IO driver design, universal functional instruction driver design, and universal interrupt function design.

8. The computer program product for developing the operation method according to claim 7, characterized in that: The general IO driver design includes: (1-1) Define the IO pin structure: The IO pin structure refers to a structure variable defined based on C language, which encapsulates the IO port information in the structure. The IO pin structure is defined as tPin_IO, which includes two members, one member is an unsigned 8-bit integer variable gpioPort, and the other member is an unsigned 8-bit integer variable gpioPin; tPin_IO is the name of the IO pin structure; gpioPort is the port number of the CPU pin; gpioPin is the pin number of the CPU pin; (1-2) Instantiate the IO pin structure variable and define the number of members of the instantiated variable. According to the IO pin structure defined in step (1-1), instantiate a structure pointer variable named ioConf; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named ioCnt. (1-3) Initialize the variables and structure pointer variables for the number of structure pointer variables. First, initialize the variable ioCnt for the number of structure pointer variables defined in step (1-2) according to the number of IO variables configured by the user. Then, according to the value of ioCnt and the memory size of the structure tPin_IO, use the malloc keyword to allocate space for the structure pointer variable ioConf. Finally, initialize the member variables gpioPort and gpioPin of the structure pointer variable ioConf according to the IO pin configuration parameters configured by the user. (1-4) Design and implement the IO pin configuration interface and the read-write IO driver interface. According to the gpioPort, gpioPin and ioCnt initialized in step (1-3), design the IO pin configuration interface and the read-write IO driver interface. The IO pin configuration interface process is: in the loop from 0 to ioCnt, a CPU pin is configured, and the configuration content includes configuring the pin clock, configuring the corresponding pin register and configuring the pin port register; the read-write IO driver interface finds the corresponding port according to gpioPort, and then calls the read-write register to perform the corresponding function operation.

9. The computer program product for developing a working method according to claim 7, characterized in that: The general functional instruction driven design includes: (2-1) defining a functional instruction structure, wherein the functional instruction structure refers to defining a structure variable based on C language, encapsulating the parameters involved in the functional instruction in a structure, and naming the structure tFunc; (2-2) Instantiate a functional instruction structure variable and define the number of members of the instantiated variable. According to the functional instruction structure defined in step (2-1), instantiate a structure pointer variable named pFunc; then define a variable for the number of loads for this pointer variable. The variable is an unsigned 8-bit integer variable named cntFunc. (2-3) Initialize the variables and structure pointer variables for the number of structure pointer variables. First, initialize the variable cntFunc for the number of structure pointer variables defined in step (2-2) according to the number of function instruction variables called in user programming; then allocate space for the structure pointer variable pFunc through the malloc keyword according to the value of cntFunc and the memory size of the structure tFunc; finally, initialize the member variables of the structure pFunc according to the configuration of the function instruction parameters called in user programming; if there are parameters involving hardware port information in the function instruction structure, call the relevant configuration data to initialize the member variables related to the hardware configuration of pFunc; (2-4) Design and implement a functional instruction initialization interface and a driver interface. According to the pFunc and cntFunc initialized in step (2-3), design a functional instruction initialization interface and a driver interface; initialize corresponding function registers according to the different types of CPU pins used for different functions; the driver interface is called when the user configures the driver interface; The general interrupt function design includes: (3-1) Interrupt function macro definition. When a user calls an interrupt interface, an interrupt macro is first defined. The interrupt macro refers to the macro definition representing a certain interrupt. (3-2) Define the interrupt service function. When the user calls the interrupt interface, define another interrupt service function. The interrupt program written by the user in the ladder diagram programming is converted from the ladder diagram language to the C language to generate a C language interrupt program, and this C language interrupt program is encapsulated in the above interrupt service function; (3-3) Predeclare the interrupt service function. According to the interrupt macro in step (3-1), use the conditional compilation method to predeclare the interrupt service function. (3-4) Preprocessing the basic functions of interrupt service. Each interrupt function needs to do some basic function processing in advance to pave the way for user interrupt service functions. In order to facilitate the implementation of the basic functions, combined with the interrupt macro in step (3-1), conditional compilation is used for preprocessing.