WO2018218885A1 - 避免主从设备冲突的rs485通信***及方法 - Google Patents

避免主从设备冲突的rs485通信***及方法 Download PDF

Info

Publication number
WO2018218885A1
WO2018218885A1 PCT/CN2017/111555 CN2017111555W WO2018218885A1 WO 2018218885 A1 WO2018218885 A1 WO 2018218885A1 CN 2017111555 W CN2017111555 W CN 2017111555W WO 2018218885 A1 WO2018218885 A1 WO 2018218885A1
Authority
WO
WIPO (PCT)
Prior art keywords
master
time
data
slave
slave device
Prior art date
Application number
PCT/CN2017/111555
Other languages
English (en)
French (fr)
Inventor
周鸣
张智
孟庆锐
Original Assignee
烽火通信科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 烽火通信科技股份有限公司 filed Critical 烽火通信科技股份有限公司
Publication of WO2018218885A1 publication Critical patent/WO2018218885A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40052High-speed IEEE 1394 serial bus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0647Synchronisation among TDM nodes
    • H04J3/065Synchronisation among TDM nodes using timestamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40052High-speed IEEE 1394 serial bus
    • H04L12/40078Bus configuration

Definitions

  • the invention relates to the field of RS485 communication, in particular to an RS485 communication system and method for avoiding conflicts between master and slave devices.
  • the RS485 serial bus standard is widely used when the communication distance is required to be several tens of meters to several kilometers.
  • RS485 uses balanced transmit and differential receive, so it has the ability to reject common mode interference. In addition to the high sensitivity of the bus transceiver, it can detect voltages as low as 200mV, so the transmitted signal can be recovered beyond the kilometer.
  • RS485 adopts half-duplex working mode, and only one point can be sent at any time. Therefore, the transmitting circuit must be controlled by the enable signal.
  • RS485 is very convenient for multi-point interconnection and can save many signal lines.
  • Applications RS485 can be networked to form a distributed system that allows up to 32 drives and 32 receivers to be connected in parallel.
  • the 1RS485 bus has a simple structure and is easy to construct. Since it uses balanced transmission, the physical medium only needs a pair of twisted pairs.
  • the transmission distance is as far as 1200m, and the speed range is several tens to several hundred kb/s.
  • 3 bus can be connected to multiple nodes, ranging from a few dozen to more than one hundred, which can meet the needs of most industrial applications.
  • 4 bus interface chip is rich, easy to buy, such as MAX481, MAX483, MAX485, MAX487, MAX488, MAX491, MAX253, MAX1480, etc. It is very common in the market.
  • the RS485 bus constitutes a field network
  • its topology structure mainly includes bus type, ring form, star form, etc.
  • the bus topology is the most widely used. In this configuration, only one pair of trunk lines is needed, and the RS485 bus devices (nodes) scattered throughout can be directly "hanged" on the bus.
  • the physical medium for transmitting data is only a pair of twisted pairs, this determines that only one node can be in the transmitting state at any time, and other RS485 nodes must be in the receiving state, so the RS485 bus can only be half-double. Work mode to communicate.
  • the master-slave working mode is often adopted, that is, only a single master node (usually a host computer) exists in the system, and the rest Nodes are in a subordinate position.
  • the occupation and allocation of the bus is completely dominated by the master node, and the slave node must completely "hear" the "command" of the master node.
  • the master node scans each node one by one in a polling manner and establishes communication with it. The scanning is performed in a broadcast manner.
  • the address field in the scan code string contains the address of a node to be accessed, and all the slave nodes receive the same code string. However, only the node with the same address in the code string will receive the same.
  • the code analyzes, executes the host command, modifies some field parameters, and returns the status data of the site to the host.
  • the bus is released immediately after the transmission is completed.
  • Other RS485 nodes will discard the code string just received because of the address mismatch, and will not respond.
  • the object of the present invention is to overcome the deficiencies of the above background art and to provide an avoidance
  • the RS485 communication system and method in which the master and slave devices collide can realize that the master device and the slave device transmit data in their own time slots, thereby effectively improving the real-time performance and reliability of the device.
  • the invention provides an RS485 communication system for avoiding conflicts between master and slave devices, the system comprising a master device and a plurality of slave devices,
  • the master device When the master device detects that a slave device is powered on, the master device encapsulates the current time and time stamp of the master device into time synchronization data in its own time slot, and sends the data to the slave device that is powered on.
  • the slave device receives the master device. After the time synchronization data is sent, the packet is grouped, and the time and time stamp are updated according to the time synchronization data after the group packet until the time synchronization is successful;
  • the slave device sends the response data of the time synchronization success to the master device in its own time slot; after receiving the response data sent from the device, the master device performs the group packet, and confirms the time of the master and slave devices according to the response data after the group packet.
  • the synchronization is successful;
  • the master and slave devices transmit data in their respective gap slots to avoid collisions between master and slave devices.
  • the process for the master and slave devices to send data in respective gap slots is as follows: when the master device has four slave devices, the data period is transmitted in one second, and the second clock is divided into five. For 200 milliseconds, the master device and the four slave devices have 20 milliseconds of transmission slots in each 200 milliseconds, and there is a gap of 20 milliseconds between the master and slave devices to prevent them from colliding when transmitting data in their own slot slots.
  • the primary device when the primary device sends data, the primary device first calculates a difference according to the current time and the timestamp, analyzes which interval of the difference is in the range of 1 to 1000 ms, and then determines whether it is in its own time slot. If it is, send the data directly; if it is not, wait for its own time slot to send the data again.
  • the master-slave device performs RS485 initialization.
  • the RS485 initialization process is: Establish RS485 sending task, RS485 sending task queue, RS485 receiving task, RS485 receiving task queue.
  • the invention also provides an RS485 communication method for avoiding conflicts between master and slave devices, comprising the following steps:
  • the master device When the master device detects that a slave device is powered on, the master device encapsulates the current time and time stamp of the master device into time synchronization data in its own time slot, and sends the data to the slave device that is powered on.
  • the slave device receives the master device. After the time synchronization data is sent, the packet is grouped, and the time and time stamp are updated according to the time synchronization data after the group packet until the time synchronization is successful;
  • the slave device sends the response data of the time synchronization success to the master device in its own time slot; after receiving the response data sent from the device, the master device performs the group packet, and confirms the time of the master and slave devices according to the response data after the group packet.
  • the synchronization is successful;
  • the master and slave devices transmit data in their respective gap slots to avoid collisions between master and slave devices.
  • the process for the master and slave devices to send data in respective gap slots is as follows: when the master device has four slave devices, the data period is transmitted in one second, and the second clock is divided into five. For 200 milliseconds, the master device and the four slave devices have 20 milliseconds of transmission slots in each 200 milliseconds, and there is a gap of 20 milliseconds between the master and slave devices to prevent them from colliding when transmitting data in their own slot slots.
  • the primary device when the primary device sends data, the primary device first calculates a difference according to the current time and the timestamp, analyzes which interval of the difference is in the range of 1 to 1000 ms, and then determines whether it is in its own time slot. If it is, send the data directly; if it is not, wait for its own time slot to send the data again.
  • the method further includes the following steps: the master and slave devices perform RS485 initialization.
  • the RS485 initialization process is: Establish RS485 sending task, RS485 sending task queue, RS485 receiving task, RS485 receiving task queue.
  • the present invention solves the problem of RS485 communication conflict by using time division, and does not need to be a master device to send a slave device response as in the past, the slave device can freely transmit data to the master device, and can realize that the master device and the slave device are in their own time slots. Send data to effectively improve the real-time and reliability of the device.
  • the applicant adopts the communication system and the communication method of the present invention in the newly revised intelligent ODN system, and can transplant and seamlessly replace the traditional RS485 communication one-answer communication mode.
  • the slave node must also have the control of the bus.
  • the invention has concurrency, high efficiency, security, redundancy, and is easy to manage, and can meet the large-volume data acquisition, parallel, reliable and secure configuration management of the communication device.
  • FIG. 1 is a flow chart of a method for avoiding RS485 communication of a master-slave device conflict in an embodiment of the present invention.
  • FIG. 2 is a slot diagram of a master-slave device in an embodiment of the present invention.
  • FIG. 3 is a flow chart of a master-slave device transmitting data according to a time slot in an embodiment of the present invention.
  • Embodiments of the present invention provide an RS485 communication system that avoids conflicts between master and slave devices, and includes a master device and multiple slave devices.
  • the embodiment of the invention further provides an RS485 communication method for avoiding conflict between a master and a slave device, comprising the following steps:
  • the master-slave device performs RS485 initialization, and the RS485 initialization process is: creating RS485 sending task, RS485 sending task queue, RS485 receiving task, RS485 receiving task queue;
  • the master device When the master device detects that a slave device is powered on, the master device encapsulates the current time and time stamp of the master device into time synchronization data in its own time slot, and sends the data to the slave device that is powered on.
  • the slave device receives the master device. After the time synchronization data is sent, the packet is grouped, and the time and time stamp are updated according to the time synchronization data after the group packet until the time synchronization is successful;
  • the slave device sends the response data of the time synchronization success to the master device in its own time slot; after receiving the response data sent from the device, the master device performs the group packet, and confirms the time of the master and slave devices according to the response data after the group packet.
  • the synchronization is successful;
  • the master and slave devices transmit data in their respective gap slots to avoid collisions between master and slave devices.
  • an RS485 communication method for avoiding a conflict between a master and a slave device in the embodiment of the present invention includes the following steps:
  • Step 101 The master and slave devices respectively perform RS485 initialization, and the RS485 initialization process is: creating an RS485 sending task, an RS485 sending task queue, an RS485 receiving task, and an RS485 receiving task queue;
  • Step 102 After the master device detects that the slave device is powered on, the master device takes the current time and timestamp, packs the current time and time stamp into the time synchronization data, and enters the RS485 sending task queue.
  • Step 103 The RS485 sending task of the master device takes time synchronization data, and sends time synchronization data to the slave device according to its own time slot.
  • Step 104 Receive time synchronization data from the RS485 receiving task of the device and group the packet, because the RS485 data may be sent by the packet, so the receiving party (slave device) must group the RS485 data packet;
  • Step 105 The slave device obtains the current time and time from the time synchronization data after the group packet.
  • the timestamp, the current time obtained is set to the current time of the slave device, and the acquired timestamp is set to the timestamp of the slave device until the synchronization is successful;
  • Step 106 The slave device sends the time synchronization response data to its own RS485 transmission queue.
  • Step 107 The RS485 sending task of the slave device extracts the time synchronization response data from the RS485 sending queue, and sends the time synchronization response data to the master device according to its own time slot;
  • Step 108 The RS485 receiving task of the master device groups the packet after receiving the data sent from the device;
  • Step 109 The master device confirms that the time synchronization of the master and slave devices is successful according to the time synchronization response data after the group packet. Subsequently, the master and slave devices transmit data in the respective gap slots without conflict.
  • the embodiment of the invention solves the problem of RS485 communication conflict by using time division, and can realize that the master device and the slave device transmit data in their own time slots, thereby effectively improving the real-time performance and reliability of the device.
  • the process of transmitting data by the master and slave devices in their respective gap slots is as follows: when the master device has 4 slave devices, the data period is transmitted in 1 second, and 1 second is divided into 5 200 milliseconds, the master device and the four slaves.
  • the device has a 20 millisecond transmit time slot in each 200 milliseconds. As shown in Figure 2, there is a 20 millisecond gap between the master and slave devices to prevent them from colliding when transmitting data in their own gap slots.
  • the master device When the master device sends data, the master device first calculates a difference based on the current time and timestamp, analyzes which interval the difference is in the range of 1 to 1000 ms, and then determines whether it is in its own time slot. If it is, directly sends data; if not Wait for your own time slot to send data again.
  • Step 201 The RS485 sending task of the master device acquires time synchronization data from the RS485 sending task queue.
  • Step 202 The master device calculates a difference between the current time and the timestamp, where the time difference is a number between 1 and 1000 milliseconds;
  • Step 203 the master device determines whether it is in the transmission time slot according to the time difference, and if so, proceeds to step 204; if not, proceeds to step 205;
  • Step 204 The master device sends data in its own time slot.
  • Step 205 The master device waits to send data to its own time slot.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本发明公开了一种避免主从设备冲突的RS485通信***及方法,涉及RS485通信领域。该方法包括以下步骤:主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至同步成功;从设备在自己的时隙,将同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;主从设备在各自的空隙时隙发送数据,避免冲突。本发明能实现主设备和从设备在自己的时隙发送数据,有效提高设备的实时性和可靠性。

Description

避免主从设备冲突的RS485通信***及方法 技术领域
本发明涉及RS485通信领域,具体是涉及一种避免主从设备冲突的RS485通信***及方法。
背景技术
在要求通信距离为几十米到上千米时,广泛采用RS485串行总线标准。RS485采用平衡发送和差分接收,因此具有抑制共模干扰的能力。加上总线收发器具有高灵敏度,能检测低至200mV的电压,故传输信号能在千米以外得到恢复。RS485采用半双工工作方式,任何时候只能有一点处于发送状态,因此,发送电路须由使能信号加以控制。RS485用于多点互连时非常方便,可以省掉许多信号线。应用RS485可以联网构成分布式***,其允许最多并联32台驱动器和32台接收器。
在通信设备***应用中,RS485总线构成的现场网络得到了广泛的应用,原因如下:
①RS485总线结构简单、易于建构,由于它采用平衡传输,物理介质只须一对双绞线。
②传输距离远,可达1200m,速率范围达几十~几百kb/s。
③总线上可以挂接多个节点,少则三十几个,多则上百个,可以满足大多数的工业应用需要。
④总线接口芯片丰富,易于购买,如MAX481、MAX483、MAX485、MAX487、MAX488、MAX491、MAX253、MAX1480等 在市场上是很常见的。
⑤造价低,有很好的性价比。
RS485总线在构成现场网络时,其拓扑结构形式主要有总线式、环形式、星形式等,其中以总线式拓扑结构应用最广。在这种结构中,只需要一对主干线,分散在各处的RS485总线设备(节点)可以直接“挂”在总线上。
但是,由于传输数据的物理介质只是一对双绞线,这就决定了:***在任一时刻,只能有一个节点处于发送状态,其他RS485节点必须处于接收状态,所以RS485总线只能以半双工方式进行通信。
如果现场各分布节点的实时操作性要求不十分严格,或***中节点数不是很大时,常采用主-从工作模式,即***中只存在唯一的主节点(通常是上位计算机),其余各节点都处于从属地位。
总线的占用与分配完全由主节点来主导,从节点要完全“听从”主节点的“指挥”。主节点以巡回轮流的方式,逐一扫描各节点,并与其建立通信联系。扫描是以广播方式进行的,扫描编码串中的地址字段包含有某个待访问节点的地址,所有从节点都接收同一编码串,然而,只有与编码串中地址相同的节点,才会对接收的代码进行分析、执行主机命令、修改某些现场参数,并将现场的状态数据回传给主机,发送完毕后立刻释放总线。其他RS485节点则由于地址不符,故会弃掉刚才收到的码串,不作任何回应。
可以看出,当RS485节点数较多时,对各节点轮流扫描一遍所需要的时间开销是相当可观的,这意味着***实时性差,RS485总线的通信效率降低。
发明内容
本发明的目的是为了克服上述背景技术的不足,提供一种避免 主从设备冲突的RS485通信***及方法,能够实现主设备和从设备在自己的时隙发送数据,有效提高设备的实时性和可靠性。
本发明提供一种避免主从设备冲突的RS485通信***,该***包括一个主设备和多个从设备,
主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至时间同步成功;
从设备在自己的时隙,将时间同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;
主从设备在各自的空隙时隙内发送数据,避免主从设备冲突。
在上述技术方案的基础上,所述主从设备在各自的空隙时隙内发送数据的流程如下:主设备带4个从设备时,以1秒为一个发送数据周期,将1秒分为5个200毫秒,主设备和4个从设备在每个200毫秒里有20毫秒的发送时隙,主从设备之间有20毫秒的空隙,避免它们在自己的空隙时隙发送数据时冲突。
在上述技术方案的基础上,所述主设备发送数据时,主设备先根据当前时间和时间戳算出一个差值,分析差值处于1到1000ms的哪个区间,再判断是否在自己的时隙内,如果在,直接发送数据;如果不在,等自己的时隙到了再发送数据。
在上述技术方案的基础上,所述主设备检测到有从设备上电之前,主从设备各自进行RS485初始化。
在上述技术方案的基础上,所述RS485初始化的过程为:创 建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列。
本发明还提供一种避免主从设备冲突的RS485通信方法,包括以下步骤:
主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至时间同步成功;
从设备在自己的时隙,将时间同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;
主从设备在各自的空隙时隙内发送数据,避免主从设备冲突。
在上述技术方案的基础上,所述主从设备在各自的空隙时隙内发送数据的流程如下:主设备带4个从设备时,以1秒为一个发送数据周期,将1秒分为5个200毫秒,主设备和4个从设备在每个200毫秒里有20毫秒的发送时隙,主从设备之间有20毫秒的空隙,避免它们在自己的空隙时隙发送数据时冲突。
在上述技术方案的基础上,所述主设备发送数据时,主设备先根据当前时间和时间戳算出一个差值,分析差值处于1到1000ms的哪个区间,再判断是否在自己的时隙内,如果在,直接发送数据;如果不在,等自己的时隙到了再发送数据。
在上述技术方案的基础上,所述主设备检测到有从设备上电之前,还包括以下步骤:主从设备各自进行RS485初始化。
在上述技术方案的基础上,所述RS485初始化的过程为:创 建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列。
与现有技术相比,本发明的优点如下:
(1)本发明利用时分解决RS485通信冲突的问题,不需要像以往那样必须是主设备发送从设备回应,从设备可以自由发送数据到主设备,能够实现主设备和从设备在自己的时隙发送数据,有效提高设备的实时性和可靠性。申请人在新改版的智能ODN***中采用了本发明的通信***及通信方法,能够移植和无缝的替代传统的RS485通信一问一答的通信方式。
(2)如果应用现场对实时性有较高要求,例如要及时上传某个设备的突发状态,就必须让从节点也能够享有总线控制权。本发明具有并发性、高效率、安全性、冗余性,并且便于管理,能满足通信设备大批量数据采集、并行、可靠安全的配置管理。
附图说明
图1是本发明实施例中避免主从设备冲突的RS485通信方法的流程图。
图2是本发明实施例中主从设备的时隙图。
图3是本发明实施例中主从设备根据时隙发送数据的流程图。
具体实施方式
下面结合附图及具体实施例对本发明作进一步的详细描述。
本发明实施例提供一种避免主从设备冲突的RS485通信***,该***包括一个主设备和多个从设备。
本发明实施例还提供一种避免主从设备冲突的RS485通信方法,包括以下步骤:
主从设备各自进行RS485初始化,RS485初始化的过程为:创建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列;
主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至时间同步成功;
从设备在自己的时隙,将时间同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;
主从设备在各自的空隙时隙内发送数据,避免主从设备冲突。
参见图1所示,本发明实施例中避免主从设备冲突的RS485通信方法,具体包括以下步骤:
步骤101、主从设备各自进行RS485初始化,RS485初始化的过程为:创建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列;
步骤102、主设备检测到从设备上电后,主设备取当前时间和时间戳,将当前时间和时间戳打包到时间同步数据中,并打入到RS485发送任务队列;
步骤103、主设备的RS485发送任务取出时间同步数据,并根据自己的时隙发送时间同步数据给从设备;
步骤104、从设备的RS485接收任务收到时间同步数据并组包,因为RS485数据可能会被分包发送,所以接收方(从设备)必须要对RS485数据包进行组包;
步骤105、从设备从组包后的时间同步数据中获取当前时间和时 间戳,将获取的当前时间设置为从设备的当前时间,并将获取的时间戳设置为从设备的时间戳,直至同步成功;
步骤106、从设备将时间同步响应数据打入到自己的RS485发送队列中;
步骤107、从设备的RS485发送任务从RS485发送队列中取出时间同步响应数据,根据自己的时隙,发送时间同步响应数据给主设备;
步骤108、主设备的RS485接收任务在收到从设备发来的数据后组包;
步骤109、主设备根据组包后的时间同步响应数据,确认主从设备的时间同步成功,后续,主从设备在各自的空隙时隙内发送数据而不会冲突。
本发明实施例利用时分解决RS485通信冲突的问题,能够实现主设备和从设备在自己的时隙发送数据,有效提高设备的实时性和可靠性。
主从设备在各自的空隙时隙内发送数据的流程如下:主设备带4个从设备时,以1秒为一个发送数据周期,将1秒分为5个200毫秒,主设备和4个从设备在每个200毫秒里有20毫秒的发送时隙,参见图2所示,主从设备之间有20毫秒的空隙,避免它们在自己的空隙时隙发送数据时冲突。
主设备发送数据时,主设备先根据当前时间和时间戳算出一个差值,分析差值处于1到1000ms的哪个区间,再判断是否在自己的时隙内,如果在,直接发送数据;如果不在,等自己的时隙到了再发送数据。
参见图3所示,主从设备在各自的空隙时隙内发送数据的具体流 程如下:
步骤201、主设备的RS485发送任务从RS485发送任务队列中获取时间同步数据;
步骤202、主设备计算出当前时间和时间戳的差值,时间差值是1到1000毫秒之间的一个数;
步骤203、主设备根据时间差判断自己是否处于发送时隙内,如果是,就到转到步骤204;如果不是,就转到步骤205;
步骤204、主设备在自己的时隙内发送数据;
步骤205、主设备等到自己的时隙再发送数据。
本领域的技术人员可以对本发明实施例进行各种修改和变型,倘若这些修改和变型在本发明权利要求及其等同技术的范围之内,则这些修改和变型也在本发明的保护范围之内。
说明书中未详细描述的内容为本领域技术人员公知的现有技术。

Claims (10)

  1. 一种避免主从设备冲突的RS485通信***,该***包括一个主设备和多个从设备,其特征在于:
    主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至时间同步成功;
    从设备在自己的时隙,将时间同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;
    主从设备在各自的空隙时隙内发送数据,避免主从设备冲突。
  2. 如权利要求1所述的避免主从设备冲突的RS485通信***,其特征在于:所述主从设备在各自的空隙时隙内发送数据的流程如下:主设备带4个从设备时,以1秒为一个发送数据周期,将1秒分为5个200毫秒,主设备和4个从设备在每个200毫秒里有20毫秒的发送时隙,主从设备之间有20毫秒的空隙,避免它们在自己的空隙时隙发送数据时冲突。
  3. 如权利要求2所述的避免主从设备冲突的RS485通信***,其特征在于:所述主设备发送数据时,主设备先根据当前时间和时间戳算出一个差值,分析差值处于1到1000ms的哪个区间,再判断是否在自己的时隙内,如果在,直接发送数据;如果不在,等自己的时隙到了再发送数据。
  4. 如权利要求1所述的避免主从设备冲突的RS485通信***,其特征在于:所述主设备检测到有从设备上电之前,主从设备各自进行RS485初始化。
  5. 如权利要求4所述的避免主从设备冲突的RS485通信***,其特征在于:所述RS485初始化的过程为:创建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列。
  6. 一种避免主从设备冲突的RS485通信方法,其特征在于,包括以下步骤:
    主设备检测到有从设备上电时,主设备在自己的时隙内,将主设备的当前时间、时间戳打包为时间同步数据,发送到上电的从设备;该从设备接收到主设备发来的时间同步数据后进行组包,根据组包后的时间同步数据更新自己的时间和时间戳,直至时间同步成功;
    从设备在自己的时隙,将时间同步成功的响应数据发送给主设备;主设备接收到从设备发来的响应数据后进行组包,根据组包后的响应数据,确认主从设备的时间同步成功;
    主从设备在各自的空隙时隙内发送数据,避免主从设备冲突。
  7. 如权利要求6所述的避免主从设备冲突的RS485通信方法,其特征在于:所述主从设备在各自的空隙时隙内发送数据的流程如下:主设备带4个从设备时,以1秒为一个发送数据周期,将1秒分为5个200毫秒,主设备和4个从设备在每个200毫秒里有20毫秒的发送时隙,主从设备之间有20毫秒的空隙,避免它们在自己的空隙时隙发送数据时冲突。
  8. 如权利要求7所述的避免主从设备冲突的RS485通信方法,其特征在于:所述主设备发送数据时,主设备先根据当前时间和时间戳算出一个差值,分析差值处于1到1000ms的哪个区间,再判断是否在自己的时隙内,如果在,直接发送数据;如果不在,等自己的时隙到了再发送数据。
  9. 如权利要求6所述的避免主从设备冲突的RS485通信方法, 其特征在于:所述主设备检测到有从设备上电之前,还包括以下步骤:主从设备各自进行RS485初始化。
  10. 如权利要求9所述的避免主从设备冲突的RS485通信方法,其特征在于:所述RS485初始化的过程为:创建RS485发送任务、RS485发送任务队列、RS485接收任务、RS485接收任务队列。
PCT/CN2017/111555 2017-05-27 2017-11-17 避免主从设备冲突的rs485通信***及方法 WO2018218885A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710396263.2A CN107294827B (zh) 2017-05-27 2017-05-27 避免主从设备冲突的rs485通信***及方法
CN201710396263.2 2017-05-27

Publications (1)

Publication Number Publication Date
WO2018218885A1 true WO2018218885A1 (zh) 2018-12-06

Family

ID=60095020

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/111555 WO2018218885A1 (zh) 2017-05-27 2017-11-17 避免主从设备冲突的rs485通信***及方法

Country Status (2)

Country Link
CN (1) CN107294827B (zh)
WO (1) WO2018218885A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106953809B (zh) * 2017-02-24 2020-04-14 烽火通信科技股份有限公司 一种基于485分时通信的设备资源采集方法
CN107294827B (zh) * 2017-05-27 2019-10-25 烽火通信科技股份有限公司 避免主从设备冲突的rs485通信***及方法
CN108011793A (zh) * 2017-11-24 2018-05-08 中国航空工业集团公司西安航空计算技术研究所 一种多通道总线通信控制方法
CN109841047A (zh) * 2017-11-27 2019-06-04 深圳市科比特航空科技有限公司 无人机集群控制方法、装置及***
CN109088753B (zh) * 2018-07-27 2021-10-26 江苏航天大为科技股份有限公司 自动检测rs485通信故障的电路和方法
CN109358256B (zh) * 2018-12-20 2021-09-03 上海欧秒电力监测设备有限公司 Rs485通讯中实现同步采样的避雷器在线监测***
EP4102920A4 (en) * 2020-03-06 2023-04-12 Huawei Technologies Co., Ltd. COMMUNICATION METHOD AND ASSOCIATED DEVICE

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729890A (zh) * 2013-06-28 2014-04-16 深圳市金溢科技有限公司 二义性路径识别***及交互通信方法
CN105680975A (zh) * 2016-03-07 2016-06-15 浙江大学 一种主从结构多节点网络的时间同步方法
CN107294827A (zh) * 2017-05-27 2017-10-24 烽火通信科技股份有限公司 避免主从设备冲突的rs485通信***及方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101404604A (zh) * 2008-11-03 2009-04-08 浪潮电子信息产业股份有限公司 一种485总线式监控***及其高可扩展性方法
CN102546141B (zh) * 2012-02-20 2015-02-18 杭州海康威视***技术有限公司 485总线***及其异步半双工通信方法
CN103269263B (zh) * 2013-05-17 2016-03-23 浙江赛思电子科技有限公司 基于自定义的扩展时钟和通信总线的rs422/485时间码协议的时钟扩展输出装置和方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729890A (zh) * 2013-06-28 2014-04-16 深圳市金溢科技有限公司 二义性路径识别***及交互通信方法
CN105680975A (zh) * 2016-03-07 2016-06-15 浙江大学 一种主从结构多节点网络的时间同步方法
CN107294827A (zh) * 2017-05-27 2017-10-24 烽火通信科技股份有限公司 避免主从设备冲突的rs485通信***及方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
FU, DAOJUN: "A time synchronization protocol for RS485 Bus", SHIP ELECTRONIC ENGINEERING, vol. 35, no. 5, 31 May 2015 (2015-05-31), ISSN: 1672-9730 *

Also Published As

Publication number Publication date
CN107294827A (zh) 2017-10-24
CN107294827B (zh) 2019-10-25

Similar Documents

Publication Publication Date Title
WO2018218885A1 (zh) 避免主从设备冲突的rs485通信***及方法
CN106155014B (zh) 工业互联网现场层宽带总线实时性实现方法
CN104317765B (zh) 一种基于串口通讯的一对多通讯***和实现方法
CN107465764B (zh) 基于星型拓扑结构的物联网通信***、网关设备及方法
US10164786B2 (en) Industry internet field broadband bus architecture system
CN104079677A (zh) Rs485通讯端口地址的自动分配方法
US20140355619A1 (en) Industrial network apparatus and data communication method
WO2020063995A1 (zh) Pon网络,用于pon网络的方法及装置,以及机器人***
CN102421187A (zh) 一种无线传感器网络的高精度时钟同步方法
CN110635982B (zh) 通讯总线上双主机通讯方法、***、工控网关及储存介质
CN109995675A (zh) 一种基于软件定义的自适应工业以太网网关***与方法
CN100481801C (zh) 以太网通信***中多用户实时通信方法及以太网通信***
CN106873541A (zh) 一种基于DSP的EtherCAT分布式伺服运动控制***
CN103856578A (zh) Modbus RTU从站自动获取站地址方法及从站
WO2021082674A1 (zh) 时间同步的方法、通信设备和***
CN102546070A (zh) 使用现有网络线缆来同步网络的方法和***
CN202617155U (zh) 多主机rs485通信装置
CN103716092A (zh) 一种总线型网络中双向光纤通信的组网***及通信方法
CN116991121A (zh) 一种多协议兼容的epa调度方法及装置
CN109328449A (zh) RTEX-EtherCAT协议转换装置及工业控制***
WO2018153127A1 (zh) 一种基于485分时通信的设备资源采集方法
CN204463106U (zh) Um-bus总线通道故障检测控制器
CN101895560B (zh) 一种开放性二级拓扑结构的现场总线dp-net
CN105141483A (zh) 基于can总线的多节点网络最小通信间隔测定方法
CN102843290B (zh) 数据采集监控***的问答式规约报文处理方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17911501

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17911501

Country of ref document: EP

Kind code of ref document: A1