Slave address automatic allocation method based on switching circuit and communication system

By adopting the automatic slave address allocation method based on switching circuit in the serial communication system, the problem of low efficiency and poor accuracy of slave address allocation in the prior art is solved, efficient and accurate automatic address allocation is realized, and the scalability and reliability of the system are improved.

CN119814731APending Publication Date: 2025-04-11TIANDI CHANGZHOU AUTOMATION +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510024971.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In serial communication systems, the prior art is difficult to achieve automatic, accurate and efficient allocation of slave addresses, resulting in low manual configuration efficiency, error-prone, and poor system flexibility and maintainability.

Method used

The slave address automatic allocation method based on the switch circuit is adopted, and the slave address is automatically calculated and allocated to automatically allocate the slave address through the host.

Benefits of technology

Automatic allocation of slave addresses is realized, manual intervention is reduced, address allocation efficiency, accuracy and system scalability are improved, duplicate address problems are avoided, and system costs are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814731A_ABST
    Figure CN119814731A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of communication, in particular to a slave address automatic allocation method based on a switching circuit and a communication system, the communication system comprises a host and a plurality of slaves, the host sends a bus turn-off command, the slaves control switches to turn off a post-stage bus and uniformly delay, then timing is started to monitor the bus level, and the slave addresses are automatically allocated. And when the bus is monitored to be at a low level, reading a timer value, turning off the timer, obtaining a local address according to an algorithm, turning on a subordinate bus after time delay, after waiting for a period of time, sequentially polling the slaves from the address 1, and if the slave at the address n does not respond, determining that the number of the slaves is n-1. According to the method, manual address setting of equipment one by one is not needed any more, time and labor are saved, meanwhile, the problems of repeated addresses and the like are reduced, the reliability of the system is improved, additional cables are not needed, and wiring work and system cost are not needed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of communication technology, and in particular relates to a method and a communication system for automatically allocating slave addresses based on a switch circuit in a serial communication environment. Background Art

[0002] In a serial communication system, there is usually a master and multiple slaves. The correct allocation of slave addresses is crucial for accurate data transmission and stable operation of the system.

[0003] Traditional slave address allocation methods often require manual pre-setting or configuration with the help of special programming tools. This method is not only inefficient, but also prone to human errors. Especially in large-scale serial communication networks, as the number of slaves increases, the difficulty and error probability of manual configuration increase significantly. In addition, when the system is expanded or the slave device changes, reconfiguring the slave address will consume a lot of time and labor costs, seriously affecting the flexibility and maintainability of the system. Therefore, there is an urgent need for a method that can automatically, efficiently and accurately allocate slave addresses to improve the performance and reliability of serial communication systems. Summary of the invention

[0004] The present invention provides a switch circuit-based slave address automatic allocation method and communication system, which realize automatic allocation of slave addresses, reduce manual intervention, and improve the efficiency and accuracy of address allocation and the scalability of the system.

[0005] The present invention provides a communication system, including a host and multiple slaves, the host and the slaves are connected by wired communication, for example, using communication protocols such as RS485 bus and CAN bus for data transmission, each slave includes an MCU and a switch circuit connected to the MCU.

[0006] The present invention also provides a method for automatically allocating slave addresses based on a switch circuit, comprising the following steps:

[0007] (1) The host sends a bus shutdown command, which contains the time slice T slot and delay time T delay And other parameters;

[0008] (2) The slave receives the bus disconnect command from the master, controls the switch to shut down the subsequent bus, and delays T uniformly. delay , then start timing and monitor the bus level. Through circuit design, the bus is disconnected at a high level and the bus is connected at a low level;

[0009] (3) When the bus is detected to be at a low level, the timer value T is read elapsed , turn off the timer;

[0010] (4) Based on Get the site address;

[0011] (5) Delay T slot +T delta -T elapsed %T slot Then connect the lower level bus;

[0012] (6) The slave operates according to steps (3) to (5) in sequence;

[0013] (7) The host waits for a period of time T wait After that, the estimated number of slaves is N,T wait >T delta +N*T slot , poll the slaves in sequence starting from address 1;

[0014] (8) If the slave at address n does not respond, it is determined that the number of slaves is n-1.

[0015] The beneficial effects of the present invention are as follows: the present invention no longer requires manual address setting for each device, which saves time and effort while reducing problems such as duplicate addresses and improving system reliability. The present invention also does not require additional cables, and does not increase wiring work and system costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic diagram of the structure of the communication system of the present invention;

[0017] Figure 2 The figure is a flow chart of the automatic slave address allocation method based on the switch circuit of the present invention. DETAILED DESCRIPTION

[0018] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0019] like Figure 1 A communication system shown includes a host and multiple slaves. The host and the slaves transmit data through communication protocols such as RS485 bus and CAN bus. Each slave includes an MCU and a switching circuit connected to the MCU. The switching circuit can control the on and off of the next-level bus through the MCU, and the slave has the function of monitoring the bus level.

[0020] The figure shows a way of switching the circuit, that is, the switching circuit is placed on Tx. In actual implementation, it can also be placed on the Rx line or on the power line. If it is placed on the power line, the slave should add a battery power supply or use capacitor energy storage.

[0021] The switch circuit of the present invention is on the bus, and no additional cables are required, which is very advantageous in long-distance communication. In addition, the present invention only requires the host to send a command once, and the slave obtains the time of state change according to IO monitoring, and then calculates the address according to the algorithm, without the need for back-and-forth communication, and it only takes about 1 second to allocate the addresses of 100 slaves.

[0022] Based on the above communication system, the present invention also provides a method for automatically allocating slave addresses based on a switch circuit, Figure 2 As shown, the following steps are included:

[0023] (1) The host sends a bus shutdown command, which contains the time slice T slot and delay time T delay And other parameters;

[0024] (2) The slave receives the bus disconnect command from the master, controls the switch to shut down the subsequent bus, and delays T uniformly. delay , then start timing and monitor the bus level. Through circuit design, the bus is disconnected at a high level and the bus is connected at a low level;

[0025] (3) When the bus is detected to be at a low level, the timer value T is read elapsed , turn off the timer;

[0026] (4) Based on The slave obtains the local station address;

[0027] (5) Delay T slot +T delta -T elapsed %T slot Then connect the lower level bus;

[0028] (6) The slave operates according to steps (3) to (5) in sequence;

[0029] (7) The host waits for a period of time T wait After that, the estimated number of slaves is N,T wai t>T delta +N*T slot , poll the slaves in sequence starting from address 1;

[0030] (8) If the slave at address n does not respond, it is determined that the number of slaves is n-1.

[0031] The above method realizes the automatic allocation of slave addresses without adding connection cables, and also avoids the problems of inefficiency and unreliability of manual address setting.

[0032] For example, in an actual application scenario, the host and the slave are connected via an RS485 bus, and the switch circuit is placed on the A line of the RS485 bus. By default, all switches are turned on. After the system is powered on, the host broadcasts a shutdown bus command via the RS485 bus. The command contains the time slice T slot and delay time T delta Parameters, T slot Take 10ms, T delay Take 100ms. After sending the command, the host delays 50ms to control the A line to a low level through IO. After receiving the host's bus shutdown command, all slaves control the switch to shut down the subsequent bus and delay T uniformly. delay That is, 100ms, then start timing and monitor the bus A level; when the bus A is detected to be low, read the timer value T elapsed , turn off the timer, according to The slave obtains the local address. Since the first slave is directly connected to the master, T elapsed is 0, then addr is 1; the slave delays T after obtaining the address slot +T delta -T elapsed %T slot Then connect the lower bus, T delta If 4ms is taken, the first slave will delay 14ms to connect to the lower bus; when the second slave receives the falling edge of IO, T elapsed is 14ms, then 2, then delay T slot +T delta -T elapsed %T slot That is, 10ms, the lower bus is connected; when the third slave receives the falling edge of IO, T elapsed is 24ms, then is 3, then delay T slot +T delta -T elapsed %T slot That is, 10ms, the lower-level bus is connected, and the subsequent slaves operate in sequence to obtain addresses; after waiting for 1s, the host polls the slaves in sequence starting from address 1, and the slave polled to its own address will respond to the host. If the slave with address 51 does not respond, it is determined that the number of slaves is 50.

[0033] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for automatically allocating slave addresses based on a switch circuit, characterized in that: The steps include: (1) The host sends a bus shutdown command, which contains the time slice T slot and delay time T delay parameter; (2) The slave receives the bus disconnect command from the master, controls the switch to shut down the subsequent bus, and uniformly delays T delay , then start timing and monitor the bus level, the bus is disconnected for high level, and the bus is connected for low level; (3) When the bus is detected to be at a low level, the timer value T is read elapsed , turn off the timer; (4) Based on Get the site address; (5) Delay T slot +T delta -T elapsed %T slot Then connect the lower level bus; (6) The subsequent slaves follow steps (3) to (5) in sequence; (7) The host waits for a period of time T wait After that, the estimated number of slaves is N,T wait >T delay +N*T slot , poll the slaves in sequence starting from address 1; (8) If the slave with address n does not respond, it is determined that the number of slaves is n-1.

2. A communication system for the automatic slave address allocation method based on a switch circuit as claimed in claim 1, characterized in that: The system comprises a host and multiple slaves, wherein the host and the slaves are connected via wired communication, and each slave comprises an MCU and a switch circuit connected to the MCU.

3. The communication system according to claim 2, characterized in that The host and the slave use RS485 bus and CAN bus communication protocols for data transmission.