An IoT communication method based on token ring networking
Through the introduction of the tokend ring network mechanism in the 485+MODBUS scheme, the bus locking problem was solved, and the efficient and stable IoT communications were realized, and the multi -master network and fault transfer were supported.
Patent Information
- Application Number
- CN202311602421.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-28
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2043-11-28
AI Technical Summary
The existing 485+Modbus solution has bus locking problems, resulting in low communication efficiency and network failure.
The Internet of Things communication method based on the token ring network is adopted, and the routing table is established through the preset host scanning the main line host, and the rotation mechanism of the token is ensured to ensure that each host has instructions to send a window to avoid locking in the bus.
Each device has the right to speak, avoid locking in the bus, improves communication efficiency and stability, and supports multi -master network, fault transfer, and multi -layer ring network.
Smart Images

Figure CN117459349B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of Internet of Things, and in particular relates to an Internet of Things communication method based on token ring networking. Background Art
[0002] In order to realize the networking setting of IoT devices, the existing technical solutions, such as the invention patent CN201810450377.5 "A 485 bus intelligent expansion method and device based on modbus communication protocol", connects multiple hosts to multiple data forwarding serial ports respectively, and the data acquisition serial port of the intelligent expansion device is connected to multiple slaves, thereby realizing multiple hosts communicating with multiple slaves on the 485 bus at the same time, thereby improving communication efficiency.
[0003] However, the existing 485+Modbus solution has some defects, the main problem of which is that each data communication can only be carried out through a single channel. The host sends instructions to the slave, and then the slave returns data. The host then sends instructions to slaves with other addresses and waits for the return data. This one-to-one timing results in only one-way transmission each time. If the slave fails and continues to send data, the entire 485 bus will be locked, causing the entire Modbus network to be paralyzed.
[0004] In view of the above technical problems, the present invention provides an Internet of Things communication method based on token ring networking. Summary of the invention
[0005] To achieve the purpose of the present invention, the present invention adopts the following technical solutions:
[0006] According to one aspect of the present invention, a communication method for an Internet of Things based on token ring networking is provided.
[0007] A communication method for Internet of Things based on token ring networking, characterized by comprising:
[0008] Based on the preset host, the entire bus host connected via RS485 is scanned, and the bus host whose address bit is scanned is returned to the preset host, and a routing table is established according to the scanning order of the address bit, and all the bus hosts in the ring network connected via RS485 are synchronized and the routing table is stored;
[0009] Determine the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends a query instruction to the first-order host according to the order of the routing table, release the token and enter the monitoring data receiving state;
[0010] Based on the fact that the first-priority host sends the collected data to the preset host after receiving the query instruction, and when the first-priority host sends the query instruction to the second-priority host, the token is released and rotated to the second-priority host, and the second-priority host sends the collected data to the preset host after receiving the query instruction, and circulates and rotates the token in sequence according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host.
[0011] The beneficial effects of the present invention are:
[0012] By constructing a communication method based on the RS485 protocol bus, the compatibility of RS485 protocol equipment in the industrial field is achieved. Based on the RS485 wiring and networking mode, by controlling the data transmission mode of the 2-wire differential voltage, according to the order of the networking routing table, each host in the network obtains a token (obtaining a token means having the right to issue instructions, and without a token, it can only receive data) instruction window through token rotation, keeping the ITRB bus token instruction always in unique occupation, and completely solving the bus locking phenomenon caused by timing tokens (the bus transmission and reception are both single-channel. If the bus host sends instructions, other hosts cannot receive data. If the host is receiving, other hosts cannot send instructions. Therefore, if any machine timing collides, it will cause bus conflict and lock).
[0013] Under the premise of keeping the timing conflict free, every device connected to the protocol has a say, which will not cause a certain device to occupy the bus and other devices to be unable to communicate. Each device in the routing table has a window period for sending instructions, and can also better judge whether the data collection segment data has been sent without delay waiting. Compared with other protocols, it has better stability, higher efficiency and more balanced timing control.
[0014] A further technical solution is that the preset host is determined according to the starting machine in the bus host connected to the RS485, and is responsible for generating query instructions and receiving collected data from the bus host.
[0015] A further technical solution is that the routing table consists of a sequence, an address bit and a status.
[0016] A further technical solution is that when the token rotates to the preset host, the current time is used as the instruction window period, and when in the instruction window period, the preset host sends a communication instruction to the first-priority host and rotates the token again.
[0017] A further technical solution is that the communication instructions include exiting the network, synchronizing the routing table, monitoring and correcting the routing table, and starting the ring network.
[0018] A further technical solution is that the preset host includes at least one backup preset host, and during the instruction window period, the preset host and the backup preset host actively monitor each other's issuance of the communication instruction, and determine whether the preset host is offline based on the issuance of the communication instruction.
[0019] A further technical solution is that, when the preset host is offline, a standby preset host that is not offline is replaced by a new preset host, and the communication instruction is generated and issued by the new preset host.
[0020] A further technical solution is that the specific steps of replacing the standby preset host with a new preset host are:
[0021] The standby preset host is in the routing table by default for token ring rotation, and is always listening to the heartbeat command of the preset host. If the preset host does not send a heartbeat when it rotates, the standby preset host will seize the token, create a command window, send a command to change the host address bit of the collection end, and synchronize the routing table at the same time. At this time, all data collection ends will start to send the collected data to the standby preset host to complete the failover of the data collection end;
[0022] A further technical solution is that when the backup preset host acts as the host, it will continue to monitor the heartbeat of the preset host. If the preset host is started, the heartbeat will be restored. When the backup preset host rotates to the token ownership, it will restore the host collection end sovereignty of the preset host through the command window, complete the master-slave recovery, and the backup preset host enters the silent listening state.
[0023] A further technical solution is that the number of the backup preset hosts is dynamically evaluated according to the historical heartbeat monitoring data of the preset hosts and the number of bus hosts connected via RS485, wherein the specific steps for determining the number of the backup preset hosts are:
[0024] S11 obtains the number of bus hosts connected via RS485, and determines the recommended number of the backup preset hosts based on the number of bus hosts, determines the number of disappearances of the historical heartbeat instructions of the preset hosts based on the historical heartbeat monitoring data of the preset hosts, and determines whether the running state of the preset hosts is stable in combination with the monitoring time of the backup preset hosts, if yes, proceeds to the next step, if not, proceeds to step S14;
[0025] S12 determines the number of times the historical heartbeat instructions of the preset host disappear within a preset unit time based on the historical heartbeat monitoring data of the preset host, and uses it as the unit disappearance number, and judges whether the unit disappearance number meets the requirement, if so, proceeds to the next step, if not, proceeds to step S14;
[0026] S13 determines the interval durations between different near disappearance times of the historical heartbeat instructions of the preset host through the historical heartbeat monitoring data of the preset host, and determines whether the running state of the preset host is stable based on the disappearance times whose interval duration is less than the preset duration, and if so, uses the recommended number of the backup preset hosts as the number of the backup preset hosts, and if not, proceeds to the next step;
[0027] S14 obtains the average value of the interval durations between different adjacent disappearance times of the historical heartbeat instructions of the preset host and the number of disappearance times with an interval duration less than the preset duration, and evaluates the operational reliability of the preset host in combination with the number of disappearances of the preset host within different preset unit time lengths and the number of disappearances of the historical heartbeat instructions, obtains the monitoring time of the backup preset host, and corrects the recommended number of the backup preset hosts in combination with the operational reliability of the preset host to obtain the number of the backup preset hosts.
[0028] A further technical solution is that the preset host supports nested ring networking, each ring network uses a separate set of routing tables, and gateway data is exchanged through the bus host. When the bus host exchanges gateway data, the bus host is used as the preset host, and each bus host includes a backup preset host.
[0029] On the other hand, the present invention provides an Internet of Things communication system based on token ring networking, which adopts the above-mentioned Internet of Things communication method based on token ring networking, and is characterized in that it specifically includes:
[0030] Routing table generation module, instruction output module, token rotation module;
[0031] The routing table generation module is responsible for scanning the entire bus host connected via RS485 based on the preset host, returning the bus host whose address bit is scanned to the preset host, and establishing a routing table according to the scanning order of the address bit, synchronizing all the bus hosts in the ring network connected via RS485 and storing the routing table;
[0032] The instruction output module is responsible for determining the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends the query instruction to the first-order host according to the order of the routing table, the token is released to enter the monitoring data receiving state;
[0033] The token rotation module is responsible for sending the collected data to the preset host after the first-priority host receives the query instruction, and when the first-priority host sends the query instruction to the second-priority host, releasing the token to rotate to the second-priority host. After receiving the query instruction, the second-priority host sends the collected data to the preset host, and circulates and rotates the token in sequence according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host.
[0034] Other features and advantages will be described in the following description, and partly become apparent from the description, or understood by practicing the invention. The purpose and other advantages of the invention are realized and obtained by the structures particularly pointed out in the description and the drawings.
[0035] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other features and advantages of the present invention will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings.
[0037] Figure 1 It is a flow chart of a communication method of the Internet of Things based on token ring networking;
[0038] Figure 2 It is a framework diagram of an Internet of Things communication system based on token ring networking; DETAILED DESCRIPTION
[0039] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0040] S485 port: RS-485 is developed based on RS-422, so it has many similar electrical regulations with RS-422, such as balanced transmission and the need to connect terminal resistors on the transmission line. RS-485 uses a two-wire connection method, and up to 32 devices can be connected to the bus.
[0041] Half-duplex: Half-duplex transmission means that data can be transmitted in both directions of a signal carrier, but not at the same time.
[0042] Token: A token is a master device that has the right to send, usually the master device.
[0043] Token Ring: Token Ring is a network technology theory proposed by IBM in the early 1980s. It completes data exchange through point-to-point communication between adjacent nodes.
[0044] Master: The master has the token and can send commands.
[0045] Slave: The slave does not have token rights and cannot send commands, but can only receive commands.
[0046] Communication medium (communication connection method): The communication medium uses shielded twisted pair cable, that is, a two-core cable with a shielding layer.
[0047] Differential signal: Differential signal is a typical differential communication method. Logical "1" is represented by a voltage difference of +(0.2~6)V between the two lines, and logical "0" is represented by a voltage difference of -(0.2~6)V between the two lines.
[0048] bps: bps is the abbreviation for bits per second and is often used to indicate the transfer rate of serial bus devices.
[0049] Bps: Bps is the abbreviation of bytes per second, which is usually used to indicate the transfer rate of parallel bus devices.
[0050] Kbps: Kbps is the abbreviation of kilobits per second, also known as kilobit rate, which is used to indicate the transmission rate of digital signals, that is, how many thousands of bits of information are transmitted per second (k means thousand, and kb means thousand bits).
[0051] Modbus protocol: Modbus protocol is a master / slave architecture protocol. In the Modbus protocol, only one node is the master node, and the other nodes that use the protocol for communication are slave nodes. Each slave device has a unique address. Generally, there can be up to 32 devices (1 master device + 31 slave devices) running under the Modbus protocol using the RS485 bus. Depending on the different RS485 integrated chips, up to 256 devices can be supported.
[0052] Existing technical problems:
[0053] The existing 485+Modbus solution has some defects, the main problem of which is that each data communication can only be carried out through a single channel. The host sends instructions to the slave, and then the slave returns data. The host then sends instructions to slaves with other addresses and waits for the return data. This one-to-one timing results in only one-way transmission for each communication. If the slave has not sent all the data, the host can no longer send instructions. In addition, if the slave fails and continues to send data, the entire 485 bus will be locked, causing the entire Modbus network to be paralyzed. This problem of bus timing paralysis has always plagued developers using 485+Modbus. Since the host cannot determine whether the slave data has been sent, the following methods are usually used to solve it:
[0054] 1.1. Fixed-length message: Each message contains only 6 fixed characters. Once the host receives 6 characters, it determines that the data reception is complete.
[0055] 1.2. Set a fixed waiting time: According to the estimated time required for messages of different lengths, wait for the corresponding time through programming before sending the command.
[0056] However, both methods have some defects. The first method cannot unify the command characters when connecting to different devices. The second method will cause delay waste of transceiver efficiency, and if the data of the slave is large, it will cause the bus to be occupied and locked, and the host cannot send commands, thus causing the above risks.
[0057] Once a command collision occurs and the bus is locked, the host program will exit with an error or the host polling timing will be disordered, resulting in incomplete data collection and other risks. The root cause of these problems is that it is impossible to achieve accurate master-slave communication duration adaptation through half-duplex.
[0058] 2. Does not support multi-master and multi-slave networking
[0059] In the existing 485+Modbus protocol networking, only one master and multiple slaves can be used for communication. Before networking, the master-slave relationship must be determined, and the slave address needs to be set in the host. This is done to avoid bus lock due to timing confusion. Each time the host communicates, it will send a request instruction one by one, and the slave will respond and return data after receiving the instruction. However, this protocol does not support mutual communication between multiple hosts and multiple slaves, which will bring great pressure to the host, and different hosts cannot be used to handle different services in one bus.
[0060] 3. Does not support failover and automatic master-slave switching
[0061] The one-master-multiple-slave networking mode based on the existing 485+modbus protocol has a serious problem: if the host fails and cannot send instructions, the entire 485 network will be paralyzed and all slaves will be unable to send or receive data.
[0062] When any slave fails, the master will keep requesting data and waiting for communication, which may cause errors, request command bus occupancy too long, etc. Even if the slave is programmed to handle exceptions, the faulty machine cannot escape the fault handling caused by the request list.
[0063] 4. Does not support multi-layer ring network and cross-network communication
[0064] Based on the current 485+modbus protocol, one master and multiple slaves networking mode and address bit communication structure, only polling network communication can be performed by the host according to the address bit. However, this mode cannot achieve subnet construction and cross-segment communication because the identities of the host and slave cannot be switched. The slave cannot communicate across network segments by sending instructions. Therefore, this single-layer networking structure has great limitations.
[0065] 5. The number of networking devices is limited to 256.
[0066] Based on the existing 485+modus protocol and the 0-255 address bit communication limitation, the maximum number of devices in the network cannot exceed 255.
[0067] Example 1
[0068] To solve the above problems, according to one aspect of the present invention, Figure 1 As shown, a method for Internet of Things communication based on token ring networking is provided, which is characterized by specifically including:
[0069] Based on the preset host, the entire bus host connected via RS485 is scanned, and the bus host whose address bit is scanned is returned to the preset host, and a routing table is established according to the scanning order of the address bit, and all the bus hosts in the ring network connected via RS485 are synchronized and the routing table is stored;
[0070] As the initial host, the preset host is the basic link for network startup. Each ITRB ring network must have a starting machine. The main function of the preset host is to initialize and scan the RS485 network, obtain the address information of the entire network, complete the construction of the routing table, and achieve the goal of automated networking.
[0071] Table 1 ITRB Networking - Routing Table
[0072] Sequence address state 0 0x01 00 1 0x02 01 2 0x03 02 3 0x04 02 4 0x05 03
[0073] "00" represents the preset host, whose functions include data collection, networking and host sequence routing table establishment. It sends the start communication protocol, starts the token rotation, and is responsible for receiving data from the "data acquisition machine" (02 / 03). When the routing table finds the "00" machine in turn, it will send a command. If there is no command, it will send a request command to the next host according to the routing table, and the cycle will continue. (The current network is referred to as: main network 01)
[0074] After the network is fully established, the routing table ranking is broadcast through the bus, and all hosts will synchronize the routing table and save it locally.
[0075] The host sends a start command to the first host in the routing table to start collection, and the token ring network starts the cycle.
[0076] It should be noted that the preset host is determined according to the starting machine in the bus host connected to the RS485, and is responsible for generating query instructions and receiving collected data from the bus host.
[0077] It can be understood that the routing table consists of sequence, address bits and status.
[0078] Determine the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends a query instruction to the first-order host according to the order of the routing table, release the token and enter the monitoring data receiving state;
[0079] Based on the fact that the first-priority host sends the collected data to the preset host after receiving the query instruction, and when the first-priority host sends the query instruction to the second-priority host, the token is released and rotated to the second-priority host, and the second-priority host sends the collected data to the preset host after receiving the query instruction, and circulates and rotates the token in sequence according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host.
[0080] It should be noted that when the token rotates to the preset host, the current time is used as the instruction window period, and when in the instruction window period, the preset host sends a communication instruction to the first-priority host and rotates the token again.
[0081] Specifically, the communication instructions include exiting networking, synchronizing routing tables, monitoring and modifying routing tables, and starting a ring network.
[0082] It can be understood that the preset host includes at least one backup preset host, and during the instruction window period, the preset host and the backup preset host actively monitor each other's issuance of the communication instruction, and determine whether the preset host is offline based on the issuance of the communication instruction.
[0083] "01" represents the data collector, which is the backup machine of "00". When the routing table finds "01", it will send a request command to the next host according to the routing table and listen to the token rotation command of "00". If "00" does not issue a command within 1 second, "01" will take over the work of the data collector, update the address bit of the data collector to "01" in the routing table, and forward the next token rotation command in sequence. This realizes the function of the backup machine taking over data collection when the host is abnormal. When "00" responds to the token rotation command, the fault recovery is completed by synchronously updating the routing table, and "01" enters the backup machine instruction forwarding heartbeat silence.
[0084] "02" represents the data collection machine. After receiving the instruction from the upper computer according to the order of the routing table, it collects data and sends it to the current data collection machine, then obtains the token, and sends the request instruction to the next host according to the routing table. After the next host obtains the instruction, it collects data and sends it to the data collection machine, then obtains the token again, and sends the request instruction to the next host according to the routing table, and so on.
[0085] "03" represents the data collection machine (gateway machine), which has the same function as "02", but it has two processes that can independently run a token ring ITRB network (temporarily called: subnet 1), and send the collected data of subnet 1 to the data collection machine through the current network. At the same time, "03" machine functions as the data collection machine of the main network 01 and the data collection machine of subnet 1, and completes the data gateway exchange.
[0086] "04" represents a faulty machine, which is identified as a faulty host by the "00 / 01" machine through monitoring the bus. The faulty machine will be marked in the routing table (change the code) and then synchronized. The faulty machine will no longer participate in the rotation of the token ring, and the "00 / 01" machine will receive the token and then wake up with a command. If there is no response, it will continue to skip until the faulty machine recovers and returns to the routing table.
[0087] Furthermore, when the preset host is offline, the standby preset host that is not offline is replaced by a new preset host, and the communication instruction is generated and issued through the new preset host.
[0088] In one possible embodiment, the specific steps of replacing the backup preset host with a new preset host are:
[0089] The standby preset host is in the routing table by default for token ring rotation, and is always listening to the heartbeat command of the preset host. If the preset host does not send a heartbeat when it rotates, the standby preset host will seize the token, create a command window, send a command to change the host address bit of the collection end, and synchronize the routing table at the same time. At this time, all data collection ends will start to send the collected data to the standby preset host to complete the failover of the data collection end;
[0090] Specifically, when the backup preset host serves as the host, it will continue to monitor the heartbeat of the preset host. If the preset host is started, the heartbeat will be restored. When the backup preset host rotates to the token ownership, it will restore the host collection end sovereignty of the preset host through the command window, complete the master-slave recovery, and the backup preset host enters the silent listening state.
[0091] In one possible embodiment, the number of the backup preset hosts is dynamically evaluated based on the historical heartbeat monitoring data of the preset hosts and the number of bus hosts connected via RS485, wherein the specific steps for determining the number of the backup preset hosts are:
[0092] S11 obtains the number of bus hosts connected via RS485, and determines the recommended number of the backup preset hosts based on the number of bus hosts, determines the number of disappearances of the historical heartbeat instructions of the preset hosts based on the historical heartbeat monitoring data of the preset hosts, and determines whether the running state of the preset hosts is stable in combination with the monitoring time of the backup preset hosts, if yes, proceeds to the next step, if not, proceeds to step S14;
[0093] S12 determines the number of times the historical heartbeat instructions of the preset host disappear within a preset unit time based on the historical heartbeat monitoring data of the preset host, and uses it as the unit disappearance number, and judges whether the unit disappearance number meets the requirement, if so, proceeds to the next step, if not, proceeds to step S14;
[0094] S13 determines the interval durations between different near disappearance times of the historical heartbeat instructions of the preset host through the historical heartbeat monitoring data of the preset host, and determines whether the running state of the preset host is stable based on the disappearance times whose interval duration is less than the preset duration, and if so, uses the recommended number of the backup preset hosts as the number of the backup preset hosts, and if not, proceeds to the next step;
[0095] S14 obtains the average value of the interval durations between different adjacent disappearance times of the historical heartbeat instructions of the preset host and the number of disappearance times with an interval duration less than the preset duration, and evaluates the operational reliability of the preset host in combination with the number of disappearances of the preset host within different preset unit time lengths and the number of disappearances of the historical heartbeat instructions, obtains the monitoring time of the backup preset host, and corrects the recommended number of the backup preset hosts in combination with the operational reliability of the preset host to obtain the number of the backup preset hosts.
[0096] It should be noted that the preset host supports nested ring networking. Each ring network uses a separate set of routing tables, and gateway data is exchanged through the bus host. When the bus host exchanges gateway data, the bus host is used as the preset host, and each bus host includes a backup preset host.
[0097] The "03" machine (i.e., bus host) can simultaneously act as a data acquisition machine for the upper network and a data collection machine for the lower network, and send the lower network networking data to the upper data collection machine through the token rotation window of the routing table, completing the work of cross-network data exchange between the upper and lower networks. The "03" host can simultaneously cross multiple subnets based on the host performance and the capabilities of the 485 bus (the subnet 485 bus must be independent and isolated, and cannot be on the same bus), and the "03" host can continue to exist within the subnet to collect data across network segments.
[0098] Compared with other existing serial port networking protocols, the present invention has the following beneficial effects:
[0099] Table 2 ITRB Token Ring Bus Protocol Comparison Table
[0100] project ITRB Token Ring Bus Modbus Powerbus Can M_bus Communication distance 1200M 1200M 3000M 1000M 1000M Gateway Relay Self-support / network Switch cable Switch cable Switch cable Switch cable Communication level Differential Voltage Differential Voltage Lower voltage and upper current Differential Voltage Lower voltage and upper current Bus voltage 5V 5V 48V 1.5-3.5 35V Wiring method 2-wire shielding 2-wire shielding 2-wire power supply 2-wire shielding 2-wire power supply Wiring method Multi-layer series Single layer series Any branch Hybrid topology Any branch Load Capacity 65025 32-256 512 128 256 Transfer rate 115200 115200 9600 115200 9600 Timing Control Automatic Timing Host computer control Host computer control Idle Arbitration Host computer control Bus locked Does not exist exist exist exist exist Host computer mode Not fixed fixed fixed Not fixed fixed Active / standby redundancy Multiple active and multiple standby Not supported Not supported support Not supported Ring network nesting support Not supported Not supported Not supported Not supported Ad Hoc Network support Not supported Not supported Not supported Not supported Network controller Software Control Software Control complex Software Control Specialized modules
[0101] Example 2
[0102] On the other hand, Figure 2 As shown, the present invention provides an Internet of Things communication system based on token ring networking, adopting the above-mentioned Internet of Things communication method based on token ring networking, which is characterized by specifically including:
[0103] Routing table generation module, instruction output module, token rotation module;
[0104] The routing table generation module is responsible for scanning the entire bus host connected via RS485 based on the preset host, returning the bus host whose address bit is scanned to the preset host, and establishing a routing table according to the scanning order of the address bit, synchronizing all the bus hosts in the ring network connected via RS485 and storing the routing table;
[0105] The instruction output module is responsible for determining the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends the query instruction to the first-order host according to the order of the routing table, the token is released to enter the monitoring data receiving state;
[0106] The token rotation module is responsible for sending the collected data to the preset host after the first-priority host receives the query instruction, and when the first-priority host sends the query instruction to the second-priority host, releasing the token to rotate to the second-priority host. After receiving the query instruction, the second-priority host sends the collected data to the preset host, and circulates and rotates the token in sequence according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host.
[0107] Based on the above embodiments, the present application achieves the following beneficial effects:
[0108] By constructing a communication method based on the RS485 protocol bus, the compatibility of RS485 protocol equipment in the industrial field is achieved. Based on the RS485 wiring and networking mode, by controlling the data transmission mode of the 2-wire differential voltage, according to the order of the networking routing table, each host in the network obtains a token (obtaining a token means having the right to issue instructions, and without a token, it can only receive data) instruction window through token rotation, keeping the ITRB bus token instruction always in unique occupation, and completely solving the bus locking phenomenon caused by timing tokens (the bus transmission and reception are both single-channel. If the bus host sends instructions, other hosts cannot receive data. If the host is receiving, other hosts cannot send instructions. Therefore, if any machine timing collides, it will cause bus conflict and lock).
[0109] Under the premise of keeping the timing conflict free, every device connected to the protocol has a say, which will not cause a certain device to occupy the bus and other devices to be unable to communicate. Each device in the routing table has a window period for sending instructions, and can also better judge whether the data collection segment data has been sent without delay waiting. Compared with other protocols, it has better stability, higher efficiency and more balanced timing control.
[0110] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0111] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0112] The above description is only one or more embodiments of this specification and is not intended to limit this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included in the scope of the claims of this specification.
Claims
1. A communication method for the Internet of Things based on token ring networking, characterized in that: Specifically include: Scan the entire bus host connected via RS485 based on the preset host, and return the bus host with the scanned address bit to the preset host, and establish a routing table according to the scanning order of the address bit, synchronize all the bus hosts in the ring network connected via RS485 and store the routing table; Determine the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends a query instruction to the first-order host according to the order of the routing table, release the token and enter the monitoring data receiving state; Based on the first-priority host sending the collected data to the preset host after receiving the query instruction, and when the first-priority host sends the query instruction to the second-priority host, the token is released and rotated to the second-priority host, and the second-priority host sends the collected data to the preset host after receiving the query instruction, and circulates and rotates the token in turn according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host; The preset host has more than one backup preset host, and during the command window period, the preset host and the backup preset host actively monitor each other's issuance of communication commands, and determine whether the preset host is offline based on the issuance of communication commands; When the preset host is offline, a standby preset host that is not offline is replaced with a new preset host, and the communication instruction is generated and issued through the new preset host; The specific steps of replacing the standby preset host with a new preset host are: The standby preset host is in the routing table by default for token ring rotation, and is always listening to the heartbeat command of the preset host. If the preset host does not send a heartbeat when it rotates, the standby preset host will seize the token, create a command window, send a command to change the host address bit of the collection end, and synchronize the routing table at the same time. At this time, all data collection ends will start to send the collected data to the standby preset host to complete the failover of the data collection end; The number of the standby preset hosts is dynamically evaluated according to the historical heartbeat monitoring data of the preset hosts and the number of bus hosts connected via RS485, wherein the specific steps for determining the number of the standby preset hosts are: S11 obtains the number of bus hosts connected via RS485, and determines the recommended number of the backup preset hosts based on the number of bus hosts, determines the number of disappearances of the historical heartbeat instructions of the preset hosts based on the historical heartbeat monitoring data of the preset hosts, and determines whether the running state of the preset hosts is stable in combination with the monitoring time of the backup preset hosts, if yes, proceeds to the next step, if not, proceeds to step S14; S12 determines the number of times the historical heartbeat instructions of the preset host disappear within a preset unit time based on the historical heartbeat monitoring data of the preset host, and uses it as the unit disappearance number, and judges whether the unit disappearance number meets the requirement, if so, proceeds to the next step, if not, proceeds to step S14; S13 determines the interval durations between different near disappearance times of the historical heartbeat instructions of the preset host through the historical heartbeat monitoring data of the preset host, and determines whether the running state of the preset host is stable based on the disappearance times whose interval duration is less than the preset duration, and if so, uses the recommended number of the backup preset hosts as the number of the backup preset hosts, and if not, proceeds to the next step; S14 obtains the average value of the interval durations between different adjacent disappearance times of the historical heartbeat instructions of the preset host and the number of disappearance times with an interval duration less than the preset duration, and evaluates the operational reliability of the preset host in combination with the number of disappearances of the preset host within different preset unit time lengths and the number of disappearances of the historical heartbeat instructions, obtains the monitoring time of the backup preset host, and corrects the recommended number of the backup preset hosts in combination with the operational reliability of the preset host to obtain the number of the backup preset hosts.
2. The Internet of Things communication method based on token ring networking as claimed in claim 1, characterized in that: The preset host is determined according to the starting machine in the bus host connected by RS485, and is responsible for generating query instructions and receiving collected data from the bus host.
3. The Internet of Things communication method based on token ring networking as claimed in claim 1, characterized in that: When the token rotates to the preset host, the current time is used as the instruction window period, and when in the instruction window period, the preset host sends a communication instruction to the first-priority host and rotates the token again.
4. The Internet of Things communication method based on token ring networking as claimed in claim 1, characterized in that: When the backup preset host becomes the host, it will continue to monitor the heartbeat of the preset host. If the preset host is started, the heartbeat will be restored. When the backup preset host rotates to the token ownership, it will restore the host collection end sovereignty of the preset host through the command window, complete the master-slave recovery, and the backup preset host will enter the silent listening state.
5. The Internet of Things communication method based on token ring networking as claimed in claim 1, characterized in that: The preset host supports nested ring network networking. Each ring network uses a separate set of routing tables. Gateway data exchange is performed through the bus host. When the bus host performs gateway data exchange, the bus host is used as the preset host, and each preset host in the ring network has a backup preset host.
6. An Internet of Things communication system based on token ring networking, using an Internet of Things communication method based on token ring networking according to any one of claims 1 to 5, characterized in that: Specifically include: Routing table generation module, instruction output module, token rotation module; The routing table generation module is responsible for scanning the entire bus host connected via RS485 based on the preset host, returning the bus host whose address bit is scanned to the preset host, and establishing a routing table according to the scanning order of the address bit, synchronizing all the bus hosts in the ring network connected via RS485 and storing the routing table; The instruction output module is responsible for determining the first-order host and the second-order host according to the order of the address bits of the routing table, and after the preset host sends the query instruction to the first-order host according to the order of the routing table, the token is released to enter the monitoring data receiving state; The token rotation module is responsible for sending the collected data to the preset host after the first-priority host receives the query instruction, and when the first-priority host sends the query instruction to the second-priority host, releasing the token to rotate to the second-priority host. After receiving the query instruction, the second-priority host sends the collected data to the preset host, and circulates and rotates the token in sequence according to the address bit of the bus host, and sends the collected data of the bus host with the query instruction to the preset host.
Citation Information
Patent Citations
A method and apparatus for intelligent expansion of 485 bus based on Modbus communication protocol
CN108733604B
Multi-master 485 routing communication method and system based on bidirectional looped network
CN110519145A
EtherCAT communication system and method based on cold redundancy mechanism
CN110830276A
Address allocation method and system for elevator hall outside calling landing devices
CN113800341A