CN111698139A - RS485 bus multi-host competition switching method - Google Patents
RS485 bus multi-host competition switching method Download PDFInfo
- Publication number
- CN111698139A CN111698139A CN202010681878.1A CN202010681878A CN111698139A CN 111698139 A CN111698139 A CN 111698139A CN 202010681878 A CN202010681878 A CN 202010681878A CN 111698139 A CN111698139 A CN 111698139A
- Authority
- CN
- China
- Prior art keywords
- bus
- devices
- stand
- alone
- slave
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 12
- 238000004891 communication Methods 0.000 claims abstract description 5
- 238000010586 diagram Methods 0.000 description 3
- 206010033799 Paralysis Diseases 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40143—Bus networks involving priority mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Bus Control (AREA)
Abstract
The invention discloses a RS485 bus multi-host competition switching method, which comprises the following specific steps: the two stand-alone devices are connected in parallel, the dial switch is used for setting different priorities of the stand-alone devices, then the stand-alone devices determine the time from power-on to communication starting according to the priorities, if the RS485_1 and the RS485_2 of the two devices are connected together and then powered on, and after the stand-alone controller is powered on, the RS485_1 and the RS485_2 are initialized to be slave machines, the invention has the advantages that: (1) whether a host exists on the bus is confirmed by detecting data on the bus, and accurate judgment can be completed without intervention of an external controller. (2) The parallel single-machine equipment can be ensured to be used as the host machine after being electrified every time, and additional arrangement is not needed.
Description
Technical Field
The invention relates to the technical field of communication, in particular to a multi-host competition switching method for an RS485 bus.
Background
The existing RS485 bus generally has only one host, and a superior controller is often used for controlling and switching master-slave modes under the condition that two hosts conflict possibly. By switching the master-slave mode of the RS485 by the superior controller, once the superior controller is separated from the controller, the two hosts always compete for the control right of the bus, so that the whole bus can not be normally used.
The prior art has the following two defects:
less than 1: additional controller intervention is required to achieve master-slave switching.
And less than 2: when the superior controller is not in use, once two hosts always compete for the bus control right, the whole bus is paralyzed and cannot be recovered.
Disclosure of Invention
The invention aims to provide a multi-host competition switching method for an RS485 bus, so as to solve the problems in the background technology.
In order to achieve the purpose, the invention provides the following technical scheme:
a RS485 bus multi-host competition switching method comprises the following specific steps: two stand-alone devices are connected in parallel, different priorities of the stand-alone devices are set by using a dial switch, then the stand-alone devices determine the time from power-on to communication starting according to the priorities, if RS485_1 and RS485_2 of the two devices are connected together and then powered on, after a stand-alone controller is powered on, the RS485_1 and RS485_2 are initialized into slave devices, the overtime waiting time is determined according to the priorities set by the dial switch, the overtime waiting time with high priority is short, and the overtime waiting time with low priority is longer, during the overtime waiting period, if the RS485_2 detects that data flows on the RS485 bus II, the state of the RS485_2 slave devices is maintained, if no data is detected on the bus II in the whole overtime waiting time, the RS485 bus II is proved to have no host device, the RS485_2 is switched from the slave device mode to the host device mode, if the two devices are respectively powered on, the RS485_1 and the RS485_2 are connected together, the two stand-alone devices are respectively electrified, the RS485 bus I and the RS485 bus II are disconnected, therefore, after the timeout waiting time is exceeded, the two stand-alone controllers are switched from the slave mode to the master mode and respectively control the RS485 bus II, when the stand-alone controllers detect that the RS485 bus II has bus collision, the two stand-alone controllers immediately exit the master mode and are switched to the slave mode, a delay waiting mechanism during electrification is executed, the two devices exit the master mode together to enter the timeout waiting state, the devices with high priority have short waiting time and are firstly switched to the master mode, the devices with low priority detect data sent by the devices with high priority during the timeout waiting period, and the slave mode is continuously kept.
As a further technical scheme of the invention: the single machine controller in the parallel machine state needs to inquire the information of the subordinate slave devices, and needs to inquire other single machine controllers in the slave machine state through the RS485 bus to acquire the state of another single machine device.
As a further technical scheme of the invention: when the RS485 buses of the two single-machine devices are connected together, two hosts are arranged on the RS485 bus II, the two hosts always send commands, and bus collision can occur.
As a further technical scheme of the invention: the timeout waiting time with the high priority is set to 10 ms.
As a further technical scheme of the invention: the timeout waiting time of the low priority is set to 100 ms.
Compared with the prior art, the invention has the beneficial effects that: (1) whether a host exists on the bus is confirmed by detecting data on the bus, and accurate judgment can be completed without intervention of an external controller. (2) The parallel single-machine equipment can be ensured to be used as the host machine after being electrified every time, and additional arrangement is not needed.
Drawings
FIG. 1 is a schematic diagram of a stand-alone apparatus.
FIG. 2 is a schematic diagram of a single unit plant used in parallel.
FIG. 3 is a software process flow diagram.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1-3, example 1: a RS485 bus multi-host competition switching method comprises the following specific steps: two stand-alone devices are connected in parallel, different priorities of the stand-alone devices are set by using a dial switch, then the stand-alone devices determine the time from power-on to communication starting according to the priorities,
the following two cases are distinguished:
1. if RS485_1 and RS485_2 of the two devices are connected together and then powered on, after the single-machine controller is powered on, the RS485_1 and the RS485_2 are initialized to be slave machines, the overtime waiting time is determined according to the priority set by the dial switch, the overtime waiting time with high priority is short, the overtime waiting time with low priority is longer, during the overtime waiting period, if the RS485_2 detects that data flows on the RS485 bus II, the state of the slave machines of the RS485_2 is maintained, if the data on the bus II is not detected in the whole overtime waiting time, the RS485_2 is proved to have no host machine device on the RS485 bus II, and at the moment, the RS485_2 is switched from the slave machine mode to the host machine mode.
2. If the two devices are respectively electrified and then the RS485_1 and the RS485_2 are connected together, the two single-machine devices are respectively electrified, and the RS485 bus I and the RS485 bus II are disconnected, therefore, after the timeout waiting time is exceeded, the two single-machine controllers are switched from the slave mode to the host mode to respectively control the respective RS485 buses II, when the RS485 buses of the two single-machine devices are connected together, the two hosts are arranged on the RS485 bus II, and the two hosts always send commands, and at this time, bus collision inevitably occurs. When the single-machine controller detects that the RS485 bus II has bus collision, the host mode is immediately exited, the slave mode is switched to, a delay waiting mechanism during power-on is executed, the two devices exit the main mode together and enter an overtime waiting state, the waiting time of the device with high priority is short, the device with low priority is firstly switched to the host mode, the device with low priority detects data sent by the device with high priority during the overtime waiting period, and the slave mode is continuously kept.
Therefore, whether the bus is connected first and then powered on or first and then connected, the device with high priority can be ensured to be the master, and the device with low priority is ensured to be the slave. The software processing flow after the two cases are integrated is shown in figure 3.
Embodiment 2 is based on embodiment 1, in the parallel operation state, the single-machine controller needs to query information of the lower slave device, and also needs to query other single-machine controllers in the slave state through the RS485 bus to acquire the state of another single-machine device.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.
Furthermore, it should be understood that although the present description refers to embodiments, not every embodiment may contain only a single embodiment, and such description is for clarity only, and those skilled in the art should integrate the description, and the embodiments may be combined as appropriate to form other embodiments understood by those skilled in the art.
Claims (5)
1. A RS485 bus multi-host competition switching method is characterized by comprising the following specific steps: two stand-alone devices are connected in parallel, different priorities of the stand-alone devices are set by using a dial switch, then the stand-alone devices determine the time from power-on to communication starting according to the priorities, if RS485_1 and RS485_2 of the two devices are connected together and then powered on, after a stand-alone controller is powered on, the RS485_1 and RS485_2 are initialized into slave devices, the overtime waiting time is determined according to the priorities set by the dial switch, the overtime waiting time with high priority is short, and the overtime waiting time with low priority is longer, during the overtime waiting period, if the RS485_2 detects that data flows on the RS485 bus II, the state of the RS485_2 slave devices is maintained, if no data is detected on the bus II in the whole overtime waiting time, the RS485 bus II is proved to have no host device, the RS485_2 is switched from the slave device mode to the host device mode, if the two devices are respectively powered on, the RS485_1 and the RS485_2 are connected together, the two stand-alone devices are respectively electrified, the RS485 bus I and the RS485 bus II are disconnected, therefore, after the timeout waiting time is exceeded, the two stand-alone controllers are switched from the slave mode to the master mode and respectively control the RS485 bus II, when the stand-alone controllers detect that the RS485 bus II has bus collision, the two stand-alone controllers immediately exit the master mode and are switched to the slave mode, a delay waiting mechanism during electrification is executed, the two devices exit the master mode together to enter the timeout waiting state, the devices with high priority have short waiting time and are firstly switched to the master mode, the devices with low priority detect data sent by the devices with high priority during the timeout waiting period, and the slave mode is continuously kept.
2. The RS485 bus multi-master competition switching method according to claim 1, wherein the single-machine controller in the parallel operation state needs to inquire information of the subordinate slave devices, and needs to inquire other single-machine controllers in the slave devices through the RS485 bus to acquire the state of another single-machine device.
3. The RS485 bus multi-host competition switching method according to claim 2, wherein when the RS485 buses of two single devices are connected together, there are two hosts on the RS485 bus two, and both hosts are always sending commands, and bus collision occurs.
4. The RS485 bus multi-master contention switching method according to claim 3, wherein the timeout waiting time with high priority is set to 10 ms.
5. The RS485 bus multi-master contention switching method according to claim 4, wherein the timeout waiting time with low priority is set to 100 ms.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010681878.1A CN111698139A (en) | 2020-07-15 | 2020-07-15 | RS485 bus multi-host competition switching method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010681878.1A CN111698139A (en) | 2020-07-15 | 2020-07-15 | RS485 bus multi-host competition switching method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111698139A true CN111698139A (en) | 2020-09-22 |
Family
ID=72485667
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010681878.1A Pending CN111698139A (en) | 2020-07-15 | 2020-07-15 | RS485 bus multi-host competition switching method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111698139A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113949671A (en) * | 2021-09-29 | 2022-01-18 | 深圳市优必选科技股份有限公司 | Master-slave communication system and method, master and slave |
CN114726675A (en) * | 2022-04-09 | 2022-07-08 | 温州大学乐清工业研究院 | 485 communication network and intelligent lighting system based on area detects conflict |
CN116047887A (en) * | 2022-12-29 | 2023-05-02 | 孚瑞肯电气(深圳)有限公司 | Method and device for multi-host variable-frequency constant-pressure water supply |
CN117194300A (en) * | 2023-08-30 | 2023-12-08 | 深圳市英锐恩科技有限公司 | Multi-device serial synchronization method, device and system and electronic device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6272147B1 (en) * | 1996-09-27 | 2001-08-07 | Hewlett-Packard Company | Method and apparatus for prioritized transmission of data over a network |
CN101136828A (en) * | 2007-09-27 | 2008-03-05 | 广州市聚晖电子科技有限公司 | RS485 based multi-host machine wired serial communication method |
CN210324188U (en) * | 2019-08-27 | 2020-04-14 | 深圳市迈铭科技有限公司 | Integrated circuit bus IIC master-slave competition automatic switching equipment and system thereof |
CN111277478A (en) * | 2020-02-20 | 2020-06-12 | 福建师范大学 | RS485 bus multiplexing control method based on slave devices with different baud rates |
-
2020
- 2020-07-15 CN CN202010681878.1A patent/CN111698139A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6272147B1 (en) * | 1996-09-27 | 2001-08-07 | Hewlett-Packard Company | Method and apparatus for prioritized transmission of data over a network |
CN101136828A (en) * | 2007-09-27 | 2008-03-05 | 广州市聚晖电子科技有限公司 | RS485 based multi-host machine wired serial communication method |
CN210324188U (en) * | 2019-08-27 | 2020-04-14 | 深圳市迈铭科技有限公司 | Integrated circuit bus IIC master-slave competition automatic switching equipment and system thereof |
CN111277478A (en) * | 2020-02-20 | 2020-06-12 | 福建师范大学 | RS485 bus multiplexing control method based on slave devices with different baud rates |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113949671A (en) * | 2021-09-29 | 2022-01-18 | 深圳市优必选科技股份有限公司 | Master-slave communication system and method, master and slave |
CN113949671B (en) * | 2021-09-29 | 2023-06-02 | 深圳市优必选科技股份有限公司 | Master-slave communication system, method, host and slave |
CN114726675A (en) * | 2022-04-09 | 2022-07-08 | 温州大学乐清工业研究院 | 485 communication network and intelligent lighting system based on area detects conflict |
CN114726675B (en) * | 2022-04-09 | 2023-07-18 | 温州大学乐清工业研究院 | 485 communication network and intelligent lighting system based on conflict detection |
CN116047887A (en) * | 2022-12-29 | 2023-05-02 | 孚瑞肯电气(深圳)有限公司 | Method and device for multi-host variable-frequency constant-pressure water supply |
CN117194300A (en) * | 2023-08-30 | 2023-12-08 | 深圳市英锐恩科技有限公司 | Multi-device serial synchronization method, device and system and electronic device |
CN117194300B (en) * | 2023-08-30 | 2024-05-28 | 深圳市英锐恩科技有限公司 | Multi-device serial synchronization method, device and system and electronic device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111698139A (en) | RS485 bus multi-host competition switching method | |
US7039734B2 (en) | System and method of mastering a serial bus | |
CN103377083B (en) | For the method for the automated system for running redundancy | |
CN106951336B (en) | MCU (microprogrammed control Unit) resetting method, device and system | |
CN108632015B (en) | The communication means of slave unit, serial communication system and serial communication system | |
CN104570721B (en) | Redundant manipulator master slave mode determines method | |
US20120254486A1 (en) | Usb peripheral device comprising limited function usb host controller | |
CN102130669B (en) | Method, system, device and network equipment for detecting state of hot-plug module | |
CN1246672A (en) | Data processor having hot connect/disconnect function and its method | |
CN103678198B (en) | The latch-release method of bus, apparatus and system | |
EP2323012A2 (en) | Energy saving circuit for a peripheral, peripheral, distribution device and work method | |
CN112100007A (en) | Method and system for switching main controller in multi-controller storage equipment | |
CN102253910A (en) | Inter-integrated circuit (I2C) transmission method and device | |
CN109976489B (en) | Automatic reset implementation method and system under IIC (inter-Integrated Circuit) bus abnormal condition | |
CN212324117U (en) | RS485 bus multi-host competition switching system | |
CN210324188U (en) | Integrated circuit bus IIC master-slave competition automatic switching equipment and system thereof | |
CN100479295C (en) | Synchronized switching controller and its control for parallel uninterrupted power supply | |
CN108983695A (en) | A kind of master-slave switching method and device based on Complex Programmable Logic Devices | |
US8412146B2 (en) | Mutual awakening system and method thereof between a handheld device and a wireless communication module | |
CN103095739A (en) | Cabinet server system and node communication method thereof | |
CN102486675B (en) | Control device, control method and image processing system | |
CN115987999A (en) | Master-slave competition method and device for multi-machine system, ARM and storage medium | |
WO2021047339A1 (en) | Air conditioner communication method based on single line half duplex communication and air conditioner | |
US20120150421A1 (en) | Dynamic Transitioning Between Intersection Controller Traffic Engines | |
CN112787360B (en) | High-reliability charging pile |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200922 |