Automatic addressing system and method for multi-device parallel master-slave communication
By adopting the master-slave mode and resistor connection structure in a multi-device system, automatic slave device addressing is realized, which solves the problems of complexity of multi-device addressing and limited number of parallel communications in the existing technology, and realizes unlimited devices. Effects of parallel communication and precise address positioning.
Patent Information
- Application Number
- CN202211489273.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-11-25
AI Technical Summary
In the existing technology, when multiple devices are flexibly spliced, it is difficult for the master device to automatically distinguish and address the slave devices, which requires professional operations. Moreover, the maximum number of parallel communications is limited, and the addressing is complex, making it impossible to achieve unlimited parallel communications.
Design an automatic addressing system for multi-device parallel master-slave communication. Through the resistance connection and interface loop structure between the master device and the slave device, it adopts the master question and slave answer mode. The master device communicates with the slave through the broadcast address and request address interface. Addressing of devices enables fool-proof plug-and-play addressing to avoid bus congestion.
There is no need to add additional DIP switches to achieve independent addressing of unlimited parallel communication. The address of each slave device is accurately located, which facilitates information viewing, avoids bus congestion, and simplifies the communication addressing process of flexible assembly of multiple devices.
Smart Images

Figure CN115883516B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of multi-device addressing, and in particular to an automatic addressing system and method for multi-device parallel master-slave communication. Background Art
[0002] Flexible and intelligent product design generally allows products or devices to be flexibly spliced, and can be connected in series or in parallel to meet the flexible needs of users. Intelligent devices, also known as slave devices, generally have communication functions, and a master device aggregates and displays information. When flexibly spliced, since the slave devices are all the same product, the master device cannot locate the slave device to distinguish communication and display.
[0003] The existing technology generally uses a dip switch to address each device independently for multiple devices, which generally requires very professional personnel to complete the addressing. At the same time, the number of dip switches and the maximum number of parallel communications supported are also limited, or generally only support 2 devices for expansion parallel connection. At this time, no additional addressing is required because the second device can be fixedly addressed by the program. If there are many devices, professional personnel are required to complete the addressing, and the compilation is very complicated. Summary of the invention
[0004] The purpose of the present invention is to overcome the deficiencies in the prior art and to provide an automatic addressing system and method for multi-device parallel master-slave communication.
[0005] In order to achieve the above object, the present invention is achieved through the following technical solutions:
[0006] An automatic addressing system for multi-device parallel master-slave communication, comprising a master device U1, a plurality of slave devices, a main MCU, a plurality of slave MCUs, a resistor R1, a resistor R2, and a power supply VCC, wherein the plurality of slave devices are slave devices U2, U3, U4, ..., Ux, the plurality of slave devices and the master device U1 all have communication functions, the master device U1 is used for information aggregation and display, the master device U1 is connected to the main MCU, each of the slave devices is connected to a slave MCU, the master device U1 is provided with a main interface, the slave device is provided with a first interface and a second interface, and the main interface is connected to a power supply through the resistor R1 VCC, the master interface is connected to the first interface of a certain slave device, the first interface of the certain slave device is connected to the power supply VCC through the resistor R2, the first interface of the certain slave device is connected to the second interface of a certain slave device, the second interface of the certain slave device is connected to the first interface of the next slave device Ux-1, the first interface of the next slave device Ux-1 is connected to the power supply VCC through the resistor R2, the first interface of the next slave device Ux-1 is connected to the second interface of the next slave device Ux-1, the second interface of the next slave device Ux-1 is connected to the first interface of the next slave device X, and then the cycle is repeated.
[0007] Preferably, the main interface is provided with a communication interface A, a communication interface B, an addressing interface C, and a request address interface D, and the first interface and the second interface are provided with a communication interface E, a communication interface F, an addressing interface G, and a request address interface H.
[0008] The communication interface A is connected to the communication E interface of the first interface of a certain slave device, the communication E interface of the first interface of a certain slave device is connected to the communication E interface of the second interface of a certain slave device, the communication E interface of the second interface of a certain slave device is connected to the communication E interface of the first interface of the next slave device Ux-1, the communication E interface of the first interface of the next slave device Ux-1 is connected to the communication E interface of the second interface of the next slave device Ux-1, the communication E interface of the second interface of the next slave device Ux-1 is connected to the communication E interface of the first interface of the next slave device X, and then the cycle continues;
[0009] The communication interface B is connected to the communication F interface of the first interface of a certain slave device, the communication F interface of the first interface of a certain slave device is connected to the communication F interface of the second interface of a certain slave device, the communication F interface of the second interface of a certain slave device is connected to the communication F interface of the first interface of the next slave device Ux-1, the communication F interface of the first interface of the next slave device Ux-1 is connected to the communication F interface of the second interface of the next slave device Ux-1, the communication F interface of the second interface of the next slave device Ux-1 is connected to the communication F interface of the first interface of the next slave device X, and then the cycle continues;
[0010] The request address interface D is connected to the input port IN of the main MCU, and the request address interface D is also connected to the power supply VCC through the resistor R1. The request address interface D is connected to the request address interface H of the first interface of a certain slave device, and the request address interface H of the first interface of a certain slave device is connected to the request address interface H of the second interface of a certain slave device, and the request address interface H of the second interface of a certain slave device is connected to the request address interface H of the first interface of the next slave device Ux-1, and the request address interface H of the first interface of the next slave device Ux-1 is connected to the request address interface H of the second interface of the next slave device Ux-1, and the request address interface H of the second interface of the next slave device Ux-1 is connected to the request address interface H of the first interface of the next slave device X, and then the cycle is repeated;
[0011] The address addressing interface C is connected to the ground signal GND, the address addressing interface C is connected to the address addressing interface G of the first interface of a certain slave device, the address addressing interface G of the first interface of a certain slave device is connected to the power supply VCC through the resistor R2, the address addressing interface G of the first interface of a certain slave device is connected to the input port IN of the slave MCU, the address addressing interface G of the second interface of a certain slave device is connected to the output port OUT of the slave MCU, the address addressing interface G of the second interface of a certain slave device is connected to the address addressing interface G of the first interface of the next slave device Ux-1, and the address addressing interface G of the first interface of the next slave device Ux-1 Interface G is connected to the power supply VCC through resistor R2, the address addressing interface G of the first interface of the next slave device Ux-1 is connected to the input port IN of the slave MCU, the address addressing interface G of the second interface of the next slave device Ux-1 is connected to the output port OUT of the slave MCU, the address addressing interface G of the second interface of the next slave device Ux-1 is connected to the address addressing interface G of the first interface of the next slave device X, the address addressing interface G of the first interface of the next next slave device X is connected to the input port IN of the slave MCU, the address addressing interface G of the first interface of the next next slave device X is connected to the power supply VCC through resistor R2, and then the cycle is repeated.
[0012] Preferably, the power supply VCC is 3-5V.
[0013] An automatic addressing method for multi-device parallel master-slave communication includes the following steps:
[0014] Step 1: Several slave devices are connected and initialized;
[0015] Step 2: The master device U1 detects that the slave device enters the addressing state;
[0016] Step 3: The master device U1 addresses several slave devices:
[0017] Step 4: The master device U1 determines whether the slave device has been removed and is re-addressed.
[0018] Preferably, the slave device is initialized to a high level state at the input port IN of the slave MCU of the slave device, and the input port IN of the slave MCU of the slave device outputs high impedance, so that the address addressing interface G of the second interface of the slave device is pulled low.
[0019] Preferably, the master device U1 detects that the slave device enters the addressing state when the master device U1 detects that the request address interface H of the first interface of the slave device is pulled low, and at the same time, the address addressing interface C of the master device U1 is pulled to ground, and the address addressing interface G of the first interface of the slave device is pulled low, indicating that the current slave device can enter the addressing state.
[0020] As a preferred embodiment, the master device U1 addresses several slave devices: the master device U1 addresses several slave devices. When the master device U1 identifies the device that needs to be addressed through the request address interface C, it will broadcast the address on the bus where the request address interface D is located. The broadcast address is 0. All slave devices can receive the signal during the broadcast. If the current number of devices is 0, and because a slave device is identified to be connected, it starts to try to query the first interface of the slave device for communication. At this time, the slave device pulls down the address addressing interface C of the first interface to determine that the current slave device has entered the addressing state. At the same time, it receives that the number of slave devices on the bus is 0, so it addresses itself as address 1 and waits for the query command of the master device U1. When the command of querying address 1 from the master device U1 is received, the current slave device Normal response. At this time, the new address confirmation is completed. The slave device restores the request address interface H of its first interface to a high-impedance state, and no longer pulls down the request address allocation. At the same time, the address addressing interface G of its second interface changes from a high-impedance state to a low state, informing the next connected slave device that it can also enter the addressing state. At this time, if there is no slave device connected, the master device U1 detects that the request address interface D has returned to a high level, and the addressing is completed. Otherwise, there are slave devices connected at this time, because the address has not been allocated yet. The previous slave device has restored high impedance, but the next slave device Ux-1 has not yet restored, so the request address interface D is still at a low level. The master device U1 has to continue to broadcast the current total number of devices as 1, and at the same time start query communication with the next slave device Ux-1 of address 2;
[0021] The address addressing interface G of the first interface of the next slave device Ux-1 is pulled down by the previous slave device. At this time, the next slave device Ux-1 also enters the addressable state, and at the same time receives the current total number of devices broadcast by the master device U1 as 1. At this time, the next slave device Ux-1 addresses itself as 2, and waits to receive the query command for address 2 from the master device U1. After receiving the command and responding correctly, the next slave device Ux-1 confirms that the address is completed. The next slave device Ux-1 restores the request address interface H of its first interface to the high-impedance state, and no longer pulls down the request allocation address. At the same time, the address addressing interface G of its second interface is changed from the high-impedance state to the pulled-down state, informing the next connected slave device that it can also enter the addressing state, and so on.
[0022] Preferably, the master device U1 determines whether the slave device has been removed and re-addresses. The master device U1 determines whether the slave device has been removed. If not, it ends. Otherwise, the current slave device changes the address addressing interface G of its first interface from the state originally pulled down by the previous slave device to being released. The slave device detects that it has been removed from the bus, clears its original addressing and restores it to the unaddressed state. At the same time, it restores the request address interface H of its first interface to the high-impedance state. Any next slave device Ux-1 connected to the slave device also clears the originally programmed address. At the same time, the address addressing interface G of the first interface of the next slave device Ux-1 is pulled low, indicating that it needs to be re-addressed. The master device U1 detects that the slave device communication has not responded and actively removes it from the bus, and rebroadcasts the bus number. If the slave device finds that the address exceeds the maximum number of devices broadcast, it actively restores itself to the unaddressed state to prevent bus addressing confusion.
[0023] The beneficial effects of the present invention are as follows: the present invention does not require additional dial switches, does not require professional personnel to operate, and can theoretically achieve independent addressing of unlimited parallel communications. The present invention can perform fool-proof plug-and-play addressing, solving the communication addressing problem when multiple devices are flexibly assembled. At the same time, the address of each slave device can be accurately located according to its position, making it convenient to correspond to the corresponding slave device one by one when viewing information; the present invention adopts a master-question-slave-answer mode to avoid bus congestion. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a module connection diagram of embodiment 1 of the present invention;
[0025] Figure 2 This is a module connection diagram of Example 2 of the present invention. DETAILED DESCRIPTION
[0026] The technical solution of the present invention is further described below in conjunction with the accompanying drawings:
[0027] Example 1
[0028] like Figure 1As shown, an automatic addressing system for multi-device parallel master-slave communication includes a master device U1, two slave devices, a main MCU, two slave MCU5, a resistor R1, two resistors R2, and a power supply VCC. The two slave devices are slave device U2 and slave device U3. The two slave devices and the master device have communication functions. The master device U1 is used for information aggregation and display. The master device is connected to the main MCU4. The two slave devices are connected to a slave MCU5. The master device U1 is provided with a master interface 1, the slave device U2 is provided with a first interface 21, a second interface 22, and the slave device U3 is provided with a first interface 21, a second interface 22, and a second interface 23. A first interface 21 and a second interface 22 are provided, wherein the master interface 1 is connected to a power supply VCC via a resistor R1, the master interface 1 is connected to a first interface 21 of a slave device U2, the first interface 21 of the slave device U2 is connected to a power supply VCC via a resistor R2, the first interface 21 of the slave device U2 is connected to a second interface of the slave device U2, the second interface of the slave device U2 is connected to a first interface 21 of a slave device U3, the first interface 21 of the slave device U3 is connected to a power supply VCC via a resistor R2, and the first interface 21 of the slave device U3 is connected to a second interface 22 of the slave device U3.
[0029] like Figure 1 As shown, the main interface 1 is provided with a communication interface A, a communication interface B, an addressing interface C, and a request address interface D. The first interface 21 and the second interface 22 are both provided with a communication interface E, a communication interface F, an addressing interface G, and a request address interface H.
[0030] like Figure 1 As shown, the communication interface A is connected to the communication E interface of the first interface 21 of the slave device U2, the communication E interface of the first interface 21 of the slave device U2 is connected to the communication E interface of the second interface 21 of the slave device U2, the communication E interface of the second interface 21 of the slave device U2 is connected to the communication E interface of the first interface 21 of the slave device U3, and the communication E interface of the first interface 21 of the slave device U3 is connected to the communication E interface of the second interface 21 of the slave device U3.
[0031] like Figure 1 As shown, the communication interface B is connected to the communication F interface of the first interface 21 of the slave device U2, the communication F interface of the first interface 21 of the slave device U2 is connected to the communication F interface of the second interface 21 of the slave device U2, the communication F interface of the second interface 21 of the slave device U2 is connected to the communication F interface of the first interface 21 of the slave device U3, and the communication F interface of the first interface 21 of the slave device U3 is connected to the communication F interface of the second interface 22 of the slave device U3.
[0032] like Figure 1As shown, the request address interface D is connected to the input port IN of the main MCU4, and the request address interface D is also connected to the power supply VCC through the resistor R1, the request address interface D is connected to the request address interface H of the first interface 21 of the slave device U2, the request address interface H of the first interface 21 of the slave device U2 is connected to the request address interface H of the second interface 22 of the slave device U2, the request address interface H of the second interface 22 of the slave device U2 is connected to the request address interface H of the first interface 21 of the slave device U3, and the request address interface H of the first interface 21 of the slave device U3 is connected to the request address interface H of the second interface 22 of the slave device U3.
[0033] like Figure 1 As shown, the address addressing interface C is connected to the ground signal GND, the address addressing interface C is connected to the address addressing interface G of the first interface 21 of the slave device U2, the address addressing interface G of the first interface 21 of the slave device U2 is connected to the power supply VCC through the resistor R2, the address addressing interface G of the first interface 21 of the slave device U2 is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of the slave device U2 is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of the slave device U2 is connected to the address addressing interface G of the first interface 21 of the slave device U3, the address addressing interface G of the first interface 21 of the slave device U3 is connected to the power supply VCC through the resistor R2, the address addressing interface G of the first interface 21 of the slave device U3 is connected to the input port IN of the slave MCU5, and the address addressing interface G of the second interface 22 of the slave device U3 is connected to the input port IN of the slave MCU5.
[0034] like Figure 1 As shown, the power supply VCC is 3-5V.
[0035] An automatic addressing method for multi-device parallel master-slave communication includes the following steps:
[0036] Step 1: Access and initialize the slave device;
[0037] Step 2: The master device U1 detects that the slave device enters the addressing state;
[0038] Step 3: The master device U1 addresses the slave devices U2 and U3:
[0039] Step 4: The master device U1 determines whether the slave devices U2 and U3 have been removed and re-addressed.
[0040] The slave device is initialized to pull up the input port ININ of the slave MCU5 of the slave device U2 and the slave device U3 to a high level state, and the input port IN of the slave MCU5 of the slave device U2 and the slave device U3 outputs a high impedance, so that the address addressing interface G of the second interface 22 of the slave device U2 and the slave device U3 is pulled down.
[0041] The master device U1 detects that the slave device enters the addressing state when the master device U1 detects that the request address interface H of the first interface 21 of the slave device is pulled low. At the same time, the address addressing interface C of the master device U1 is pulled to the ground, and the address addressing interface G of the first interface 21 of the slave device is pulled low, indicating that the current slave device can enter the addressing state.
[0042] The master device U1 addresses the slave devices U2 and U3: The master device U1 addresses the slave devices U2 and U3. When the master device U1 identifies the device that needs to be addressed through the request address interface C, it will broadcast the address on the bus where the request address interface D is located. The broadcast address is 0. All slave devices can receive the signal during the broadcast. If the current number of devices is 0, and because a slave device is identified to be connected, it starts to try to query the first interface of the slave device U2 for communication. At this time, the slave device U2 pulls down the address addressing interface C of the first interface to determine that the current slave device U2 has entered the addressing state. At the same time, it receives that the number of slave devices on the bus is 0, so it addresses itself as address 1 and waits for the query command from the master device U1. When it receives the command from the master device U1 to query address 1, , the current slave device U2 responds normally, and the new address confirmation is completed at this time. The slave device U2 restores the request address interface H of its first interface 21 to a high-impedance state, and no longer pulls down the request address allocation state. At the same time, the address addressing interface G of the second interface 22 of the slave device U2 is changed from a high-impedance state to a low state, informing the slave device U3 that it can also enter the addressing state. At this time, if there is no slave device connected, the master device U1 detects that the request address interface D has recovered to a high level, and the addressing is completed. Otherwise, there are slave devices connected later at this time, because the address has not been allocated yet, the previous slave device has recovered to a high impedance, but the slave device U3 has not recovered yet, so the request address interface D is still at a low level, and the master device U1 has to continue to broadcast the current total number of devices as 1, and at the same time start query communication with the slave device U2 of address 2;
[0043] The address addressing interface G of the first interface of the slave device U3 is pulled down by the previous slave device. At this time, the slave device U3 also enters the addressable state. At the same time, it receives the current total number of devices broadcast by the master device U1 as 1. At this time, the slave device U3 addresses itself as 2, and waits to receive the query command for address 2 from the master device U1. After receiving the command and responding correctly, the slave device U3 confirms that the address is completed, and the slave device U3 restores the request address interface H of its first interface 21 to a high-impedance state, and no longer pulls down the request allocation address. At the same time, the address addressing interface G of the second interface 22 of the slave device U3 is changed from a high-impedance state to a low state.
[0044] The master device determines whether the slave device has been removed and re-addresses. The master device determines whether the slave device has been removed. If not, it ends. Otherwise, the current slave device U2 changes the address addressing interface G of its first interface from the state originally being used by the slave device U1 to being released. The slave device U2 detects that it has been removed from the bus, and clears its original addressing and restores it to an unaddressed state. At the same time, the request address interface H of the first interface of the slave device U2 is restored to a high-impedance state. Any slave device U1 connected to the slave device U2 also clears the originally programmed address. At the same time, the address addressing interface G of the first interface 21 of the slave device U1 is pulled low, indicating that it needs to be re-addressed. The master device U1 detects that the slave device U1 communication has not responded and actively removes it from the bus, and rebroadcasts the bus number. If the slave device finds that the address exceeds the maximum number of devices broadcast, it actively restores itself to an unaddressed state to prevent bus addressing confusion.
[0045] The present invention does not require additional dial switches, does not require professional personnel to operate, and can theoretically achieve independent addressing of unlimited parallel communications. The present invention can perform fool-proof plug-and-play addressing, solving the communication addressing problem when multiple devices are flexibly assembled. At the same time, the address of each slave device can be accurately located according to its position, which is convenient for one-to-one correspondence with the corresponding slave device when viewing information; the present invention adopts a master-question-slave-answer mode to avoid bus congestion.
[0046] Example 2
[0047] like Figure 2As shown, an automatic addressing system for multi-device parallel master-slave communication includes a master device U1, a plurality of slave devices, a main MCU4, a plurality of slave MCU5, a resistor R1, a resistor R2, and a power supply VCC. The plurality of slave devices are slave devices U2, slave devices U3, slave devices U4...slave devices Ux. The plurality of slave devices and the master device U1 have communication functions. The master device U1 is used for information aggregation and display. The master device U1 is connected to the main MCU4, and each of the slave devices is connected to a slave MCU5. The master device U1 is provided with a master interface 1, and the slave device is provided with a first interface 21 and a second interface 22. The master interface 1 is connected to the power supply VCC through the resistor R1. The master interface 1 is connected to the first interface 21 of a certain slave device, the first interface 21 of the certain slave device is connected to the power supply VCC through the resistor R2, the first interface 21 of the certain slave device is connected to the second interface 22 of a certain slave device, the second interface 22 of the certain slave device is connected to the first interface 21 of the next slave device Ux-1, the first interface 21 of the next slave device Ux-1 is connected to the power supply VCC through the resistor R2, the first interface 21 of the next slave device Ux-1 is connected to the second interface 22 of the next slave device Ux-1, the second interface 22 of the next slave device Ux-1 is connected to the first interface 21 of the next slave device X, and then the cycle is repeated.
[0048] like Figure 2 As shown, the main interface 1 is provided with a communication interface A, a communication interface B, an addressing interface C, and a request address interface D. The first interface 21 and the second interface 22 are both provided with a communication interface E, a communication interface F, an addressing interface G, and a request address interface H.
[0049] The communication interface A is connected to the communication E interface of the first interface 21 of a certain slave device, the communication E interface of the first interface 21 of a certain slave device is connected to the communication E interface of the second interface 22 of a certain slave device, the communication E interface of the second interface 22 of a certain slave device is connected to the communication E interface of the first interface 21 of the next slave device Ux-1, the communication E interface of the first interface 21 of the next slave device Ux-1 is connected to the communication E interface of the second interface 22 of the next slave device Ux-1, the communication E interface of the second interface 22 of the next slave device Ux-1 is connected to the communication E interface of the first interface 21 of the next slave device X, and then the cycle continues;
[0050] The communication interface B is connected to the communication F interface of the first interface 21 of a certain slave device, the communication F interface of the first interface 21 of a certain slave device is connected to the communication F interface of the second interface 22 of a certain slave device, the communication F interface of the second interface 22 of a certain slave device is connected to the communication F interface of the first interface 21 of the next slave device Ux-1, the communication F interface of the first interface 21 of the next slave device Ux-1 is connected to the communication F interface of the second interface 22 of the next slave device Ux-1, the communication F interface of the second interface 22 of the next slave device Ux-1 is connected to the communication F interface of the first interface 21 of the next slave device X, and then the cycle continues;
[0051] The request address interface D is connected to the input port IN of the main MCU4, and the request address interface D is also connected to the power supply VCC through the resistor R1. The request address interface D is connected to the request address interface H of the first interface 21 of a certain slave device, and the request address interface H of the first interface 21 of a certain slave device is connected to the request address interface H of the second interface 22 of a certain slave device, and the request address interface H of the second interface 22 of a certain slave device is connected to the request address interface H of the first interface 21 of the next slave device Ux-1, and the request address interface H of the first interface 21 of the next slave device Ux-1 is connected to the request address interface H of the second interface 22 of the next slave device Ux-1, and the request address interface H of the second interface 22 of the next slave device Ux-1 is connected to the request address interface H of the first interface 21 of the next slave device X, and then the cycle is repeated in sequence;
[0052] The address addressing interface C is connected to the ground signal GND, the address addressing interface C is connected to the address addressing interface G of the first interface 21 of a certain slave device, the address addressing interface G of the first interface 21 of a certain slave device is connected to the power supply VCC through the resistor R2, the address addressing interface G of the first interface 21 of a certain slave device is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of a certain slave device is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of a certain slave device is connected to the address addressing interface G of the first interface 21 of the next slave device Ux-1, the address addressing interface G of the first interface 21 of the next slave device Ux-1 Interface G is connected to the power supply VCC through resistor R2, the address addressing interface G of the first interface 21 of the next slave device Ux-1 is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of the next slave device Ux-1 is connected to the input port IN of the slave MCU5, the address addressing interface G of the second interface 22 of the next slave device Ux-1 is connected to the address addressing interface G of the first interface 21 of the next slave device X, the address addressing interface G of the first interface 21 of the next slave device X is connected to the input port IN of the slave MCU5, the address addressing interface G of the first interface 21 of the next slave device X is connected to the power supply VCC through resistor R2, and then the cycle is repeated.
[0053] like Figure 2 As shown, the power supply VCC is 3-5V.
[0054] An automatic addressing method for multi-device parallel master-slave communication includes the following steps:
[0055] Step 1: Several slave devices are connected and initialized;
[0056] Step 2: The master device U1 detects that the slave device enters the addressing state;
[0057] Step 3: The master device U1 addresses several slave devices:
[0058] Step 4: The master device U1 determines whether the slave device has been removed and is re-addressed.
[0059] The slave device is initialized to a high level state at the input port IN of the slave MCU5 of the slave device, and the input port IN of the slave MCU5 of the slave device outputs high impedance, so that the addressing interface G of the second interface 22 of the slave device is pulled low.
[0060] The master device U1 detects that the slave device enters the addressing state when the master device U1 detects that the request address interface H of the first interface 21 of the slave device is pulled low. At the same time, the address addressing interface C of the master device U1 is pulled to the ground, and the address addressing interface G of the first interface 21 of the slave device is pulled low, indicating that the current slave device can enter the addressing state.
[0061] The master device U1 addresses several slave devices: The master device U1 addresses several slave devices. When the master device U1 identifies the device that needs to be addressed through the request address interface C, it will broadcast the address on the bus where the request address interface D is located. The broadcast address is 0. All slave devices can receive the signal during the broadcast. If the current number of devices is 0, and because a slave device is identified to be connected, it starts to try to query the first interface 21 of the slave device for communication. At this time, the slave device pulls down the address addressing interface C of the first interface 21 to determine that the current slave device has entered the addressing state. At the same time, it receives that the number of slave devices on the bus is 0, so it addresses itself as address 1 and waits for the query command of the master device U1. When the command of querying address 1 from the master device U1 is received, the current slave device responds normally. Answer: At this time, the new address is confirmed, and the slave device restores the request address interface H of its first interface 21 to a high impedance state, and no longer pulls down the request address allocation state. At the same time, the address addressing interface G of its second interface 22 changes from a high impedance state to a low state, informing the next connected slave device that it can also enter the addressing state. At this time, if there is no slave device connected, the master device U1 detects that the request address interface D returns to a high level, and the addressing is completed. Otherwise, there are slave devices connected at this time, because the address has not been allocated yet. The previous slave device has restored high impedance, but the next slave device Ux-1 has not yet restored, so the request address interface D is still at a low level. The master device U1 has to continue to broadcast the current total number of devices as 1, and at the same time start query communication with the next slave device Ux-1 of address 2;
[0062] The address addressing interface G of the first interface 21 of the next slave device Ux-1 is pulled down by the previous slave device. At this time, the next slave device Ux-1 also enters the addressable state, and at the same time receives the current total number of devices broadcast by the master device U1 as 1. At this time, the next slave device Ux-1 addresses itself as 2, and waits to receive the query command for address 2 from the master device U1. After receiving the command and responding correctly, the next slave device Ux-1 confirms that the address is completed. The next slave device Ux-1 restores the request address interface H of its first interface 21 to a high-impedance state, and no longer pulls down the request allocation address. At the same time, the address addressing interface G of its second interface 22 is changed from a high-impedance state to a low state, informing the next connected slave device that it can also enter the addressing state, and so on.
[0063] like Figure 2As shown, the master device U1 determines whether the slave device has been removed and re-addresses. The master device U1 determines whether the slave device has been removed. If not, it ends. Otherwise, the current slave device changes the addressing interface G of its first interface 21 from the state originally pulled down by the previous slave device to being released. The slave device detects that it has been removed from the bus, clears its original addressing and restores it to the unaddressed state. At the same time, it restores the request address interface H of its first interface 21 to the high-impedance state. Any next slave device Ux-1 connected to the slave device also clears the originally programmed address. At the same time, the addressing interface G of the first interface 21 of the next slave device Ux-1 is pulled low, indicating that it needs to be re-addressed. The master device U1 detects that the slave device communication has not responded and actively removes it from the bus, and re-broadcasts the bus number. If the slave device finds that the address exceeds the maximum number of devices broadcast, it actively restores itself to the unaddressed state to prevent bus addressing confusion.
[0064] like Figure 2 As shown, the present invention is composed of a master device and N slave devices, the master device is provided with a communication interface, and the slave device is provided with two communication interfaces. The master device is mainly for communication and management of the slave device, and is also the main initiator of the communication. The slave is set as the responder of the communication. The master-slave communication adopts the master-question-slave-answer mode to avoid bus congestion. There are generally 4 interface lines, namely communication A and communication B, which are illustrated as differential communication lines that can be connected in parallel (generally communication interfaces such as RS485 / CAN), the third is the request address line, and the fourth is the address addressing line. Generally, the connecting line of the product matching is used to connect the interface of the master device to the interface 1 of any slave device, and then the interface 2 is connected to the interface 1 of the next slave device. The connection generally adopts a male and female head structure in structure to avoid connection errors. In the present invention, the internal communication A, communication B, and request address lines are all internally connected in parallel, and are directly connected on the first interface 21 and the second interface 22 of each slave device. The communication addressing line is not directly connected at the first interface 21 and the second interface 22. The signal is connected from the first interface 21 to the input IO of the MCU, and then connected to the same signal of the second interface 22 through the output IO of the MCU. The address line inside the master device is connected to GND, the request address line is connected to resistor R1 and then pulled up to the internal MCU power supply VCC, and then the signal is connected to the input port IN of the MCU inside the master device U1 for identification. The address line of slave device 1 is connected to resistor R2 and then pulled up to VCC, and then the chip is connected to the MCU inside the device for input identification. Other slave devices are connected in the same way.
[0065] like Figure 2As shown, each slave device is consistent and does not leave the factory without addressing. The address addressing line IN port of the first interface 21 is in a high-level state, and the OUT output of the second interface 22 is high impedance. At the same time, the address request line is in a low state. To tell the bus that there are devices that need to be addressed on the current bus. When the master device is connected to the first interface 22 of any slave device, the master device detects that the slave device pulls the request address line low. At the same time, the address addressing line of the master device is pulled to the ground, and the address addressing line of the interface 1 of the slave device is pulled low, indicating that the current device can enter the addressing state. When the master device identifies the device that needs to be addressed through the address request line, it will broadcast on the bus. The broadcast address is generally 0. When broadcasting, all devices can receive the signal. The number of devices that have been connected, such as the current number of devices is 0. At the same time, because it is recognized that there is a device connected, it starts to try to query communication to address 1. At this time, the slave device U2 judges that it is currently in the addressing state by pulling down the address addressing line of the first interface 21. At the same time, it receives that the number of bus slave devices is 0, and addresses itself to address 1. At the same time, it waits for the query command of the master device. When receiving the command of the master device to query address 1, the slave device U2 responds normally, and the new address confirmation is completed. The slave device U2 restores the request address line to a high impedance state and no longer pulls down the request address allocation. At the same time, the address addressing line of the second interface 22 is pulled down from a high impedance state. Inform the next connected slave device U3 that it can also enter the addressing state. At this time, if there is no slave device connected, the master device U1 detects that the request address line has recovered to a high level, and the addressing is completed. If the slave device U3 is still connected at this time, because the address has not been assigned, the slave device U2 has restored high impedance, but the slave device U2 has not yet recovered, so the request address line is still at a low level. The master device U1 has to continue to broadcast the current total number of devices as 1, and at the same time start query communication with the slave device U3 of address 2. The address addressing line of the first interface 21 of the slave device U3 is pulled down by the slave device U2, and at this time the slave device U3 also enters the addressable state, and at the same time receives the current total number of devices broadcast by the master device as 1, and at this time the slave device U3 addresses itself as 2. At the same time, it waits to receive the query command of address 2 from the master device U1. After receiving the command and responding correctly, the slave device U3 confirms that the address is completed and restores the address request line from the low state to the high impedance state. At the same time, the address addressing line of its second interface 22 is pulled down from high impedance to low level, so that the next slave device X can also enter the addressing state. And so on. The bus can be dynamically connected to a theoretically unlimited number of slave devices. At the same time, they can be addressed in turn, and the address and exact location of the device can be clearly located during communication.
[0066] like Figure 2As shown, when the slave device is removed, the address line of the first interface 21 is released from the state originally pulled low by the previous slave device. The slave device detects that it has been removed from the bus, and clears its original address and restores it to the unaddressed state. At the same time, the address request line of the second interface 22 is restored to the high impedance state. Any slave device connected to the slave device should also clear the originally programmed address again, and at the same time, the request address line is pulled low, indicating that it needs to be re-addressed. The master device detects that the slave device communication is not responding and actively removes it from the bus, and rebroadcasts the bus number at the same time. If the slave device finds that the address exceeds the maximum number of devices broadcast, it will actively restore itself to the unaddressed state to prevent bus addressing confusion.
[0067] The request address line is connected in parallel with all online slave devices. The slave device pulls down the request address line to inform that there are other slave devices that need to be addressed.
[0068] When the master device receives the request address, it broadcasts the current number of devices to the bus and starts querying the slave device with the new address.
[0069] When the slave device enters the addressing state and receives the number of broadcast devices, it can address itself. After the new address is successfully received, the address line of the second interface is pulled low to allow the next slave device to enter the addressing state.
[0070] If the address line of the first interface 21 of the current slave device is removed, the current slave device detects the removal from the bus and returns to the unaddressed state. At the same time, the address line of the second interface 22 is also restored to the high-impedance state, informing the next slave device to be removed from the bus and also need to be restored to the unaddressed state.
[0071] When the master device detects that the slave device does not respond to communication, it will actively remove it from the bus and rebroadcast the bus number. If the slave device finds that the address exceeds the maximum number of devices broadcast, it will actively restore itself to unaddressed loading to prevent bus addressing confusion.
[0072] The present invention does not require additional dial switches, does not require professional personnel to operate, and can theoretically achieve independent addressing of unlimited parallel communications. The present invention can perform fool-proof plug-and-play addressing, solving the communication addressing problem when multiple devices are flexibly assembled. At the same time, the address of each slave device can be accurately located according to its position, which is convenient for one-to-one correspondence with the corresponding slave device when viewing information; the present invention adopts a master-question-slave-answer mode to avoid bus congestion.
[0073] It should be noted that the above is only a specific embodiment of the present invention. Obviously, the present invention is not limited to the above embodiment, and there are many variations. In short, all variations that can be directly derived or associated with the content disclosed by ordinary technicians in this field should be considered as the protection scope of the present invention.
Claims
1. An automatic addressing system for multi-device parallel master-slave communication, It is characterized in that The invention comprises a master device U1, a plurality of slave devices, a master MCU (4), a plurality of slave MCUs (5), a resistor R1, a resistor R2, and a power source VCC. The plurality of slave devices are slave devices U2, slave devices U3, slave devices U4, ... slave devices Ux. The plurality of slave devices and the master device U1 all have a communication function. The master device U1 is used for information aggregation and display. The master device U1 is connected to the master MCU (4). Each of the slave devices is connected to a slave MCU (5). The master device U1 is provided with a master interface. The slave device is provided with a first interface (21) and a second interface (22). The master interface is connected to the power source VCC via the resistor R1. The master interface is connected to the first interface of a certain slave device. (21), the first interface (21) of a certain slave device is connected to the power supply VCC through the resistor R2, the first interface (21) of a certain slave device is connected to the second interface (22) of a certain slave device, the second interface (22) of a certain slave device is connected to the first interface (21) of the next slave device Ux-1, the first interface (21) of the next slave device Ux-1 is connected to the power supply VCC through the resistor R2, the first interface (21) of the next slave device Ux-1 is connected to the second interface (22) of the next slave device Ux-1, the second interface (22) of the next slave device Ux-1 is connected to the first interface (21) of the next slave device X, and then the cycle continues; The main interface is provided with a communication interface A, a communication interface B, an addressing interface C, and a request address interface D. The first interface (21) and the second interface (22) are both provided with a communication interface E, a communication interface F, an addressing interface G, and a request address interface H. The communication interface A is connected to the communication E interface of the first interface (21) of a certain slave device, the communication E interface of the first interface (21) of a certain slave device is connected to the communication E interface of the second interface (22) of a certain slave device, the communication E interface of the second interface (22) of a certain slave device is connected to the communication E interface of the first interface (21) of the next slave device Ux-1, the communication E interface of the first interface (21) of the next slave device Ux-1 is connected to the communication E interface of the second interface (22) of the next slave device Ux-1, the communication E interface of the second interface (22) of the next slave device Ux-1 is connected to the communication E interface of the first interface (21) of the next slave device X, and then the cycle continues in sequence; The communication interface B is connected to the communication F interface of the first interface (21) of a certain slave device, the communication F interface of the first interface (21) of a certain slave device is connected to the communication F interface of the second interface (22) of a certain slave device, the communication F interface of the second interface (22) of the certain slave device is connected to the communication F interface of the first interface (21) of the next slave device Ux-1, the communication F interface of the first interface (21) of the next slave device Ux-1 is connected to the communication F interface of the second interface (22) of the next slave device Ux-1, the communication F interface of the second interface (22) of the next slave device Ux-1 is connected to the communication F interface of the first interface (21) of the next slave device X, and then the cycle continues in sequence; The request address interface D is connected to the input port IN of the main MCU (4), and the request address interface D is also connected to the power supply VCC through the resistor R1. The request address interface D is connected to the request address interface H of the first interface (21) of a certain slave device, the request address interface H of the first interface (21) of the certain slave device is connected to the request address interface H of the second interface (22) of a certain slave device, the request address interface H of the second interface (22) of the certain slave device is connected to the request address interface H of the first interface (21) of the next slave device Ux-1, the request address interface H of the first interface (21) of the next slave device Ux-1 is connected to the request address interface H of the second interface (22) of the next slave device Ux-1, the request address interface H of the second interface (22) of the next slave device Ux-1 is connected to the request address interface H of the first interface (21) of the next slave device X, and then the cycle is repeated in sequence; The address addressing interface C is connected to a ground signal GND, the address addressing interface C is connected to an address addressing interface G of a first interface (21) of a certain slave device, the address addressing interface G of the first interface (21) of a certain slave device is connected to a power supply VCC via a resistor R2, the address addressing interface G of the first interface (21) of a certain slave device is connected to an input port IN of a slave MCU (5), the address addressing interface G of a second interface (22) of a certain slave device is connected to an output port OUT of the slave MCU (5), the address addressing interface G of the second interface (22) of a certain slave device is connected to an address addressing interface G of a first interface (21) of a next slave device Ux-1, and the address addressing interface G of the first interface (21) of the next slave device Ux-1 is connected to a power supply VCC via a resistor R2. The interface G is connected to the power supply VCC via the resistor R2, the address addressing interface G of the first interface (21) of the next slave device Ux-1 is connected to the input port IN of the slave MCU (5), the address addressing interface G of the second interface (22) of the next slave device Ux-1 is connected to the output port OUT of the slave MCU (5), the address addressing interface G of the second interface (22) of the next slave device Ux-1 is connected to the address addressing interface G of the first interface (21) of the next slave device X, the address addressing interface G of the first interface (21) of the next slave device X is connected to the input port IN of the slave MCU (5), the address addressing interface G of the first interface (21) of the next slave device X is connected to the power supply VCC via the resistor R2, and then the cycle continues.
2. According to claim 1, an automatic addressing system for multi-device parallel master-slave communication, It is characterized in that The power supply VCC is 3-5V.
3. An automatic addressing method for multi-device parallel master-slave communication, based on the automatic addressing system for multi-device parallel master-slave communication described in claim 1, It is characterized in that The steps include: Step 1: Several slave devices are connected and initialized; Step 2: The master device U1 detects that the slave device enters the addressing state; Step 3: The master device U1 addresses several slave devices: Step 4: The master device U1 determines whether the slave device has been removed and re-addressed; The master device U1 detects that the slave device enters the addressing state when the master device U1 detects that the request address interface H of the first interface (21) of the slave device is pulled low, and at the same time, the address addressing interface C of the master device U1 is pulled to the ground, and the address addressing interface G of the first interface (21) of the slave device is pulled low, indicating that the current slave device can enter the addressing state; The master device U1 addresses a number of slave devices: the master device U1 addresses a number of slave devices. When the master device U1 identifies a device that needs to be addressed through the request address interface C, it will broadcast the address on the bus where the request address interface D is located. The broadcast address is 0. When broadcasting, all slave devices can receive the signal. If the current number of devices is 0, and because a slave device is identified to be connected, it starts to try to query the first interface (21) of the slave device for communication. At this time, the slave device pulls down the address addressing interface C of the first interface (21) to determine that the current slave device has entered the addressing state. At the same time, it receives that the number of bus slaves is 0, so it addresses itself as address 1 and waits for the query command of the master device U1. When the command of querying address 1 from the master device U1 is received, the current slave device is normal. Response, at this time, the new address confirmation is completed, the slave device restores the request address interface H of its first interface (21) to a high impedance state, no longer pulls down the request address allocation, and at the same time changes the address addressing interface G of its second interface (22) from a high impedance state to a low state, notifying the next connected slave device that it can also enter the addressing state. At this time, if there is no slave device connected, the master device U1 detects that the request address interface D has returned to a high level, then the addressing is completed. Otherwise, at this time, there are still slave devices connected later, because the address has not been allocated yet, the previous slave device has restored high impedance, but the next slave device Ux-1 has not yet restored, so the request address interface D is still at a low level, and the master device U1 has to continue to broadcast the current total number of devices as 1, and at the same time start query communication with the next slave device Ux-1 of address 2; The address addressing interface G of the first interface (21) of the next slave device Ux-1 is pulled down by the previous slave device. At this time, the next slave device Ux-1 also enters the addressable state, and at the same time receives the current total number of devices broadcast by the master device U1 as 1. At this time, the next slave device Ux-1 addresses itself as 2, and waits to receive the query command for address 2 from the master device U1. After receiving the command and responding correctly, the next slave device Ux-1 confirms that the address is completed. The next slave device Ux-1 restores the request address interface H of its first interface (21) to a high-impedance state, and no longer pulls down the request allocation address. At the same time, the address addressing interface G of its second interface (22) changes from a high-impedance state to a pulled-down state, notifying the next connected slave device that it can also enter the addressing state, and addressing is performed in this way.
4. According to claim 3, a method for automatic addressing of multi-device parallel master-slave communication, It is characterized in that The slave device is initialized to a state where the input port IN of the slave MCU (5) of the slave device is pulled up to a high level state, and the output port OUT of the slave MCU (5) of the slave device outputs a high impedance, so that the address addressing interface G of the second interface (22) of the slave device is pulled down.
5. According to claim 4, an automatic addressing method for multi-device parallel master-slave communication, It is characterized in that The master device U1 determines whether the slave device has been removed and re-addresses. The master device U1 determines whether the slave device has been removed. If not, the process ends. Otherwise, the current slave device changes the addressing interface G of its first interface (21) from the state originally pulled down by the previous slave device to being released. The slave device detects that it has been removed from the bus, clears its original addressing and restores it to an unaddressed state. At the same time, it restores the request address interface H of its first interface (21) to a high impedance state. Any next slave device Ux-1 connected to the slave device also clears the originally programmed address. At the same time, the addressing interface G of the first interface (21) of the next slave device Ux-1 is pulled low, indicating that it needs to be re-addressed. The master device U1 detects that the slave device communication has not responded and actively removes it from the bus. At the same time, it re-broadcasts the bus number. If the slave device finds that the address exceeds the maximum number of devices broadcast, it actively restores itself to an unaddressed state to prevent bus addressing confusion.
Citation Information
Patent Citations
Master-slave communication system, slave position identification method and mobile power supply renting device
CN110830304A
Rapid judgment and quit method for multiple hosts
CN110850770A
Master-slave automatic addressing method and device, equipment and storage medium
CN112291387A
Method for automatically distributing device communication addresses
CN113794785A
Master / slave communication system, method for identifying positions of slave machines, and appartus for leasing mobile power source
WO2021093540A1
