CN114785635B - Programmable logic controller connection method and device, terminal equipment and storage medium - Google Patents

Programmable logic controller connection method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN114785635B
CN114785635B CN202210701922.XA CN202210701922A CN114785635B CN 114785635 B CN114785635 B CN 114785635B CN 202210701922 A CN202210701922 A CN 202210701922A CN 114785635 B CN114785635 B CN 114785635B
Authority
CN
China
Prior art keywords
module
serial number
identification code
product serial
slave module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210701922.XA
Other languages
Chinese (zh)
Other versions
CN114785635A (en
Inventor
李�亨
张震
毛浩翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Yankong Automation Technology Co ltd
Original Assignee
Shenzhen Yankong Automation Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Yankong Automation Technology Co ltd filed Critical Shenzhen Yankong Automation Technology Co ltd
Priority to CN202210701922.XA priority Critical patent/CN114785635B/en
Publication of CN114785635A publication Critical patent/CN114785635A/en
Application granted granted Critical
Publication of CN114785635B publication Critical patent/CN114785635B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/05Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
    • G05B19/054Input/output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2596Translation of addresses of the same type other than IP, e.g. translation from MAC to MAC addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Power Engineering (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Automation & Control Theory (AREA)
  • Programmable Controllers (AREA)

Abstract

The application discloses a programmable logic controller connection method, a programmable logic controller connection device, terminal equipment and a storage medium, and belongs to the field of industrial control. The method comprises the following steps: receiving the virtual identification code and the product serial number sent by the slave module; binding the virtual identification code and the product serial number; sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number; and receiving a write success mark returned after the slave module is successfully compared so as to establish software communication with the slave module. According to the connecting method of the programmable logic controller, the virtual identification code of the slave module is bound and compared with the product serial number, so that the module identification ID of the programmable logic controller is changed from the connection based on the hardware ID and the physical interface into the identification and interconnection communication based on software, the reliable connection is ensured, and the product hardware cost is effectively reduced.

Description

Programmable logic controller connection method and device, terminal equipment and storage medium
Technical Field
The present application relates to the field of industrial control, and in particular, to a method and an apparatus for connecting a programmable logic controller, a terminal device, and a storage medium.
Background
A PLC (Programmable Logic Controller) is a Programmable memory in nature, and controls various types of mechanical devices or production processes through digital or analog input and output, and is widely used in the fields of industrial control, automatic control, and the like. Because the PLC is not provided with enough interfaces, an expansion module is often required to be used, most of the current PLCs are designed into a multi-module connection mode, and therefore, the research on the connection method of the PLC is very meaningful.
A more common PLC connection method is to identify a master module and a slave module by sampling an identification code (ID), and a multi-bit toggle switch or a master-slave IO (Input-Output) is required to identify the ID. However, the industrial multi-bit dial switch is high in cost, a testing station of the dial switch must be added in production of products, production efficiency is reduced, production cost is greatly increased, and if module identification is performed by using a master-slave IO, although cost is reduced to a certain extent compared with that of the dial switch, an extra master-slave IO connecting line still needs to be added, and hardware cost still exists. Another PLC connection method is to perform connection by sampling Ethcat (ethernet Control Automation Technology), and this method needs to work under a specific communication protocol and a specific hardware interface form, so that hardware cost and product overall cost are greatly increased.
Therefore, it is necessary to provide a connection method of the programmable logic controller which is effective in reducing the cost.
Disclosure of Invention
The present application mainly aims to provide a method and an apparatus for connecting a programmable logic controller, a terminal device, and a storage medium, and aims to solve the problem of high hardware cost in the current programmable logic controller connection scheme.
In order to achieve the above object, the present application provides a method for connecting a programmable logic controller, where the programmable logic controller includes: the method is applied to a master module of a programmable logic controller, and the programmable logic controller connection method comprises the following steps:
receiving the virtual identification code and the product serial number sent by the slave module;
binding the virtual identification code and the product serial number;
sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and receiving a write success mark returned after the slave module is successfully compared so as to establish software communication with the slave module.
Optionally, the step of receiving the virtual identification code and the product serial number sent by the slave module comprises:
establishing a physical connection with the slave module;
based on the physical connection, transmitting a broadcast signal to the slave module to cause the slave module to transmit the virtual identification code and product serial number.
Optionally, the main module comprises: the method comprises a slave module identification code storage area and a master module product serial number storage area, wherein the step of binding the virtual identification code and the product serial number comprises the following steps:
registering the virtual identification code in the slave module identification code storage area;
and registering the product serial number in the main module product serial number area.
Optionally, the step of receiving a write success flag returned after the slave module successfully compares the write success flag to establish software communication with the slave module includes:
calculating the number of the write success flags received by the master module;
and if the number of the successfully written marks is equal to the number of the bound virtual identification codes and product serial numbers sent by the master module, performing software communication with the slave module according to a preset communication protocol.
In order to achieve the above object, the present invention further provides a method for connecting a programmable logic controller, the method being applied to a slave module of the programmable logic controller, the method comprising the steps of:
receiving a broadcast signal sent by a main module of the programmable logic controller;
sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal;
receiving the bound virtual identification code and the product serial number sent by the main module;
comparing the product serial number with the bound virtual identification code;
and if the comparison is successful, sending a writing success mark to the main module to establish software communication with the main module.
Optionally, the slave module comprises: the method comprises a slave module virtual identification code storage area and a slave module product serial number storage area, wherein the step of sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal further comprises the following steps:
assigning the virtual identification code to the slave module;
writing the virtual identification code into the slave module virtual identification code storage area;
and writing the product serial number of the slave module into the slave module product serial number storage area.
Optionally, the step of comparing the bound virtual identification code with the product serial number includes:
and if the product serial number in the bound virtual identification code and the product serial number is equal to the product serial number in the slave module product serial number storage area, the comparison is successful.
In addition, an embodiment of the present application further provides a programmable logic controller connection device, where the programmable logic controller connection device includes:
the data receiving module is used for receiving the virtual identification code and the product serial number sent by the slave module;
the data binding module is used for binding the virtual identification code and the product serial number;
the data transmission module is used for sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and the communication module is used for receiving a write-in success mark returned after the slave module successfully compares so as to establish software communication with the slave module.
In addition, the present application also provides a terminal device, where the terminal device includes a memory, a processor, and a program for connecting a programmable logic controller, which is stored in the memory and can be executed on the processor, and when the program for connecting a programmable logic controller is executed by the processor, the method for connecting a programmable logic controller as described above is implemented.
Furthermore, the present application also proposes a computer-readable storage medium, on which a programmable logic controller connection program is stored, which, when executed by a processor, implements the steps of the programmable logic controller connection method as described above.
The programmable logic controller connection method, the programmable logic controller connection device, the terminal equipment and the storage medium provided by the embodiment of the application receive the virtual identification code and the product serial number sent by the slave module; binding the virtual identification code and the product serial number; sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number; and receiving a write success mark returned by the comparison success of the slave module so as to establish software communication with the slave module. Based on the scheme of the application, for the problem of module connection of the programmable logic controller, the virtual ID (identification code) of the module is used for replacing the physical hardware ID of the module so as to perform software connection and communication between the modules, so that software ID identification is completely realized, hardware ID identification by using extra hardware equipment is avoided, and cost caused by hardware ID identification is effectively reduced.
Drawings
Fig. 1 is a schematic diagram of functional modules of a terminal device to which a programmable logic controller connection device belongs according to the present application;
FIG. 2 is a schematic flow chart illustrating a first embodiment of a programmable logic controller connection method according to the present application;
FIG. 3 is a schematic flow chart diagram illustrating a second embodiment of a PLC connection method according to the present application;
FIG. 4 is a schematic diagram of a programmable logic controller connection method according to the present application, illustrating physical connections between master and slave modules of the programmable logic controller;
FIG. 5 is a schematic flow chart illustrating a third exemplary embodiment of a programmable logic controller connection method according to the present application;
FIG. 6 is a schematic flow chart illustrating a fourth exemplary embodiment of a programmable logic controller connection method according to the present application;
FIG. 7 is a schematic flow chart illustrating a fifth exemplary embodiment of a programmable logic controller connection method according to the present application;
fig. 8 is a flowchart illustrating a method for connecting a programmable logic controller according to a sixth embodiment of the present application.
The implementation, functional features and advantages of the object of the present application will be further explained with reference to the embodiments, and with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
The main solution of the embodiment of the application is as follows: by receiving the virtual identification code and the product serial number sent by the slave module; binding the virtual identification code and the product serial number; sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number; and receiving a write-in success mark returned after the slave module is successfully compared so as to establish software communication with the slave module. Based on the scheme, aiming at the problem of connection of the programmable logic controller, the virtual identification code and the product serial number are combined, hardware-based ID identification such as a hardware dial switch, a hardware IO and the like is converted into the virtual identification code of the module through software amplitude, so that the virtual identification code of the module replaces the physical hardware ID of the module to carry out connection and communication between the modules, software ID identification is completely realized, and the cost brought by hardware ID identification is effectively reduced.
The technical terms related to the embodiments of the present application are:
a Programmable Logic Controller (PLC), a digital operation Controller with a microprocessor for automatic control, which can load control instructions into a memory at any time for storage and execution. The programmable controller consists of functional units such as a CPU, an instruction and data memory, an input/output interface, a power supply, a digital-analog converter and the like. Early PLC had only logic control function, so it was named PLC, and later, with the development of the Computer module with simple function, it had various functions including logic control, sequential control, analog control, multi-Computer communication, etc., and its name was changed to PLC (Programmable Controller), but because its abbreviation PC conflicts with the abbreviation PC (Personal Computer), and because of the habitual reason, people often used the abbreviation of PLC, and still used the abbreviation of PLC.
The PLC widely uses the ladder diagram to replace a computer language, has certain advantages for programming, and can understand the ladder diagram into a programming language just like a calculator language such as assembly, and only has different application ranges. It is common practice for PLC software to convert ladder diagrams into C or assembly language (determined by the CPU used by the PLC) and then compiled into machine code using an assembly or C-compiler system. The PLC essentially runs only machine code, and the ladder diagram is simply easier for the user to use.
In order to cope with various complicated application scenarios, in current industrial applications, the PLC is often designed in a multi-level module interconnection form. Generally, a PLC has a main module (a power module, a CPU, and an I/O module are integrated together), and sometimes, since the number of points required for controlling a control object is large and the number of I/O points of a main unit is insufficient, a slave module needs to be added, or a specific control module (a communication module, an analog module, etc.) is required in some fields, and these modules are not integrated on the main unit, these expansion modules need to be added to meet the control requirement of the system. Typically, the expansion modules communicate with the PLC connection via a bus, and the address or ID of each expansion module must be unique to distinguish it from the other modules. In the field of current automation control, the schemes for PLC connection are mainly composed of two types: one is that hardware ID is sampled to identify and connect the master module and the slave module, and the identification of the hardware ID is realized by a multi-bit dial switch or master-slave IO; the other mode is a sampling EthCat cascade mode, which is improved in transmission efficiency and response speed but limited by a specific communication protocol and a specific hardware interface, so that the hardware cost and the whole product cost are greatly improved. In order to meet the market demand for low-cost, stable and reliable PLC, it is necessary to design a PLC connection method to reduce cost.
In the embodiment of the application, because the industrial-grade multi-bit dial switch is high in cost, and a test station of the dial switch must be added in the production of a product, if the multi-bit dial switch is adopted for hardware ID identification, the production efficiency is reduced, and the production cost is increased, and the cascading expansion of the product is limited by the number of the dial switch, for example, an 8-bit dial switch can support 32 hardware IDs at most, which limits the number of slave modules. If the master-slave IO is adopted for module ID identification, although the cost is reduced to a certain extent compared with a dial switch, a connection line between the master-slave IO and the slave IO is still required, similarly, the production test cost of product functions is inevitably existed in the product design based on hardware, the production function test is inevitably existed in the hardware function in design, and the production test cost is existed even if the IO connection is also subjected to open-short circuit test. In addition, the number of the IO for hardware ID identification is usually limited by the number of the MCU (Micro Controller Unit, single chip microcomputer) and the number of the connection lines of the master module and the slave module, and the number of the IO for hardware ID identification is usually not more than 8 bits, which causes a similar problem, that is, the number of supportable IDs is 32 at most, so that the maximum number of the slave modules is limited to 32.
Therefore, according to the scheme of the embodiment of the application, the practical problem of PLC module connection is solved, the limitation and the defect of the existing hardware ID identification scheme are overcome, the existing hardware ID is assigned through software, and software identification and software interconnection communication are realized, so that the cost is effectively reduced in product design and production, and the benefits brought by a PLC cascade expansion technology are improved.
Specifically, referring to fig. 1, fig. 1 is a schematic diagram of functional modules of a terminal device to which the plc connecting device of the present application belongs. The PLC connection device may be a device capable of PLC connection, which is independent from the terminal device, and may be carried on the terminal device in the form of hardware or software. The terminal device may be any mobile terminal with a data processing function, or may be a fixed terminal or a server with a data processing function.
In this embodiment, the terminal device to which the plc connector belongs at least includes an output module 110, a processor 120, a memory 130, and a communication module 140.
The memory 130 stores therein an operating system and a plc connection program, and the plc connection program may store information such as a virtual identification code and a product serial number sent from a slave module, a binding result between the virtual identification code and the product serial number, a result of comparing the bound virtual identification code and the product serial number, and a write success flag sent to the master module when the comparison is successful, in the memory 130; the output module 110 may be a display screen or the like. The communication module 140 may include a WI-FI module, a mobile communication module, a bluetooth module, and the like, and communicates with an external device or a server through the communication module 140.
Wherein the plc interface in the memory 130 when executed by the processor implements the following steps:
receiving the virtual identification code and the product serial number sent by the slave module;
binding the virtual identification code and the product serial number;
sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and receiving a write success mark returned after the comparison of the slave module is successful so as to establish software communication with the slave module.
Further, the plc connector in the memory 130 when executed by the processor further performs the following steps:
establishing a physical connection with the slave module;
based on the physical connection, transmitting a broadcast signal to the slave module to cause the slave module to transmit the virtual identification code and the product serial number.
Further, the plc connector in the memory 130 when executed by the processor further implements the following steps:
registering the virtual identification code in the slave module identification code storage area;
and registering the product serial number in the main module product serial number area.
Further, the plc connector in the memory 130 when executed by the processor further performs the following steps:
calculating the number of the write success flags received by the master module;
and if the number of the successfully written marks is equal to the number of the bound virtual identification codes and product serial numbers sent by the master module, performing software communication with the slave module according to a preset communication protocol.
Further, the plc connector in the memory 130 when executed by the processor further implements the following steps:
receiving a broadcast signal sent by a main module of the programmable logic controller;
according to the broadcast signal, sending the virtual identification code and the product serial number of the slave module to the master module for binding; receiving the bound virtual identification code and the product serial number sent by the main module;
comparing the product serial number with the bound virtual identification code;
and if the comparison is successful, sending a writing success mark to the main module so as to establish software communication with the main module.
Further, the plc connector in the memory 130 when executed by the processor further performs the following steps:
assigning a virtual identification code to the slave module;
writing the virtual identification code into the slave module virtual identification code storage area;
and writing the product serial number of the slave module into the slave module product serial number storage area.
Further, the plc connector in the memory 130 when executed by the processor further implements the following steps:
and if the product serial number in the bound virtual identification code and the product serial number is equal to the product serial number in the slave module product serial number storage area, the comparison is successful.
In this embodiment, by adopting the above scheme, the virtual identification code and the product serial number sent by the slave module are specifically received; binding the virtual identification code and the product serial number; sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number; and receiving a writing success mark returned by the slave module so as to establish software communication with the slave module. Based on the scheme of the application, for the connection problem of the programmable logic controller, the virtual ID of the module replaces the physical hardware ID of the module to carry out connection and communication between the modules, and software ID identification is completely realized, so that the cost brought by hardware ID identification is effectively reduced.
Embodiments of the method of the present application are presented based on the above terminal device architecture, but not limited to the above, and it should be noted that although a logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different from that here. The main body of the method of this embodiment may be a plc connection device, or may also be a terminal device, and this embodiment is exemplified by the plc connection device, and the device may be integrated on a terminal device such as a desktop computer and a notebook computer having a data processing function.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a first embodiment of a method for connecting a programmable logic controller according to the present application. The programmable logic controller includes: the method is applied to a master module of a programmable logic controller, and the programmable logic controller connection method comprises the following steps:
step S10, receiving the virtual identification code and the product serial number sent by the slave module;
specifically, each PLC (i.e. programmable logic controller, for convenience, the present application refers to a programmable logic controller in the following description) module includes a Serial Number (SN), sometimes called SerialNo, that is, an SN Number (for convenience, the present application refers to a product Serial Number of a PLC module in the following description), which is a concept introduced for verifying "legal identity of a product", and each PLC module has a unique SN Number, so that the PLC module can be uniquely identified according to the SN Number.
More specifically, this embodiment is directed to connection between a master module and N (the number of the slave modules is determined by software addresses and driving capability of the interconnected communication device, and theoretically may be any natural number greater than 0) slave modules, where the PLC module referred to in this embodiment is a module that has been subjected to software assignment, and there are three storage areas in a ROM (Read-Only Memory) of the master module, where the three storage areas are:
a VMID area for storing a virtual identification code of the main module;
an MRSID area for storing an identification code of a slave module connected to the master module;
and the SSN area is used for storing SN numbers of the slave modules connected with the master module.
In contrast, there are also three memory areas in the ROM of each slave module, respectively:
a VSID area for storing a virtual identification code of the slave module;
an SRSID area for storing an actual identification code of the slave module;
and the SNN area is used for storing the SN number of the slave module.
After software assignment is completed, the VMID area of the master module stores the virtual identification code assigned to the master module, the VSID area of each slave module writes the virtual identification code assigned to the slave module, the SNN area of each slave module writes the SN number of the slave module, and other storage areas of the master module and the slave module write related information after the whole connection process is completed.
Step S20, binding the virtual identification code and the product serial number;
specifically, after receiving the virtual identification code and the product serial number sent by the slave module, the master module will bind the virtual identification code and the product serial number of each slave module, as an embodiment of the present invention, the binding process may be implemented by establishing a mapping table in the master module, writing the virtual identification code-product serial number of each slave module as a mapping into the mapping table, and when the subsequent master module needs to communicate with the slave module, looking up the identification code of the slave module through the mapping table, so as to implement the binding in a software level.
Step S30, the bound virtual identification code and the product serial number are sent to the slave module to compare the product serial number;
specifically, after the binding of the virtual identification code and the product serial number is completed, the master module sends the bound data to the slave module for checking, and the slave module confirms whether the product serial numbers in the bound data are the same or not and returns information. As an implementation manner, the master module may broadcast to all the slave modules, the sent broadcast information includes the bound data, each slave module connected to the master module receives the broadcast information, and compares its SNN region according to the broadcast to see whether SN numbers are equal.
And S40, receiving a write-in success mark returned after the slave module is successfully compared so as to establish software communication with the slave module.
Specifically, after the master module sends a broadcast containing binding data to the slave module, the slave module compares the binding data with the SN number stored in its SNN region, returns the stored binding data and a flag indicating that the binding write is successful to the master module if the comparison is successful, and does not send the binding data if the comparison is unsuccessful. After receiving the returned write success flag, the master module considers that the code binding with the slave module is successful, that is, the software ID connection with the slave module is established, so that software communication can be performed with the slave module.
In this embodiment, by adopting the above scheme, the virtual identification code and the product serial number sent by the slave module are specifically received; binding the virtual identification code and the product serial number; sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number; and receiving a write success mark returned after the slave module is successfully compared so as to establish software communication with the slave module. In the embodiment, the virtual identification code of the module and the product serial number are bound and returned to the slave module for confirmation, and the successful connection is determined by the write-in success mark returned by the slave module, so that the virtual identification code based on the software ID can replace the hardware ID for identification and communication, the hardware identification cost is effectively reduced, and the whole machine cost is reduced.
Further, referring to fig. 3, a second embodiment of the plc connection method according to the present application provides a flowchart, and based on step S10 of the above embodiment shown in fig. 2, the step of receiving the virtual identification code and the product serial number sent by the slave module includes:
step A10, establishing physical connection with the slave module;
specifically, referring to fig. 4, fig. 4 is a schematic diagram of physical connection between a master module and a slave module, and as shown in the figure, the product of this embodiment is configured as a master-slave structure programmable logic controller, and is formed by cascading or expanding one master module and N slave modules. As one embodiment, the master module and the slave module may perform interconnection communication using an industry standard communication protocol such as RS485 or CAN, and the connection between the slave modules may be a parallel connection or a serial connection, and is not limited to a physical connection.
More specifically, the present embodiment gives part of the description about the RS485 protocol and the CAN protocol:
RS485 protocol:
the interface level is low, the chip is not easy to damage, and logic '1' is represented by the voltage difference between two lines being + (2-6) V; logic '0' is expressed by the voltage difference between two lines being- (2-6) V, the interface signal level is lower than RS232, and the chip of the interface circuit is not easy to damage;
the transmission rate is high, the highest data transmission rate of RS485 can reach 35Mbps within a distance of 10 meters, and the transmission speed can reach 100Kbps at 1200 m;
the RS485 interface adopts the combination of a balanced driver and a differential receiver, so that the common-mode interference resistance is enhanced, namely, the noise interference resistance is good;
the transmission distance is long, the number of the supporting nodes is large, the RS485 bus can transmit more than 1200m (the rate is less than or equal to 100 Kbps) and generally supports 32 nodes at the maximum, if a special 485 chip is used, 128 or 256 nodes can be achieved, and 400 nodes can be supported at the maximum.
CAN protocol:
a Controller Area Network (CAN) bus is a serial communication protocol bus for real-time applications, which CAN use twisted pair wires to transmit signals, and is one of the most widely used field buses in the world. The CAN protocol is used for communication between various components in an automobile, thereby replacing expensive and heavy wiring harnesses. The robustness of this protocol extends its use to other automation and industrial applications. The features of the CAN protocol include serial data communication for integrity, real-time support, transmission rates up to 1Mb/s, and 11-bit addressing and error detection capabilities.
Step A20, based on the physical connection, sending a broadcast signal to the slave module to make the slave module send the virtual identification code and the product serial number.
Specifically, after the master-slave modules are physically connected, the master-slave modules are powered on, and after the master-slave modules are powered on, the master module can send broadcast signals to all the slave modules in a broadcast manner. In this step, the address of the broadcast signal is the virtual identification code of all existing slave modules, and the content of the broadcast signal may be a software field that notifies the slave modules to send their own virtual identification codes and SN numbers, which is not described in detail in this embodiment. After receiving the broadcast signal, the slave module responds and sends corresponding information to the sending address of the broadcast signal, namely the virtual identification code of the master module.
In this embodiment, by the above scheme, a physical connection with the slave module is specifically established; transmitting a broadcast signal to the slave module based on the physical connection. In this embodiment, the instruction information for sending the virtual identification code and the SN number is transmitted to the slave module through the above steps, so that after the slave module receives the broadcast signal containing the instruction information, the virtual identification code and the SN number of the slave module at this level can be automatically returned to the slave module, and the virtual identification code of the master module can be obtained according to the broadcast signal.
Further, referring to fig. 5, a third embodiment of the plc connection method according to the present application provides a flowchart. Based on the step S20 of the embodiment shown in fig. 2, the step of binding the virtual identification code and the product serial number includes:
step A201, registering the virtual identification code in the slave module identification code storage area;
step a202, the product serial number is registered in the main module product serial number area.
Specifically, before the master module receives the virtual identification code and the product serial number of the slave module, before binding the virtual identification code and the product serial number of the slave module, the master module needs to register the virtual identification code of the slave module in the MRSID area of the master module, and register the product serial number of the slave module in the SSN area of the master module.
More specifically, as an implementation manner, the virtual identification code and the product serial number of the slave module may be registered in the master module in any database form, and each time the master module receives a piece of information, the piece of information is stored in the database of the corresponding storage area, so that registration is completed, and after registration, the master module has the virtual identification code and the product serial number of the slave module, and thus, in a subsequent step, the virtual identification code and the product serial number of the slave module are connected, and broadcast may be performed according to the virtual identification code, and the binding data is sent to the slave module for comparison.
In this embodiment, by using the above scheme, the virtual identification code is specifically registered in the slave module identification code storage area; and registering the product serial number in the main module product serial number area. The embodiment is implemented before step S20 in the embodiment shown in fig. 2, and before the binding action of the main module is executed, registration is performed in the corresponding storage area, so that it is ensured that the binding does not affect the storage of data and the sending of subsequent information, and the application scenario of the present application is further expanded.
Further, referring to fig. 6, a fourth embodiment of the plc connection method according to the present application provides a schematic flow chart. Based on the step S40 in the embodiment shown in fig. 2, the step of receiving the write success flag returned after the slave module successfully compares the write success flag with the slave module to establish software communication with the slave module includes:
step S401, calculating the number of the write success flags received by the master module;
specifically, after all returned write success flags have been received in the master module, the number of write success flags is further counted, and each write success flag represents that the master module has established a stable and reliable communication connection with the slave module that sent the flag. As a calculation method, an updatable variable S may be set in the receiving area of the master module, the value of the variable S is incremented by 1 each time the master module receives a write success flag, and the variable S represents the number of all write success flags received by the master module after the master module receives the write success flag.
And step S402, if the number of the writing success marks is equal to the number of the bound virtual identification codes and product serial numbers sent by the master module, performing software communication with the slave module according to a preset communication protocol.
Specifically, ideally, if the master sends N pieces of binding data, the N write success flags should be received, but due to the possibility of various burst failures, it cannot be guaranteed that all the slaves can return the write success flags. Therefore, in this step, the number of the sent bound data is compared with the number of the received write success flags, if the two numbers are equal, it is proved that all the slave modules perform stable communication with the master module, and communication between the master module and the slave module CAN be performed according to a preset communication protocol (as shown in the above embodiment, RS485, CAN, or the like); if the number of the slave module and the master module is not equal, the connection failure of the slave module and the master module is proved to exist. In specific implementation, the slave module with the failed connection may be further processed, such as resending data, checking physical connection, and the like, which is not described herein again.
In this embodiment, by using the above scheme, the number of the write success flags received by the master module is specifically calculated; and if the number of the writing success marks is equal to the number of the bound virtual identification codes and product serial numbers sent by the master module, communicating with the slave module according to a preset communication protocol. Compared with the above embodiments, the present embodiment provides a scheme for determining connection conditions between the master module and all the slave modules, further expands application scenarios of the present application, and enhances the practicability of the present application.
Further, referring to fig. 7, a fifth embodiment of the connection method for a programmable logic controller according to the present application provides a flowchart, and this embodiment is applied to a slave module of the programmable logic controller, and the connection method for a programmable logic controller includes:
step S100, receiving a broadcast signal sent by a main module of a programmable logic controller;
step S200, according to the broadcast signal, sending the virtual identification code and the product serial number of the slave module to the master module for binding;
specifically, according to the broadcast signal sent by the master module, each slave module receiving the broadcast signal arranges its own virtual identification code and SN number into a piece of communication information and feeds back the piece of communication information to the master module, and the identification code of the master module can be obtained through the sending field of the broadcast signal, so that the master module can bind the virtual identification code and SN number of each slave module, for example, the slave module 1 sends its own virtual identification code ID1 and SN1 to the master module, the master module will register and bind ID1 and SN1 respectively, after binding is completed, the bound data will be sent to the slave module 1 again, and the slave module 1 will verify the bound data.
Step S300, receiving the bound virtual identification code and the product serial number sent by the main module;
step S400, comparing the product serial number with the bound virtual identification code;
specifically, after the master module is bound, the master module sends a broadcast signal to all slave modules, where the signal includes the bound virtual identification code and product serial number, and the slave modules compare the signals, such as bound SN1 and ID1, and the slave modules check whether SN1 is equal to their own SN number, and if so, store ID1 in the SRSID area of the slave module (regarding the respective storage area of the master and slave modules, refer to the content of the embodiment shown in fig. 2 above). Since the binding and comparing processes are implemented based on the software programming of the PLC module, the specific implementation methods are various, and this embodiment is not limited herein.
Step S500, if the comparison is successful, a writing success mark is sent to the main module so as to establish software communication with the main module.
If the comparison is successful, namely the SN1 in the binding data is equal to the SN number of the slave module at the current level, the master module can be considered to successfully bind the virtual identification code and the SN number of the slave module, and the slave module sends a writing success mark to the master module to indicate that the software communication between the slave module and the master module is successfully established. For a detailed description of the writing success flag, reference may be made to the related contents in the embodiment shown in fig. 6, and details are not repeated here.
In this embodiment, by the above scheme, a broadcast signal sent by a main module of a programmable logic controller is received; transmitting the virtual identification code and the product serial number of the slave module to the master module according to the broadcast signal; receiving the bound virtual identification code and the product serial number sent by the main module; comparing the product serial number with the bound virtual identification code; and if the comparison is successful, sending a writing success mark to the main module. Compared with the above embodiment, in the embodiment, for the description of the action executed by the slave module, the slave module feeds back the broadcast signal, performs registration binding on the master module, and helps the master module to determine the connection condition of each slave module by sending the write success flag, so that a scheme is provided for the slave module to connect the programmable logic controller, the application scenario of the application is further expanded, and the practicability of the application is enhanced.
Further, referring to fig. 8, a sixth embodiment of the plc connection method of the present application provides a flowchart. Based on the step S200 of the embodiment shown in fig. 7, the step of sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal includes:
step A100, assigning a virtual identification code to the slave module;
step A200, writing the virtual identification code into the slave module virtual identification code storage area;
specifically, the application aims to realize software communication between a master module and a slave module of the programmable logic controller, so that a virtual identification code is required to be used for identification instead of a hardware ID. When assigning a fixed virtual identification code to the slave module, factors such as a software address, the driving capability of the interconnected communication devices and the like can be comprehensively considered, and a fixed virtual identification code is assigned to the slave module according to actual needs and written into a VSID area of the slave module. Regarding the storage area of the slave module, reference may be made to the description in the embodiment shown in fig. 2, and the way of opening up the storage area may be in a software form, or may also be in a hardware form, so as to achieve the purpose of classified storage.
Step A300, writing the product serial number of the slave module into the slave module product serial number storage area.
As a unique identifier of each module, the SN number is stored in a slave module product serial number storage area SNN, each PLC module includes a non-volatile memory such as a ROM, and the storage area storing the SN number may be a stack in the ROM of the slave module, and the description of the storage area in the embodiment shown in fig. 2 may be specifically referred to.
In this embodiment, by the above scheme, a virtual identification code is specifically assigned to the slave module; writing the virtual identification code into the slave module virtual identification code storage area; and writing the product serial number of the slave module into the slave module product serial number storage area. Compared with the embodiment, the embodiment provides the information writing scheme of the slave module, so that the application scene of the application is expanded.
In addition, an embodiment of the present application further provides a programmable logic controller connection device, where the programmable logic controller connection device includes:
the data receiving module is used for receiving the virtual identification code and the product serial number sent by the slave module;
the data binding module is used for binding the virtual identification code and the product serial number;
the data transmission module is used for sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and the communication module is used for receiving a write-in success mark returned after the slave module is successfully compared so as to establish software communication with the slave module.
The embodiment of the present application provides another programmable logic controller connection device corresponding to a slave module of a programmable logic controller, where the device includes:
the data receiving module is used for receiving the broadcast signals sent by the main module of the programmable logic controller;
the data feedback module is used for sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal;
the binding data receiving module is used for receiving the bound virtual identification code and the product serial number sent by the main module;
the comparison module is used for comparing the product serial number with the bound virtual identification code;
and the comparison result feedback module is used for sending a writing success mark to the main module if the comparison is successful so as to establish software communication with the main module.
For the principle and implementation process of implementing the connection of the programmable logic controller, please refer to the above embodiments, which are not described herein again.
In addition, an embodiment of the present application further provides a terminal device, where the terminal device includes a memory, a processor, and a connection program of the programmable logic controller that is stored on the memory and is executable on the processor, and when the connection program of the programmable logic controller is executed by the processor, the steps of the connection method of the programmable logic controller described above are implemented.
Since the program for connecting the programmable logic controller is executed by the processor, all technical solutions of all the foregoing embodiments are adopted, so that at least all the beneficial effects brought by all the technical solutions of all the foregoing embodiments are achieved, and details are not repeated herein.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where a programmable logic controller connection program is stored on the computer-readable storage medium, and when executed by a processor, the programmable logic controller connection program implements the steps of the programmable logic controller connection method described above.
Since the program for connecting a programmable logic controller is executed by a processor, all technical solutions of all the foregoing embodiments are adopted, so that at least all the beneficial effects brought by all the technical solutions of all the foregoing embodiments are achieved, and details are not repeated herein.
Compared with the prior art, the method, the device, the terminal device and the storage medium for connecting the programmable logic controller provided by the embodiment of the application are used for connecting a master module and a slave module of the programmable logic controller, and the method specifically includes: obtaining a virtual identification code and a product serial number of the slave module; binding the virtual identification code and the product serial number of the slave module in the master module; comparing the bound virtual identification code with the product serial number; and if the comparison is successful, sending a writing success mark to the main module. According to the technical scheme, the module identification ID of the programmable logic controller is changed into software identification and interconnection communication from connection based on the hardware ID and the physical interface through binding the virtual identification code and the product serial number, so that the product hardware cost is effectively reduced while stable connection is ensured.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, a controlled terminal, or a network device) to execute the method of each embodiment of the present application.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all the equivalent structures or equivalent processes that can be directly or indirectly applied to other related technical fields by using the contents of the specification and the drawings of the present application are also included in the scope of the present application.

Claims (9)

1. A programmable logic controller connection method, the programmable logic controller comprising: the method is applied to a master module of a programmable logic controller, and the programmable logic controller connection method comprises the following steps:
receiving a virtual identification code and a product serial number sent by the slave module, wherein the virtual identification code is written in a virtual identification code storage area of the slave module, and the product serial number is written in a product serial number storage area of the slave module;
binding the virtual identification code and the product serial number;
sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and receiving a write-in success mark returned after the slave module is successfully compared so as to establish software communication with the slave module.
2. The programmable logic controller connection method of claim 1, wherein the step of receiving the virtual identification code and the product serial number transmitted from the slave module is preceded by:
establishing a physical connection with the slave module;
based on the physical connection, transmitting a broadcast signal to the slave module to cause the slave module to transmit the virtual identification code and product serial number.
3. The programmable logic controller connection method of claim 1, wherein the master module comprises: the method comprises a slave module identification code storage area and a master module product serial number storage area, wherein the step of binding the virtual identification code and the product serial number comprises the following steps:
registering the virtual identification code in the slave module identification code storage area;
and registering the product serial number in the main module product serial number area.
4. The plc connection method according to claim 1, wherein the step of receiving a write success flag returned after the slave module comparison succeeds to establish software communication with the slave module comprises:
calculating the number of the writing success marks received by the main module;
and if the number of the writing success marks is equal to the number of the bound virtual identification codes and product serial numbers sent by the master module, performing software communication with the slave module according to a preset communication protocol.
5. A programmable logic controller connection method is applied to a slave module of a programmable logic controller, and comprises the following steps:
receiving a broadcast signal sent by a main module of the programmable logic controller;
sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal, wherein the slave module sends the virtual identification code and the product serial number to the master module after receiving the broadcast signal;
receiving the bound virtual identification code and the product serial number sent by the main module;
comparing the product serial number with the bound virtual identification code;
if the comparison is successful, sending a writing success mark to the main module to establish software communication with the main module;
the slave module includes: the method comprises a slave module virtual identification code storage area and a slave module product serial number storage area, wherein the step of sending the virtual identification code and the product serial number of the slave module to the master module for binding according to the broadcast signal comprises the following steps:
assigning the virtual identification code to the slave module;
writing the virtual identification code into the slave module virtual identification code storage area;
and writing the product serial number of the slave module into the slave module product serial number storage area.
6. The plc connection method according to claim 5, wherein the step of comparing the bound virtual identification code and product serial number includes:
and if the product serial number in the bound virtual identification code and the product serial number is equal to the product serial number in the slave module product serial number storage area, the comparison is successful.
7. A programmable logic controller connection device, the connection device comprising:
the data receiving module is used for receiving the virtual identification code and the product serial number sent by the slave module, wherein the virtual identification code is written in the virtual identification code storage area of the slave module, and the product serial number is written in the product serial number storage area of the slave module;
the data binding module is used for binding the virtual identification code and the product serial number;
the data transmission module is used for sending the bound virtual identification code and the product serial number to the slave module for comparing the product serial number;
and the communication module is used for receiving a write-in success mark returned after the slave module is successfully compared so as to establish software communication with the slave module.
8. A terminal device, characterized in that the terminal device comprises a memory, a processor and a programmable logic controller connection program stored on the memory and executable on the processor, the programmable logic controller connection program, when executed by the processor, implementing the steps of the programmable logic controller connection method according to any of claims 1-4 or 5-6.
9. A computer-readable storage medium, characterized in that a programmable logic controller connection program is stored on the computer-readable storage medium, which when executed by a processor implements the steps of the programmable logic controller connection method of any of claims 1-4 or 5-6.
CN202210701922.XA 2022-06-21 2022-06-21 Programmable logic controller connection method and device, terminal equipment and storage medium Active CN114785635B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210701922.XA CN114785635B (en) 2022-06-21 2022-06-21 Programmable logic controller connection method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210701922.XA CN114785635B (en) 2022-06-21 2022-06-21 Programmable logic controller connection method and device, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114785635A CN114785635A (en) 2022-07-22
CN114785635B true CN114785635B (en) 2022-10-18

Family

ID=82420746

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210701922.XA Active CN114785635B (en) 2022-06-21 2022-06-21 Programmable logic controller connection method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114785635B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107703878A (en) * 2015-11-27 2018-02-16 中工科安科技有限公司 A kind of PLC distributed remotes I/O expansion module
CN110515343A (en) * 2019-09-25 2019-11-29 深圳市海浦蒙特科技有限公司 Communication link, programmable logic controller (PLC), the means of communication and product
CN113495498A (en) * 2021-07-06 2021-10-12 中国工商银行股份有限公司 Simulation method, simulator, device, and medium for hardware device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102955460A (en) * 2011-08-31 2013-03-06 上海三一精机有限公司 Control system of numerical control system master station over input/output (IO) terminal slave station
US10402358B2 (en) * 2014-09-30 2019-09-03 Honeywell International Inc. Module auto addressing in platform bus
JP6623856B2 (en) * 2016-03-11 2019-12-25 オムロン株式会社 Slave device, control method of slave device, information processing program, and recording medium
CN113625654B (en) * 2021-08-13 2022-03-29 杭州航民达美染整有限公司 Industrial equipment remote control method and device based on PLC
CN113645086A (en) * 2021-10-18 2021-11-12 四川旷谷信息工程有限公司 Data communication method, apparatus and medium for controlling device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107703878A (en) * 2015-11-27 2018-02-16 中工科安科技有限公司 A kind of PLC distributed remotes I/O expansion module
CN110515343A (en) * 2019-09-25 2019-11-29 深圳市海浦蒙特科技有限公司 Communication link, programmable logic controller (PLC), the means of communication and product
CN113495498A (en) * 2021-07-06 2021-10-12 中国工商银行股份有限公司 Simulation method, simulator, device, and medium for hardware device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
开放式PLC及扩展模块的实现;张锐等;《武汉理工大学学报(交通科学与工程版)》(第01期);第147-150页 *

Also Published As

Publication number Publication date
CN114785635A (en) 2022-07-22

Similar Documents

Publication Publication Date Title
US20150207631A1 (en) Accessory identification for mobile computing devices
US5941966A (en) Method and apparatus using a plural level processor for controlling a data bus
CN103605359A (en) Automobile diagnostic system and method
CN102104514A (en) Method for transmitting data from and to a control device
CN105635184A (en) Communication protocol conversion method, device and system
JP3426171B2 (en) Communication protocol conversion system, monitor device
JP3415849B2 (en) Data bus controllers and processes
CN113760334A (en) ECU program flashing method and device
CN108445860B (en) Diagnostic apparatus, diagnostic request processing method, and computer-readable storage medium
CN112996020A (en) Bluetooth-based automatic testing method and device and Bluetooth testing terminal
CN114785635B (en) Programmable logic controller connection method and device, terminal equipment and storage medium
JP2006020038A (en) Physical quantity sensor device and inspecting device therefor
CN113821440A (en) VxWorks application software testing method, system and simulator
KR100726081B1 (en) Network system and method thereof using inter-integrated circuit for vehicle
CN107453844B (en) Method and device for automatically networking intelligent equipment
CN107645430B (en) Data processing method, system and related equipment
JPH0320778B2 (en)
CN115980554A (en) Chip testing method and electronic equipment thereof
JP4962721B2 (en) Tool device and method for creating message transmission program
CN110757449A (en) Demonstrator-to-lower controller communication method, computer readable storage medium and robot
CN112769666B (en) PLC inter-station communication method
CN107168720B (en) SPI (Serial peripheral interface) configuration method based on FPGA (field programmable Gate array)
CN114221890B (en) Message simulation device, message sending method and device and computer storage medium
CN114338358B (en) Data interaction method, device, storage medium and PLC
CN116263866B (en) Automatic burning method and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant