A system and method for allocating addresses to slave devices via RS-485 bus
By forming slaves into an array and connecting them with relays, the allocation process of slave devices in the RS-485 bus system is simplified, and the problem of complex and low efficiency in the existing technology is solved, and efficient and low-cost address is achieved. Distribution, suitable for a wide range of RS-485 systems.
Patent Information
- Application Number
- CN202111507595.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-12-10
AI Technical Summary
The existing RS-485 bus system has problems such as large workload, low coding efficiency, and error-prone operation when setting the slave address. The added branch lines and arbitration lines complicate the system, increase costs, and in the event of failure. Problems that may cause inconsistent address.
By forming a M row and N column array, each row and each column of slave bus A and bus B are all connected, and connected to the bus A and bus B of the host through a relay, and are allocated in turn using the address allocation software Address simplifies the address writing process.
It realizes simple, fast and low-cost allocation of slave device addresses, reduces operational strength, is suitable for all systems with RS-485 bus, and avoids the problem of address inconsistency.
Smart Images

Figure CN114257468B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of RS-485 bus control, and in particular to a system and method for implementing address allocation to slave devices via RS-485 bus. Background Art
[0002] At present, the measurement and control system composed of RS-485 bus generally adopts the master-slave communication mode, that is, a host (generally called the upper computer) and several (no more than 254) slaves (generally called the lower computers) communicate through the RS-485 bus. The master-slave communication mode is always initiated by the host. After receiving the command, the slave obtains the bus control right and sends information to the bus. After the transmission is completed, the bus control right is returned to the host. When the host communicates with each slave through the RS-485 bus, it is necessary to distinguish each slave device through the device identification. The simplest way is to use the address to distinguish each slave device.
[0003] Therefore, when all slave devices are connected to the RS-485 bus, they need to be assigned communication addresses in advance and ensure that the addresses of all slave devices are not repeated, otherwise the entire network communication will fail.
[0004] So far, there are two main methods for setting addresses for slave devices. One is to install a multi-bit DIP switch on the device, and the device determines its own address by reading the code of the DIP switch. This method has a large workload when setting addresses for a large number of slaves, and manual operation is prone to errors. Another method is to connect the host computer to the slave device through the RS-485 bus and use special address writing software to write the address into the slave device. However, this method can only be written manually one by one, which is more troublesome in actual application, the efficiency of address burning is low, and the workload of manual operation is large.
[0005] In order to solve the above problems, technicians have proposed a variety of methods to improve the existing technology.
[0006] Patent 1, with publication number CN102331762A, directly connects a host to one of multiple slaves, and a relay is set on the branch line between the host and each slave. The host can send instructions through the RS-485 bus to make the slave control its own relay to open and close. Through the relay connected in series on each slave branch line, the host can use the existing RS-485 bus to automatically write the address to the slave without the need to equip the slave with a separate address line.
[0007] Patent 2, with publication number CN104516851A, adds an arbitration line based on the original RS-485 network connection, selects the slave device through the arbitration line and then assigns an address to the slave device.
[0008] Patent three, publication number CN111654557 A discloses a method for automatically allocating RS-485 addresses, which does not require the allocation of RS-485 communication addresses of access devices during initial networking. When access devices are subsequently maintained and replaced, there is no need to know the RS-485 communication addresses of the replaced devices and set the RS-485 communication addresses of the new devices.
[0009] However, there are still many problems with the above patents. For example, the method adopted in Patent 1 adds an additional branch line and a relay to each slave, making the system more complicated and increasing the cost of the system; the method adopted in Patent 2 adds an additional arbitration line to each slave, which also increases the complexity and cost of the system; in Patent 3, when a slave fails and needs to reallocate the address, the addresses allocated twice are likely to be inconsistent, which is not allowed in some applications.
[0010] Therefore, the present invention aims to provide a system that can solve the defects of the existing RS-485 bus communication address setting. Summary of the invention
[0011] The object of the present invention is to provide a system and method for allocating addresses to slave devices via an RS-485 bus, so as to solve the technical problem of defects in setting communication addresses of the RS-485 bus in the prior art.
[0012] The present invention provides a system and method for implementing address allocation to slave devices through RS-485 bus, comprising a host and multiple slaves, wherein the host and the multiple slaves all comprise RS-485 interfaces and communicate through the RS-485 bus, and the multiple slaves form an array of M rows and N columns, and the buses A in the RS-485 buses of the N slaves in each row are connected to each other, and the slaves in each row are connected to the bus A of the RS-485 bus of the host through a pair of open points of a relay, and the buses B in the RS-485 buses of the M slaves in each column are connected to each other, and the slaves in each column are connected to the bus B of the RS-485 bus of the host through a pair of open points of a relay, and the addresses are allocated in sequence according to the positions of the selected slaves in the rows and columns in the array of M rows and N columns.
[0013] Furthermore, the host is provided with address allocation software, through which the host allocates addresses to all slaves.
[0014] A method for allocating addresses to slave devices via an RS-485 bus comprises the following steps:
[0015] Sp1: Open the address allocation software on the host;
[0016] Sp2: After the system is powered on, select a slave from the slave array of M rows and N columns displayed in the interface of the address allocation software, and enter the address to be written to this slave;
[0017] Sp3: The host controls the relays on the corresponding rows and columns to be attracted according to the horizontal and vertical positions of the selected slave in the slave array, and the bus A and bus B of the host are connected to the bus A and bus B of the only slave respectively, and the host sends the address to be written to the selected slave through the RS-485 bus;
[0018] Sp4: Select multiple slaves in the slave array on the interface of the address allocation software according to the order, and input the address to be written to each slave in turn. The host writes these addresses into the corresponding slaves in turn through the method of Sp3.
[0019] Compared with the prior art, the beneficial effects of the present invention are:
[0020] First, under the prior art, when a slave is connected to the RS-485 bus, it is necessary to allocate a communication address in advance, and ensure that the addresses of all slaves are not repeated, otherwise the entire network communication will fail. When allocating addresses to slaves, there are problems such as large workload, low coding efficiency, and easy operation errors. Therefore, the present invention proposes a system that can solve the defects of the existing RS-485 bus communication address setting, which organizes multiple slaves into an M-row and N-column slave array, and the buses A of the slaves in each row are all connected together and connected to the bus A of the host through a relay, and the buses B of the slaves in each column are all connected together and connected to the bus B of the host through a relay. The address can be written into the slave by only closing the relays of the row and column where the slave to be written is located, thereby realizing the sequential writing of the address of each slave. Therefore, the present invention can conveniently realize the writing of the addresses of multiple slave devices, with simple operation, high efficiency, reduced work intensity and low cost.
[0021] Secondly, the address allocation system in the present invention is applicable to all systems with RS-485 bus. It only needs to ensure that both the master device and the slave device include RS-485 interface modules, and the slave device is connected to the master device through the RS-485 bus, and has strong applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A schematic diagram of the connection method between the host and the slave in the present invention;
[0024] Figure 2 It is a flow chart of the present invention.
[0025] Reference numerals:
[0026] 1. Host; 2. Slave; 3. Relay. DETAILED DESCRIPTION
[0027] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments.
[0028] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention.
[0029] Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of the present invention.
[0030] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0031] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances. Specific embodiment 1:
[0033] Combine the following Figure 1As shown, embodiment 1 of the present invention provides a system for implementing address allocation to slave devices through RS-485 bus, including a host 1 and multiple slaves 2, wherein the host and the multiple slaves 2 all include RS-485 interfaces and communicate through the RS-485 bus, characterized in that: the multiple slaves 2 form an array of M rows and N columns, and the buses A in the RS-485 buses of the N slaves 2 in each row are interconnected, and the slaves 2 in each row are connected to the bus A of the RS-485 bus of the host 1 through a pair of open points of a relay 3, and the buses B in the RS-485 buses of the M slaves 2 in each column are interconnected, and the slaves 2 in each column are connected to the bus B of the RS-485 bus of the host 1 through a pair of open points of a relay 3, and the addresses are allocated in sequence according to the positions of the selected slaves 2 in the rows and columns in the M rows and N columns array. Under the prior art, when the slave 2 is connected to the RS-485 bus, it is necessary to allocate a communication address in advance, and ensure that the addresses of all the slaves 2 are not repeated, otherwise the entire network communication will fail. When allocating addresses to the slaves 2, there are problems such as large workload, low coding efficiency, and easy operation errors. Therefore, the present invention proposes a system that can solve the defects of the existing RS-485 bus communication address setting, which forms a slave 2 array of M rows and N columns with multiple slaves 2, and the buses A of the slaves 2 in each row are all connected together and connected to the bus A of the host 1 through a relay 3, and the buses B of the slaves 2 in each column are all connected together and connected to the bus B of the host 1 through a relay 3. The address can be written into the slave 2 by only closing the relay 3 of the row and column where the slave 2 to be written is located, thereby realizing the sequential writing of the address of each slave 2. Therefore, the present invention can conveniently realize the writing of the addresses of multiple slave devices, is simple to operate, has high efficiency, can reduce the work intensity and has low cost, and is suitable for all systems with RS-485 buses.
[0034] Specifically, the host 1 is provided with address allocation software, and the host 1 allocates addresses to all the slaves 2 through the address allocation software. Specific embodiment 2:
[0036] Combination Figure 2 As shown, Embodiment 2 of the present invention provides a method for allocating addresses to slave devices via an RS-485 bus, comprising the following steps:
[0037] Sp1: Open the address allocation software on host 1;
[0038] Sp2: After the system is powered on, select a slave 2 from the slave 2 array of M rows and N columns displayed in the interface of the address allocation software, and enter the address to be written to this slave 2;
[0039] Sp3: The host 1 controls the relays 3 on the corresponding rows and columns to attract according to the horizontal and vertical positions of the selected slave 2 in the array of slaves 2, and the bus A and bus B of the host 1 are connected to the bus A and bus B of the only slave 2 respectively, and the host 1 sends the address to be written to the selected slave 2 through the RS-485 bus;
[0040] Sp4: Select multiple slaves 2 in the slave 2 array on the interface of the address allocation software according to the order, input the address to be written to each slave 2 in turn, and the host 1 writes these addresses into the corresponding slaves 2 in turn through the method of Sp3.
[0041] The address allocation system and method of the present invention can be applied to all systems with RS-485 bus. It only needs to ensure that the master device and the slave device both include RS-485 interface modules, and the slave device is connected to the master device through the RS-485 bus, and has strong applicability.
[0042] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A system for implementing address allocation to slave devices via an RS-485 bus, comprising a host (1) and a plurality of slaves (2), wherein the host and the plurality of slaves (2) both comprise RS-485 interfaces and communicate via the RS-485 bus. Features: A plurality of the slave machines (2) form an array of M rows and N columns, and the buses A in the RS-485 buses of the N slave machines (2) in each row are connected to each other, and the slave machines (2) in each row are connected to the bus A of the RS-485 bus of the host machine (1) through a pair of open points of a relay (3), and the buses B in the RS-485 buses of the M slave machines (2) in each column are connected to each other, and the slave machines (2) in each column are connected to the bus B of the RS-485 bus of the host machine (1) through a pair of open points of a relay (3), and addresses are sequentially allocated according to the positions of the selected slave machines (2) in the rows and columns in the array of M rows and N columns, and the host machine (1) has an address. Address allocation software is provided. By opening the address allocation software, the host (1) allocates addresses to all slaves (2). A slave (2) is selected from the array of slaves (2) of M rows and N columns displayed in the interface of the address allocation software, and an address to be written to the slave (2) is input. The host (1) controls the relays (3) on the corresponding rows and columns to be attracted according to the horizontal and vertical positions of the selected slave (2) in the array of slaves (2). The bus A and bus B of the host (1) are respectively connected to the bus A and bus B of the only slave (2). The host (1) sends the address to be written to the selected slave (2) via the RS-485 bus.
2. A method for allocating addresses to slave devices via an RS-485 bus, the method being used in the implementation system of claim 1, Features: The following steps are involved: Sp1: Open the address allocation software on the host (1); Sp2: After the system is powered on, select a slave (2) from the array of slaves (2) with M rows and N columns displayed in the interface of the address allocation software, and input the address to be written to the slave (2); Sp3: The host (1) controls the relays (3) on the corresponding rows and columns to be attracted according to the horizontal and vertical positions of the selected slave (2) in the array of the slaves (2), and the bus A and bus B of the host (1) are connected to the bus A and bus B of the only slave (2) respectively, and the host (1) sends the address to be written to the selected slave (2) via the RS-485 bus; Sp4: Select multiple slaves (2) in the slave (2) array on the interface of the address allocation software according to the order, input the address to be written to each slave (2) in turn, and the host (1) writes these addresses into the corresponding slaves (2) in turn through the method of Sp3.
