Master-slave communication device, method, electronic device and storage medium

Through the combination of the master control chip and PLD chip, the unified hardware design of Modbus master-slave communication is realized, solving the limitations of the multi-channel communication interface, improving communication efficiency and reducing costs.

CN116016018BActive Publication Date: 2025-07-25STATE NUCLEAR POWER AUTOMATION SYST ENGCO
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211626101.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-15
Publication Date
2025-07-25
Estimated Expiration
2042-12-15

AI Technical Summary

Technical Problem

The existing Modbus master and slave communication equipment have different hardware, and the multi-channel communication interface can only be achieved at most two channels, the system is complex and the communication efficiency is not high.

Method used

Using the combination of the main control chip and the PLD chip, the main control chip can work in the main station mode or the slave mode, and realizes multiple parallel communication through the PLD chip to unify the hardware design.

Benefits of technology

Reduces hardware costs and maintenance workload, improves communication efficiency, simplifies design and reduces device count.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116016018B_ABST
    Figure CN116016018B_ABST
Patent Text Reader

Abstract

The present invention discloses a master-slave station communication device, method, electronic device and storage medium. Among them, the master-slave station communication device includes a main control chip and a PLD chip which are communicatively connected, and the main control chip can operate in the master station mode or the slave station mode. This device runs the master station communication function and the slave station communication function with different programs in the same hardware environment, unifying the hardware design, reducing the manufacturing cost and the workload of device maintenance; this device can realize parallel multi-channel transceiver of communication data through the multi-channel communication interfaces provided by the PLD chip, improving the communication efficiency; this device requires fewer components, has a simple design and a lower cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of communication technologies, and particularly relates to a master-slave station communication device and method. Background Art

[0002] The communication protocol is a commonly used protocol in DCS (Distributed Control System). This protocol is a pure software protocol. When applied, it usually uses an RS485 bus connection. The RS485 bus has stable communication, low cost, and a communication rate that can reach above 1 Mbps, fully meeting the communication requirements of industry.

[0003] Currently, both Modbus master station communication devices and Modbus slave station communication devices are communication interface modules that are frequently used in DCS. However, Modbus master station communication devices and Modbus slave station communication devices require different hardware modules, resulting in a large amount of maintenance work. Moreover, existing multi-channel Modbus communication devices are limited by the number of UART interfaces of the CPU and it is difficult to achieve more than two channels. Multi-channel Modbus communication devices above two channels require the use of multiple CPUs. Such a design makes the system complex, and the communication between CPUs basically uses serial ports (SPI, UART, or IIC interfaces) for communication, having the drawback of low communication efficiency. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to overcome the defects in the prior art that the hardware of Modbus master and slave station communication devices is different and the multi-channel communication interface can at most achieve two channels, and to provide a master-slave station communication device, method, electronic device, and storage medium.

[0005] The present invention solves the above technical problem through the following technical solutions:

[0006] In a first aspect, a master-slave station communication device is provided. The device includes a main control chip and a PLD (Programable Logic Device) chip that are communicatively connected. The main control chip operates in a master station mode or a slave station mode;

[0007] When the main control chip operates in the master station mode, the main control chip is used to connect to a master station device, the PLD chip is used to connect to a slave station device. The main control chip is used to respond to a request command sent by the master station device, generate a request frame according to the communication protocol, and send the request frame to the slave station device through the PLD chip, and receive a response frame sent by the slave station device through the PLD chip, and parse the response frame according to the communication protocol to obtain response data, and send the response data to the master station device;

[0008] When the master control chip operates in the slave mode, the master control chip is used to connect to the slave device, the PLD chip is used to connect to the master device, the master control chip is used to respond to a request frame sent by the master device through the PLD, obtain response data corresponding to the request frame, generate a response frame according to the communication protocol, and send the response frame to the master device through the PLD chip.

[0009] Preferably, when the master control chip operates in the master mode, the master control chip is used to send stored link information to the PLD chip, and the PLD chip is used to communicate with the slave device according to the link information; wherein, the link information includes the number of channels and the data transmission parameters of each channel.

[0010] Preferably, when the master control chip operates in the slave mode, the master control chip is used to periodically obtain accessible data from the slave device, store the accessible data in a preset memory area, and respond to a request frame sent by the master device through the PLD chip, and obtain response data corresponding to the request frame from the accessible data stored in the preset memory area.

[0011] Preferably, when the master control chip operates in the slave mode, the master control chip is specifically used to periodically obtain the accessible data from the slave device according to the stored slave register information.

[0012] Preferably, the slave register information includes a time interval, and the master control chip is specifically used to periodically obtain the accessible data from the slave device according to the time interval.

[0013] and / or

[0014] the slave register information includes a register address, and the master control chip is specifically used to obtain the accessible data from the register corresponding to the register address in the slave device.

[0015] In a second aspect, a master-slave communication method is provided, which uses any one of the master-slave communication devices for communication, and includes the following steps:

[0016] When the master control chip operates in the master mode, the master control chip responds to a request command sent by the master device, generates a request frame according to the communication protocol, and sends the request frame to the slave device through the PLD chip, and receives a response frame sent by the slave device through the PLD chip, and parses the response frame according to the communication protocol to obtain response data, and sends the response data to the master device;

[0017] When the master control chip operates in the slave mode, the master control chip responds to the request frame sent by the master device through the PLD, obtains the response data corresponding to the request frame, generates a response frame according to the communication protocol, and sends the response frame to the master device through the PLD chip.

[0018] Preferably, the master-slave communication method further includes the following steps:

[0019] When the master control chip operates in the master mode, the master control chip sends the stored link information to the PLD chip, and the PLD chip communicates with the slave device according to the link information; wherein, the link information includes the number of channels and the data transmission parameters of each channel.

[0020] Preferably, the master-slave communication method further includes the following steps:

[0021] When the master control chip operates in the slave mode, the master control chip periodically obtains accessible data from the slave device and stores the accessible data in a preset memory area; in response to the request frame sent by the master device through the PLD chip, obtains the response data corresponding to the request frame from the accessible data stored in the preset memory area.

[0022] In a third aspect, an electronic device is provided, including a memory, a master control chip, and a computer program stored on the memory and executable on the master control chip. When the master control chip executes the computer program, any of the master-slave communication methods is implemented.

[0023] In a fourth aspect, a computer-readable storage device is provided, on which a computer program is stored. When the computer program is executed by the master control chip, any of the master-slave communication methods is implemented.

[0024] The positive and progressive effects of the present invention are as follows: The present invention provides a master-slave communication device, method, electronic device, and storage medium. The master control chip in the master-slave communication device can operate in the master mode or the slave mode, running the master communication function and the slave communication function in different programs in the same hardware environment, unifying the hardware design, reducing the manufacturing cost and the workload of device maintenance; the device can realize parallel multi-channel transceiver communication data through the multi-channel communication interface provided by the PLD chip, improving the communication efficiency; the device requires fewer components, has a simple design, and a lower cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a hardware structure diagram of the master-slave communication device provided in Embodiment 1 of the present invention.

[0026] Figure 2The connection structure diagram of the master-slave communication device provided in Embodiment 1 of the present invention when working in the master station mode with an external device.

[0027] Figure 3 The connection structure diagram of the master-slave communication device provided in Embodiment 1 of the present invention when working in the master station mode with an external device.

[0028] Figure 4 The structural schematic diagram of the electronic device provided in Embodiment 3 of the present invention. Detailed implementation manners

[0029] The present invention will be further described below by way of embodiments, but the present invention is not limited to the scope of the described embodiments.

[0030] Embodiment 1

[0031] This embodiment discloses a master-slave communication device that uses a certain communication protocol during communication, and the communication protocol can be the Modbus communication protocol. The hardware structure of the device when using the Modbus communication protocol is as Figure 1 shown, including a main control chip 1 and a PLD chip 2 that are communicatively connected, and the main control chip 1 operates in the master station mode or the slave station mode.

[0032] Specifically, the main control chip 1 can be a CPU or an MCU, including an 8-bit MCU, a 16-bit MCU, a 32-bit MCU, a 64-bit MCU, or can also be an MPU; the PLD chip 2 can also be an FPGA or a CPLD; the main control chip 1 communicates with an external master station device or slave station device through a serial interface or an Ethernet interface, and communicates with the PLD chip 2 through a parallel interface or a serial interface; the PLD chip 2 communicates with an external master station device or slave station device through a Modbus-RS485 interface.

[0033] When the main control chip 1 operates in the master station mode, the connection structure of the master-slave communication device with an external device is as Figure 2 shown, the main control chip 1 is used to connect to the master station device, the PLD chip 2 is used to connect to the slave station device, and the connected slave station device can be one or multiple, and the connection links are Modbus-RS485_CH1 to Modbus-RS485_CHn; the main control chip 1 is used to respond to the request command sent by the master station device, generate a request frame according to the communication protocol, and send the request frame to the one or more slave station devices through the PLD chip 2, and receive the response frame sent by the slave station device through the PLD chip 2, and parse the response frame according to the communication protocol to obtain response data, and send the response data to the master station device.

[0034] When the master control chip 1 operates in the slave mode, the master control chip 1 is used to connect to slave devices, and the PLD chip 2 is used to connect to master devices. The master control chip is configured to respond to a request frame sent by the master device through the PLD chip 2, obtain response data corresponding to the request frame, generate a response frame according to the communication protocol, and send the response frame to the master device through the PLD chip 2. In a specific implementation, the device address stored in the master control chip 1 is set according to the device address of the slave device it is connected to. The device address is the device address in the Modbus data frame, and the data frame can be the request frame or the response frame.

[0035] In an alternative implementation, when the master control chip 1 operates in the master mode, the master control chip 1 is used to send the stored link information to the PLD chip 2, and the PLD chip 2 is used to communicate with the slave device according to the link information. Among them, the link information includes the number of channels and the data transmission parameters of each channel. Specifically, the data transmission parameters can include baud rate, port number, parity bit, stop bit, etc.

[0036] In an alternative implementation, when the master control chip 1 operates in the slave mode, the master control chip is used to periodically obtain accessible data from the slave device, store the accessible data in a preset memory area, and respond to a request frame sent by the master device through the PLD chip 2 to obtain response data corresponding to the request frame from the accessible data stored in the preset memory area.

[0037] In an alternative implementation, when the master control chip 1 operates in the slave mode, the master control chip 1 is specifically configured to periodically obtain the accessible data from the slave device according to the stored slave register information.

[0038] In an alternative implementation, the slave register information includes a time interval, and the master control chip 1 is specifically configured to periodically obtain the accessible data from the slave device according to the time interval.

[0039] In an alternative implementation, the slave register information includes a register address, and the master control chip 1 is specifically configured to obtain the accessible data from the register corresponding to the register address in the slave device.

[0040] In addition, the slave register information may further include a start address, a number of channels, a data type, a register type, an endian setting, etc. Among them, the start address is the start address of the register in the slave device where the accessible data is stored, and the data type is the data type of the accessible data.

[0041] This embodiment provides a master-slave communication device. The main control chip in this device operates in the master mode or the slave mode, running the master station communication function and the slave station communication function with different programs in the same hardware environment, unifying the hardware design, reducing the manufacturing cost and the workload of device maintenance. The device can realize parallel multi-channel transceiver communication data through the multi-channel communication interfaces provided by the PLD chip, improving the communication efficiency. The device requires fewer components, has a simple design, and lower costs.

[0042] Embodiment 2

[0043] This embodiment provides a master-slave communication method, which uses the master-slave communication device in Embodiment 1 for communication. During the communication process, a certain communication protocol is adopted. The communication protocol can be the Modbus communication protocol, including the following steps:

[0044] When the main control chip operates in the master mode, the main control chip responds to the request command sent by the master device, generates a request frame according to the communication protocol, and sends the request frame to the slave device through the PLD chip, and receives the response frame sent by the slave device through the PLD chip, and parses the response frame according to the communication protocol to obtain response data, and sends the response data to the master device;

[0045] When the main control chip operates in the slave mode, the main control chip responds to the request frame sent by the master device through the PLD, obtains the response data corresponding to the request frame, generates a response frame according to the communication protocol, and sends the response frame to the master device through the PLD chip.

[0046] In an optional embodiment, the master-slave communication method further includes the following steps:

[0047] The main control chip reads the stored driver type. If the driver type is the master type, the main control chip operates in the master mode. If the driver type is the slave type, the main control chip operates in the slave mode.

[0048] In an optional embodiment, the master-slave communication method further includes the following steps:

[0049] When the main control chip operates in the master mode, the main control chip sends the stored link information to the PLD chip, and the PLD chip communicates with the slave device according to the link information; wherein, the link information includes the number of channels and the data transmission parameters of each channel. Specifically, the data transmission parameters can include baud rate, port number, parity bit, stop bit, etc.

[0050] In an alternative embodiment, the master-slave communication method further includes the following steps:

[0051] When the master control chip operates in the slave mode, the master control chip periodically obtains accessible data from the slave device and stores the accessible data in a preset memory area; in response to a request frame sent by the master device through the PLD chip, the master control chip obtains response data corresponding to the request frame from the accessible data stored in the preset memory area.

[0052] This embodiment provides a master-slave communication method, which uses the master-slave communication device described in Embodiment 1 for communication. The master control chip in the master-slave communication device operates in the master mode or the slave mode, and runs the master station communication function and the slave station communication function in different programs in the same hardware environment, unifying the hardware design, reducing the manufacturing cost and the workload of device maintenance; the device can implement parallel multi-channel transceiver communication data through the multi-channel communication interface provided by the PLD chip, improving the communication efficiency; the device requires fewer components, has a simple design, and a lower cost.

[0053] Embodiment 3

[0054] Figure 4 FIG. 13 is a schematic structural diagram of an electronic device provided for Embodiment 3 of the present invention. The electronic device includes a memory, a master control chip, and a computer program stored on the memory and executable on the master control chip. When the master control chip executes the program, it implements the Modbus master-slave communication method provided in Embodiment 1. Figure 4 The displayed electronic device 40 is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.

[0055] As Figure 4 shown, the electronic device 40 may be presented in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 40 may include, but are not limited to: at least one of the above-mentioned master control chips 1, at least one of the above-mentioned memories 42, and a bus 43 connecting different system components (including the memory 42 and the master control chip 1).

[0056] The bus 43 includes a data bus, an address bus, and a control bus.

[0057] The memory 42 may include volatile memory, such as a random access memory (RAM) 421 and / or a cache memory 422, and may further include a read-only memory (ROM) 423.

[0058] The memory 42 may also include a program / utilities 425 having a set (at least one) of program modules 424. Such program modules 424 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment.

[0059] The main control chip 1 executes various functional applications and data processing by running a computer program stored in the memory 42, such as the master-slave communication method provided in Embodiment 2 of the present invention.

[0060] The electronic device 40 can also communicate with one or more external devices 44 (such as a keyboard, a pointing device, etc.). Such communication can be carried out through an input / output (I / O) interface 45. And, the device 40 for model generation can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 46. As shown in the figure, the network adapter 46 communicates with other modules of the device 40 for model generation through a bus 43. It should be understood that although Figure 3 not shown in the figure, other hardware and / or software modules can be used in combination with the device 40 for model generation, including but not limited to: microcode, device drivers, redundant main control chips, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.

[0061] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. In fact, according to the embodiments of the present invention, the features and functions of two or more of the above-described units / modules can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.

[0062] Embodiment 4

[0063] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by the main control chip, the master-slave communication method provided in Embodiment 2 is implemented.

[0064] Among them, the more specific readable storage medium that can be adopted includes, but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0065] In a possible implementation, the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to cause the terminal device to execute the master-slave communication method provided in Embodiment 2.

[0066] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages. The program code can be executed entirely on the user device, partially on the user device, executed as an independent software package, partially on the user device and partially on a remote device, or entirely on a remote device.

[0067] Although the specific implementation manners of the present invention have been described above, those skilled in the art should understand that this is only an example. The protection scope of the present invention is defined by the appended claims. Without departing from the principle and essence of the present invention, those skilled in the art can make various changes or modifications to these implementation manners, but these changes and modifications all fall within the protection scope of the present invention.

[0068] Although the specific implementation manners of the present invention have been described above, those skilled in the art should understand that this is only an example. The protection scope of the present invention is defined by the appended claims. Without departing from the principle and essence of the present invention, those skilled in the art can make various changes or modifications to these implementation manners, but these changes and modifications all fall within the protection scope of the present invention.

Claims

1. A master-slave communication device, characterized in that: It includes a main control chip and a PLD chip that are communicatively connected; The main control chip operates in the master mode or the slave mode; When the main control chip operates in the master mode, the main control chip is used to connect to the master device, the PLD chip is used to connect to the slave device, the main control chip is used to respond to the request command sent by the master device, generate a request frame according to the communication protocol, and send the request frame to the slave device through the PLD chip, and receive the response frame sent by the slave device through the PLD chip, and parse the response frame according to the communication protocol to obtain response data, and send the response data to the master device; When the main control chip operates in the slave mode, the main control chip is used to connect to the slave device, the PLD chip is used to connect to the master device, the main control chip is used to respond to the request frame sent by the master device through the PLD chip, obtain the response data corresponding to the request frame, generate a response frame according to the communication protocol, and send the response frame to the master device through the PLD chip; When the main control chip operates in the slave mode, the main control chip is used to periodically obtain accessible data from the slave device and store the accessible data in a preset memory area, and respond to the request frame sent by the master device through the PLD, and obtain the response data corresponding to the request frame from the accessible data stored in the preset memory area.

2. The master-slave station communication device according to claim 1, wherein: When the main control chip operates in the master mode, the main control chip is used to send the stored link information to the PLD chip, and the PLD chip is used to communicate with the slave device according to the link information; wherein, the link information includes the number of channels and the data transmission parameters of each channel.

3. The master-slave station communication device according to claim 1, characterized in that: When the main control chip operates in the slave mode, the main control chip is specifically used to periodically obtain the accessible data from the slave device according to the stored slave register information.

4. The master-slave station communication device according to claim 3, characterized in that: The slave register information includes a time interval, and the main control chip is specifically used to periodically obtain the accessible data from the slave device according to the time interval, and / or, The slave register information includes a register address, and the main control chip is specifically used to obtain the accessible data from the register corresponding to the register address in the slave device.

5. A master-slave communication method, characterized in that: Communicating using the master-slave communication device according to any one of claims 1-4 includes the following steps: When the main control chip operates in the master mode, the main control chip responds to the request command sent by the master device, generates a request frame according to the communication protocol, and sends the request frame to the slave device through the PLD chip, and receives the response frame sent by the slave device through the PLD chip, and parses the response frame according to the communication protocol to obtain response data, and sends the response data to the master device; When the master control chip operates in the slave mode, the master control chip responds to a request frame sent by the master device through the PLD chip, obtains response data corresponding to the request frame, generates a response frame according to the communication protocol, and sends the response frame to the master device through the PLD chip; When the master control chip operates in the slave mode, the master control chip periodically obtains accessible data from the slave device and stores the accessible data in a preset memory area; in response to a request frame sent by the master device through the PLD chip, obtains response data corresponding to the request frame from the accessible data stored in the preset memory area.

6. The master-slave station communication method according to claim 5, wherein: The master-slave communication method further includes the following steps: When the master control chip operates in the master mode, the master control chip sends stored link information to the PLD chip, and the PLD chip communicates with the slave device according to the link information; wherein, the link information includes the number of channels and data transmission parameters of each channel.

7. An electronic device, comprising a memory, a main control chip, and a computer program stored in the memory and executable on the main control chip, characterized in that: When the master control chip executes the computer program, it implements the master-slave communication method according to any one of claims 5-6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the master control chip, it implements the master-slave communication method according to any one of claims 5-6.

Citation Information

Patent Citations

  • Master-slave station communication method and system

    CN113938350A