A control program conversion method and device, electronic equipment and storage medium
By converting non-standard control programs into standard control programs in a programmable logic controller (PLC), the problem that existing technologies cannot support non-standard programs is solved, and the generation and execution of standard programs are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU CHUANGYUAN ELECTRON CO LTD
- Filing Date
- 2022-09-22
- Publication Date
- 2026-06-30
AI Technical Summary
Existing programmable logic controllers do not support programs that do not conform to the IEC 61131-3 standard, and cannot convert non-standard control programs into standard control programs.
The first global instruction list is generated by storing the instructions in the non-standard control program in line order. Then, the ladder identifiers are inserted and deleted according to the positions of the first and second operators and the serial block operators of the parallel loops. The omitted instructions are then inserted into the second global instruction list to generate the third global instruction list. Finally, the standard control program is determined according to the third global instruction list and the variable mapping table.
It enables the conversion of non-standard control programs into standard control programs that conform to the IEC 61131-3 standard, supporting execution in programmable logic controllers.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial control, and more specifically, to a method, apparatus, electronic device, and storage medium for converting control programs. Background Technology
[0002] A programmable logic controller (PLC) is a digital logic controller with a microprocessor at its core, typically used as a control core in industrial control applications. Currently, engineers use PLC programmable logic controller program editors to write programs conforming to the IEC (International Electrotechnical Commission) 61131-3 standard. These IEC 61131-3 compliant programs are then configured in the purchased PLC, which in turn updates the status of field devices based on the IEC 61131-3 compliant program.
[0003] However, existing programmable logic controllers do not support programs that do not conform to the IEC 61131-3 standard. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method, apparatus, electronic device and storage medium for converting control programs, which can convert non-standard control programs into standard control programs.
[0005] In a first aspect, embodiments of this application provide a method for converting a control program, the method comprising: The instructions in the non-standard control program are stored in the first global instruction list in line order; the variables in the instructions and their corresponding data types are stored in the variable mapping table. Based on the positions of the first operator and the serial block operator of the parallel circuit, the ladder identifiers are inserted and deleted in the first global instruction list to obtain the second global instruction list; Based on the operators of each instruction in the second global instruction list, the omitted instructions are inserted into the second global instruction list to obtain the third global instruction list; The standard control procedure is determined based on the third global instruction list and the variable mapping table.
[0006] In one possible implementation, based on the positions of the first operator and the serial block operator of the parallel loop, a second global instruction list is obtained by inserting and deleting ladder identifiers in the first global instruction list, including: The first global instruction list is traversed sequentially. If the operator of the currently traversed instruction is the first operator, a ladder identifier is inserted before the currently traversed instruction. If the operator of the current traversal instruction is the serial block operator of the parallel circuit, then the first global instruction list is traversed in reverse order starting from the current traversal instruction. When the operator of the current traversal instruction is the ladder identifier, the current traversal instruction is deleted and the first global instruction list is traversed sequentially starting from the current traversal position.
[0007] In one possible implementation, based on the operators of each instruction in the second global instruction list, an omitted instruction is inserted into the second global instruction list to obtain a third global instruction list, which includes: Sequentially traverse the second global instruction list; If the operator of the current traversal instruction is a ladder identifier, then clear the instruction stack; If the operator of the current traversal instruction is a terminal operator or a stack operator, then the omitted instruction is inserted into the second global instruction list according to the terminal operator or the stack operator. If the operator of the current traversal instruction is not the last operator, stack operator, or ladder identifier, then determine whether the instruction preceding the current traversal instruction is the last instruction. If the instruction preceding the current traversal instruction is the last instruction, then store all instructions in the instruction stack and the current traversal instruction in sequence into the third global instruction list. If the instruction preceding the current traversal instruction is not the last instruction, then store the current traversal instruction into the third global instruction list and the end of the instruction list at the top of the instruction stack.
[0008] In one possible implementation, an omitted instruction is inserted into the second global instruction list based on the end operator or stack operator to obtain a third global instruction list, which includes: If the operator of the current instruction being traversed is the last operator, then the current instruction being traversed is stored sequentially into the third global instruction list; determine if the instruction preceding the current instruction being traversed is the last instruction; if the instruction preceding the current instruction being traversed is the last instruction, then store all instructions in the instruction stack into the third global instruction list. If the operator of the current traversal instruction is MPS, then an empty instruction list is added to the top of the instruction stack; and it is determined whether the instruction preceding the current traversal instruction is the last instruction; if the instruction preceding the current traversal instruction is the last instruction, then all instructions in the instruction stack are inserted into the third global instruction list in sequence; the stack operators include MPS, MRD and MPP; If the operator of the current traversal instruction is MRD or MPP, pop the instruction list at the top of the instruction stack; then insert all the instructions in the popped nested instruction stack into the third global instruction list in sequence.
[0009] In one possible implementation, the standard control procedure is determined based on the third global instruction list and the variable mapping table, including: The variables in the variable mapping table and their corresponding data types are output sequentially to the preset locations in the program file; and the third global instruction list is traversed sequentially. If the current traversal instruction is a Boolean operation instruction, then insert the first preset string at the beginning of the current statement list; If the current traversal instruction is a block operation instruction, then add the string of the Boolean operator corresponding to the current traversal instruction, the element in the linked list at the top of the compute stack, and pop the top element of the compute stack in sequence to the end of the current statement linked list; If the current traversal instruction is an output instruction, the standard control procedure is determined based on the operands of the current traversal instruction; If the current traversal instruction is an input instruction, check if the current statement list is empty. If the current statement list is empty, store the variable names of the operands of the current traversal instruction into the current statement list. If the current statement list is not empty, push the contents of the current statement list onto the top of the compute stack, then clear the current statement list, and finally store the variable names of the operands of the current traversal instruction into the current statement list.
[0010] In one possible implementation, the standard control procedure is determined based on the operands of the current traversal instruction, including: If the operand of the current traversal instruction is the output operand of the time relay, insert the contents of the current statement list into the end of the current function block statement list; clear the current statement list; insert the second preset string into the beginning of the current function block statement list and the third preset string into the end; insert the fourth preset string into the current statement list. If the operand of the current traversal instruction is not the output operand of the time relay, then insert the fifth preset string at the beginning of the current statement list; Output the current function block statement list and the contents of the current statement list to the program file to obtain the standard control program; and clear the current function block statement list and the current statement list.
[0011] In one possible implementation, the method further includes: Obtain the current execution status information of the field devices corresponding to the variables in the control program; The current execution status information of the field device is input into the standard control program to obtain the next execution status information of the field device; the next execution status information includes speed information; the field device includes single-axis devices; According to the preset speed change rules, the target speed information of the single-axis device is determined based on the speed information of the single-axis device in the next execution status information; All next execution status information except for the speed information of the single-axis device, and the target speed information of the single-axis device are determined as the final next execution status information of the field device.
[0012] In one possible implementation, the method further includes: Obtain the product's location information.
[0013] The location information is input into the standard control program to obtain camera control information.
[0014] The camera control information is sent to the camera so that the camera can take a picture of the product when the camera control information is set to shoot, thereby obtaining a product image.
[0015] Receive product images sent by the camera; analyze the product images through the image perception operator library to determine whether the product is defective; if the product is defective, control the robotic arm to send the product to the defective product area; if the product is not defective, control the robotic arm to send the product to the good product area.
[0016] Secondly, embodiments of this application also provide a control program conversion device, which includes: The storage module is used to store instructions from non-standard control programs in line-by-line order into the first global instruction list; and to store variables in the instructions and their corresponding data types into the variable mapping table. The operation module is used to insert and delete ladder identifiers in the first global instruction list according to the position of the first operator and the serial block operator of the parallel circuit to obtain the second global instruction list; The operation module is also used to insert omitted instructions into the second global instruction list based on the operators of each instruction in the second global instruction list to obtain the third global instruction list; The determination module is used to determine the standard control program based on the third global instruction list and the variable mapping table.
[0017] In one possible implementation, the operation module is specifically used to sequentially traverse the first global instruction list. If the operator of the current traversal instruction is the first operator, a ladder identifier is inserted before the current traversal instruction. If the operator of the current traversal instruction is a serial block operator of a parallel circuit, the first global instruction list is traversed in reverse order starting from the current traversal instruction. When the operator of the current traversal instruction is a ladder identifier, the current traversal instruction is deleted and the first global instruction list is continued to be traversed sequentially starting from the current traversal position.
[0018] In one possible implementation, the operation module is specifically used to sequentially traverse the second global instruction list; if the operator of the currently traversed instruction is a ladder identifier, then the instruction stack is cleared; if the operator of the currently traversed instruction is a last operator or a stack operator, then the omitted instruction is inserted into the second global instruction list according to the last operator or stack operator to obtain the third global instruction list; if the operator of the currently traversed instruction is not a last operator, a stack operator, or a ladder identifier, then it is determined whether the previous instruction of the currently traversed instruction is the last instruction; if the previous instruction of the currently traversed instruction is the last instruction, then all instructions in the instruction stack and the currently traversed instruction are stored sequentially into the third global instruction list; if the previous instruction of the currently traversed instruction is not the last instruction, then the currently traversed instruction is stored in the third global instruction list and at the end of the instruction list at the top of the instruction stack.
[0019] In one possible implementation, the operation module is specifically configured to: if the operator of the currently traversed instruction is a last instruction operator, then store the currently traversed instruction sequentially into a third global instruction list; determine whether the instruction preceding the currently traversed instruction is a last instruction; if the instruction preceding the currently traversed instruction is a last instruction, then store all instructions in the instruction stack into the third global instruction list; if the operator of the currently traversed instruction is MPS, then add an empty instruction list to the top of the instruction stack; and determine whether the instruction preceding the currently traversed instruction is a last instruction; if the instruction preceding the currently traversed instruction is a last instruction, then insert all instructions in the instruction stack sequentially into the third global instruction list; the stack operators include MPS, MRD, and MPP; if the operator of the currently traversed instruction is MRD or MPP, pop the instruction list at the top of the instruction stack; and insert all instructions in the popped nested instruction stack sequentially into the third global instruction list.
[0020] In one possible implementation, the determining module is specifically used to sequentially output the variables and their corresponding data types from the variable mapping table to a preset location in the program file; and sequentially traverse the third global instruction linked list; if the current traversal instruction is a Boolean operation instruction, then insert a first preset string at the beginning of the current statement linked list; if the current traversal instruction is a block operation instruction, then sequentially add the string of the Boolean operation operator corresponding to the current traversal instruction and the element in the linked list at the top position of the calculation stack to the end of the current statement linked list; pop the top element of the calculation stack; if the current traversal instruction is an output instruction, determine the standard control program based on the operand of the current traversal instruction; if the current traversal instruction is an input instruction, determine whether the current statement linked list is empty; if the current statement linked list is empty, then store the variable name of the operand of the current traversal instruction into the current statement linked list; if the current statement linked list is not empty, then push the contents of the current statement linked list onto the top position of the calculation stack, then clear the current statement linked list, and finally store the variable name of the operand of the current traversal instruction into the current statement linked list.
[0021] In one possible implementation, the determining module is further configured to: If the operand of the current traversal instruction is the output operand of the time relay, insert the contents of the current statement list into the end of the current function block statement list; clear the current statement list; insert the second preset string into the beginning of the current function block statement list and the third preset string into the end; insert the fourth preset string into the current statement list. If the operand of the current traversal instruction is not the output operand of the time relay, then insert the fifth preset string at the beginning of the current statement list; Output the current function block statement list and the contents of the current statement list to the program file to obtain the standard control program; and clear the current function block statement list and the current statement list.
[0022] In one possible implementation, the device further includes: an acquisition module and an input module; The acquisition module is used to acquire the current execution status information of the field devices corresponding to the variables in the control program; The input module is used to input the current execution status information of the field device into the standard control program to obtain the next execution status information of the field device; the next execution status information includes speed information; the field device includes single-axis devices; The determination module is also used to determine the target speed information of the single-axis device according to the speed information of the single-axis device in the next execution status information, based on the preset speed change rules. The determination module is also used to determine all the next execution status information except for the speed information of the single-axis device and the target speed information of the single-axis device in the next execution status information as the final next execution status information of the field device.
[0023] In one possible implementation, the device further includes: a transmitting module, a receiving module, and a judging module; The acquisition module is also used to acquire the product's location information.
[0024] The input module is also used to input location information into the standard control program to obtain camera control information.
[0025] The sending module is used to send camera control information to the camera so that the camera can take pictures of the product when the camera control information is set to shoot, and obtain product images.
[0026] The receiving module is used to receive product images sent by the camera; The judgment module is used to analyze product images through an image perception operator library to determine whether the product is defective. If the product is defective, the robot arm is controlled to send the product to the defective product area; if the product is not defective, the robot arm is controlled to send the product to the good product area.
[0027] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the conversion method of any of the control programs in the first aspect.
[0028] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the conversion method of any of the control programs in the first aspect.
[0029] This application provides a method, apparatus, electronic device, and storage medium for converting control programs. The method includes: storing instructions from a non-standard control program in a first global instruction list in line order; storing variables and their data types in a variable mapping table; inserting and deleting ladder identifiers in the first global instruction list according to the positions of the first operator and the serial block operator of the parallel loop to obtain a second global instruction list; inserting omitted instructions in the second global instruction list according to the operators of each instruction in the second global instruction list to obtain a third global instruction list; and determining a standard control program based on the third global instruction list and the variable mapping table. This application converts a non-standard control program into a standard control program by inserting and deleting ladder identifiers in the first global instruction list according to the positions of the first operator and the serial block operator of the parallel loop, obtaining a second global instruction list, inserting omitted instructions in the second global instruction list to obtain a third global instruction list, and finally obtaining a standard control program based on the third global instruction list and the variable mapping table. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 A flowchart illustrating a control program conversion method provided in an embodiment of this application is shown; Figure 2 A flowchart illustrating another control procedure conversion method provided in an embodiment of this application is shown; Figure 3 A flowchart illustrating another control procedure conversion method provided in an embodiment of this application is shown; Figure 4 This illustration shows a schematic diagram of the structure of a control program conversion device provided in an embodiment of this application; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0033] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0034] To enable those skilled in the art to utilize the content of this application, and in conjunction with the specific application scenario of "industrial control," the following implementation methods are provided. For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is primarily described in the context of "industrial control," it should be understood that this is merely an exemplary embodiment.
[0035] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0036] The following is a detailed description of a control program conversion method provided in the embodiments of this application.
[0037] Reference Figure 1 The diagram shown is a flowchart illustrating a control program conversion method provided in an embodiment of this application. The exemplary steps of this embodiment are described below: S101. Store the instructions in the non-standard control program in the first global instruction chain in line order; store the variables in the instructions and their corresponding data types in the variable mapping table.
[0038] In this embodiment, the engineer inputs the written control program and its type into the software PLC system. The control program type includes Mitsubishi program type, standard program type, etc. When the input program is in Mitsubishi language type, it indicates that the control program is a non-standard language type, and therefore needs to be converted into a standard control program. First, the instructions in the non-standard control program are stored in the first global instruction chain list in line order, and the variables of all instructions in the non-standard control program and their data types are stored in a variable mapping table.
[0039] Here, standard program type refers to a program that conforms to the IEC 61131-3 standard. There are various forms of programs that conform to the IEC 61131-3 standard. Currently, the focus is on the conversion between programs that conform to the IEC 61131-3 standard. There is no method for converting non-standard control programs into standard control programs.
[0040] S102. Based on the positions of the first operator and the serial block operator of the parallel circuit, insert or delete the corresponding ladder identifiers in the first global instruction list to obtain the second global instruction list.
[0041] In this embodiment, the non-standard control program is generally derived from a ladder diagram. A ladder diagram consists of multiple independent rungs, but the rung information is lost in the non-standard control program. Therefore, it is necessary to mark the rung identifier in the first global instruction list. The rung identifier is specifically represented by the string "NEWLINE". The first operator specifically includes the four basic operators: LD, LDI, LDP, and LDF. The series block operator for parallel circuits is specifically represented as ANB.
[0042] Specifically, the first global instruction list is traversed sequentially. If the operator of the current traversal instruction is the first operator, a ladder identifier is inserted before the current traversal instruction. If the operator of the current traversal instruction is the serial block operator of a parallel circuit, the first global instruction list is traversed in reverse order starting from the current traversal instruction. When the operator of the current traversal instruction is a ladder identifier, the current traversal instruction is deleted and the first global instruction list is traversed sequentially starting from the current traversal position.
[0043] S103. Based on the operators of each instruction in the second global instruction list, insert the omitted instructions into the second global instruction list to obtain the third global instruction list.
[0044] In this embodiment, before inserting omitted instructions, an instruction stack needs to be established to store the omitted instructions for each ladder level. Then, the instructions in the instruction stack are inserted into the third global instruction list. First, the second global instruction list is traversed sequentially. Then, for each operator in the second global instruction list, the omitted instructions are inserted into the second global instruction list according to the following three rules to obtain the third global instruction list: When the operator of the currently traversed instruction is a terminal operator, the operation corresponding to rule 1 is performed. When the operator of the currently traversed instruction is a terminal operator or a stack operator, the operation corresponding to rule 2 is performed. When the operator of the currently traversed instruction is not a terminal operator, a stack operator, or a ladder level identifier, the response operation in rule 3 is performed. The final third global instruction list is obtained after all instructions in the second global instruction list have been traversed.
[0045] Rule 1: If the operator of the current traversal instruction is a ladder identifier, then clear the instruction stack.
[0046] Rule 2: If the operator of the current traversal instruction is the end operator or the stack operator, then the omitted instruction is inserted into the second global instruction list according to the end operator or the stack operator to obtain the third global instruction list.
[0047] In this embodiment, if the operator of the current traversal instruction is a terminal operator, then the corresponding operation is performed when the operator of the next traversal instruction is also a terminal operator. If the operator of the current traversal instruction is a stack operator, then the corresponding operation is performed when the operator of the next traversal instruction is also a stack operator. The stack operators include MPS, MRD, and MPP.
[0048] Optionally, if the operator of the currently traversed instruction is the last operator, then the currently traversed instructions are stored sequentially into the third global instruction list; it is determined whether the instruction preceding the currently traversed instruction is the last instruction; if the instruction preceding the currently traversed instruction is the last instruction, then all instructions in the instruction stack are stored into the third global instruction list.
[0049] Optionally, if the operator of the current traversal instruction is MPS, then add the empty instruction list to the top of the instruction stack; and determine whether the instruction preceding the current traversal instruction is the last instruction; if the instruction preceding the current traversal instruction is the last instruction, then insert all instructions in the instruction stack into the third global instruction list in sequence.
[0050] Optionally, if the operator of the current traversal instruction is MRD or MPP, pop the instruction list at the top of the instruction stack; and insert all the instructions in the popped nested instruction stack into the third global instruction list in sequence.
[0051] Rule 3: If the operator of the current traversal instruction is not the last operator, stack operator, or ladder identifier, then determine whether the instruction preceding the current traversal instruction is the last instruction. If the instruction preceding the current traversal instruction is the last instruction, then store all instructions in the instruction stack and the current traversal instruction sequentially into the third global instruction list. If the instruction preceding the current traversal instruction is not the last instruction, then store the current traversal instruction into the third global instruction list and the end of the instruction list at the top of the instruction stack.
[0052] S104. Determine the standard control program based on the third global instruction list and the variable mapping table.
[0053] Specifically, the variables in the variable mapping table and their corresponding data types are output sequentially to the preset locations in the program file; and the third global instruction list is traversed sequentially.
[0054] In this embodiment, the string "PROGRAM program0" is first generated and output to the first line of the program file. Then, the variables in the variable mapping table and their corresponding data types are sequentially output to the preset locations in the program file.
[0055] Specifically, if the current traversal instruction is a Boolean operation instruction, then the first preset string is inserted at the beginning of the current statement list.
[0056] In this embodiment of the application, the first preset string is "operand operator".
[0057] Specifically, if the current traversal instruction is a block operation instruction, then the string of the Boolean operator corresponding to the current traversal instruction and the element in the linked list at the top of the compute stack are added sequentially to the end of the current statement linked list; the top element of the compute stack is popped.
[0058] Specifically, if the current traversal instruction is an output instruction, the standard control procedure is determined based on the operands of the current traversal instruction.
[0059] Here, if the operand of the current traversal instruction is the output operand of the time relay, the content of the current statement list is inserted after the current function block statement list; the current statement list is cleared; a second preset string is inserted before the current function block statement list and a third preset string is inserted after it; a fourth preset string is inserted into the current statement list. If the operand of the current traversal instruction is not the output operand of the time relay, a fifth preset string is inserted before the current statement list; the current function block statement list and its contents are output to the program file to obtain the standard control program; and the current function block statement list and the current statement list are cleared.
[0060] In this embodiment, the second preset string is "function block instance name (IN :=". The third preset string is ", PT := T#nms)". The fourth preset string is "operand := function block instance name.Q". The fifth preset string is "operand :=".
[0061] Specifically, if the current traversal instruction is an input instruction, check if the current statement list is empty; if the current statement list is empty, store the variable names of the operands of the current traversal instruction into the current statement list; if the current statement list is not empty, push the contents of the current statement list onto the top of the compute stack, then clear the current statement list, and finally store the variable names of the operands of the current traversal instruction into the current statement list.
[0062] In this embodiment, when the operand variable name of an operator ending with "I" is stored in the current statement list, it is stored as the string "NOT(operand)". Other operators directly store the operand variable name in the current statement list.
[0063] Reference Figure 2 The diagram shown is a flowchart illustrating another control program conversion method provided in this application embodiment. The exemplary steps of this application embodiment are described below: S201. Obtain the current execution status information of the field devices corresponding to the variables in the control program.
[0064] In this embodiment, the field equipment includes cylinders, robotic arms, motion devices, etc. The execution status information can be that the cylinder is in a lifting state, etc.
[0065] S202. Input the current execution status information of the field equipment into the standard control program to obtain the next execution status information of the field equipment.
[0066] In this embodiment, the standard control program can be used to update the next execution state information of the field device based on the current execution state information of the field device in order to control the field device; the next execution state information includes speed information; the field device includes a single-axis device.
[0067] S203. According to the preset speed change rules, determine the target speed information of the single-axis device based on the speed information of the single-axis device in the next execution status information.
[0068] For example, if the speed of a single-axis device in the current execution status information is 2 m / s, and the speed of the single-axis device in the next execution status information is 6 m / s, then to increase the speed of the single-axis device from 2 m / s to 6 m / s, the preset speed change rule is a change of 2 m / s per second. Therefore, the target speed information in the next execution status information of the single-axis device should be 4 m / s, and the target speed information in the next execution status information should be 6 m / s.
[0069] S204. Determine all next execution status information except for the speed information of the single-axis device and the target speed information of the single-axis device in the next execution status information as the final next execution status information of the field device.
[0070] In the embodiments of this application, as can be seen from the above example, the target speed information is the target speed information over a period of time.
[0071] Reference Figure 3 The diagram shown is a flowchart illustrating another control program conversion method provided in this application embodiment. The exemplary steps of this application embodiment are described below: S301. Obtain the product's location information.
[0072] S302. Input the location information into the standard control program to obtain camera control information.
[0073] In this application embodiment, the camera control information includes turning on and off.
[0074] S303. Send camera control information to the camera so that the camera can take pictures of the product when the camera control information is set to capture, and obtain product images.
[0075] S304. Receive product images sent by the camera; analyze the product images through the image perception operator library to determine whether the product is defective; if the product is defective, control the robotic arm to send the product to the defective product area; if the product is not defective, control the robotic arm to send the product to the good product area.
[0076] Reference Figure 4 As shown, this application provides a control program conversion device, which includes: Storage module 401 is used to store the instructions in the non-standard control program in line order into the first global instruction chain list; and to store the variables in the instructions and their corresponding data types into the variable mapping table. Operation module 402 is used to insert and delete ladder identifiers in the first global instruction list according to the position of the first operator and the serial block operator of the parallel circuit to obtain the second global instruction list; The operation module 402 is also used to insert omitted instructions into the second global instruction chain to obtain a third global instruction chain based on the operators of each instruction in the second global instruction chain; The determination module 403 is used to determine the standard control program based on the third global instruction list and the variable mapping table.
[0077] In one possible implementation, the operation module 402 is specifically used to sequentially traverse the first global instruction list. If the operator of the current traversal instruction is the first operator, then a ladder identifier is inserted before the current traversal instruction. If the operator of the current traversal instruction is a serial block operator of a parallel circuit, then the first global instruction list is traversed in reverse order starting from the current traversal instruction. When the operator of the current traversal instruction is a ladder identifier, the current traversal instruction is deleted and the first global instruction list is continued to be traversed sequentially starting from the current traversal position.
[0078] In one possible implementation, the operation module 402 is specifically used to sequentially traverse the second global instruction list; if the operator of the currently traversed instruction is a ladder identifier, then the instruction stack is cleared; if the operator of the currently traversed instruction is a last operator or a stack operator, then the omitted instruction is inserted into the second global instruction list according to the last operator or stack operator to obtain the third global instruction list; if the operator of the currently traversed instruction is not a last operator, a stack operator, or a ladder identifier, then it is determined whether the previous instruction of the currently traversed instruction is the last instruction; if the previous instruction of the currently traversed instruction is the last instruction, then all instructions in the instruction stack and the currently traversed instruction are stored sequentially into the third global instruction list; if the previous instruction of the currently traversed instruction is not the last instruction, then the currently traversed instruction is stored in the third global instruction list and at the end of the instruction list at the top of the instruction stack.
[0079] In one possible implementation, the operation module 402 is specifically configured to: if the operator of the current traversal instruction is a last operator, store the current traversal instruction sequentially into the third global instruction list; determine whether the previous instruction of the current traversal instruction is a last instruction; if the previous instruction of the current traversal instruction is a last instruction, store all instructions in the instruction stack into the third global instruction list; if the operator of the current traversal instruction is MPS, add an empty instruction list to the top of the instruction stack; and determine whether the previous instruction of the current traversal instruction is a last instruction; if the previous instruction of the current traversal instruction is a last instruction, insert all instructions in the instruction stack sequentially into the third global instruction list; the stack operators include MPS, MRD, and MPP; if the operator of the current traversal instruction is MRD or MPP, pop the instruction list located at the top of the instruction stack; and insert all instructions in the popped nested instruction stack sequentially into the third global instruction list.
[0080] In one possible implementation, the determining module 403 is specifically used to sequentially output the variables and their corresponding data types from the variable mapping table to a preset location in the program file; and sequentially traverse the third global instruction linked list; if the current traversal instruction is a Boolean operation instruction, insert a first preset string at the beginning of the current statement linked list; if the current traversal instruction is a block operation instruction, sequentially add the string of the Boolean operation operator corresponding to the current traversal instruction and the element in the linked list at the top position of the calculation stack to the end of the current statement linked list; pop the top element of the calculation stack; if the current traversal instruction is an output instruction, determine the standard control program based on the operand of the current traversal instruction; if the current traversal instruction is an input instruction, determine whether the current statement linked list is empty; if the current statement linked list is empty, store the variable name of the operand of the current traversal instruction into the current statement linked list; if the current statement linked list is not empty, push the contents of the current statement linked list onto the top position of the calculation stack, then clear the current statement linked list, and finally store the variable name of the operand of the current traversal instruction into the current statement linked list.
[0081] In one possible implementation, the determining module 403 is further configured to: If the operand of the current traversal instruction is the output operand of the time relay, insert the contents of the current statement list into the end of the current function block statement list; clear the current statement list; insert the second preset string into the beginning of the current function block statement list and the third preset string into the end; insert the fourth preset string into the current statement list. If the operand of the current traversal instruction is not the output operand of the time relay, then insert the fifth preset string at the beginning of the current statement list; Output the current function block statement list and the contents of the current statement list to the program file to obtain the standard control program; and clear the current function block statement list and the current statement list.
[0082] In one possible implementation, the device further includes: an acquisition module 404 and an input module 405; The acquisition module 404 is used to acquire the current execution status information of the field device corresponding to the variables in the control program; Input module 405 is used to input the current execution status information of the field device into the standard control program to obtain the next execution status information of the field device; the next execution status information includes speed information; the field device includes a single-axis device; The determination module 403 is also used to determine the target speed information of the single-axis device according to the speed information of the single-axis device in the next execution status information, based on the preset speed change rules. The determination module 403 is also used to determine all the next execution status information except the speed information of the single-axis device and the target speed information of the single-axis device in the next execution status information as the final next execution status information of the field device.
[0083] In one possible implementation, the device further includes: a sending module 406, a receiving module 407, and a judging module 408; The acquisition module 404 is also used to acquire the product's location information.
[0084] The input module 405 is also used to input position information into the standard control program to obtain camera control information.
[0085] The sending module 406 is used to send camera control information to the camera so that the camera can take pictures of the product when the camera control information is set to shooting, and obtain product images.
[0086] Receiver module 407 is used to receive product images sent by the camera; The judgment module 408 is used to analyze the product image through the image perception operator library to determine whether the product is defective; if the product is defective, the robot arm is controlled to send the product to the defective product area; if the product is not defective, the robot arm is controlled to send the product to the good product area.
[0087] like Figure 5 As shown in the embodiment of this application, an electronic device 500 includes a processor 501, a memory 502, and a bus. The memory 502 stores machine-readable instructions that can be executed by the processor 501. When the electronic device is running, the processor 501 communicates with the memory 502 through the bus. The processor 501 executes the machine-readable instructions to perform the steps of the conversion method of the control program described above.
[0088] Specifically, the memory 502 and processor 501 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 501 runs the computer program stored in the memory 502, it can execute the above-mentioned control program conversion method.
[0089] Corresponding to the above-described control program conversion method, this application embodiment also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of the above-described control program conversion method.
[0090] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0091] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0092] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0093] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the information processing methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0094] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for converting control programs, characterized in that, The conversion method of the control program includes: The instructions in the non-standard control program are stored in the first global instruction chain in line order; the variables in the instructions and their data types are stored in the variable mapping table. Based on the positions of the first operator and the serial block operator of the parallel circuit, the ladder identifiers are inserted or deleted in the first global instruction list to obtain the second global instruction list; Based on the operators of each instruction in the second global instruction list, the omitted instructions are inserted into the second global instruction list to obtain the third global instruction list; The standard control procedure is determined based on the third global instruction list and the variable mapping table; The step of inserting and deleting ladder identifiers in the first global instruction list according to the positions of the first operator and the serial block operator of the parallel circuit to obtain the second global instruction list includes: sequentially traversing the first global instruction list; if the operator of the current traversal instruction is the first operator, then inserting a ladder identifier before the current traversal instruction; if the operator of the current traversal instruction is the serial block operator of the parallel circuit, then traversing the first global instruction list in reverse order from the current traversal instruction; when the operator of the current traversal instruction is a ladder identifier, deleting the current traversal instruction and continuing to sequentially traverse the first global instruction list from the current traversal position. The step of inserting omitted instructions into the second global instruction list to obtain a third global instruction list based on the operators of each instruction in the second global instruction list includes: Establish an instruction stack; the instruction stack is used to store the omitted instructions for each level; The second global instruction list is traversed sequentially. If the operator of the current traversal instruction is a ladder identifier, then the instruction stack is cleared; If the operator of the current traversal instruction is a terminal operator or a stack operator, then the omitted instruction is inserted into the second global instruction list according to the terminal operator or stack operator to obtain the third global instruction list; If the operator of the current traversal instruction is not a last operator, a stack operator, or a ladder identifier, then determine whether the instruction preceding the current traversal instruction is the last instruction. If the instruction preceding the current traversal instruction is the last instruction, then store all instructions in the instruction stack and the current traversal instruction sequentially into the third global instruction linked list. If the instruction preceding the current traversal instruction is not the last instruction, then store the current traversal instruction into the third global instruction linked list and the end position of the instruction linked list at the top of the instruction stack.
2. The control program conversion method according to claim 1, characterized in that, The step of inserting omitted instructions into the second global instruction list based on the end operator or stack operator to obtain the third global instruction list includes: If the operator of the current traversal instruction is the last operator, then the current traversal instruction is stored sequentially in the third global instruction list; determine whether the instruction preceding the current traversal instruction is the last instruction; if the instruction preceding the current traversal instruction is the last instruction, then store all instructions in the instruction stack in the third global instruction list. If the operator of the current traversal instruction is MPS, then an empty instruction list is added to the top of the instruction stack; and it is determined whether the instruction preceding the current traversal instruction is the last instruction; if the instruction preceding the current traversal instruction is the last instruction, then all instructions in the instruction stack are sequentially inserted into the third global instruction list; the stack operators include MPS, MRD and MPP; If the operator of the current traversal instruction is MRD or MPP, pop the instruction list at the top of the instruction stack; then insert all the instructions in the popped nested instruction stack into the third global instruction list in sequence.
3. The control program conversion method according to claim 2, characterized in that, The step of determining the standard control program based on the third global instruction list and the variable mapping table includes: The variables in the variable mapping table and their corresponding data types are sequentially output to the preset location in the program file; and the third global instruction chain is traversed sequentially. If the current traversal instruction is a Boolean operation instruction, then insert the first preset string at the beginning of the current statement list; If the current traversal instruction is a block operation instruction, then add the string of the Boolean operator corresponding to the current traversal instruction and the element in the linked list at the top of the stack in the computation stack to the end of the current statement linked list in sequence; pop the top element of the computation stack. If the current traversal instruction is an output instruction, the standard control procedure is determined based on the operands of the current traversal instruction; If the current traversal instruction is an input instruction, determine whether the current statement list is empty; if the current statement list is empty, store the variable names of the operands of the current traversal instruction into the current statement list; if the current statement list is not empty, push the contents of the current statement list onto the top of the compute stack, then clear the current statement list, and finally store the variable names of the operands of the current traversal instruction into the current statement list.
4. The control program conversion method according to claim 3, characterized in that, Determining the standard control procedure based on the operands of the current traversal instruction includes: If the operand of the current traversal instruction is the output operand of the time relay, insert the contents of the current statement list into the end of the current function block statement list; clear the current statement list; insert a second preset string into the beginning of the current function block statement list and a third preset string into the end; insert a fourth preset string into the current statement list. If the operand of the current traversal instruction is not the output operand of the time relay, then insert the fifth preset string at the beginning of the current statement list; Output the current function block statement list and the contents of the current statement list to the program file to obtain the standard control program; and clear the current function block statement list and the current statement list.
5. The control program conversion method according to any one of claims 1 to 4, characterized in that, The method further includes: Obtain the current execution status information of the field devices corresponding to the variables in the control program; The current execution status information of the field device is input into the standard control program to obtain the next execution status information of the field device; the next execution status information includes speed information; the field device includes a single-axis device; According to the preset speed change rules, the target speed information of the single-axis device is determined based on the speed information of the single-axis device in the next execution state information; All next execution state information except for the speed information of the single-axis device, and the target speed information of the single-axis device are determined as the final next execution state information of the field device.
6. The control program conversion method according to any one of claims 1 to 4, characterized in that, The method further includes: Obtain the product's location information; The location information is input into the standard control program to obtain camera control information; The camera control information is sent to the camera so that the camera can capture images of the product when the camera control information is set to capture; Receive product images sent by a camera; analyze the product images using an image perception operator library to determine whether the product is defective; if the product is defective, control the robotic arm to send the product to the defective product area; if the product is not defective, control the robotic arm to send the product to the good product area.
7. A control program conversion device, characterized in that, The control program conversion device includes: The storage module is used to store the instructions in the non-standard control program in line order into the first global instruction linked list; and to store the variables in the instructions and the data types of the variables into the variable mapping table. The operation module is used to insert and delete ladder identifiers in the first global instruction list according to the position of the first operator and the serial block operator of the parallel circuit to obtain the second global instruction list; The operation module is further configured to insert omitted instructions into the second global instruction chain list according to the operators of each instruction in the second global instruction chain list to obtain a third global instruction chain list; The determination module is used to determine the standard control program based on the third global instruction list and the variable mapping table; The operation module is specifically used to sequentially traverse the first global instruction list. If the operator of the current traversal instruction is the first operator, a ladder identifier is inserted before the current traversal instruction. If the operator of the current traversal instruction is the serial block operator of a parallel circuit, the first global instruction list is traversed in reverse order starting from the current traversal instruction. When the operator of the current traversal instruction is a ladder identifier, the current traversal instruction is deleted and the first global instruction list is continued to be traversed sequentially starting from the current traversal position.
8. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the control program conversion method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the control program conversion method as described in any one of claims 1 to 6.