Program module calling method and device in PLC ladder diagram programming environment

By encapsulating and importing the functions of AI modules into dynamic link libraries in the PLC ladder diagram programming environment, the problem of difficulty in applying the functions of AI modules is solved and the PLC control capability is enhanced.

CN113454546BActive Publication Date: 2025-05-02SIEMENS AG
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201980091427.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-16
Publication Date
2025-05-02
Estimated Expiration
2039-04-16

AI Technical Summary

Technical Problem

In the PLC ladder diagram programming environment, the functions of the AI ​​module are difficult to apply, which limits the control capabilities of the PLC.

Method used

By determining the functions that need to be called in the PLC ladder programming environment from the AI ​​module, setting them as an interface that complies with the PLC interface specifications, encapsulate them as a dynamic link library, and importing them into the PLC ladder programming environment, the corresponding FB module is automatically generated.

Benefits of technology

The function of conveniently applying AI modules in the PLC ladder diagram programming environment is realized, and the control capabilities of PLC are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113454546B_ABST
    Figure CN113454546B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of industrial control technology, and in particular to a method and device for calling a program module in a programmable controller (PLC) ladder diagram programming environment. The method comprises: determining (101) a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment from functions implemented by an artificial intelligence (AI) module compiled by a computer programming language; setting (102) the first function as an interface that complies with the interface specification of the PLC ladder diagram programming environment; setting (103) the second function as a non-calling method; encapsulating (104) the non-calling method and the interface into a dynamic link library; and importing (105) the dynamic link library into the PLC ladder diagram programming environment. One or more functions of the AI ​​module can be conveniently called in the PLC ladder diagram programming environment to enhance the control capability of the PLC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial control technology, and in particular to a program module calling method and device in a programmable logic controller (PLC) ladder diagram programming environment. Background Art

[0002] Artificial intelligence (AI) has a significant impact on the manufacturing industry. Manufacturers have begun to recognize and experience the advantages of AI. In particular, AI related to computer vision plays an important role in driving the manufacturing industry towards Industry 4.0.

[0003] PLCs can be implemented as small devices with dozens of input / output (I / O) interfaces or as large rack-mounted modular devices with thousands of I / O interfaces. PLCs process large amounts of data and can be used for further analysis processes.

[0004] Ladder Diagram (LD) programming language is a commonly used graphical programming language in PLC. Ladder Diagram programming language has the advantage of being intuitive and easy to understand. Ladder diagram consists of contacts, coils and function blocks (FB). Contacts represent logical input conditions, such as external switches and buttons; coils usually represent logical output results, which are used to control external indicator lights, contactors, etc.; FB is used to represent functions such as timers, counters or mathematical operation additional instructions.

[0005] Program modules used to implement artificial intelligence algorithms or functions, hereinafter referred to as "AI modules", are usually compiled by computer programming languages ​​such as C++ or C#. However, PLC programming engineers who are familiar with ladder diagram programming may not be proficient in AI knowledge. Therefore, many functions of AI modules are difficult to be applied in the PLC ladder diagram programming environment, and the realization of PLC control capabilities is limited. Summary of the invention

[0006] The embodiment of the present invention proposes a program module calling method and device in a PLC ladder diagram programming environment, so as to enhance the realization of the control capability of the PLC.

[0007] In the first aspect, a method for calling a program module in a PLC ladder diagram programming environment is provided. The method comprises: determining a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment from functions implemented by an AI module compiled by a computer programming language; setting the first function to an interface that complies with the interface specification of the PLC ladder diagram programming environment; setting the second function to a non-calling method; encapsulating the non-calling method and the interface into a dynamic link library (Dynamic LinkLibrary); and importing the dynamic link library into the PLC ladder diagram programming environment.

[0008] Therefore, the embodiment of the present invention sets the function (i.e., the first function) among the functions implemented by the AI ​​module that needs to be called in the PLC ladder diagram programming environment as an interface that complies with the interface specification of the PLC ladder diagram programming environment, encapsulates the method and the interface corresponding to the function (i.e., the second function) among the functions implemented by the AI ​​module that does not need to be called in the PLC ladder diagram programming environment as a dynamic link library, and imports the dynamic link library into the PLC ladder diagram programming environment. Therefore, the PLC ladder diagram programming environment can automatically generate an FB module corresponding to the first function based on the interface in the dynamic link library. Based on operating the FB module in the PLC ladder diagram programming environment by dragging and dropping, etc., the first function can be conveniently applied in the PLC ladder diagram programming environment, thereby enhancing the control capability of the PLC.

[0009] Preferably, setting the first function to an interface that complies with the interface specification of the PLC ladder diagram programming environment includes: converting the first function into a first method; and setting the input parameter type and output parameter type of the first method based on the interface specification of the PLC ladder diagram programming environment.

[0010] It can be seen that the embodiment of the present invention is based on declaring the first method corresponding to the first function as a global function, and the first method is implemented as an interface that can be called by an external program, so that the PLC ladder diagram programming environment can automatically generate an FB module corresponding to the first function based on the interface. Moreover, the input parameter type and output parameter type of the interface are set based on the interface specification of the PLC ladder diagram programming environment, which can avoid the situation where the first method cannot be recognized in the PLC ladder diagram programming environment due to different naming specifications.

[0011] Preferably, the interface specification based on the PLC ladder diagram programming environment, setting the input parameter type and output parameter type of the first method includes: setting the input parameter type of the first method to a string type or a Boolean type; or setting the output parameter type of the first method to a string type or a Boolean type.

[0012] Therefore, considering the characteristics that computer programming languages ​​and ladder diagram programming languages ​​have the same command specifications for string types or Boolean types, the input parameter type and output parameter type of the first method are uniformly set to string type or Boolean type, which effectively avoids the situation where the first method cannot be recognized in the PLC ladder diagram programming environment.

[0013] Preferably, setting the second function as a non-calling method includes: converting the second function into a second method; and declaring the second method as a local function.

[0014] Therefore, the implementation mode of the present invention declares the second method as a local function. The second method is equivalent to a hidden function that is not recognized by external programs. The FB module corresponding to the second method will not appear in the PLC ladder diagram programming environment, thereby streamlining the PLC ladder diagram programming interface.

[0015] In a second aspect, a program module calling device in a PLC ladder diagram programming environment is provided. The device comprises:

[0016] A function determination module, used to determine a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment from functions implemented by an AI module compiled by a computer programming language;

[0017] A first setting module, used for setting the first function to an interface conforming to an interface specification of the PLC ladder diagram programming environment;

[0018] a second setting module, used for setting the second function as a non-calling method;

[0019] A packaging module, used for packaging the non-calling method and the interface into a dynamic link library;

[0020] An import module is used to import the dynamic link library into the PLC ladder diagram programming environment.

[0021] Therefore, the embodiment of the present invention sets the first function among the functions implemented by the AI ​​module that needs to be called in the PLC ladder diagram programming environment as an interface that complies with the interface specification of the PLC ladder diagram programming environment, encapsulates the method corresponding to the second function among the functions implemented by the AI ​​module that does not need to be called in the PLC ladder diagram programming environment and the interface into a dynamic link library, and imports the dynamic link library into the PLC ladder diagram programming environment. The PLC ladder diagram programming environment can automatically generate an FB module corresponding to the first function based on the interface in the dynamic link library. Based on operating the FB module in the PLC ladder diagram programming environment by dragging and dropping, etc., the first function can be conveniently applied in the PLC ladder diagram programming environment, thereby enhancing the control capability of the PLC.

[0022] Preferably, the first setting module is used to convert the first function into a first method; set the input parameter type and output parameter type of the first method based on the interface specification of the PLC ladder diagram programming environment; and declare the first method as a global function.

[0023] It can be seen that the embodiment of the present invention is based on declaring the first method corresponding to the first function as a global function, and the first method is implemented as an interface that can be called by an external program, so that the PLC ladder diagram programming environment can automatically generate an FB module corresponding to the first function based on the interface. Moreover, the input parameter type and output parameter type of the interface are set based on the interface specification of the PLC ladder diagram programming environment, which can avoid the situation where the first method cannot be recognized in the PLC ladder diagram programming environment due to different naming specifications.

[0024] Preferably, the first setting module is used to set the input parameter type of the first method to a string type or a Boolean type; or, to set the output parameter type of the first method to a string type or a Boolean type.

[0025] Therefore, considering the characteristics that computer programming languages ​​and ladder diagram programming languages ​​have the same command specifications for string types or Boolean types, the input parameter type and output parameter type of the first method are uniformly set to string type or Boolean type, which effectively avoids the situation where the first method cannot be recognized in the PLC ladder diagram programming environment.

[0026] Preferably, the second setting module is used to convert the second function into a second method; and declare the second method as a local function.

[0027] Therefore, the implementation mode of the present invention declares the second method as a local function. The second method is equivalent to a hidden function that is not recognized by external programs. The FB module corresponding to the second method will not appear in the PLC ladder diagram programming environment, thereby streamlining the PLC ladder diagram programming interface.

[0028] In a third aspect, a program module calling device in a PLC ladder diagram programming environment is provided. The device includes a processor and a memory; the memory stores an application program executable by the processor, which is used to enable the processor to execute the program module calling method in the PLC ladder diagram programming environment as described in any one of the above items.

[0029] In a fourth aspect, a computer-readable storage medium is provided, in which computer-readable instructions are stored, and the computer-readable instructions are used to execute the program module calling method in the PLC ladder diagram programming environment as described in any of the above items. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The invention discloses a program module calling method in a PLC ladder diagram programming environment implemented by an embodiment of the present invention.

[0031] Figure 2 This is an exemplary structural diagram of a visual inspection module implemented with an AI algorithm in an embodiment of the present invention.

[0032] Figure 3 It is a schematic diagram of storing SCL files in a PLC ladder diagram programming environment according to an embodiment of the present invention.

[0033] Figure 4 A schematic diagram of configuring the environment variables of the visual inspection module in an embodiment of the present invention.

[0034] Figure 5 Schematic diagram showing input parameters and output parameters of a camera included in a visual inspection module according to an embodiment of the present invention.

[0035] Figure 6 Schematic diagram of parameter configuration of the scratch detection FB module according to an embodiment of the present invention.

[0036] Figure 7 It is a schematic diagram of the arrangement of the scratch detection FB module in the execution sequence according to the embodiment of the present invention.

[0037] Figure 8 It is a schematic diagram of calling newly added functions based on program modules in the PLC ladder diagram programming environment according to an embodiment of the present invention.

[0038] Fig. 9 It is a schematic diagram of a newly added SIFT algorithm in the PLC ladder diagram programming environment in an embodiment of the present invention.

[0039] Fig.10 The first exemplary structural diagram of the program module calling device in the PLC ladder diagram programming environment implemented in the embodiment of the present invention.

[0040] Fig.11 The second exemplary structural diagram of the program module calling device in the PLC ladder diagram programming environment implemented in the embodiment of the present invention.

[0041] The reference numerals are as follows:

[0042]

[0043]

[0044] DETAILED DESCRIPTION

[0045] In order to make the technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and implementation methods. It should be understood that the specific implementation methods described herein are only used to illustrate the present invention and are not configured to limit the scope of protection of the present invention.

[0046] For the sake of brevity and intuitiveness in description, the scheme of the present invention is explained below by describing several representative implementations. A large number of details in the implementations are only configured to help understand the scheme of the present invention. However, it is obvious that the technical solution of the present invention may not be limited to these details when implemented. In order to avoid unnecessarily obscuring the scheme of the present invention, some implementations are not described in detail, but only a framework is given. Hereinafter, "including" means "including but not limited to", and "according to..." means "at least according to..., but not limited to only according to...". Due to the language habits of Chinese, when the number of a component is not specifically specified below, it means that the component can be one or more, or can be understood as at least one.

[0047] The applicant found that: in the PLC programming process, the AI ​​module is usually compiled by computer programming languages ​​such as C++ or C#, but PLC programming engineers who are familiar with ladder diagram programming may not be proficient in computer programming languages, which makes it difficult for many functions of the AI ​​module to be applied in the PLC ladder diagram programming environment, thereby limiting the realization of the PLC control capability. In addition, the applicant also found that: by setting the first function among the functions implemented by the AI ​​module that needs to be called in the PLC ladder diagram programming environment as an interface that complies with the interface specification of the PLC ladder diagram programming environment, the method corresponding to the second function among the functions implemented by the AI ​​module that does not need to be called in the PLC ladder diagram programming environment and the interface are encapsulated as a dynamic link library, and after the dynamic link library is imported into the PLC ladder diagram programming environment, the PLC ladder diagram programming environment can generate an FB module corresponding to the interface based on the dynamic link library and can be called in the PLC ladder diagram programming environment. Based on operating the FB module in the PLC ladder diagram programming environment by dragging and dropping, the first function can be conveniently applied in the PLC ladder diagram programming environment, thereby enhancing the realization of the PLC control capability. Based on this, an embodiment of the present invention provides a program module calling method, device, and computer-readable medium in a PLC ladder diagram programming environment, which are specifically described as follows.

[0048] The embodiment of the present invention proposes a program module calling method in a PLC ladder diagram programming environment.

[0049] Figure 1 The invention discloses a program module calling method in a PLC ladder diagram programming environment implemented by an embodiment of the present invention.

[0050] like Figure 1 As shown, the method includes:

[0051] Step 101: Determine, from the functions implemented by the AI ​​module compiled by the computer programming language, a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment.

[0052] The AI ​​module usually includes one or more functions. Based on whether it needs to be called in the PLC ladder diagram programming environment, the functions implemented by the AI ​​module can be determined as the first function and the second function respectively. Among them: one or more functions that need to be called in the PLC ladder diagram programming environment are determined as the first function; one or more functions that do not need to be called in the PLC ladder diagram programming environment are determined as the second function.

[0053] Among them, the computer programming language for compiling the AI ​​module can be implemented as various types of programming languages ​​such as C++ programming language, C# programming language, C programming language, JAVA programming language, etc.

[0054] Preferably, the AI ​​module can be implemented as a machine vision AI module, such as a visual inspection module or a robot vision module. Specifically: a visual inspection module is used to perform high-precision quantitative inspections based on AI algorithms (e.g., cell classification of microphotographs, size and position measurement of mechanical parts, etc.) and qualitative or semi-quantitative inspections without measuring instruments (e.g., appearance inspection of products, identification and positioning of parts on assembly lines, defect detection and assembly completeness detection, etc.). A robot vision module is used to guide the operation and actions of robots in a large range based on AI algorithms, such as picking up workpieces from a pile of messy workpieces sent from a hopper and placing them on a conveyor belt or other equipment in a certain orientation.

[0055] Preferably, the AI ​​module can also be implemented as a vibration detection module that monitors the mechanical vibration state based on the AI ​​algorithm, or a sound detection module that detects sound based on the AI ​​algorithm, etc.

[0056] The above exemplary descriptions are typical examples of computer programming languages ​​and AI modules. Those skilled in the art will appreciate that such descriptions are merely exemplary and are not intended to limit the scope of protection of the embodiments of the present invention.

[0057] The following takes the implementation of the AI ​​module as a visual inspection module as an example to illustrate that the functions implemented by the AI ​​module are determined as the first function and the second function.

[0058] Figure 2 This is an exemplary structural diagram of a visual inspection module implemented with an AI algorithm in an embodiment of the present invention.

[0059] Depend on Figure 2It can be seen that the visual inspection module 20 includes a scratch detection function 201 , a surface defect detection function 202 , a label position detection function 203 , a photo taking function 204 and a camera connection function 205 .

[0060] Among them: the camera connection function 205 is used to establish a connection with the camera; the photo function 204 is used to take a photo of the workpiece based on the connection relationship with the camera; the label position detection function 203 is used to detect information related to the label based on the taken photos, including whether there is a label, whether the label position is deviated, whether the label is damaged, the position of the label mark (LOGO), etc.; the surface defect detection function 202 is used to detect the defect state of the workpiece surface based on the taken photos, such as determining whether there are surface defects such as cracks, silver streaks, grooves, ripples, waviness and embrittlement; the scratch detection function 201 is used to detect whether there are scratches on the workpiece surface based on the taken photos.

[0061] In the embodiment of the present invention, based on whether it is necessary to be used in the PLC ladder diagram programming environment, the function implemented by the visual inspection module 20 is determined as a first function and a second function. Among them, the first function is a function that needs to be used in the PLC ladder diagram programming environment, and the number of the first function and the second function is a function that does not need to be used in the PLC ladder diagram programming environment, and the number of the second function and the second function can also be one or more.

[0062] Example 1: When only the scratch detection function 201 is needed in the PLC ladder diagram programming environment, the scratch detection function 201 is determined as the first function, and the surface defect detection function 202, the label position detection function 203, the photo taking function 204 and the camera connection function 205 are determined as the second function.

[0063] Example 2: When the scratch detection function 201 and the surface defect detection function 202 are needed in the PLC ladder diagram programming environment, the scratch detection function 201 and the surface defect detection function 202 are determined as the first function, and the label position detection function 203, the photo taking function 204 and the camera connection function 205 are determined as the second function.

[0064] Example 3: When the scratch detection function 201 and the label position detection function 203 are needed in the PLC ladder diagram programming environment, the scratch detection function 201 and the label position detection function 203 are determined as the first function, and the surface defect detection function 202, the photo taking function 204 and the camera connection function 205 are determined as the second function.

[0065] The above uses the AI ​​module implemented as a visual detection module as an example to illustrate the situation where the functions implemented by the AI ​​module are determined as the first function and the second function. Those skilled in the art can appreciate that this description is only exemplary and is not used to limit the protection scope of the embodiments of the present invention. For example, the AI ​​module can also be implemented as a robot vision module, a vibration detection module, or a sound detection module, etc.

[0066] Step 102: Setting the first function as an interface that complies with the interface specification of the PLC ladder diagram programming environment.

[0067] In one embodiment, setting the first function determined in step 102 as an interface that complies with the interface specification of the PLC ladder diagram programming environment specifically includes: converting the first function into a first method; setting the input parameter type and output parameter type of the first method based on the interface specification of the PLC ladder diagram programming environment; and declaring the first method as a global (public) function. The specific process of converting the first function into the first method includes: determining one or more code segments corresponding to the first function; and encapsulating the one or more code segments into the first method.

[0068] Preferably, in view of the fact that the naming conventions for string or Boolean types in the interface specifications of the PLC ladder diagram programming environment are the same as the naming conventions for string or Boolean types in computer programming languages ​​such as C++, C# or JAVA, the input parameter type of the first method is set to string or Boolean type, and the output parameter type of the first method is set to string or Boolean type, thereby avoiding the situation where the first method cannot be recognized in the PLC ladder diagram programming environment due to the different naming conventions between the PLC ladder diagram programming environment and the computer programming language.

[0069] After declaring the first method set based on the interface specification of the PLC ladder diagram programming environment as a global function, the first method is equivalent to an interface that can be called by an external program.

[0070] Step 103: Set the second function as a non-calling method.

[0071] In one embodiment, setting the second function determined in step 101 as a non-calling method specifically includes: converting the second function into a second method; declaring the second method as a local (private) function. The specific process of converting the second function into the second method includes: determining one or more code segments corresponding to the second function; and encapsulating the one or more code segments into the second method.

[0072] Therefore, after declaring the second method as a local function, the second method is equivalent to a hidden function that is not recognized by external programs.

[0073] Preferably, step 102 and step 103 may be specifically performed in a computer programming language compilation environment taking Visual Studio as an example.

[0074] For example, in step 102, using the Visual Studio compilation environment, the input parameters of the method corresponding to the scratch detection function determined as the first function in step 101 are set to:

[0075] (1) Photoelectric sensor signal, named REQ, configured as Boolean type, where 1 indicates that the photoelectric sensor is blocked by the workpiece, that is, the workpiece is detected, and 0 indicates that the photoelectric sensor is not blocked by the workpiece, that is, the workpiece is not detected; (2) Camera IP address signal, named myIPPort, configured as string type, used to input the camera IP address; (3) Camera shooting parameters, named myRequest1, configured as string type, used to input shooting parameters such as exposure time and sensitivity; (4) Storage location of the collected image, named myRequest2, configured as string type, used to input the specific storage location of the collected image.

[0076] Furthermore, in step 102, using the Visual Studio compilation environment, the output parameters of the method corresponding to the scratch detection function determined as the first function in step 101 are set to:

[0077] (1) The first output signal of the detection result is named myPass and is configured as a Boolean type, where 1 indicates that a scratch is detected and 0 indicates that no scratch is detected; (2) The second output signal of the detection result is named myRely and is configured as a string type, where the detection result is described in the form of a string, such as "cannot connect to the camera", "camera connection is unstable", etc.

[0078] The configuration process of the input parameters and output parameters of the first function is described above by taking the scratch detection function as an example. Those skilled in the art will appreciate that such description is merely exemplary and is not intended to limit the protection scope of the embodiments of the present invention.

[0079] Step 104: Encapsulate the non-calling methods and interfaces into a dynamic link library.

[0080] Here, non-calling methods and interfaces can be encapsulated as a dynamic link library in the development environment corresponding to the AI ​​module compilation language.

[0081] For example, when the AI ​​module is compiled by computer programming languages ​​such as C++, C# or JAVA, the non-calling methods and interfaces can be encapsulated as a dynamic link library in the VisualStudio computer programming language compilation environment. For example, the specific versions of Visual Studio that can encapsulate dynamic link libraries include: Visual Studio 2008; VisualStudio 2010; Visual Studio 2012; Visual Studio 2013; Visual Studio 2014; VisualStudio 2015, etc.

[0082] The above exemplary description is of the compilation environment used to encapsulate non-call methods and interfaces into a dynamic link library. Those skilled in the art will appreciate that such description is merely exemplary and is not intended to limit the protection scope of the embodiments of the present invention.

[0083] Step 105: Import the dynamic link library into the PLC ladder diagram programming environment.

[0084] Here, the dynamic link library encapsulated in step 104 is imported into the PLC ladder diagram programming environment, and the PLC ladder diagram programming environment can automatically generate an FB module corresponding to the interface in the dynamic file library.

[0085] For example, when the PLC ladder diagram programming environment is implemented as a Totally Integrated Automation (TIA) portal, the dynamic link library can be imported into the target project folder of the TIA portal. Based on the dynamic link library, the TIA portal automatically generates a file in the structured control language (Structured Control Language, SCL) file format in the external source folder, and the SCL file declares an interface that can be converted into an FB module. Then, by receiving a trigger command for the SCL file (for example, right-click), an FB module corresponding to the interface can be generated, and the FB module has a first function.

[0086] Figure 3 Schematic diagram of storing SCL files in a PLC ladder diagram programming environment according to an embodiment of the present invention. Figure 3It can be seen that the SCL file ODK_zeromk.scl (wherein the SCL file can be automatically named by TIA Portal) 71 automatically generated by TIA Portal based on the import of the dynamic link library is automatically saved in the external source folder 70 of TIA Portal. When an interface that can be converted to an FB module is declared in the SCL file 71, if TIA Portal receives a trigger command issued by a user right-clicking the SCL file 71, TIA Portal automatically generates an FB module based on the SCL file 71, and the FB module has a first function corresponding to the interface. When multiple interfaces that can be converted to FB modules are declared in the SCL file 71, if TIA Portal receives a trigger command issued by a user right-clicking the SCL file 71, TIA Portal automatically generates multiple FB modules based on the SCL file 71, and each FB module has a first function corresponding to a respective interface.

[0087] When the FB module is applied in the PLC ladder diagram programming environment, it is usually necessary to set environment variables (such as system time, output text font, output text size, etc.).

[0088] The following takes the TIA Portal environment where the AI ​​module is implemented as a visual inspection module including three cameras, the first function is the scratch detection function, and all three cameras are associated with the scratch detection function as an example to illustrate the process of setting environmental variables.

[0089] Figure 4 A schematic diagram of configuring environment variables of a visual inspection module in a project tree according to an embodiment of the present invention.

[0090] Depend on Figure 4It can be seen that the environment variables of the visual detection module can be configured in the "Device" properties of the project tree of the TIA Portal. For example, the configuration area includes the setting area 400, the acquisition area 401 and the camera area 402. Among them, the setting area 400 contains the operating environment setting parameters of the visual detection module, such as system time, default time zone, etc.; the acquisition area 401 contains the preset parameters of the output value of the visual detection module, such as the default font of the output text, the default size of the output text, etc.; the camera area 402 contains the setting parameters of the camera, in which 3 cameras are presented: Camera 1 (named ODK_ZEROMQODK_mqCIient_i_i_i_o_o_img_DB_ANA_AUTO_CAMERA_1), Camera 2 (named ODK_ZEROMQODK_mqCIient_i_i_i_o_o_img_DB_ANA_AUTO_CAMERA_2) Camera 3 (named ODK_ZEROMQODK_mqCIient_i_i_i_o_o_img_DB_ANA_AUTO_CAMERA_3).

[0091] When a camera in the camera area 402 is triggered, the input parameters and output parameters of the scratch detection function may be specifically displayed in the new interface.

[0092] Figure 5 Schematic diagram showing the input parameters and output parameters of the scratch detection function in the embodiment of the present invention. Figure 4 When camera 1 in camera area 402 is triggered, the Figure 5 The interface shown.

[0093] Depend on Figure 5 It can be seen that the input (INPUT) parameters of the scratch detection function related to camera 1 include: (1) the photoelectric sensor signal generated based on the user configuration, named REQ; (2) the camera IP address signal generated based on the user configuration, named myIPPort; (3) the camera shooting parameters generated based on the user configuration, named myRequest1; (4) the storage location of the captured image generated based on the user configuration, named myRequest2. The output (OUTPUT) parameters of the scratch detection function related to camera 1 include: the error (ERROR) signal generated by TIA Portal by default, the completed (DONE) signal generated by TIA Portal by default, the busy (BUSY) signal generated by TIA Portal by default, the status (STATUS) signal generated by TIA Portal by default, the first output signal generated based on the user configuration (named myPass) and the second output signal generated based on the user configuration (named myRely).

[0094] Among them, both input signals and output signals can include specific attributes such as data type, initial value, retain attribute, access attribute, read attribute, writeable attribute, visible attribute, set point attribute and supervisor attribute. Among them, the data type of input signals and output signals is not editable by default to prevent them from being recognized in the PLC ladder diagram programming environment due to misediting, while other attributes of input signals and output signals are editable.

[0095] The above PLC ladder diagram programming environment is exemplarily described using TIA Portal as an example, and those skilled in the art will appreciate that this description is only exemplary. In fact, the PLC ladder diagram programming environment can also be implemented as other PLC programming environments, and the embodiments of the present invention are not limited to this.

[0096] After the PLC compiler generates the FB module, the PLC programming engineer can call the FB module in the PLC ladder diagram programming environment by dragging and dropping. For example, the PLC programming engineer can drag the FB module into the ladder diagram execution sequence in the PLC ladder diagram programming environment, and the PLC programming engineer configures the specific values ​​of the input parameters of the FB module in the ladder diagram execution sequence. Then, the PLC compiler executes the ladder diagram execution sequence, thereby introducing AI capabilities into the PLC.

[0097] Figure 6 It is a schematic diagram of parameter configuration of the scratch detection FB module according to an embodiment of the invention.

[0098] Depend on Figure 6 It can be seen that on the interface of the PLC ladder diagram programming environment, the scratch detection FB module 30 generated by the PLC compiler is displayed as a box. The left side of the box is the input side, and the right side is the output side.

[0099] Specifically, the input parameters of the scratch detection FB module 30 include:

[0100] (1) The enable (EN) signal automatically generated by the PLC compiler is configured as a Boolean type, where 0 represents disabled and 1 represents enabled;

[0101] (2) A photoelectric sensor signal (REQ) generated based on user configuration, which is configured as a Boolean type, where 1 indicates that the photoelectric sensor is blocked by the workpiece, and 0 indicates that the photoelectric sensor is not blocked by the workpiece;

[0102] (3) The camera IP address signal (myIPPort) generated based on the user configuration is configured as a string type and is used to input the camera IP address;

[0103] (4) The camera shooting parameters (myRequest1) generated based on the user configuration are configured as a string type and are used to input shooting parameters such as exposure time and sensitivity.

[0104] (5) The storage location of the collected images generated based on the user configuration (myRequest2) is configured as a string type and is used to enter the specific storage location of the collected images.

[0105] Moreover, the output parameters of the scratch detection FB module 30 generated by the PLC compiler include:

[0106] (1) The enable output signal (ENO) automatically generated by the PLC compiler is configured as a Boolean type, where 0 represents disabled and 1 represents enabled;

[0107] (2) The error (ERROR) signal automatically generated by the PLC compiler is configured as a Boolean type;

[0108] (3) The completed (DONE) signal automatically generated by the PLC compiler is configured as a Boolean type;

[0109] (4) The BUSY signal automatically generated by the PLC compiler is configured as a Boolean type;

[0110] (5) The status (STATUS) signal automatically generated by the PLC compiler is configured as an integer type;

[0111] (6) A first output (myPass) signal generated based on user configuration, configured as a Boolean type;

[0112] (7) The second output (myRely) signal generated based on the user configuration is configured as a string type.

[0113] It can be seen that the input parameters of the scratch detection FB module 30 generated by the PLC compiler correspond to the input parameter settings of the method corresponding to the scratch detection function in step 102, and the output parameters of the scratch detection FB module 30 generated by the PLC compiler correspond to the output parameter settings of the method corresponding to the scratch detection function in step 102.

[0114] After the PLC programming engineer drags the scratch detection FB module 30 to the ladder diagram execution sequence in the PLC ladder diagram programming environment, he then configures specific values ​​of the input parameters of the scratch detection FB module 30 in the ladder diagram execution sequence.

[0115] Figure 7FIG. 4 is a schematic diagram of the arrangement of the scratch detection FB block in the execution sequence according to an embodiment of the present invention.

[0116] For example, the PLC programming engineer can fill in the camera IP address of the string type in the camera IP address signal (myIPPort) of the scratch detection FB module 30; fill in the exposure time, sensitivity and other string type photography parameters in the camera photography parameters (myRequest1) of the scratch detection FB module 30; and fill in the storage location of the collected picture in the storage location (myRequest2) of the collected picture of the scratch detection FB module 30. In addition, the PLC programming engineer can connect the photoelectric sensor signal (REQ) to the photoelectric sensor for providing a Boolean photoelectric sensor signal, and connect the EN signal to the bus in the execution sequence.

[0117] After the PLC programmer configures the input parameters, the PLC programmer triggers the PLC compiler to execute the ladder diagram execution sequence. At this time, the scratch detection FB module 30 can output a first output signal (myPass) indicating whether a scratch is detected and a second output signal (myRely) for explaining the detection result.

[0118] It can be seen that in the embodiments of the present invention, various capabilities in the AI ​​module can be introduced into the PLC without the need for the PLC programming engineer to be proficient in AI knowledge, thereby enriching the processing capabilities of the PLC.

[0119] Figure 8 It is a schematic diagram of calling newly added functions based on program modules in the PLC ladder diagram programming environment according to an embodiment of the present invention.

[0120] Depend on Figure 8 It can be seen that based on the embodiment of the present invention, a FB module 801 supporting a C++ library 802 can be added to the PLC ladder diagram programming environment 800. By dragging the FB module 801 in the PLC ladder diagram programming environment, many functions supported by OpenCV version 4.0 (or above) 803 can be implemented in the PLC, such as the deep learning deployment toolkit 804, data flow graph (TENSORFLOW) 805, deep learning library (MXNET) 806, open neural network exchange (ONNX) 807, region-based convolutional neural network (Region-Based Convolution Network) 808, YOLO version 3 (V3) 809 or open pose evaluation (OpenPose) 810, etc.

[0121] The above exemplary descriptions describe the new functions of the PLC ladder diagram programming environment based on program module calls. Those skilled in the art will appreciate that such descriptions are merely exemplary and are not intended to limit the scope of protection of the embodiments of the present invention.

[0122] For example, the Scale-Invariant Feature Transform (SIFT) function can also be applied in PLC.

[0123] Fig. 9 It is a schematic diagram of applying SIFT algorithm in PLC ladder diagram programming environment in the embodiment of the present invention.

[0124] based on Figure 1 In the process shown, the SIFT function 900 contained in the AI ​​module is determined as the first function, and the other functions contained in the AI ​​module are determined as the second function. The first function is converted into the first method, and the second function is converted into the second method. Based on the interface specification of the PLC ladder diagram programming environment, the parameter types of the template URL 901 and the captured image URL 902 of the input parameters of the first method are configured, the parameter types of the result 903 and the text message 904 of the output parameters of the first method are configured, and the first method is declared as a global function, and the second method is declared as a local function. The first method and the second method are encapsulated as a dynamic link library, and after the dynamic link library is imported into the PLC ladder diagram programming environment, the PLC ladder diagram programming environment automatically generates an FB module corresponding to the interface in the dynamic file library. Therefore, the SIFT function 900 can be freely called in the PLC ladder diagram programming environment by dragging the FB module.

[0125] Based on the above description, the embodiment of the present invention further proposes a program module calling device in a PLC ladder diagram programming environment.

[0126] Fig.10 It is a first exemplary structural diagram of a program module calling device in a PLC ladder diagram programming environment according to an embodiment of the present invention.

[0127] like Fig.10 As shown, the program module calling device 500 in the PLC ladder diagram programming environment includes:

[0128] The function determination module 501 is used to determine, from the functions implemented by an AI module compiled by a computer programming language, a first function that needs to be called in a PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment;

[0129] A first setting module 502, used to set the first function to an interface that complies with an interface specification of a PLC ladder diagram programming environment;

[0130] The second setting module 503 is used to set the second function as a non-calling method;

[0131] The encapsulation module 504 is used to encapsulate the non-calling methods and interfaces into a dynamic link library;

[0132] The import module 505 is used to import the dynamic link library into the PLC ladder diagram programming environment.

[0133] In one embodiment, the first setting module 502 is used to convert the first function into a first method; set the input parameter type and output parameter type of the first method based on the interface specification of the PLC ladder diagram programming environment; and declare the first method as a global function.

[0134] In one embodiment, the first setting module 502 is used to set the input parameter type of the first method to be a string type or a Boolean type; or, to set the output parameter type of the first method to be a string type or a Boolean type.

[0135] In one embodiment, the second setting module 503 is used to convert the second function into a second method; and declare the second method as a local function.

[0136] Fig.11 It is a second exemplary structural diagram of the program module calling device in the PLC ladder diagram programming environment according to the embodiment of the invention.

[0137] exist Fig.11 In the present invention, a program module calling device 600 in a PLC ladder diagram programming environment includes a memory 602 and a processor 601; the memory 602 stores an application program that can be executed by the processor 601, which is used to enable the processor 601 to execute the program module calling method in the PLC ladder diagram programming environment as described in any of the above items.

[0138] It should be noted that not all steps and modules in the above processes and structure diagrams are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The division of each module is only for the convenience of describing the functional division adopted. In actual implementation, a module can be implemented by multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or in different devices.

[0139] The hardware modules in each embodiment can be implemented mechanically or electronically. For example, a hardware module may include a specially designed permanent circuit or logic device (such as a dedicated processor, such as an FPGA or ASIC) for performing a specific operation. The hardware module may also include a programmable logic device or circuit (such as a general-purpose processor or other programmable processor) temporarily configured by software to perform a specific operation. As for whether to implement the hardware module mechanically, or using a dedicated permanent circuit, or using a temporarily configured circuit (such as configured by software), it can be decided based on cost and time considerations.

[0140] The present invention also provides a machine-readable storage medium, storing instructions for making a machine perform a method as described herein. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code for realizing the function of any one of the embodiments described in the above-mentioned embodiments is stored, and the computer (or CPU or MPU) of the system or device reads out and executes the program code stored in the storage medium. In addition, the operating system etc. operated on the computer can also be made to complete part or all of the actual operations by instructions based on the program code. The program code read out from the storage medium can also be written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then the CPU etc. installed on the expansion board or expansion unit are made to perform part and all of the actual operations based on the instructions of the program code, thereby realizing the function of any one of the embodiments described in the above-mentioned embodiments.

[0141] Storage media implementations for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, program code can be downloaded from a server computer or cloud via a communication network.

[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0143] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments, but the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A program module calling method in a programmable logic controller (PLC) ladder diagram programming environment, characterized in that: include: Determine (101) a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment from functions implemented by an artificial intelligence (AI) module compiled in a computer programming language; Setting (102) the first function to an interface that complies with an interface specification of the PLC ladder diagram programming environment; Wherein, the first function includes a scratch detection function and a scale-invariant feature transformation function; The second function is set (103) as a non-calling method; the non-calling method and the interface are packaged (104) into a dynamic link library; Importing (105) the dynamic link library into the PLC ladder diagram programming environment; Wherein, the step of importing (105) the dynamic link library into the PLC ladder diagram programming environment comprises: The dynamic link library is imported into a target project folder of a fully integrated automation portal; based on the dynamic link library, the fully integrated automation portal automatically generates a file in a structured control language file format in an external source folder, wherein the file declares an interface that can be converted into a function block module.

2. The method according to claim 1, characterized in that Setting (102) the first function to an interface that complies with an interface specification of the PLC ladder diagram programming environment includes: converting the first function into a first method; Based on the interface specification of the PLC ladder diagram programming environment, setting the input parameter type and the output parameter type of the first method; Declare the first method as a global function.

3. The method according to claim 2, characterized in that The interface specification based on the PLC ladder diagram programming environment, setting the input parameter type and output parameter type of the first method includes: Set the input parameter type of the first method to string or Boolean; or Set the output parameter type of the first method to string or Boolean type.

4. The method according to any one of claims 1 to 3, characterized in that: Setting the second function (103) as a non-calling method includes: converting the second function into a second method; Declare the second method as a local function.

5. A program module calling device (500) in a programmable logic controller (PLC) ladder diagram programming environment, characterized in that: include: A function determination module (501) is used to determine a first function that needs to be called in the PLC ladder diagram programming environment and a second function that does not need to be called in the PLC ladder diagram programming environment from functions implemented by an artificial intelligence (AI) module compiled in a computer programming language; A first setting module (502) is used to set the first function as an interface that complies with the interface specification of the PLC ladder diagram programming environment; wherein the first function includes a scratch detection function and a scale-invariant feature transformation function; A second setting module (503), used for setting the second function as a non-calling method; A packaging module (504), used for packaging the non-calling method and the interface into a dynamic link library; An import module (505) for importing the dynamic link library into the PLC ladder diagram programming environment; The import module (505) is further used for: The dynamic link library is imported into a target project folder of a fully integrated automation portal; based on the dynamic link library, the fully integrated automation portal automatically generates a file in a structured control language file format in an external source folder, wherein the file declares an interface that can be converted into a function block module.

6. The device (500) according to claim 5, characterized in that The first setting module (502) is used to convert the first function into a first method; set the input parameter type and output parameter type of the first method based on the interface specification of the PLC ladder diagram programming environment; and declare the first method as a global function.

7. The device (500) according to claim 6, characterized in that The first setting module (502) is used to set the input parameter type of the first method to be a string type or a Boolean type; or, to set the output parameter type of the first method to be a string type or a Boolean type.

8. The device (500) according to any one of claims 5 to 7, characterized in that The second setting module (503) is used to convert the second function into a second method; and declare the second method as a local function.

9. A program module calling device (500) in a programmable logic controller (PLC) ladder diagram programming environment, characterized in that: comprising a processor (601) and a memory (602); The memory (602) stores an application program that can be executed by the processor (601), which is used to enable the processor (601) to execute a program module calling method in a PLC ladder diagram programming environment as described in any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that Computer-readable instructions are stored therein, and the computer-readable instructions are used to execute the program module calling method in the PLC ladder diagram programming environment as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for Object Oriented Programming of Programmable Logic Controllers in Graphical Programming Languages

    US20140059518A1