Multi-slave automatic sequential coding system and method based on chain connection
The automatic sequential coding system for multiple slave devices connected in a chain uses current detection and analog-to-digital converters to generate slave address codes, solving the problem of cumbersome address code management in existing technologies. This enables plug-and-play slave devices and simplifies production, installation, and maintenance processes, reducing costs and improving reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FOSHAN SMARTSUN AUTO LIGHTING TECHNOIOGY CO LTD
- Filing Date
- 2026-01-30
- Publication Date
- 2026-04-28
AI Technical Summary
In existing technologies, address code management in multi-slave single-master systems is cumbersome and costly, requires manual intervention, and cannot achieve plug-and-play functionality for slave devices or simplify production, installation, and maintenance processes.
A chain-connected multi-slave automatic sequential encoding system is adopted. A current detection module and an analog-to-digital converter are used to generate a unique address code for the slave. The master automatically allocates and stores the address code in the slave's memory, thereby realizing the automatic allocation and sorting of the address code.
It enables plug-and-play functionality for slave devices, reduces production and maintenance costs, avoids human error, improves system reliability, and simplifies management processes.
Smart Images

Figure CN121940403A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a multi-slave automatic sequential encoding system and method based on chain connection. Background Technology
[0002] In a chained network system with multiple slave devices and a single master device, the master device needs to communicate precisely point-to-point with each slave device. Therefore, each slave device must have a unique address code (ID). Common methods for ensuring address code uniqueness in existing technologies include: 1. Pre-writing during production: During slave device production, a unique address code is written into its non-volatile memory (such as the Flash or EEPROM of an MCU). While this method achieves consistency in mass production, it incurs significant management costs, including address code planning, allocation, recording, and preventing duplication. Especially during field installation or after-sales maintenance, if a single slave device needs to be replaced, technicians must manually record the old slave device's address code and pre-write it into the new slave device, or reconfigure the entire slave device list on the master device. This process is cumbersome, error-prone, requires cross-departmental collaboration, and has extremely high management costs. 2. DIP switch or jumper setting: Each slave device is assigned an address via a physical DIP switch. This method also requires manual intervention, increasing the complexity of production and installation, and carries the risk of DIP switch errors, resulting in low reliability.
[0003] Therefore, there is an urgent need in this field for an automatic coding technology that enables slave devices to be "plug and play" without the need for manual intervention in address management, so as to simplify the production, installation and maintenance process. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a multi-slave automatic sequential encoding system and method based on chain connection, which can automatically assign a unique address code to all slaves on the link after the system is powered on, reflecting their physical connection order, completely eliminating the production pre-coding and manual configuration links, and realizing the arbitrary replacement, addition or reduction of slaves.
[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is: an automatic sequential encoding system for multiple slaves based on chain connection, comprising a master and at least two slaves, wherein the master is connected to the first slave, and subsequent slaves are connected in series in a chain manner; Each slave device includes: Current detection module: used to detect the current value flowing through the power bus of this slave device in real time; Analog-to-digital converter (ADC): Connected to the current detection module, used to convert the detected current value into a voltage value; Microcontroller (MCU): Connected to the analog-to-digital converter (ADC) and the communication bus, used to read the voltage value and send it to the host via the communication bus.
[0006] As an improvement, the host includes: Communication control module: used for broadcast and unicast communication with all slave devices; Encoding module: Used to receive voltage values reported by all slave devices, sort them according to their magnitude to determine the physical connection order of each slave device on the link; and then generate a unique sequence address code based on this order. Address allocation module: used to assign the generated sequential address codes to the corresponding slave devices in turn, and instruct the slave devices to store them in their respective memory.
[0007] As an improvement, the host and slave are connected to the same local area network.
[0008] As an improvement, the slave device is connected to a power load.
[0009] As an improvement, the communication bus is an RS-485 bus.
[0010] As an improvement, the current detection module includes the BTS6143D chip.
[0011] The automatic sequential encoding method of the present invention includes the following steps: (1) System connection: The master is connected to the first slave, and the subsequent slaves are connected in series in a chain manner. The current flowing through the power bus of each slave in the chain connection decreases step by step. (2) System power-on initialization: Power on the host and all slave devices; (3) Current value reporting: The host sends a broadcast command to all slaves in the network, requiring all slaves to report the current currently detected by their built-in current detection module; (4) Data collection: The microcontroller (MCU) of each slave device reads the voltage value converted by the current detection module through the analog-to-digital converter (ADC) and sends the value to the host. The host collects the voltage values reported by all slave devices. (5) Sorting and address generation: The host sorts all the collected voltage values. Since the power supply current decreases step by step in the chain connection, the slave device that is closer to the power input point has a larger current and a higher detected voltage value. Therefore, the order of voltage values from high to low corresponds to the physical connection order of the slave devices from near to far. The host generates a set of increasing or decreasing sequential address codes according to this order. (6) Address allocation and storage: The host sends the unique address code assigned to each slave in a determined order; after receiving the address code, the slave stores it in its own memory and uses the address code in this and subsequent power-on communications. (7) Encoding complete: All slave address codes have been assigned and the system enters normal communication mode.
[0012] The beneficial effects of this invention compared to the prior art are: 1. Completely free of manual coding: The slave device does not need to pre-write address codes during the production stage, realizing completely consistent production and inventory preparation of the equipment, which greatly reduces production and material management costs; 2. Plug and play, easy maintenance: During on-site installation or maintenance, slave units can be replaced, added, or removed at will; after the system is powered on again, it can automatically complete the new address assignment of all slave units without any manual recording or configuration, which significantly reduces the cost and time of after-sales technical support; 3. High reliability: The encoding process is completed automatically by the system, avoiding address conflicts or errors caused by human error; 4. Simple principle and low cost: Utilizing existing current detection and ADC circuits, no complex hardware equipment is required, resulting in low cost and easy integration into existing products. Attached Figure Description
[0013] Figure 1 This is a system block diagram.
[0014] Figure 2 This is the flowchart of the host program.
[0015] Figure 3 This is the flowchart for the slave device program. Detailed Implementation
[0016] The present invention will now be further described with reference to the accompanying drawings.
[0017] like Figure 1 As shown, a multi-slave automatic sequential encoding system based on chain connection includes a master unit and at least two slave units. The master unit is connected to the first slave unit, and subsequent slave units are connected in series in a chain-like manner. The master unit and slave units are connected in the same local area network (LAN). The master unit and all slave units are connected in a chain topology via a communication bus (such as an RS-485 bus) and a power bus, with power supplied from one end of the network. Each slave unit in the chain connection is connected to a power load. If each slave device enters a working mode (e.g., if the power load is an LED, then the LED is lit), the current flowing through its respective power bus decreases sequentially.
[0018] Each slave device includes: Current detection module: used to detect the current value flowing through the power bus of this slave device in real time. The current detection module includes the BTS6143D chip. Analog-to-digital converter (ADC): Connected to the current detection module, used to convert the detected current value into a voltage value; Microcontroller (MCU): Connected to the analog-to-digital converter (ADC) and the communication bus, used to read the voltage value and send it to the host via the communication bus.
[0019] The host includes: Communication control module: used for broadcast and unicast communication with all slave devices; Encoding module: Used to receive voltage values reported by all slave devices, sort them according to their magnitude to determine the physical connection order of each slave device on the link; and then generate a unique sequence address code based on this order. Address allocation module: used to assign the generated sequential address codes to the corresponding slave devices in turn, and instruct the slave devices to store them in their respective memory.
[0020] like Figure 2 , 3 As shown, the automatic sequential encoding method of the present invention includes the following steps: (1) System connection: The master is connected to the first slave, and the subsequent slaves are connected in series in a chain manner. The current flowing through the power bus of each slave in the chain connection decreases step by step. (2) System power-on initialization: Power on the host and all slave devices; (3) Current value reporting: The host sends a broadcast command to all slaves in the network, requiring all slaves to report the current currently detected by their built-in current detection module; (4) Data collection: The microcontroller (MCU) of each slave device reads the voltage value converted by the current detection module through the analog-to-digital converter (ADC) and sends the value to the master device. The master device collects the voltage values reported by all slave devices. For example, the current detected by slave device S1 is converted into voltage value V1, the current detected by slave device S2 is converted into voltage value V2, and similarly, the current detected by slave device S3 is converted into voltage value V3, and V1 > V2 > V3 > ... > Vn; (5) Sorting and address generation: The host sorts all the collected voltage values. Since the power supply current decreases step by step in the chain connection, the slave device that is closer to the power input point has a larger current and a higher detected voltage value. Therefore, the order of voltage values from high to low corresponds to the physical connection order of the slave devices from near to far. The host generates a set of increasing or decreasing sequential address codes according to this order, such as 1, 2, 3... (6) Address allocation and storage: The host sends the unique address code assigned to each slave in a determined order; after receiving the address code, the slave stores it in its own memory and uses the address code in this and subsequent power-on communications. (7) Encoding complete: All slave address codes have been assigned and the system enters normal communication mode.
Claims
1. A multi-slave automatic sequential encoding system based on chain connection, comprising a master unit and at least two slave units, wherein the master unit is connected to the first slave unit, and subsequent slave units are connected in series in a chain-like manner; characterized in that: Each slave device includes: Current detection module: used to detect the current value flowing through the power bus of this slave device in real time; Analog-to-digital converter (ADC): Connected to the current detection module, used to convert the detected current value into a voltage value; Microcontroller (MCU): Connected to the analog-to-digital converter (ADC) and the communication bus, used to read the voltage value and send it to the host via the communication bus.
2. The multi-slave automatic sequential encoding system based on chain connection according to claim 1, characterized in that: The host includes: Communication control module: used for broadcast and unicast communication with all slave devices; Encoding module: Used to receive voltage values reported by all slave devices, sort them according to their magnitude to determine the physical connection order of each slave device on the link; and then generate a unique sequence address code based on this order. Address allocation module: used to assign the generated sequential address codes to the corresponding slave devices in turn, and instruct the slave devices to store them in their respective memory.
3. The multi-slave automatic sequential encoding system based on chain connection according to claim 1, characterized in that: The host and slave devices are connected to the same local area network.
4. The multi-slave automatic sequential encoding system based on chain connection according to claim 1, characterized in that: The slave device is connected to a power load.
5. The multi-slave automatic sequential encoding system based on chain connection according to claim 1, characterized in that: The communication bus is an RS-485 bus.
6. The multi-slave automatic sequential encoding system based on chain connection according to claim 1, characterized in that: The current detection module includes a BTS6143D chip.
7. A multi-slave automatic sequential encoding method based on chained connections, comprising the following steps: (1) System connection: The master is connected to the first slave, and the subsequent slaves are connected in series in a chain manner. The current flowing through the power bus of each slave in the chain connection decreases step by step. (2) System power-on initialization: Power on the host and all slave devices; (3) Current value reporting: The host sends a broadcast command to all slaves in the network, requiring all slaves to report the current currently detected by their built-in current detection module; (4) Data collection: The microcontroller (MCU) of each slave device reads the voltage value converted by the current detection module through the analog-to-digital converter (ADC) and sends the value to the host. The host collects the voltage values reported by all slave devices. (5) Sorting and address generation: The host sorts all the collected voltage values. Since the power supply current decreases step by step in the chain connection, the slave device that is closer to the power input point has a larger current and a higher detected voltage value. Therefore, the order of voltage values from high to low corresponds to the physical connection order of the slave devices from near to far. The host generates a set of increasing or decreasing sequential address codes according to this order. (6) Address allocation and storage: The host sends the unique address code assigned to each slave in a determined order; after receiving the address code, the slave stores it in its own memory and uses the address code in this and subsequent power-on communications. (7) Encoding complete: All slave address codes have been assigned and the system enters normal communication mode.