A communication method, apparatus, device, and medium

By using a ring full-duplex bus structure and dynamic host address allocation, the problems of slow 485 bus communication speed and inflexible device expansion are solved, enabling rapid information exchange and real-time discovery of new devices.

CN119544403BActive Publication Date: 2025-10-17CRRC INDUSTRAIL ACADEMY (QINGDAO) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In existing industrial communications, the 485 bus has slow communication speeds and lacks device discovery protocols and automatic address allocation capabilities, making the expansion of new devices inflexible.

Method used

It adopts a ring full-duplex bus structure and connects the slaves through uplink and downlink data lines. The host assigns an address to the slave at the beginning of each communication cycle and sends a downlink data frame containing the target address to realize device discovery. The clock line and frame start data line are combined to accelerate data transmission.

Benefits of technology

It enables flexible expansion of new equipment and rapid information exchange, shortens the communication cycle, and improves the real-time nature of equipment discovery and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544403B_ABST
    Figure CN119544403B_ABST
Patent Text Reader

Abstract

The application discloses a communication method applied to the communication field, and comprises the following steps: sending at least one downlink data frame containing a target address to a neighboring slave machine through a downlink data line; wherein the target address contained in one downlink data frame containing a target address is 0, and the address number of the slave machine is allocated by the neighboring superior equipment through the downlink data line at the beginning of each communication period; receiving an uplink data frame sent by the slave machine through an uplink data line, and processing and analyzing the uplink data frame; judging whether a device discovery frame exists in the uplink data frame; if the device discovery frame exists, it is determined that a new slave machine is added to the current system, and the number of known slave machines is increased by 1. The address number of the slave machine is not fixed, but is allocated again in each communication period, and meanwhile, the slave machine can also send a device discovery frame to the host machine in a time period corresponding to the downlink data frame with the target address of 0, so that the real-time discovery and flexible expansion of the new slave machine are realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication, in particular to a communication method, device, equipment and medium. BACKGROUND

[0002] At present, in industrial communication, in order to facilitate equipment maintenance, IO modules are usually designed as blade type for easy plugging and cascading, and all modules follow the same interface specification. Considering space utilization, the communication pins are generally left on the back of the module, which can be connected to the backplane through the communication pins for backplane communication. Common backplane communication uses 485 bus. The IO module automatically takes power from the backplane after being plugged in, and is connected to the 485 bus to realize the access of the host to different devices.

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

[0004] Therefore, how to realize the flexible expansion of new devices and the rapid exchange of information is a problem to be solved at present. SUMMARY

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

[0006] In a first aspect, the present application provides a communication method applied to a host, wherein a system in which the host and a 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 for transmitting an uplink data frame, and the downlink data line is used for transmitting a downlink data frame; the communication method comprises the following steps:

[0007] sending at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave judges whether the downlink data frame containing the target address is a target data frame based on the target address and the address number of the slave, and if so, the downlink data frame containing the target address is parsed and processed; wherein the target address contained in one downlink data frame containing the target address is 0, so that a new slave returning a device discovery frame is checked, and the device discovery frame is taken as the uplink data frame, and the address number is allocated to the slave by the adjacent upper device at the beginning of each communication period through the downlink data line;

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

[0009] determining whether the device discovery frame exists in the uplink data frame; if the device discovery frame exists, determining that a new slave device is added to the current system, and adding 1 to the number of known slave devices.

[0010] Optionally, the address number is allocated to the slave device by the adjacent upper device through the downlink data line at the beginning of each communication period, and the address allocation frame comprises:

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

[0012] Optionally, the transmission of the at least one downlink data frame containing the target address to the adjacent slave device through the downlink data line comprises:

[0013] The synchronization clock signal is continuously transmitted to all the slave devices through the clock line, and the start-of-frame signal is transmitted to all the devices through the start-of-frame data line;

[0014] The number n of known slave devices is obtained;

[0015] When the start-of-frame signal is switched to the start signal, n+1 downlink data frames containing the target address are sequentially transmitted to the adjacent slave device through the downlink data line according to the target address from large to small; wherein, the master device transmits one downlink data frame containing the target address, and the start-of-frame signal is switched to the end-of-frame signal.

[0016] Optionally, the transmission of the start-of-frame signal to all the devices through the start-of-frame data line comprises:

[0017] The end-of-frame signal is transmitted to the new slave device through the start-of-frame data line, so that the new slave device determines whether the frame count is equal to the address number thereof; if yes, the new slave device passes the verification; wherein, the frame count is the number of end-of-frame signals in the current communication period.

[0018] Optionally, the transmission of the start-of-frame signal to all the devices through the start-of-frame data line comprises:

[0019] A signal with a high level lasting for five CLK periods is output through the start-of-frame data line as the start signal;

[0020] A signal with a high level less than one CLK period is output through the start-of-frame data line as the start-of-frame signal as the end-of-frame signal.

[0021] Optionally, the transmission of the start-of-frame signal to all the devices through the start-of-frame data line comprises:

[0022] A frame start signal is sent to all the slaves through a frame start data line, so that when the frame count is equal to the known number of 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, and if not, it is determined that the system is abnormal, and the slave is reset; wherein the known number of 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 analysis of the uplink data frame comprises:

[0024] Based on the uplink data frame, it is determined whether the number of slaves and the address number exist abnormality;

[0025] If there is abnormality, the known number of slaves is cleared.

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

[0027] It is determined 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 period ends.

[0029] In a second aspect, the application provides a communication method applied to a slave, wherein a system in which the slave and a 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 for transmitting an uplink data frame, and the downlink data line is used for transmitting a downlink data frame; the communication method comprises:

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

[0031] A downlink data frame containing a target address sent by the host is received and forwarded through the downlink data line, and one of the downlink data frames containing the target address contains a target address of 0; and based on the target address and the address number, it is determined whether the downlink data frame is a target data frame; if yes, the downlink data frame is parsed and processed;

[0032] The uplink data frame is sent through the uplink data line, so that the host receives the uplink data frame and processes and analyzes the uplink data frame;

[0033] determining whether the slave device is a new slave device; if the slave device is a new slave device, returning a device discovery frame as the uplink data frame through the uplink data line after verification, so that the master device determines that a new device has joined the current system and adds 1 to the number of known slave devices.

[0034] Optionally, after the address number is obtained through the downlink data line, the method further comprises:

[0035] determining whether the address number allocated in the current communication period is the same as the address number allocated in the last communication period;

[0036] if not, determining that the slave device has a device fault and resetting the slave device.

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

[0038] a data sending module, configured to send at least one downlink data frame containing a target address to an adjacent slave device through the downlink data line, so that the slave device determines whether the downlink data frame is a target data frame based on the target address and the address number of the slave device, and if yes, the downlink data frame is parsed and processed; wherein the target address contained in one downlink data frame is 0, so that a new slave device returning a device discovery frame as the uplink data frame after verification, and the address number is allocated to the slave device by an adjacent superior device through the downlink data line at the beginning of each communication period;

[0039] a data receiving module, configured to receive an uplink data frame sent by the slave device through the uplink data line and process and analyze the uplink data frame;

[0040] a new device detection module, configured to determine whether the device discovery frame exists in the uplink data frame; if yes, determining that a new slave device has joined the current system and adding 1 to the number of known slave devices.

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

[0042] a memory, configured to save a computer program;

[0043] a processor, configured to execute the computer program to realize the communication method described above.

[0044] In a fifth aspect, the present application provides a computer readable storage medium, configured to save a computer program; wherein the computer program is executed by a processor to realize the communication method described above.

[0045] The communication method provided by the application is applied to a ring full-duplex bus system, adjacent devices are connected through uplink data lines and downlink data lines at the same time, the address number of the slave device is allocated by the adjacent superior device at the beginning of each communication cycle, the master device sends at least one downlink data frame containing a 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 device can reply to the device discovery frame as an uplink data frame in the time window provided by the downlink data frame with the target address of 0; the master device receives the uplink data frame sent by the slave device through the uplink data line, judges whether the device discovery frame exists in the uplink data frame, and if it exists, the number of the identified slave devices needs to be added by 1. As can be seen from the above, the communication system in the application adopts a ring full-duplex bus with a master-slave structure, can realize read-write synchronization, and can realize the fast exchange of information between the master device and the slave device. In addition, the address of the slave device in the communication system is not fixed, but is reallocated by the adjacent superior device through the downlink data line at the beginning of each communication cycle, so that when a new slave device is added, the address can be allocated in time. In addition, the downlink data frame containing the target address sent by the master device contains a downlink data frame with the target address of 0, which provides a time window for the new device to reply. The master device can receive the device discovery frame replied by the new slave device in the time window through the uplink data line, so as to realize the real-time and fast discovery of the new device, and thus the flexible expansion of the new device can be realized. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of the provided drawings.

[0047] Figure 1 A communication method flowchart provided by the application;

[0048] Figure 2 A communication system schematic diagram provided by the application;

[0049] Figure 3 A specific communication method flowchart provided by the application;

[0050] Figure 4 A device communication schematic diagram provided by the application;

[0051] Figure 5 A new slave device discovery flowchart provided by the application;

[0052] Figure 6A communication method flow chart is provided for the present application;

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

[0054] Figure 8 A communication device supporting real-time discovery is provided for the present application;

[0055] Figure 9 An electronic device structure diagram is provided for the present application. DETAILED DESCRIPTION

[0056] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0057] Currently, in industrial communication, in order to facilitate equipment maintenance, IO modules are usually designed to be easily plugged and cascaded blades, and all modules follow the same interface specification. Considering space utilization, the communication pins are generally left on the back of the module, which can be connected to the backplane through the communication pins for backplane communication. Common backplane communication uses 485 bus, IO modules are automatically powered from the backplane after being plugged in, and are connected to the 485 bus to realize the access of the host to different devices.

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

[0059] Therefore, how to realize the flexible expansion of new devices and the rapid exchange of information is a problem to be solved at present.

[0060] In order to solve the above problems, referring to Figure 1 The present application discloses a communication method applied to a host, which can 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 judges 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 the downlink data frame containing the target address; wherein the target address contained in one downlink data frame containing a target address is 0, so that the new slave returning a device discovery frame by checking, and taking the device discovery frame as the uplink data frame, the address number is allocated to the slave by the adjacent superior device at the beginning of each communication cycle through the downlink data line;

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

[0063] In this embodiment, the adjacent devices are connected through the uplink data line and the downlink data line at the same time. The uplink data line is used to receive the uplink data frame sent by the adjacent subordinate device, and sequentially send the uplink data frame and the uplink data frame to be sent by itself to the superior device. The downlink data line is used to receive and forward the downlink data frame sent by the adjacent superior device. The downlink data line in the communication system constitutes the downlink to perform the "write" operation of the master, and the uplink data line constitutes the uplink to perform the "read" operation of the master, and the master performs data reading and writing once in a communication cycle. As shown in the figure, Figure 2 The communication system contains one master and two slaves, wherein DATA_down is the downlink data line, the master only needs one downlink data line to connect with the DI_down interface of the slave, and the slave needs two downlink data lines, which are connected with the adjacent superior device through the DI_down interface and the adjacent subordinate device through the DO_down interface respectively; DATA_up is the uplink data line, and similarly, the master only needs one uplink data line to connect with the DO_up port of the slave, and the slave needs two uplink data lines, which are connected with the adjacent superior device through the DO_up port and the adjacent subordinate device through the DI_up port respectively.

[0064] In addition, in order to speed up the communication speed between devices, as Figure 2As shown, clock line and frame start data line can also be added, which are connected with all devices in the system. The clock line CLK can control the shift register of all devices to realize the synchronous transfer of data. The frame start data line can output start signal as the starting point of a communication cycle and output frame end signal as the end of a data frame. In a specific embodiment, the high level lasting 5 CLK periods is defined as start signal and the high level less than one CLK period is defined as frame end signal. It should be noted that since the frame start data line is connected with all devices in the communication system, the operation of the host outputting downlink data frame through downlink and the operation of the slave outputting uplink data frame through uplink are independent but simultaneous after the frame start data line outputs start signal.

[0065] It can be understood that in order to accurately transmit the data sent by the host to the corresponding slave for processing, the slave also needs to be allocated an address number. In the embodiment, the adjacent upper device transmits an address allocation frame to the slave through the downlink data line, the address allocation frame contains the address number allocated to the slave, and the address number is the address number of the upper device plus 1. At this time, the address number allocated to the slave by the adjacent upper device is addr, and the slave transmits a new address allocation frame to the adjacent lower slave through the downlink data line, which contains the address number allocated to the lower slave as addr+1, so that the farther the slave is from the host, the larger the corresponding address number is.

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

[0067] In the embodiment, the host sends downlink data frame through the downlink, which contains target address, i.e. the address number of the target slave. In order to discover the newly accessed slave in real time, the host needs to additionally send a downlink data frame with target address 0 in addition to the downlink data frame for normal communication, which plays a role of broadcast or synchronization guide, 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 accessing the bus. It can be understood that after the start of each communication cycle, the slave will first transmit the uplink data frame containing its own collected data through the upper link, and then forward the uplink data frame transmitted by the adjacent lower device along the uplink.

[0068] It should be noted that in order to pack the data sent by the host or the slave into a data frame, the frame header and the frame tail need to be added before and after the sent data, that is, a data frame includes a frame header part, a data part and a frame tail part. If the communication system in which the host and the slave are located is an asynchronous communication, in order to give the device receiving the data frame enough time to process the data of each frame and to re-adjust the receiving state according to the synchronization information in the frame header, there is usually a gap between the sent data frames, for example, in serial port communication, start bits and stop bits can be sent between data frames to form a gap, the start bits are used to inform the receiving end that the data starts to be sent, and the stop bits indicate the end of a data frame, providing the receiving end with time to process the data.

[0069] It can be understood that in order to ensure the stability of the system after the new slave accesses the bus and the accurate transmission of data, each new slave also needs to be verified. In a specific embodiment, the host can verify the identity of the slave based on a 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, it is determined that the identity of the slave is legal, so that the slave can normally communicate in the communication system. In another specific embodiment, the device discovery frame sent by the slave includes a digital certificate, which 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 authenticity and integrity of the digital certificate by verifying the digital signature, 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 contain the acquisition 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 along the uplink through multiple nodes, the host always receives the uplink data frame sent by the slave in the order of near first and far last.

[0072] It should be noted that the read and write operations of the host have two different cases. In one specific embodiment, the ring full-duplex bus accesses the clock line, and the host continuously sends the synchronization clock signal to the slave through the clock line, at this time the host sends the downlink data frame through the downlink at the same time, and the slave sends the uplink data frame through the uplink; in another specific embodiment, the ring full-duplex bus does not access the clock line, at this time the slave needs to judge the start and end positions of each downlink data frame through the start bit, stop bit and other flag bits contained in the downlink data frame.

[0073] Step S13, judging whether the device discovery frame exists in the uplink data frame; if yes, it is determined that a new slave joins the current system, and the number of known slaves is increased by 1.

[0074] In the embodiment, it is judged whether the device discovery frame exists in the uplink data frame accepted by the master, and if yes, it is indicated that a new slave accesses the communication system, and the number of the slaves in the master is increased by 1.

[0075] In order to judge whether the current communication period ends, it is further needed to judge whether the device end frame exists in the uplink data frame in the embodiment, the device end frame is sent by the tail device after sending an uplink data frame containing collected data; if yes, it is determined that the current communication period ends. It should be noted that if the slave cannot detect the valid signal from the lower-level slave, it is indicated that the slave is the tail device, and the tail device sends an uplink data frame containing the collected data of the slave at the beginning of each communication period, and then continuously sends the device end frame in the remaining time. Because the uplink data frame sent by the tail device needs to be forwarded by multiple nodes before reaching the master, even if the tail device continuously sends the device end frame, the master will only receive the first frame in a communication period.

[0076] It can be understood that the new slave always joins the communication system after the tail device, so if it is detected that there is a new slave in the communication system, it can be judged that the current communication period has reached the end even if it is not judged whether the master receives the device end frame.

[0077] As can be seen from the above, the communication system in the application adopts a ring full-duplex bus with a master-slave structure, can realize read-write synchronization, and realizes the fast exchange of information between the master and the slave, and realizes the fast interaction of information. The address of the slave in the communication system is not fixed, but is allocated to the slave by the adjacent upper device through the downlink data line, so that when a new device joins, the address can be allocated to the new device in time. In addition, the downlink data frame containing the target address sent by the master contains a downlink data frame with a target address of 0, which provides a time window for the new device to reply, and the master can receive the device discovery frame replied by the new device in the time window through the uplink data line, so as to realize the real-time and fast discovery of the new device, and thus the flexible expansion of the new device can be realized.

[0078] In order to realize fast collection and speed up the discovery of new devices, referring to FIG. 8, Figure 3 The embodiment of the application discloses a specific communication method applied to the master, which can include:

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

[0080] In this embodiment, the clock line is connected in the communication system, and the clock line is connected with all devices in the communication system. 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 directly sent by the host or can be sent by an external clock source to synchronize the entire communication process.

[0081] Further, the stable clock signal with fixed frequency can fix the transmission speed, match the data receiving and device sending capabilities between different devices, and realize bit synchronization, byte synchronization and frame synchronization. For example, the rising edge or falling edge of the clock signal is taken as the trigger time for the slave to read the data bits sent by the host. When a byte of data is transmitted, the slave can rely on the stable clock signal with fixed frequency to read each bit in turn.

[0082] In this embodiment, the frame start data line is connected in the communication system, and all devices are connected. When the frame start signal jumps to the start signal, it indicates the start of a communication period. It should be noted that since the downlink data frame sent by the host is not directly sent to the target slave, but is forwarded through multiple nodes to reach the target slave, even if the communication system is connected with the clock line and frame synchronization is realized, the frame start data line still needs to output a frame end signal after the host outputs a downlink data frame, to clearly define the range of each data frame.

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

[0084] In this embodiment, the host obtains n by the number of known slaves saved in the device itself.

[0085] Step S23, when the frame start signal jumps to the start signal; n+1 downlink data frames containing the target address are sent to the adjacent slave according to the target address from large to small through the downlink data line; wherein, the host sends one downlink data frame containing the target address, and the frame start signal jumps to the frame end signal.

[0086] In this embodiment, after the start of the communication period, the host sends n+1 downlink data frames containing the target address to the target slave according to the target address from large to small through the downlink. The target address of the n+1 downlink data frame is 0, and the host sends one downlink data frame, and the frame start signal jumps to the frame end signal, until all data is sent.

[0087] At this time, in a specific communication system containing one host and two slaves, the transmission of the data frame through the uplink and the downlink is as follows Figure 4 、 Figure 5As shown, within a communication cycle, there are normal device communication processes and new device discovery processes. The CLK signal is the aforementioned clock signal, the FRM signal is the aforementioned frame start signal, the Tx port of a device is connected to the Rx port of an adjacent lower-level device via a downlink data line, and the Rx port of a device is connected to the Tx port of an adjacent upper-level device via an uplink data line. It is understood that the same device can have two Rx ports and two Tx ports, respectively, meaning that the uplink data line and downlink data line are connected to different Rx ports and Tx ports of the same device, respectively.

[0088] like Figure 4 As shown in the figure, after the FRM signal jumps to the start signal, the master sends three downlink data frames with target addresses of 2, 1, and 0 to the adjacent slave via the downlink, providing three time windows. In the first time window, slave 1 sends an address allocation frame to slave 2 via the downlink, assigning an address number of 2 to slave 2, while the address number of slave 1 included in the first downlink data frame sent by the master is 1. Slave 1, adjacent to the master, receives these three downlink data frames in sequence. Slave 1 matches the downlink data frame with the same address number as itself, processes and analyzes it, and forwards these three downlink data frames in sequence in the second time window. Slave 2 also receives the address allocation frame sent by slave 1 and the downlink data frame sent by the master in sequence.

[0089] For the uplink, after the FRM signal transitions to a start signal, uplink data frames from slaves 1 and 2 are sequentially transmitted to the master. Since there are only two slaves in the system, the master receives the device end frame from slave 2 in the third time window, confirming the end of the communication cycle. Because uplink and downlink communications are independent and occur simultaneously, the system significantly reduces the time required for a single communication cycle, accelerating 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, assigning an address number to the new slave, which is 3. Then, the address allocation frames and downlink data frames accumulated on its downlink Tx port 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. However, due to the addition of the new slave, slave 2 is no longer the last device. Therefore, the new slave will continue to send device discovery frames to the host via the uplink starting from the first time window. The host will receive the first device discovery frame in the third time window, allowing the host to 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 possible causes for anomalies in a communication system, including hardware anomalies, software anomalies, and network anomalies. In actual situations, physical damage and aging hardware may directly affect the communication function of the slave device, while damaged connection lines or loose connection interfaces can affect data transmission quality and even cause network disconnection. Therefore, in order to determine whether there is an anomaly in the communication system, it is necessary to process and analyze the uplink data frames received by the host to determine whether there are any issues with the number of slave devices and the corresponding address numbers of the slave devices, and then determine whether there is an anomaly in the system.

[0093] Furthermore, 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 included in the downlink data frame containing the target address sent by the first frame of the host. It is understandable that if an abnormality occurs in the communication system, it will also affect the normal communication of the slaves in the communication system. For example, if the communication system operates normally, when the frame count is equal to the known number of 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 an abnormality has occurred in the bus. Therefore, it is also possible to determine whether the communication system is abnormal through the slave.

[0094] In addition, a new slave connected to the bus also needs to be checked for any anomalies. In one embodiment, the new slave's frame count is determined to be equal to its address number; the frame count is the number of frame end signals in the current communication cycle. If so, the new slave passes the verification. It is understood that the frame count is the number of times the frame start signal transitions to a frame end signal in the current communication cycle, as counted by the slave. A known master sends this count every communication cycle.

[0095] Step S25 , 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.

[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, the communication system can realize the synchronous transmission of control data after accessing the clock line and the frame start data line, and the host outputs a frame end signal for each downlink data frame, so as to divide the time window. Since the uplink and the downlink are independent of each other, the host can receive the uplink data frame sent by the slave in the same time window, so that the communication cycle is shortened and the identification of the device discovery frame is accelerated.

[0098] Further, referring to Figure 3 The embodiment of the present application discloses a communication method applied to a slave, which can include the following steps.

[0099] In step S31, an address number is obtained through the downlink data line at the beginning of each communication cycle, wherein the address number is allocated by a neighboring superior device.

[0100] In step S32, a downlink data frame containing a target address sent by the host is received and forwarded through the downlink data line, one of the downlink data frames containing the target address contains a target address of 0, and whether the downlink data frame is a target data frame is judged based on the target address and the address number. If yes, the downlink data frame is parsed and processed.

[0101] In step S33, the uplink data frame is sent through the uplink data line, so that the host receives the uplink data frame and processes and analyzes the uplink data frame.

[0102] In step S34, whether the slave is a new slave is judged. If the slave is a new slave, a device discovery frame is returned as the uplink data frame through the uplink data line after verification, so that the host determines that a new device is added to the current system and the number of known slaves is increased by 1.

[0103] The specific implementation process of steps S31, S32, S33 and S34 can refer to the corresponding content disclosed in the foregoing embodiments, and will not be described here.

[0104] From the above, the communication system in the application adopts a ring full-duplex bus with a master-slave structure, can realize read-write synchronization, and can realize fast exchange of information between the master and the slave, and realizes fast interaction of information. The address of the slave in the communication system is not fixed, but is allocated by the adjacent superior device through the downlink data line, so that when a new device is added, the address can be allocated in time. In addition, the downlink data frame containing the target address sent by the master contains a downlink data frame with a target address of 0, which provides a time window for the new device to reply, and the master can receive the device discovery frame replied by the new device in the time window through the uplink data line, so as to realize real-time and fast discovery of the new device, and thus flexible expansion of the new device can be realized.

[0105] Correspondingly, referring to Figure 7 The embodiment of the application further provides a communication device supporting real-time discovery, which is applied to a master and comprises:

[0106] The data sending module 11 is used for sending at least one downlink data frame containing a target address to the adjacent slave through the downlink data line, so that the slave judges whether the downlink data frame containing the target address is a target data frame based on the target address and the address number of the slave, and if yes, the downlink data frame containing the target address is parsed and processed; wherein the target address contained in one downlink data frame containing the target address is 0, so that the new slave returns a device discovery frame through verification, and the device discovery frame is taken as the uplink data frame; and the address number is allocated by the adjacent superior device for the slave through the downlink data line at the beginning of each communication period.

[0107] The data receiving module 12 is used for receiving the uplink data frame sent by the slave through the uplink data line, and processing and analyzing the uplink data frame.

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

[0109] From the above, the communication system in the application adopts a ring full-duplex bus with master-slave structure, can realize read-write synchronization, to realize the fast exchange of information between the host and the slave, and realizes the fast interaction of information. The address of the slave in the communication system is not fixed, but is allocated by the adjacent superior device through the downlink data line, so that when a new device is added, the address can be allocated 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 the time window through the uplink data line, to realize the real-time and fast discovery of the new device, and thus the flexible expansion of the new device can be realized.

[0110] In a specific embodiment, the data sending module 11 comprises:

[0111] An address numbering unit is configured to transmit an address allocation frame to the slave through the downlink data line by the adjacent superior device, and the address allocation frame contains an address number allocated to the slave, and the address number is the address number of the superior device plus 1.

[0112] In a specific embodiment, the data sending module 11 comprises:

[0113] A synchronization preset unit is configured to continuously send a synchronization clock signal to all the slaves through a clock line, and send a frame start signal to all the devices through a frame start data line.

[0114] A number acquisition unit is configured to acquire the number n of the slaves.

[0115] A data sending unit is configured to, when the frame start signal jumps to a start signal, sequentially send n+1 downlink data frames containing the target address to the adjacent slave according to the target address from large to small through the downlink data line; wherein the frame start signal jumps to a frame end signal every time the host sends one downlink data frame containing the target address.

[0116] In some specific embodiments, the synchronization preset unit comprises:

[0117] A new slave checking subunit is configured to send the frame end signal to the new slave through the frame start data line, so that the new slave judges whether the frame count is equal to the address number thereof; if yes, the new slave passes the check; wherein the frame count is the number of the frame end signal in the current communication period.

[0118] In some specific embodiments, the synchronization preset unit comprises:

[0119] The start signal output subunit outputs a signal of high level lasting five CLK periods as the start signal through the frame start data line;

[0120] The end signal output subunit outputs a signal of high level lasting less than one CLK period as the frame start signal as the end signal through the frame start data line.

[0121] In some embodiments, the synchronization preset unit comprises:

[0122] The device exception judgment subunit sends a frame start signal to all the slaves through the frame start data line, so as to judge whether the target address of the downlink data frame containing the target address received by the slave at the time when the frame count is equal to the known number of slaves is equal to the address number of the slave, and if not, determine that the system is abnormal and reset the slave; wherein the known number of slaves is contained in the downlink data frame containing the target address sent by the master in the first frame.

[0123] In one embodiment, the data receiving module 12 comprises:

[0124] The exception judgment unit judges whether the number of slaves and the address number are abnormal based on the uplink data frame, and if abnormal, clears the known number of slaves.

[0125] In one embodiment, the new device detection module 13 further comprises:

[0126] The cycle end judgment unit judges 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 ends.

[0127] Correspondingly, referring to Figure 8 The application embodiment further provides a communication device supporting real-time discovery, applied to a slave, comprising:

[0128] The address allocation module 21 obtains the address number allocated by the adjacent superior device through the downlink data line at the beginning of each communication cycle;

[0129] The data receiving module 22 receives and forwards the downlink data frame containing the target address sent by the master through the downlink data line, and one of the downlink data frames contains the target address 0; and judges whether the downlink data frame is a target data frame based on the target address and the address number; if yes, the downlink data frame is parsed and processed;

[0130] The data sending module 23 is 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 judging module 24 is configured to judge whether the device is a new slave device. If the device is a new slave device, the device returns a device discovery frame as the uplink data frame through the uplink data line after verification, so that the host determines that a new device is added to the current system and increases the number of known slave devices by 1.

[0132] The specific working processes of the above modules can refer to the corresponding contents disclosed in the foregoing embodiments, and will not be described here.

[0133] As can be seen from the above, the communication system in the application adopts a ring full-duplex bus with a master-slave structure, can realize read-write synchronization, and can realize fast exchange of information between the host and the slave device, thereby realizing fast interaction of information. The address of the slave device in the communication system is not fixed, but is allocated to the slave device by the adjacent upper device through the downlink data line. Therefore, when a new device is added, the address of the new device can be allocated in time. In addition, the downlink data frame containing the target address sent by the host contains a downlink data frame with a target address of 0, which provides a time window for the new device to reply. The host can receive the device discovery frame replied by the new device in the time window through the uplink data line, so as to realize real-time and fast discovery of the new device, and thus realize flexible expansion of the new device.

[0134] In a specific embodiment, the address allocation module 21 further comprises:

[0135] The slave device exception judging unit is configured to judge whether the address number allocated in the current communication period is the same as the address number allocated in the last communication period. If not, it is determined that the slave device has a device failure, and the slave device is reset.

[0136] Further, the application also discloses an electronic device, Figure 9 The electronic device 30 shown in the figure is not considered as any limitation on the use range of the application. The electronic device 30 can specifically include at least one processor 31, at least one memory 32, a power supply 33, a communication interface 34, an input-output interface 35 and a communication bus 36. The memory 32 is configured to store a computer program, and the computer program is loaded and executed by the processor 31 to realize the related steps in the communication method supporting real-time discovery disclosed in any of the foregoing embodiments. In addition, the electronic device 30 in the embodiment can be an electronic computer.

[0137] In this embodiment, the power supply 33 is configured to provide operating voltage for each hardware device on the electronic device 30; the communication interface 34 is configured to create a data transmission channel between the electronic device 30 and external devices, and the communication protocol followed by the communication interface 34 can be any communication protocol applicable to the technical solution of the present application, which will not be specifically limited herein; the input / output interface 35 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which will not be specifically limited herein.

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

[0139] The operating system 321 is configured to manage and control each hardware device on the electronic device 30 and the computer program 322, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the communication method executed by the electronic device 30 disclosed in any of the preceding embodiments, the computer program 322 can further include a computer program capable of completing other specific work.

[0140] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the communication method disclosed above. For the specific steps of the method, please refer to the corresponding content disclosed in the preceding embodiments, which will not be described here.

[0141] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. For the same or similar parts between each embodiment, please refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and please refer to the method part for the relevant part.

[0142] The skilled person can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of both. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in a general manner in the above description. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0143] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM, flash memory, ROM, electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. The

[0144] Finally, it should be noted that, in the description of the application, relational terms such as first and second, and the like can be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the recited element.

[0145] The above provides a detailed description of the technical solutions of the present application. The principles and implementation modes of the present application are described by applying specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed; in summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A communication method, characterized in that: Applied to a host, the system where the host and slave are located adopts a ring full-duplex bus, the slave is connected to adjacent devices via 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 least one downlink data frame containing a target address is sent to the adjacent slave machine through the downlink data line, so that the slave machine determines whether the downlink data frame containing the target address is a target data frame based on the target address and its address number. If so, the downlink data frame containing the target address is parsed and processed; wherein, the target address contained in one of the downlink data frames containing the target address is 0, so that the new slave machine 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 given to the slave machine by the adjacent upper-level device through the downlink data line at the beginning of each communication cycle. Allocating; sending at least one downlink data frame containing the target address to the adjacent slaves through the downlink data line, comprising: continuously sending a synchronous clock signal to all the slaves through the clock line, and sending a frame start signal to all the slaves through the frame start data line; obtaining the known number n of the slaves; when the frame start signal jumps to a start signal; 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; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to a frame end signal; receiving an uplink data frame sent by the slave device via 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, wherein: The address number is assigned to the slave by the adjacent upper-level device via the downlink data line at the beginning of each communication cycle, including: The adjacent upper device transmits an address allocation frame to the slave device via the downlink data line. The address allocation frame includes an address number allocated to the slave device. The address number is the address number of the upper device plus 1.

3. The communication method according to claim 1, wherein: The step of sending a frame start signal to all slave 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.

4. The communication method according to claim 1, wherein: The step of sending a frame start signal to all slave devices via a frame start data line includes: Outputting a high level signal lasting for five CLK cycles as the start signal through the frame start data line; A signal whose high level is less than one CLK cycle is outputted through the frame start data line as the frame end signal.

5. The communication method according to claim 1, wherein: The step of sending a frame start signal to all slave devices via a frame start data line includes: A frame start signal is sent to all the slaves via the 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 included in the downlink data frame containing the target address sent by the host in the first frame.

6. The communication method according to claim 1, wherein: 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 cleared.

7. The communication method according to any one of claims 1 to 6, characterized in that: After determining whether the uplink data frame contains the device discovery frame, the method further includes: Determining 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 ended.

8. A communication method, characterized in that: Applied to a slave device, the system where the slave device and the host device are located adopts a ring full-duplex bus, the slave device is connected to adjacent devices via 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 the adjacent upper-level device; 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 containing the target address 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; wherein, the process of the host sending the downlink data frame includes: continuously sending a synchronous clock signal to all the slaves through the clock line, and sending a frame start signal to all the slaves through the frame start data line; obtaining the number n of the known slaves; when the frame start signal jumps to the start signal; 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; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to a frame end signal; 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, after passing the verification, return 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 joined the current system and increase the number of known slaves by 1.

9. The communication method according to claim 8, wherein: 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.

10. A communication device, characterized in that: Applied to the host, including: The data sending module is used to send at least one downlink data frame containing a target address to an adjacent slave through a downlink data line, so that the slave can judge whether the downlink data frame is a target data frame based on the target address and its address number. If so, the downlink data frame is parsed and processed; wherein, the target address contained in one downlink data frame is 0, so that the new slave that passes the verification returns a device discovery frame as an uplink data frame, and 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; the downlink data frame is used to determine whether the target address is a target data frame based on the target address and its address number. Sending at least one downlink data frame containing a target address to an adjacent slave, comprising: continuously sending a synchronous clock signal to all the slaves via a clock line, and sending a frame start signal to all the slaves via a frame start data line; obtaining a known number n of the slaves; when the frame start signal jumps to a start signal; sending n+1 downlink data frames containing the target address in descending order according to the target address via the downlink data line to the adjacent slaves; wherein, each time the host sends a downlink data frame containing the target address, the frame start signal jumps to a frame end signal; A data receiving module, configured to receive an uplink data frame sent by the slave device via an uplink data line, and process and analyze 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.

11. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the communication method according to any one of claims 1 to 9.

12. 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 9 is implemented.

Citation Information

Patent Citations

  • Communication method based on RS485 bridge circuit device

    CN107229586A

  • Master-slave communication method and system, electronic equipment and readable storage medium

    CN118612014A