Communication method, device, equipment and medium

By adopting the circular full-duplex bus structure and target address judgment method in industrial communication, the problems of slow communication speed and inflexible expansion of 485 bus are solved, and the rapid discovery of new equipment and flexible expansion of the system are achieved.

CN119544403AActive Publication Date: 2025-02-28CRRC INDUSTRAIL ACADEMY (QINGDAO) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411740559.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-02-28
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

In existing industrial communications, the 485 bus communication speed is slow and lacks the ability to discover equipment protocols and automatic address allocation, resulting in inflexible expansion of new equipment.

Method used

Adopting a ring-shaped full-duplex bus structure, adjacent devices are connected through uplink and downlink data lines. The host sends data frames containing the target address through the downlink data lines. The slave judges the data frame type based on the address and analyzes it. The host discovers frames through the uplink data line receiving device to confirm that the new device is joined.

Benefits of technology

It realizes flexible expansion of new equipment and rapid exchange of information, improving communication speed and system scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544403A_ABST
    Figure CN119544403A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method, which is applied to the field of communication, and comprises the following steps: sending at least one downlink data frame containing a target address to an adjacent slave through a downlink data line; wherein the target address contained in one downlink data frame containing the target address is 0, and the address number is allocated to the slave through the downlink data line from adjacent superior equipment at the beginning of each round of communication cycle; receiving an uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame; judging whether an equipment discovery frame exists in the uplink data frame or not; and if yes, determining that a new slave is added into the current system, and adding 1 to the number of the known slaves. The address number of the slave is not fixed, but is redistributed in each communication cycle, and the slave can send the device discovery frame to the host within the time period corresponding to the downlink data frame with the target address being 0, so that real-time discovery and flexible expansion of the new slave are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a communication method, device, equipment and medium. Background Art

[0002] At present, in industrial communication, in order to facilitate equipment maintenance, IO modules are usually designed as plug-in and cascade blades, and all modules follow the same interface specifications. Considering space utilization, the communication pins are generally left on the back of the module, and can be connected to the backplane through the communication pins for backplane communication. Common backplane communication uses the 485 bus. When the IO module is plugged in, it automatically draws power from the backplane and connects to the 485 bus to enable the host to access different devices.

[0003] However, the 485 bus has the problem of slow communication speed. At the same time, due to the lack of device discovery protocol and the ability to automatically assign addresses to slave devices, the 485 bus cannot flexibly expand new devices.

[0004] Therefore, how to achieve flexible expansion of new equipment and rapid exchange of information is an urgent problem to be solved. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a communication method, device, equipment and medium for realizing flexible expansion of new equipment and rapid exchange of information. The specific scheme is as follows:

[0006] In a first aspect, the present application provides a communication method, which is applied to a host, wherein the system in which the host and the slave are located adopts a ring full-duplex bus, and the slave is connected to an adjacent device through an uplink data line and a downlink data line at the same time, wherein the uplink data line is used to transmit an uplink data frame, and the downlink data line is used to transmit a downlink data frame; the communication method comprises:

[0007] Send at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame containing the target address is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame containing the target address; wherein the target address contained in one of the downlink data frames containing the target address is 0, so that the new slave that passes the verification returns a device discovery frame, and uses the device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent superior device through the downlink data line at the beginning of each communication cycle;

[0008] Receiving the uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame;

[0009] Determine whether the device discovery frame exists in the uplink data frame; if so, determine that a new slave has joined the current system, and increase the number of known slaves by 1.

[0010] Optionally, the address number is allocated to the slave by an adjacent upper-level device via the downlink data line at the beginning of each communication cycle, including:

[0011] The adjacent upper device transmits an address allocation frame to the slave through the downlink data line, wherein the address allocation frame includes an address number allocated to the slave, and the address number is the address number of the upper device plus 1.

[0012] Optionally, sending at least one downlink data frame including a target address to the adjacent slave through the downlink data line includes:

[0013] Continuously sending a synchronous clock signal to all the slaves via a clock line, and sending a frame start signal to all devices via a frame start data line;

[0014] Obtain the number n of the known slaves;

[0015] When the frame start signal jumps to the start signal; n+1 downlink data frames containing the target address are sent to the adjacent slaves in descending order according to the target address through the downlink data line; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to the frame end signal.

[0016] Optionally, sending a frame start signal to all devices via a frame start data line includes:

[0017] The frame end signal is sent to the new slave via the frame start data line so that the new slave can determine whether the frame count is equal to its address number; if so, the new slave passes the verification; wherein the frame count is the number of frame end signals in the current communication cycle.

[0018] Optionally, sending a frame start signal to all devices via a frame start data line includes:

[0019] Outputting a high level signal lasting for five CLK cycles via a frame start data line as the start signal;

[0020] A signal whose high level is less than one CLK cycle is outputted through the frame start data line as the frame start signal and as the frame end signal.

[0021] Optionally, sending a frame start signal to all devices via a frame start data line includes:

[0022] A frame start signal is sent to all the slaves via a frame start data line, so that when the frame count is equal to the known number of the slaves, it is determined whether the target address of the downlink data frame containing the target address received by the slave at this time is equal to the address number of the slave; if they are not equal, it is determined that the system is abnormal and the slave is reset; wherein, the known number of the slaves is contained in the downlink data frame containing the target address sent by the host in the first frame.

[0023] Optionally, the processing and analyzing the uplink data frame includes:

[0024] Based on the uplink data frame, determining whether there is an abnormality in the number and address number of the slaves;

[0025] If there is an abnormality, the known number of the slaves is reset to zero.

[0026] Optionally, after determining whether the device discovery frame exists in the uplink data frame, the method further includes:

[0027] Determining whether the device end frame exists in the uplink data frame; the device end frame is sent by the tail device after sending an uplink data frame containing collected data;

[0028] If it exists, it is determined that the current communication cycle is ended.

[0029] In a second aspect, the present application provides a communication method, which is applied to a slave, wherein the system in which the slave and the host are located adopts a ring full-duplex bus, and the slave is connected to an adjacent device through an uplink data line and a downlink data line at the same time, wherein the uplink data line is used to transmit an uplink data frame, and the downlink data line is used to transmit a downlink data frame; the communication method comprises:

[0030] At the beginning of each communication cycle, an address number is obtained through the downlink data line; wherein the address number is allocated by an adjacent upper-level device;

[0031] Receiving and forwarding a downlink data frame including a target address sent by the host through the downlink data line, wherein the target address included in one of the downlink data frames including the target address is 0; and judging whether the downlink data frame is a target data frame based on the target address and the address number; and if so, parsing and processing the downlink data frame;

[0032] Sending the uplink data frame via the uplink data line so that the host receives the uplink data frame and processes and analyzes the uplink data frame;

[0033] Determine whether it is a new slave; if it is a new slave, after passing the verification, return the device discovery frame as the uplink data frame through the uplink data line, so that the host can determine that a new device has joined the current system and increase the number of known slaves by 1.

[0034] Optionally, after acquiring the address number through the downlink data line, the method further includes:

[0035] Determine whether the address number assigned in the current communication cycle is the same as the address number assigned in the previous communication cycle;

[0036] If they are different, it is determined that a device failure occurs in the slave device, and the slave device is reset.

[0037] In a third aspect, the present application provides a communication device, applied to a host, comprising:

[0038] A data sending module, used for sending at least one downlink data frame including a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame; wherein the target address included in one of the downlink data frames is 0, so that the new slave that passes the verification returns a device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent superior device through the downlink data line at the beginning of each communication cycle;

[0039] A data receiving module, used for receiving an uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame;

[0040] The new device detection module is used to determine whether the device discovery frame exists in the uplink data frame; if so, it is determined that a new slave has joined the current system, and the number of known slaves is increased by 1.

[0041] In a fourth aspect, the present application provides an electronic device, including:

[0042] Memory, used to store computer programs;

[0043] The processor is used to execute the computer program to implement the above communication method.

[0044] In a fifth aspect, the present application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the above-mentioned communication method is implemented.

[0045] The communication method provided by the present application, the system where the host and the slave are located is a ring full-duplex bus, and the adjacent devices are connected through the uplink data line and the downlink data line at the same time. The address number of the slave is assigned by the adjacent superior device at the beginning of each round of communication cycle. The host sends at least one downlink data frame containing the target address through the downlink data line, and the target address contained in one of the downlink data frames is 0, so that the new slave can reply the device discovery frame as the uplink data frame within the time window provided by the downlink data frame with the target address of 0; the host receives the uplink data frame sent by the slave through the uplink data line, and determines whether there is a device discovery frame in the uplink data frame. If there is, it is necessary to add 1 to the number of identified slaves. It can be obtained from the above that the communication system in the present application adopts a ring full-duplex bus with a master-slave structure, which can realize read and write synchronization to realize the rapid exchange of information between the host and the slave. And the address of the slave in the communication system is not fixed, but is reallocated to the slave by the adjacent superior device through the downlink data line at the beginning of each round of communication cycle, so when a new slave joins, it can be assigned an address in time. In addition, the downlink data frame containing the target address sent by the host will contain a downlink data frame with a target address of 0, providing a time window for the new device to reply. The host can receive the device discovery frame replied by the new slave in this time window through the uplink data line to achieve real-time and rapid discovery of new devices, and thus achieve flexible expansion of new devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0047] Figure 1 A flow chart of a communication method provided for this application;

[0048] Figure 2 A schematic diagram of a communication system provided for this application;

[0049] Figure 3 A specific communication method flow chart provided for this application;

[0050] Figure 4 A device communication schematic diagram provided for this application;

[0051] Figure 5 A schematic diagram of a new slave discovery process provided by this application;

[0052] Figure 6A flow chart of a communication method provided for this application;

[0053] Figure 7 A communication device supporting real-time discovery provided by the present application;

[0054] Figure 8 A schematic diagram of the structure of a communication device supporting real-time discovery provided by the present application;

[0055] Fig. 9 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] At present, in industrial communication, in order to facilitate equipment maintenance, IO modules are usually designed as plug-in and cascade blades, and all modules follow the same interface specifications. Considering space utilization, the communication pins are generally left on the back of the module, and can be connected to the backplane through the communication pins for backplane communication. Common backplane communication uses the 485 bus. When the IO module is plugged in, it automatically draws power from the backplane and connects to the 485 bus to enable the host to access different devices.

[0058] However, the 485 bus has the problem of slow communication speed. At the same time, due to the lack of device discovery protocol and the ability to automatically assign addresses to slave devices, the 485 bus cannot flexibly expand new devices.

[0059] Therefore, how to achieve flexible expansion of new equipment and rapid exchange of information is an urgent problem to be solved.

[0060] To solve the above problems, see Figure 1 As shown, an embodiment of the present invention discloses a communication method, which is applied to a host and may include:

[0061] Step S11, sending at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame containing the target address is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame containing the target address; wherein the target address contained in one of the downlink data frames containing the target address is 0, so that the new slave that passes the verification returns a device discovery frame, and uses the device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent superior device through the downlink data line at the beginning of each communication cycle;

[0062] It should be noted that the communication system in which the host and the slave are located adopts a ring full-duplex bus. Compared with the 485 bus commonly used in the prior art, the host is not directly connected to the slave one-to-one, but is connected in a pipeline form. The slaves can be connected to the bus in sequence according to the physical order, and use the data forwarding mode to forward the data of the upper device in sequence.

[0063] In this embodiment, adjacent devices are connected via both an uplink data line and a downlink data line. The uplink data line is used to receive uplink data frames sent by an adjacent lower-level device, and to send the uplink data frame and its own uplink data frame to be sent to the upper-level device in sequence. The downlink data line is used to receive and forward downlink data frames sent by an adjacent upper-level device. The downlink data lines in this communication system constitute a downlink link to perform the host "write" operation, and the uplink data lines constitute an uplink link to perform the host "read" operation, and the host reads and writes data once in one communication cycle. Figure 2 As shown, the communication system includes a host and two slaves, wherein DATA_down is a downlink data line, the host only needs one downlink data line to connect to the DI_down interface of the slave, and the slave needs two downlink data lines, which are respectively connected to the adjacent upper device through the DI_down interface and to the DI_down of the adjacent lower device through the DO_down interface; DATA_up is an uplink data line, similarly, the host only needs one uplink data line to connect to the DO_up port of the slave, and the slave needs two uplink data lines, which are respectively connected to the adjacent upper device through the DO_up port and to the DO_up port of the adjacent lower device through the DI_up port.

[0064] In addition, in order to speed up the communication between devices, such as Figure 2As shown, a clock line and a frame start data line can also be added, and the clock line and the frame start data line are connected to all devices in the system, wherein the clock line CLK can control the shift registers of all devices to realize the synchronous transfer of data, and the frame start data line can output a start signal as the starting point of a communication cycle, and output a frame end signal as the end of a data frame. In a specific embodiment, it is stipulated that a high level lasting for 5 CLK cycles is a start signal, and a high level less than one CLK cycle is a frame end signal. It should be noted that since the frame start data line is connected to all devices in the communication system, after the frame start data line outputs the start signal, the operation of the host outputting the downlink data frame through the downlink link and the operation of the slave outputting the uplink data frame through the uplink link are independent of each other but performed simultaneously.

[0065] It is understandable that in order to accurately transmit the data sent by the host to the corresponding slave for processing, it is also necessary to assign an address number to the slave. In this embodiment, the adjacent upper device transmits an address assignment frame to the slave through the downlink data line, and the address assignment frame includes the address number assigned to the slave, and the address number is the address number of the upper device plus 1. At this time, the address number assigned to the slave by the adjacent upper device is addr, and at the same time, the slave sends a new address assignment frame to the adjacent lower slave through the downlink data line, which includes the address number assigned to the lower slave as addr+1, so that the farther the slave is from the host, the larger the corresponding address number.

[0066] In addition, after each slave receives the newly assigned address number, it needs to compare it with the address number assigned in the previous communication cycle. If the two are not equal in multiple communication cycles, it is determined that the slave has failed, and it is reset to enter the device discovery mode.

[0067] In this embodiment, the host sends a downlink data frame through a downlink, and the downlink data frame contains a target address, that is, the address number of the target slave. In order to be able to discover the newly connected slave in real time, in addition to sending the downlink data frame of normal communication through the downlink, the host also needs to send an additional downlink data frame with a target address of 0, which plays a role of broadcasting or synchronous guidance, so that the devices on the bus can leave a unified time window for the new slave to insert the device discovery frame, which is used to detect whether there is a new device connected to the bus. It can be understood that after each round of communication cycle starts, the slave will first transmit the uplink data frame containing its own collected data through the upper link, and then forward the uplink data frames sent in sequence by the adjacent lower-level devices along the uplink.

[0068] It should be noted that in order to package the data sent by the host or slave into a data frame, it is necessary to add a frame header and a frame trailer before and after the data to be sent, that is, a data frame includes a frame header part, a data part and a frame trailer part. If the communication system where the host and the slave are located is asynchronous communication, in order to allow the device receiving the data frame to have enough time to process the data of each frame and readjust the receiving state according to the synchronization information in the frame header, there is usually an interval between the sent data frames. For example, in serial communication, a start bit and a stop bit can be sent between data frames to form an interval. The start bit is used to notify the receiving end that data has started to be sent, and the stop frame indicates the end of a data frame, which provides the receiving end with time to process the data.

[0069] It is understandable that in order to ensure the stability of the system and the accurate transmission of data after the new slave is connected to the bus, each new slave needs to be verified. In one specific embodiment, the host can verify the identity of the slave based on the password. At this time, the device discovery frame sent by the slave to the host contains a password. If the password matches the password pre-stored in the host, the identity of the slave is determined to be legal, so that the slave can communicate normally in the communication system. In another specific embodiment, the device discovery frame sent by the slave includes a digital certificate. The digital certificate is issued by an authority and contains the identity information and digital signature of the slave. After receiving the device discovery frame, the host can verify the digital signature to determine the authenticity and integrity of the digital certificate, and then verify whether the identity of the slave is legal.

[0070] Step S12, receiving the uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame;

[0071] In this embodiment, the host receives the uplink data frame sent by the slave through the uplink, and analyzes and processes it. The uplink data frame may include the collected data of the slave or the device discovery frame sent by the new slave. It can be understood that since the uplink data frame of the slave is output to the host after passing through multiple nodes along the uplink, the host always receives the uplink data frame sent by the slave in the order of near first and far later.

[0072] It should be noted that the host's read and write operations have two different situations. In one specific embodiment, the ring full-duplex bus is connected to the clock line, and the host continuously sends a synchronous clock signal to the slave through the clock line. At this time, the host sends a downlink data frame through the downlink while the slave sends an uplink data frame through the uplink; in another specific embodiment, the ring full-duplex main line is not connected to the clock line. At this time, the slave needs to determine the start and end positions of each downlink data frame by receiving flag bits such as the start bit and stop bit contained in the downlink data frame.

[0073] Step S13, determining whether the device discovery frame exists in the uplink data frame; if so, determining that a new slave has joined the current system, and increasing the number of known slaves by 1.

[0074] In this embodiment, it is determined whether there is a device discovery frame in the uplink data frame received by the host. If there is, it indicates that a new slave has accessed the communication system, and the number of slaves in the host is increased by one.

[0075] In order to determine whether this round of communication cycle is over, in this embodiment, it is also necessary to determine whether there is a device end frame in the uplink data frame; the device end frame is sent by the tail device after sending an uplink data frame containing collected data; if it exists, it is determined that the current communication cycle is over. It should be noted that if the slave cannot detect a valid signal from the lower-level slave, it means that the slave is a tail device, and the tail device will send an uplink data frame containing the collected data of the slave at the beginning of each communication cycle, and then continue to send device end frames in the remaining time. Because the uplink data frame sent by the tail device needs to be forwarded by multiple nodes before it can reach the host, even if the tail device continues to send device end frames, in a communication cycle, the host will only receive the first frame.

[0076] It is understandable that a new slave always joins the communication system after the last device. Therefore, if a new slave is detected in the communication system, it can be determined that the communication cycle has reached the end even without determining whether the host receives the device end frame.

[0077] As can be seen from the above, the communication system in this application adopts a ring full-duplex bus with a master-slave structure, which can realize read-write synchronization, so as to realize the rapid exchange of information between the host and the slave, and realize the rapid interaction of information. And the address of the slave in this communication system is not fixed, but is assigned to the slave by the adjacent superior device through the downlink data line, so when a new device is added, an address can be assigned to it in time. In addition, the downlink data frame containing the target address sent by the host will contain a downlink data frame with a target address of 0, providing a time window for the new device to reply, and the host can receive the device discovery frame replied by the new device in this time window through the uplink data line, so as to realize the real-time and rapid discovery of new devices, and therefore can realize the flexible expansion of new devices.

[0078] To achieve fast acquisition and speed up the discovery of new devices, see Figure 3 As shown, the embodiment of the present invention discloses a specific communication method, which is applied to a host and may include:

[0079] Step S21, continuously sending a synchronous clock signal to all the slaves through the clock line, and sending a frame start signal to all devices through the frame start data line;

[0080] In this embodiment, a clock line is connected to the communication system, and the clock line is connected to all devices in the communication system, and then the host obtains the number n of known slaves in the communication system. It can be understood that the clock signal in the clock line can be sent directly by the host or by an external clock source to synchronize the entire communication process.

[0081] Furthermore, the use of a stable clock signal with a fixed frequency can not only fix the transmission speed and match the data receiving and sending capabilities between different devices, but also achieve bit synchronization, byte synchronization and frame synchronization, among which the realization of bit synchronization is the basis for achieving byte synchronization and frame synchronization. For example, the rising or falling edge of the clock signal is used as the trigger moment for the slave to read the data bit sent by the host. When transmitting a byte of data, the slave can rely on a stable clock signal with a fixed frequency to read each bit in turn.

[0082] In this embodiment, the frame start data line is connected to the communication system and all devices are connected at the same time. When the frame start signal jumps to the start signal, it indicates the beginning of a communication cycle. It should be noted that since the downlink data frame sent by the host is not sent directly to the target slave, but is forwarded through multiple nodes before reaching the target slave, even if the communication system is connected to the clock line and frame synchronization is achieved, the frame start data line is still required to output a frame end signal after the host outputs a downlink data frame to clarify the scope of each data frame.

[0083] Step S22, obtaining the number n of the known slaves;

[0084] In this embodiment, the host obtains n by using the number of known slaves stored in its own device.

[0085] Step S23, when the frame start signal jumps to the start signal; through the downlink data line, n+1 downlink data frames containing the target address are sent to the adjacent slaves in descending order according to the target address; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to the frame end signal.

[0086] In this embodiment, after the communication cycle starts, the host sends n+1 downlink data frames containing the target address to the target slave through the downlink according to the target address from large to small, where the target address of the n+1th downlink data frame is 0, and each time the host sends a downlink data frame, the frame start signal jumps to the frame end signal until all data are sent.

[0087] At this time, in a specific communication system including a host and two slaves, the data frame is transmitted through the uplink and downlink as follows: Figure 4 , Figure 5As shown, in one communication cycle, there are normal device communication processes and new device discovery processes. At this time, the CLK signal is the above-mentioned clock signal, the FRM signal is the above-mentioned frame start signal, the Tx port of the device is connected to the Rx port of the adjacent lower-level device through the downlink data line, and the Rx port of the device is connected to the Tx port of the adjacent upper-level device through the uplink data line. It can be understood that the same device has two Rx ports and two Tx ports, that is, the uplink data line and the downlink data line are respectively connected to different Rx ports and Tx ports of the same device.

[0088] like Figure 4 As shown, when the FRM signal jumps to the start signal, the host sends three downlink data frames with target addresses of 2, 1, and 0 to the adjacent slaves through the downlink, providing three time windows. In the first time window, slave 1 sends an address allocation frame to slave 2 through the downlink, and allocates an address number for slave 2. The address number is 2, and the address number of slave 1 is 1 included in the first downlink data frame sent by the host. Slave 1 adjacent to the host receives the above three downlink data frames in sequence. Slave 1 will match the downlink data frame with the same address number as itself, process and analyze it, and forward the above three downlink data frames in sequence in the second time window. The same slave 2 will also receive the address allocation frame sent by slave 1 and the downlink data frame sent by the host in sequence.

[0089] As for the uplink, after the FRM signal jumps to the start signal, the uplink data frames sent by slave 1 and slave 2 are transmitted to the host in turn. Since there are 2 slaves in the system, the host can receive the device end frame sent by slave 2 in the third time window to determine the end of this round of communication cycle. At this time, since the uplink and downlink communications are independent of each other and are carried out simultaneously, the time of one communication cycle of the communication system is greatly reduced, which improves the speed of information collection.

[0090] like Figure 5 As shown in the figure, if a new slave is connected to the communication system, the downlink is still the same as the normal device communication process. The difference is that in the first time window, slave 2 will also send an address allocation frame to the new slave and assign an address number to the new slave, which is 3. Then, the address allocation frames and downlink data frames accumulated in the Tx port of its downlink will be output to the new slave in sequence through the downlink data line. In the uplink, the host still receives the uplink data frames sent by the slave according to the normal device communication process, but due to the addition of the new slave, slave 2 is no longer the tail device, so the new slave will start from the first time window and continue to send device discovery frames to the host through the uplink, and the host will receive the first device discovery frame in the third time window, so that the host can adjust the number of known slaves and determine the end of this round of communication.

[0091] Step S24, receiving an uplink data frame sent by the slave through the uplink data line, and judging whether there is an abnormality in the number and address number of the slaves based on the uplink data frame; if there is an abnormality, clearing the known number of the slaves;

[0092] It is understandable that there are many possibilities for abnormalities in the communication system, including hardware abnormalities, software abnormalities and network abnormalities. In actual situations, physical damage and hardware aging may directly affect the communication function of the slave, while damage to the connection line or loose connection interface will affect the data transmission quality and even cause the network connection to be disconnected. Therefore, in order to determine whether there is an abnormality in the communication system, it is necessary to process and analyze the uplink data frames received by the host, determine whether there is a problem with the number of slaves and the address number corresponding to the slave, and then determine whether there is an abnormality in the system.

[0093] Further, when the frame count of the slave is equal to the preset number of slaves, it is determined whether the target address contained in the downlink data frame received by the slave at this time is equal to the address number of the slave. If they are not equal, it is determined that the system is abnormal and the slave is reset; wherein the preset number of slaves is contained in the downlink data frame containing the target address sent by the first frame of the host. It can be understood that if an abnormality occurs in the communication system, it will also affect the normal communication of the slave in the communication system. For example, if the communication system operates normally, when the frame count is equal to the number of known slaves, all downlink data frames output by the host should be sent to the target device. On the contrary, if the slave parses the received downlink data frame at this time and extracts that the target address in the downlink data frame is not equal to the address number of the slave, it indicates that the bus is abnormal. Therefore, it is also possible to determine whether the communication system is abnormal through the slave.

[0094] In addition, for the new slave newly connected to the bus, it is also necessary to determine whether it has any abnormality. In a specific embodiment, it is determined whether the frame count of the new slave is equal to the address number of the new slave; wherein the frame count is the number of frame end signals in the current communication cycle; if so, the new slave passes the verification. It can be understood that the frame count is the number of times the frame start signal jumps to the frame end signal in the current communication cycle counted by the slave, because the host known to the host will send it in each round of communication cycle.

[0095] Step S25, determine whether the device discovery frame exists in the uplink data frame; if so, determine that a new slave has joined the current system, and increase the number of known slaves by 1.

[0096] The specific implementation process of step S25 can refer to the corresponding content disclosed in the above embodiments, and will not be elaborated here.

[0097] From the above, it can be concluded that after the communication system is connected to the clock line and the frame start data line, it can realize the synchronous transmission of control data. At the same time, every time the host sends a downlink data frame, the frame start signal will output a frame end signal to divide the time window. Because the uplink and downlink are independent of each other, the host starts to receive the uplink data frames sent by the slave within the same time window, shortening the time of the entire communication cycle and speeding up the recognition of device discovery frames.

[0098] For further information, see Figure 3 As shown, an embodiment of the present invention discloses a communication method, which is applied to a slave and may include:

[0099] Step S31, at the beginning of each communication cycle, obtaining an address number through the downlink data line; wherein the address number is allocated by an adjacent upper-level device;

[0100] Step S32, receiving and forwarding a downlink data frame including a target address sent by the host through the downlink data line, wherein the target address included in one of the downlink data frames including the target address is 0; and judging whether the downlink data frame is a target data frame based on the target address and the address number; if so, parsing and processing the downlink data frame;

[0101] Step S33, sending the uplink data frame through the uplink data line, so that the host receives the uplink data frame and processes and analyzes the uplink data frame;

[0102] Step S34, determine whether it is a new slave; if it is a new slave, then after passing the verification, return the device discovery frame as the uplink data frame through the uplink data line, so that the host can determine that a new device has joined the current system, and increase the number of known slaves by 1.

[0103] For the specific implementation process of steps S31, S32, S33, and S34, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further details will be given here.

[0104] As can be seen from the above, the communication system in this application adopts a ring full-duplex bus with a master-slave structure, which can realize read-write synchronization, so as to realize the rapid exchange of information between the host and the slave, and realize the rapid interaction of information. And the address of the slave in this communication system is not fixed, but is assigned to the slave by the adjacent superior device through the downlink data line, so when a new device is added, an address can be assigned to it in time. In addition, the downlink data frame containing the target address sent by the host will contain a downlink data frame with a target address of 0, providing a time window for the new device to reply, and the host can receive the device discovery frame replied by the new device in this time window through the uplink data line, so as to realize the real-time and rapid discovery of new devices, and therefore can realize the flexible expansion of new devices.

[0105] Accordingly, see Figure 7 As shown, the embodiment of the present application further provides a communication device supporting real-time discovery, which is applied to a host and includes:

[0106] The data sending module 11 is used to send at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame containing the target address is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame containing the target address; wherein the target address contained in a downlink data frame containing the target address is 0, so that the new slave that passes the verification returns a device discovery frame, and uses the device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent upper-level device through the downlink data line at the beginning of each communication cycle;

[0107] A data receiving module 12, configured to receive an uplink data frame sent by the slave through the uplink data line, and process and analyze the uplink data frame;

[0108] The new device detection module 13 is used to determine whether the device discovery frame exists in the uplink data frame; if so, it is determined that a new slave has joined the current system, and the number of known slaves is increased by 1.

[0109] As can be seen from the above, the communication system in this application adopts a ring full-duplex bus with a master-slave structure, which can realize read-write synchronization, so as to realize the rapid exchange of information between the host and the slave, and realize the rapid interaction of information. And the address of the slave in this communication system is not fixed, but is assigned to the slave by the adjacent superior device through the downlink data line, so when a new device is added, an address can be assigned to it in time. In addition, the downlink data frame containing the target address sent by the host will contain a downlink data frame with a target address of 0, providing a time window for the new device to reply, and the host can receive the device discovery frame replied by the new device in this time window through the uplink data line, so as to realize the real-time and rapid discovery of new devices, and therefore can realize the flexible expansion of new devices.

[0110] In a specific implementation, the data sending module 11 includes:

[0111] The address numbering unit is used for the adjacent upper device to transmit an address allocation frame to the slave through the downlink data line, wherein the address allocation frame includes an address number allocated to the slave, and the address number is the address number of the upper device plus 1.

[0112] In a specific implementation, the data sending module 11 includes:

[0113] A synchronization preset unit, used to continuously send a synchronization clock signal to all the slaves via a clock line, and send a frame start signal to all devices via a frame start data line;

[0114] A quantity acquisition unit, used for acquiring the known number n of the slaves;

[0115] A data sending unit is used for sending n+1 downlink data frames containing the target address to the adjacent slaves in descending order according to the target address through the downlink data line when the frame start signal jumps to the start signal; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to the frame end signal.

[0116] In some specific implementations, the synchronization preset unit includes:

[0117] The new slave check subunit is used to send the frame end signal to the new slave through the frame start data line so that the new slave can determine whether the frame count is equal to its address number; if so, the new slave passes the check; wherein the frame count is the number of frame end signals in the current communication cycle.

[0118] In some specific implementations, the synchronization preset unit includes:

[0119] A start signal output subunit, used for outputting a high level signal lasting for five CLK cycles as the start signal through a frame start data line;

[0120] The frame end signal output subunit is used to output a signal whose high level is less than one CLK cycle as the frame start signal and the frame end signal through the frame start data line.

[0121] In some specific implementations, the synchronization preset unit includes:

[0122] The device abnormality judgment subunit is used to send a frame start signal to all the slaves through the frame start data line, so that when the frame count is equal to the known number of the slaves, it is judged whether the target address of the downlink data frame containing the target address received by the slave at this time is equal to the address number of the slave; if they are not equal, it is determined that the system is abnormal and the slave is reset; wherein, the known number of the slaves is contained in the downlink data frame containing the target address sent by the host in the first frame.

[0123] In a specific implementation, the data receiving module 12 includes:

[0124] The abnormality judgment unit is used to judge whether there is an abnormality in the number and address number of the slaves based on the uplink data frame; if there is an abnormality, the known number of the slaves is cleared.

[0125] In a specific implementation manner, after the new device detection module 13, it also includes:

[0126] The cycle end judgment unit is used to judge whether the device end frame exists in the uplink data frame; the device end frame is sent by the tail device after sending an uplink data frame containing collected data; if it exists, it is determined that the current communication cycle is over.

[0127] Accordingly, see Figure 8 As shown, the embodiment of the present application further provides a communication device supporting real-time discovery, which is applied to a slave machine and includes:

[0128] The address allocation module 21 is used to obtain the address number allocated by the adjacent upper-level device through the downlink data line at the beginning of each communication cycle;

[0129] The data receiving module 22 is used to receive and forward the downlink data frame containing the target address sent by the host through the downlink data line, and the target address contained in one of the downlink data frames is 0; and based on the target address and the address number, determine whether the downlink data frame is the target data frame; if so, parse and process the downlink data frame;

[0130] A data sending module 23, configured to send the uplink data frame through the uplink data line so that the host receives the uplink data frame and processes and analyzes the uplink data frame;

[0131] The new device judgment module 24 is used to judge whether it is a new slave; if it is a new slave, after passing the verification, it returns a device discovery frame as the uplink data frame through the uplink data line, so that the host can determine that a new device has been added to the current system and increase the number of known slaves by 1.

[0132] Among them, the specific working process of each of the above modules can refer to the corresponding content disclosed in the aforementioned embodiments, which will not be repeated here.

[0133] As can be seen from the above, the communication system in this application adopts a ring full-duplex bus with a master-slave structure, which can realize read-write synchronization, so as to realize the rapid exchange of information between the host and the slave, and realize the rapid interaction of information. And the address of the slave in this communication system is not fixed, but is assigned to the slave by the adjacent superior device through the downlink data line, so when a new device is added, an address can be assigned to it in time. In addition, the downlink data frame containing the target address sent by the host will contain a downlink data frame with a target address of 0, providing a time window for the new device to reply, and the host can receive the device discovery frame replied by the new device in this time window through the uplink data line, so as to realize the real-time and rapid discovery of new devices, and therefore can realize the flexible expansion of new devices.

[0134] In a specific implementation manner, after the address allocation module 21, it also includes:

[0135] The slave abnormality judgment unit is used to judge whether the address number assigned in the current communication cycle is the same as the address number assigned in the previous communication cycle; if different, it is determined that the slave has a device failure and the slave is reset.

[0136] Furthermore, the present application also discloses an electronic device. Fig. 9 It is a structural diagram of an electronic device 30 shown according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 30 may specifically include: at least one processor 31, at least one memory 32, a power supply 33, a communication interface 34, an input and output interface 35 and a communication bus 36. Among them, the memory 32 is used to store a computer program, and the computer program is loaded and executed by the processor 31 to implement the relevant steps in the communication method supporting real-time discovery disclosed in any of the aforementioned embodiments. In addition, the electronic device 30 in this embodiment can specifically be an electronic computer.

[0137] In this embodiment, the power supply 33 is used to provide working voltage for each hardware device on the electronic device 30; the communication interface 34 can create a data transmission channel between the electronic device 30 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 35 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0138] In addition, the memory 32 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 321, a computer program 322, etc., and the storage method may be temporary storage or permanent storage.

[0139] The operating system 321 is used to manage and control the hardware devices and computer programs 322 on the electronic device 30, and can be Windows Server, Netware, Unix, Linux, etc. In addition to computer programs that can be used to complete the communication method performed by the electronic device 30 disclosed in any of the aforementioned embodiments, the computer program 322 can further include computer programs that can be used to complete other specific tasks.

[0140] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed communication method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.

[0141] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0142] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0143] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0144] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0145] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A communication method, characterized in that: Applied to a host, the system where the host and the slave are located adopts a ring full-duplex bus, the slave is connected to adjacent devices through an uplink data line and a downlink data line at the same time, the uplink data line is used to transmit uplink data frames, and the downlink data line is used to transmit downlink data frames; the communication method includes: Send at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame containing the target address is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame containing the target address; wherein the target address contained in one of the downlink data frames containing the target address is 0, so that the new slave that passes the verification returns a device discovery frame, and uses the device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent upper-level device through the downlink data line at the beginning of each communication cycle; Receiving the uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame; Determine whether the device discovery frame exists in the uplink data frame; if so, determine that a new slave has joined the current system, and increase the number of known slaves by 1.

2. The communication method according to claim 1, characterized in that: The address number is allocated to the slave by the adjacent upper device through the downlink data line at the beginning of each communication cycle, including: The adjacent upper device transmits an address allocation frame to the slave through the downlink data line, wherein the address allocation frame includes an address number allocated to the slave, and the address number is the address number of the upper device plus 1.

3. The communication method according to claim 2, characterized in that: The sending at least one downlink data frame including a target address to the adjacent slave through the downlink data line comprises: Continuously sending a synchronous clock signal to all the slaves via a clock line, and sending a frame start signal to all devices via a frame start data line; Obtain the number n of the known slaves; When the frame start signal jumps to the start signal; n+1 downlink data frames containing the target address are sent to the adjacent slaves in order from large to small according to the target address through the downlink data line; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to the frame end signal.

4. The communication method according to claim 3, characterized in that: The sending of a frame start signal to all devices via a frame start data line includes: The frame end signal is sent to the new slave via the frame start data line so that the new slave can determine whether the frame count is equal to its address number; if so, the new slave passes the verification; wherein the frame count is the number of frame end signals in the current communication cycle.

5. The communication method according to claim 3, characterized in that: The sending of a frame start signal to all devices via a frame start data line includes: Outputting a high level signal lasting for five CLK cycles via a frame start data line as the start signal; A signal whose high level is less than one CLK cycle is outputted through the frame start data line as the frame start signal and as the frame end signal.

6. The communication method according to claim 3, characterized in that: The sending of a frame start signal to all devices via a frame start data line includes: A frame start signal is sent to all the slaves via a frame start data line, so that when the frame count is equal to the known number of the slaves, it is determined whether the target address of the downlink data frame containing the target address received by the slave at this time is equal to the address number of the slave; if they are not equal, it is determined that the system is abnormal and the slave is reset; wherein, the known number of the slaves is contained in the downlink data frame containing the target address sent by the host in the first frame.

7. The communication method according to claim 3, characterized in that: The processing and analyzing of the uplink data frame includes: Based on the uplink data frame, determining whether there is an abnormality in the number and address number of the slaves; If there is an abnormality, the known number of the slaves is reset to zero.

8. The communication method supporting real-time discovery according to any one of claims 1 to 7, characterized in that: After determining whether the device discovery frame exists in the uplink data frame, the method further includes: Determining whether the device end frame exists in the uplink data frame; the device end frame is sent by the tail device after sending an uplink data frame containing collected data; If it exists, it is determined that the current communication cycle is ended.

9. A communication method, characterized in that: Applied to a slave, the system where the slave and the host are located adopts a ring full-duplex bus, the slave is connected to adjacent devices through an uplink data line and a downlink data line at the same time, the uplink data line is used to transmit uplink data frames, and the downlink data line is used to transmit downlink data frames; the communication method includes: At the beginning of each communication cycle, an address number is obtained through the downlink data line; wherein the address number is allocated by an adjacent upper-level device; Receiving and forwarding a downlink data frame including a target address sent by the host through the downlink data line, wherein the target address included in one of the downlink data frames including the target address is 0; and judging whether the downlink data frame is a target data frame based on the target address and the address number; and if so, parsing and processing the downlink data frame; Sending the uplink data frame via the uplink data line so that the host receives the uplink data frame and processes and analyzes the uplink data frame; Determine whether it is a new slave; if it is a new slave, then after passing the verification, return the device discovery frame as the uplink data frame through the uplink data line, so that the host can determine that a new device has joined the current system and increase the number of known slaves by 1.

10. The communication method according to claim 9, characterized in that: After acquiring the address number through the downlink data line, the method further includes: Determine whether the address number assigned in the current communication cycle is the same as the address number assigned in the previous communication cycle; If they are different, it is determined that a device failure occurs in the slave device, and the slave device is reset.

11. A communication device, characterized in that: Applied to the host, including: A data sending module, used for sending at least one downlink data frame including a target address to the adjacent slave through the downlink data line, so that the slave determines whether the downlink data frame is a target data frame based on the target address and its address number, and if so, parses and processes the downlink data frame; wherein the target address included in one of the downlink data frames is 0, so that the new slave that passes the verification returns a device discovery frame as the uplink data frame, and the address number is allocated to the slave by the adjacent superior device through the downlink data line at the beginning of each communication cycle; A data receiving module, used for receiving an uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame; The new device detection module is used to determine whether the device discovery frame exists in the uplink data frame; if so, it is determined that a new slave has joined the current system, and the number of known slaves is increased by 1.

12. An electronic device, characterized in that: include: Memory, used to store computer programs; The processor is used to execute the computer program to implement the communication method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the communication method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Ring-network serial communication method and system

    CN103634186A

  • Communication method based on RS485 bridge circuit device

    CN107229586A

  • Dynamic distribution method and system for integrated circuit bus address and storage medium

    CN110290227A

  • Data exchange system, method and equipment and storage medium

    CN116938840A

  • Serial peripheral interface system control method, chip, medium and device

    CN118035157A