Slave station address self-identification system and method
Automatically allocate slave addresses through voltage-dividing network and analog quantity acquisition, solving the problem of increased cost and conflict risks of hardware configuration, realizing plug-and-play slave address self-identification, which is suitable for master-slave device communication in various serial line modes.
Patent Information
- Application Number
- CN202510767661.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-08-15
AI Technical Summary
In the existing industrial master-slave system, the slave address setting requires hardware configuration, which increases hardware cost and operational risks, and is prone to address conflicts that lead to the system not working normally.
The voltage divider network and analog quantity acquisition unit are used to automatically allocate slave addresses through the power supply voltage divider line, and the MCU is used to identify the number and location of slaves, and the address self-identification is combined with the voltage divider network table to avoid hardware dial switches and EEPROMs and other devices.
It realizes automatic allocation and identification of slave addresses, reduces hardware costs, reduces the risk of address settings conflicts, supports plug and play, and adapts to the increase and decrease and combination changes of slave devices.
Smart Images

Figure CN120498921A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communication of industrial master-slave equipment, and in particular to a slave station address self-identification system and method. Background Art
[0002] In the field of industrial control, the system architecture of one master and multiple slaves is very common, mainly because of its good scalability and various combinations. Currently, the most commonly used ones are:
[0003] A. Network-based master-slave systems, such as EtherCAT and Profinet bus master-slave systems, are the development direction of mid-to-high-end industrial control equipment.
[0004] B. There are also master-slave systems based on general serial lines, such as those based on CAN bus and RS485 bus. Although the communication rate of this type of master-slave system is relatively low and the number of extended slave devices is generally controlled within 8, it is still widely used due to its low cost advantage.
[0005] In order to find a unique slave station, these master-slave systems generally need to assign a unique slave address to each slave station. Network-based master-slave systems use dedicated chips on each slave station to implement signal input and output. These chips also assign slave addresses, allowing the master station to find and identify the corresponding slave station after connection.
[0006] In order to ensure the uniqueness of the slave station, the master-slave system based on the ordinary serial line method needs to set the unique slave station address through the DIP switch or other hardware methods. This method will inevitably have the following two problems:
[0007] Question 1: The hardware cost of the slave station is increased. Whether it is configuring a dip switch or setting the EEPROM to set the ID, it increases the hardware cost of the slave station and the complexity of hardware development.
[0008] Question 2: There are operational risks in the settings when using the dial-up method or other hardware configuration methods. It is easy for human factors to cause configuration errors in the industrial field, resulting in slave address conflicts and making the master-slave system unable to work properly. Summary of the Invention
[0009] The present invention addresses the shortcomings of the prior art by providing a slave station address self-identification system and method. This system and method are primarily designed for a serial line-based master-slave system for short-range communication. The system and method consist of a master station and multiple slave stations. In addition to the basic communication bus, the master station also outputs a power signal. A voltage divider network and analog acquisition unit on the slave stations automatically assign slave station addresses, identify the number of slave stations, and identify the slave station's location within the system. Using this system and method, in short-range serial line-based master-slave communication, components for address setting on the slave station can be eliminated. For example, components such as DIP switches and EEPROMs required for determining the slave station address can be eliminated. Furthermore, in the field, the master and slave devices do not need to specifically set slave station addresses, reducing the risk of master-slave system malfunctions due to address setting conflicts and achieving plug-and-play operation. The present invention is widely applicable to various systems with short-range master-slave communication and where slave stations require external address setting, significantly reducing the hardware design cost of slave station devices in master-slave network communication.
[0010] The object of the present invention is achieved through the following technical solutions: a slave address self-identification system for short-distance communication between master and slave devices in serial line mode, the system comprising a master device and multiple slave devices, with a serial communication line and a power voltage divider line between the master and slave devices;
[0011] The serial communication line is used to mount all slave stations for master-slave communication;
[0012] The power voltage divider line serves as the power output of the master station and is connected to the slave stations in the order of access to the system. Each slave station then connects the divided power to the next slave station.
[0013] According to the voltage value sampled by each slave station, the number of slave stations in the system and the cascade position of each slave station in the system are obtained.
[0014] Furthermore, the slave station includes a voltage divider network and analog quantity acquisition. The voltage divider network includes two resistors. Based on the resistor voltage division, the voltage entering the slave station device is divided and output to the next-level slave station device; the analog quantity acquisition is ADC sampling, which is used to collect the voltage after the two resistors in the voltage divider network divide the voltage.
[0015] Furthermore, the resistance values at corresponding positions in the voltage divider network of each slave station are the same, and the output voltage of the upper-level slave station is equal to the input voltage of the lower-level slave station.
[0016] Furthermore, using V (m,n) Indicates the node voltage of the mth level slave device among a total of n levels of slave devices. Each level of slave devices is equipped with a voltage divider network of two resistors. The voltage value on each level of slave devices is:
[0017] V (n,n)=V (n-1,n) ×R (n,n) / (R1+R (n,n) )
[0018] V (m,n) =V (m-1,n) ×R (m,n) / (R1+R (m,n) )
[0019] V (1,n) =Vin×R (1,n) / (R1+R (1,n) )
[0020] Among them, Vin is the main station power supply voltage, R (m,n) It is V (m,n) The equivalent resistance of the subsequent stage to the ground at point 1 is:
[0021] R (n,n) =R2
[0022] R (m,n) =R2||(R (m+1,n) +R1)
[0023] The voltage value at each slave node is obtained based on R1, R2 and Vin.
[0024] Furthermore, the circuit of the slave device performs slave management through the MCU, identifies the node location and the number of slaves, and the node location can be used as the communication address of the slave.
[0025] Furthermore, a voltage divider network table is set up for each level of slave station. The horizontal axis is the different node positions of the slave station equipment, and the vertical axis is the number of slave stations owned by the system. The voltage divider network table presets the voltage values of each slave station node under different slave station levels. The data in the voltage divider network table are sent and modified by the master station, which can realize the dynamic adjustment function. The master station synchronously sends the error band parameters to allow the slave station to match the data within the specified error band.
[0026] Furthermore, the slave station finds a unique matching value in the voltage divider network table based on the actual voltage divider sampling value. The value can clearly indicate the number of slave stations and the location of the slave stations, and identify the corresponding address; the master station sends a response request to each slave station device in turn, and each slave station reports the number of slave stations obtained by comparing the voltage divider network table to the master station. The master station compares the number of addresses reported by each slave station. If the bus receives the slave station data normally and the slave station number data fed back by each slave station is consistent, the master station will use the self-identified address as the slave station communication address; if there is a inconsistent number, the address recognition instruction will be issued again. After the self-identification instruction is cycled three times, if there is still an inconsistency, an error alarm will be issued, and the user will check the circuit or wiring.
[0027] Furthermore, when the slave station matches multiple voltage values within the set error band, the slave station will resample the voltage divider value and match again, repeating this three times. If multiple voltage values are matched three times, the address recognition is terminated and no address will be assigned in this round to prevent system communication conflicts and wait for instructions from the master station.
[0028] Furthermore, address re-identification can be achieved based on the already identified addresses. For new devices or replaced devices, address identification and allocation can be achieved by coordinating with the original addresses. The master station communicates with each slave station in the original system and also uses the voltage matching method to allow the new slave station to confirm its position and quantity, and the master station arranges a new address.
[0029] On the other hand, the present invention further provides a method for self-identification of a slave station address based on the system according to any one of claims 1 to 9, characterized in that the method comprises the following steps:
[0030] (1) Set up serial communication lines to mount all slave stations for master-slave communication;
[0031] (2) Set the power supply voltage divider line as the power output of the master station, and connect it to the slave stations in the order of access to the system. Each slave station will continue to connect the divided power supply to the next slave station;
[0032] (3) According to the voltage value sampled by each slave station, the number of slave stations in the system and the cascade position of each slave station in the system are obtained.
[0033] Beneficial effects of the present invention:
[0034] 1. It can automatically assign slave addresses, identify the number of slaves, and their access locations in the entire system without requiring additional hardware dialing, memory chip programming, and other operations.
[0035] 2. It can automatically adapt to the addition, subtraction and combination of various slave devices, and can not only use the old addresses that have been recognized, but also re-identify new addresses.
[0036] 3. It can be applied to various serial line master and slave devices without increasing too much hardware cost, and the value of the voltage divider network can be adjusted through the cooperation of software and hardware to achieve application in various scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 This is a diagram of the system master-slave device communication architecture proposed by the present invention.
[0039] Figure 2 This is a circuit effect diagram of the slave device proposed in the present invention.
[0040] Figure 3 This is a schematic diagram of various numbers of slave station access corresponding to the method proposed in the present invention.
[0041] Figure 4 This is a flow chart of the master-slave device in the slave address self-identification mode of the present invention (left: master station, right: slave station). DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are only used to explain the present invention and are not intended to limit the present invention.
[0043] like Figure 1 As shown, the present invention provides a slave address self-identification system and method, which is suitable for short-distance communication between master and slave devices in serial line mode. The system includes a master device and multiple slave devices. There are two parts between the master and slave devices: a serial communication line and a power voltage divider line. Its main architecture is as follows Figure 1 shown.
[0044] The serial communication line is the signal line commonly used for master-slave communication. It is usually a bus such as CAN or RS485, and all slave stations are mounted on the serial communication line.
[0045] The power divider is a key component of this system. It originates from the master station and feeds each device connected to it. The master station's power supply is typically 24V. This power is then fed to the slave stations in the order they are connected to the system. Each slave then passes the divided power to the next slave.
[0046] Except for adding a power output, no additional processing is required for the main station.
[0047] The slave device needs to add two parts on the original basis, one is the voltage divider network, the other is the analog quantity acquisition. The architecture of the slave is as follows Figure 2As shown. The voltage divider network consists of two ordinary resistors ( Figure 2 The main function of the ADC is to divide the voltage entering the slave device and output it to the next slave device. Analog acquisition is conventional ADC sampling, which is used to collect the voltage V after the voltage is divided by R1 and R2. (1,1) At the same time, the voltage divided V (1,1) Output to the next stage corresponds to:
[0048] Vout = V (1,1) =Vin×R2 / (R1+R2)
[0049] The present invention uses V (m,n) Indicates the node voltage of the mth level slave device under the total n levels of slave devices. When multiple slave devices are connected, the following is formed: Figure 3 The topology effect shown. The output voltage of the upper slave is equal to the input voltage of the lower slave. In this system, the two resistors selected by each slave device are R1 and R2. So when there are two slave devices, the voltage that can be collected by the second slave after passing through the voltage divider network is:
[0050] V (2,2) =V (1,2) ×R2 / (R1+R2)
[0051] After the first-level slave station passes through the voltage divider network, the voltage that can be collected is:
[0052] V (1,2) =Vin×R (1,2) / (R1+R (1,2) )
[0053] Among them, R (1,2) It is V (1,2) The equivalent resistance of the rear stage to the ground at point 1 is R (m,n) Indicates V (m,n) For a system with two slave devices, R (1,2) =(R1+R2)×R2 / (R1+R2+R2). Substituting R1, R2, and Vin into the formula, we can get V (1,2) and V (2,2) The specific value of .
[0054] If the entire system has n levels of slave devices connected, the voltage value of each level of slave can be obtained through the voltage divider network of each slave. These values are unique, and the corresponding voltage values are:
[0055] V (n,n) =V (n-1,n) ×R (n,n) / (R1+R (n,n) )
[0056] V (m,n) =V (m-1,n) ×R (m,n) / (R1+R (m,n) )
[0057] V (1,n) =Vin×R (1,n) / (R1+R (1,n) )
[0058] Among them, the equivalent resistance R (m,n) The parallel formula can be used to work backward from the last level to obtain the equivalent resistance to ground of each level:
[0059] R (n,n) =R2
[0060] R (m,n) =R2||(R (m+1,n) +R1)
[0061] Ultimately, the node voltage at each level can be converted into a function of R1, R2, and Vin. Substituting the specific values of R1, R2, and Vin into this function, the voltage value at each slave node can be obtained. Based on this method, not only can the node voltage values of each slave device be obtained, but more importantly, these voltage values are unique and different for each slave device level, regardless of the number of slaves. The sampled voltage values can then be used to determine the number of slaves in the system and the cascade position of each slave in the system, thus obtaining a unique slave address.
[0062] To achieve the above-mentioned method, a voltage divider network table must be set up in each slave device in the system, as shown in Table 1. The horizontal axis of the network table represents the different node positions of the slave device, and the vertical axis represents the number of slaves in the system. The network table presets the voltage values for each slave node for various slave numbers. Each voltage value can be converted into R1, R2, and Vin. The values of R1 and R2 are determined after the slave is manufactured, and can be preset in the slave code or modified by the master. The value of Vin is also determined by the master after power-up, which sends the actual power supply voltage value. This provides a clear network table. The specific values of Vin, R1, and R2 are all sent and modified by the master, enabling dynamic adjustment. The master also simultaneously sends error band parameters, allowing slaves to match data within the specified error band. After the voltage divider test is completed, the master can also set the Vin output to be disabled to reduce power consumption.
[0063] Table 1 Slave voltage division network table
[0064]
[0065]
[0066] The sampled voltage divider value is then compared with the voltage values in the network table to find the unique node position within the specified error band, and the number of slave stations in the current system can be obtained.
[0067] Generally, the circuit of a slave device will have an MCU for slave management. Currently, most conventional MCUs (such as the STM32 series) have ADC functions, and their corresponding resolution can reach more than 12 bits. For the master device outputting a 24V power signal, the connection of no more than 8 slave devices can fully meet the sampling accuracy requirements to identify the node location and number of slaves. The node location can be used as the communication address of the slave. Each slave will also write its own recognized slave address into the Flash. When no re-address recognition operation is performed, these addresses will be used as the slave addresses for subsequent communications.
[0068] After a period of waiting (in milliseconds) for the master station to recognize the address of the slave station, the master station will send a response request to each slave station device in sequence, starting from the device with slave address 1. Each slave station will report the number of slave stations obtained by comparing the voltage divider network table to the master station. The master station will compare the number of addresses reported by each slave station. If the bus receives the slave station data normally and the number of slave stations fed back by each slave station is consistent, the master station will use the self-identified address as the slave station communication address to complete the self-identification mode operation. If the number is inconsistent, the address recognition instruction will be issued again. After the self-identification instruction is cycled three times, if there is still an inconsistency, an error alarm will be issued, and the user will be required to check the circuit or wiring.
[0069] So in general, after the master and slave devices are powered on, the normal working flow chart is as follows Figure 4 shown.
[0070] When the slave station matches multiple voltage values within the set error band, it will resample the voltage divider value and match again, repeating this three times. If multiple voltage values are matched three times, the address recognition ends, and no address will be assigned in this round, waiting for instructions from the master station.
[0071] This system and method can also handle common abnormal situations such as replacing slaves and reordering slaves. Once each slave's address is confirmed through an independent and unique voltage divider value, the master can control the slave's behavior through various instructions, such as maintaining the original slave address or reallocating it. Even if a new slave is added and the original slave order is changed, the master can still communicate with each slave in the original system and, using the same voltage divider matching method, confirm the location and quantity of the new slave, and assign a new address to the master.
[0072] Taking the replacement of one of the slave stations as an example, in normal working mode, after the master station is powered on, it will first traverse all the slave stations in the system. If the actual response number is inconsistent with the original system, it will send a voltage re-collection and matching instruction to the original slave station device, reconfirm the sorting position of the original slave station, and assign a specified address to the newly connected slave station.
[0073] Because the core idea of this method is to use a voltage-dividing network to perform self-identification of the slave address, other operations based on this method can be formulated through the protocol between the master and the slave, and will not be discussed in detail here.
[0074] In order to enable those skilled in the art to further understand the features and technical contents of the present invention, please refer to the following specific embodiments of the present invention.
[0075] When the slave's R1 is set to 1kΩ and R2 to 10kΩ, and the master's output power supply Vin is 24V, the voltage divider network shown in Table 2 below is obtained (this table only covers the eight-level slaves). As can be seen from the table, the voltage values between each slave are independent and unique, and the minimum voltage difference is 0.038V. For a 12-bit ADC sampling circuit, the minimum voltage difference it can resolve is 0.0058V, which is sufficient to identify all possible combinations within the eight-level slaves.
[0076] Table 2 Example of voltage divider network table (R1 = 1KΩ, R2 = 10KΩ, Vin = 24V)
[0077] Voltage / V 1 2 3 4 5 6 7 8 Level 1 21.8182 / / / / / / / Level 2 20.1527 18.3206 / / / / / / Level 3 19.0430 15.9903 14.5366 / / / / / Level 4 18.3691 14.5751 12.2387 11.1260 / / / / Level 5 17.9826 13.7635 10.9208 9.1701 8.3365 / / / Level 6 17.7683 13.3133 10.1898 8.0851 6.7891 6.1719 / / Level 7 17.6515 13.0682 9.7917 7.4944 5.9465 4.9932 4.5393 / Level 8 17.5886 12.9361 9.5771 7.1759 5.4923 4.3579 3.6593 3.3267
[0078] Each slave station matches the detected ADC voltage within the error limit (such as ±0.01V) sent by the master station, finds its position in the table, determines the number of slave stations and their positions, and uses the slave station's position as the slave station address to communicate with the master station.
[0079] The above embodiments are used to illustrate the present invention rather than to limit the present invention. Any modifications and changes made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A slave address self-identification system for short-distance communication between master and slave devices in serial line mode, characterized in that: The system includes a master device and multiple slave devices, and there are two parts between the master and slave devices: a serial communication line and a power voltage divider line; The serial communication line is used to mount all slave stations for master-slave communication; The power voltage divider line serves as the power output of the master station and is connected to the slave stations in the order of access to the system. Each slave station then connects the divided power to the next slave station. According to the voltage value sampled by each slave station, the number of slave stations in the system and the cascade position of each slave station in the system are obtained.
2. A slave station address self-identification system according to claim 1, characterized in that: The slave station includes a voltage divider network and analog quantity acquisition. The voltage divider network includes two resistors. Based on the resistor voltage division, the voltage entering the slave station device is divided and output to the next-level slave station device; Analog quantity acquisition is ADC sampling, which is used to collect the voltage after the voltage is divided by two resistors in the voltage divider network.
3. A slave station address self-identification system according to claim 2, characterized in that: The resistance values of the multiple resistors in the voltage divider network of each slave station are the same, and the output voltage of the upper-level slave station is equal to the input voltage of the lower-level slave station.
4. A slave station address self-identification system according to claim 3, characterized in that: Use V (m,n) Indicates the node voltage of the mth level slave device among a total of n levels of slave devices. Each level of slave devices is equipped with a voltage divider network of two resistors. The voltage value on each level of slave devices is: In (n,n) =V (n-1,n) ×R (n,n) / (R1+R (n,n) ) In (m,n) =V (m-1,n) ×R (m,n) / (R1+R (m,n) ) In (1,n) =Vin×R (1,n) / (R1+R (1,n) ) Among them, Vin is the main station power supply voltage, R (m,n) It is V (m,n) The equivalent resistance of the subsequent stage to the ground at point 1 is: R (n,n) =R2 R (m,n) =R2||(R (m+1,n) +R1) The voltage value at each slave node is obtained based on R1, R2 and Vin.
5. A slave station address self-identification system according to claim 1, characterized in that: The circuit of the slave device is managed by the MCU, and the node location and number of slaves are identified. The node location can be used as the communication address of the slave.
6. A slave station address self-identification system according to claim 1, characterized in that: A voltage divider network table is set up for each level of slave station. The horizontal axis is the different node positions of the slave station equipment, and the vertical axis is the number of slave stations owned by the system. The voltage divider network table presets the voltage value of each slave station node under different slave station levels. The data in the voltage divider network table is sent and modified by the master station, which can realize the dynamic adjustment function. The master station synchronously sends the error band parameters to allow the slave station to match the data within the specified error band.
7. A slave station address self-identification system according to claim 6, characterized in that: The slave station finds a unique matching value in the voltage divider network table based on the actual voltage divider sampling value. The value can clearly indicate the number of slave stations and the location of the slave stations, and identify the corresponding address; the master station sends a response request to each slave device in turn, and each slave station reports the number of slave stations obtained by comparing the voltage divider network table to the master station. The master station compares the number of addresses reported by each slave station. If the bus receives the slave station data normally and the slave station number data fed back by each slave station is consistent, the master station will use the self-identified address as the slave station communication address; if there is a inconsistent number, the address recognition instruction will be issued again. After the self-identification instruction is cycled three times, if there is still an inconsistency, an error alarm will be issued, and the user will check the circuit or wiring.
8. A slave station address self-identification system according to claim 6, characterized in that: When the slave station matches multiple voltage values within the set error band, it will resample the voltage divider value and match again, repeating this three times. If multiple voltage values are matched three times, the address recognition ends and no address is assigned in this round to prevent system communication conflicts and wait for instructions from the master station.
9. A slave station address self-identification system according to claim 7, characterized in that: Address re-identification can be achieved based on the identified address. For new devices or replacement devices, address identification and allocation can be achieved by coordinating with the original address. The master station communicates with each slave station in the original system and also uses the voltage matching method to allow the new slave station to confirm the position and quantity, and the master station arranges the new address.
10. A method for self-identification of a slave station address based on the system according to any one of claims 1 to 9, characterized in that: The method comprises the following steps: (1) Set up serial communication lines to mount all slave stations for master-slave communication; (2) Set the power supply voltage divider line as the power output of the master station, and connect it to the slave stations in the order of access to the system. Each slave station will continue to connect the divided power supply to the next slave station; (3) According to the voltage value sampled by each slave station, the number of slave stations in the system and the cascade position of each slave station in the system are obtained.
