Address allocation method, device, bus system, main device and medium

By adjusting the difference between the output current value of the variable current source and the detection current value, the address is determined and allocated, which solves the problems of slave device delay and communication reliability in the LIN bus system and achieves more stable address allocation.

CN116346782BActive Publication Date: 2025-10-10TINYCHIP MICROELECTRONICS (SHANGHAI) CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310302407.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-27
Publication Date
2025-10-10
Estimated Expiration
2043-03-27

AI Technical Summary

Technical Problem

In the prior art, the maximum external driving current of the master device limits the current of the detection resistor, resulting in a decrease in the delay and communication reliability of the slave device in the LIN bus system.

Method used

By obtaining the initial detection current value of the detection resistor in each candidate slave device, adjusting the output current value of the variable current source, and updating the candidate slave device according to the difference in the detection current value, until the candidate slave device farthest from the master device is determined and the address is assigned.

Benefits of technology

The resistance of the detection resistor is reduced, the delay of the slave device is reduced, and the reliability of communication and the stability of address allocation are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116346782B_ABST
    Figure CN116346782B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an address allocation method and device, a bus system, a master device and a medium. The method comprises: obtaining initial detection current values of detection resistors in each candidate slave device; adjusting output current values of variable current sources in each candidate slave device, and obtaining detection current values of the detection resistors in each candidate slave device; updating the candidate slave device according to differences between the detection current values and the initial detection current values of the detection resistors in each candidate slave device; performing the adjustment of the output current values of the variable current sources in each candidate slave device and the obtaining of the detection current values of the detection resistors in each candidate slave device at least twice until the number of the candidate slave devices is one, determining that the candidate slave device is the farthest candidate slave device from the master device; and allocating an address to each candidate slave device based on the farthest candidate slave device. The method can reduce the latency of the slave device and improve the reliability of communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of automobile bus systems, and in particular to an address allocation method, apparatus, bus system, master device, and medium. Background Art

[0002] In the control system of automotive electronic equipment, the master device usually transmits control signals through a bus, and the control units of each slave device are interconnected. The Local Interconnect Network (LIN) is a low-cost serial communication network that can realize the control of distributed electronic systems in automobiles. The LIN bus is an auxiliary bus network. In scenarios where the Controller Area Network (CAN) bus is not required and in multi-functional scenarios, such as communication between automotive ambient lights, the use of the LIN bus can greatly save costs. The LIN bus system includes multiple slave devices. The master device needs to selectively drive one or more slave devices, so addresses need to be assigned to the slave devices.

[0003] In the prior art, two different current sources are provided in the slave device, which inject current at different time points to measure the current flowing through the internal resistor. The slave device farthest from the master device is determined based on the current flowing through the internal resistor, and then an address is assigned.

[0004] However, in the existing technology, the maximum external driving current of the master device is 20mA, which limits the current passing through the internal resistor. Therefore, it is necessary to set an internal resistor with a larger resistance value. In the daisy chain structure of the LIN bus system, the internal resistor in the slave device may cause a delay in the farthest slave device, resulting in reduced communication reliability. Summary of the Invention

[0005] The embodiments of the present application provide an address allocation method, apparatus, bus system, master device, and medium, which can reduce the delay of slave devices and improve the reliability of communications.

[0006] In a first aspect, an embodiment of the present application provides an address allocation method, which is applied to a bus system, wherein the bus system includes: a master device and multiple slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices includes a detection resistor and a variable current source;

[0007] The method comprises:

[0008] Obtaining an initial detection current value of the detection resistor in each candidate slave device, where the initial detection current value is a current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave devices being slave devices to which no address has been assigned among all the slave devices, and the resistance of the detection resistor being less than or equal to 0.2Ω;

[0009] Adjusting the output current value of the variable current source in each candidate slave device, and obtaining the detection current value of the detection resistor in each candidate slave device, wherein the detection current value is the current value flowing through the detection resistor when the variable current source and the detection resistor are conductive, and the change in the output current value before and after each adjustment is the same;

[0010] updating the candidate slave devices according to a difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value;

[0011] Returning at least twice to perform the step of adjusting the output current value of the variable current source in each candidate slave device, obtaining the detection current value of the detection resistor in each candidate slave device, until the number of candidate slave devices reaches one, and determining that the candidate slave device is the candidate slave device farthest from the master device;

[0012] An address is assigned to each of the candidate slave devices based on the candidate slave device that is farthest from the master device.

[0013] In some embodiments, updating the candidate slave devices according to the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value includes:

[0014] determining, according to a difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value, whether the difference corresponding to each candidate slave device meets a preset condition;

[0015] The candidate slave device corresponding to the difference value that meets the preset condition is determined as the new candidate slave device.

[0016] In some embodiments, satisfying a preset condition includes: the difference being less than or equal to a preset current difference.

[0017] In some embodiments, before adjusting the output current value of the variable current source in each candidate slave device, the method further includes:

[0018] Determine the candidate slave device corresponding to the difference that does not meet the preset condition as a candidate slave device to be disconnected;

[0019] The variable current source in the candidate slave device to be disconnected is controlled to be disconnected from the detection resistor.

[0020] In some embodiments, before obtaining the initial detection current value of the detection resistor in each candidate slave device, the method further includes:

[0021] determining the number of the output current values ​​according to the clock signal of each candidate slave device and a preset allocation time threshold;

[0022] determining each output current value of the variable current source according to the number of the output current values;

[0023] The variable current sources are configured based on the order of the output current values ​​from small to large.

[0024] In some embodiments, determining the number of output current values ​​according to the clock signal of each candidate slave device and a preset allocation time threshold comprises:

[0025] Determining, based on the clock signals of the candidate slave devices, a minimum pulse width and a maximum pulse width of each of the clock signals;

[0026] determining, based on the minimum pulse width and the maximum pulse width, the time for which the variable current source maintains the same output current value;

[0027] The number of the output current values ​​is determined according to the time during which the variable current source continuously outputs the same current value and the preset allocation time threshold.

[0028] In some embodiments, determining each output current value of the variable current source according to the number of the output current values ​​includes:

[0029] Each output current value of the variable current source is determined according to a maximum current value that the master device can withstand and the number of the output current values.

[0030] In some embodiments, before obtaining the initial detection current value of the detection resistor in each candidate slave device, the method further includes:

[0031] generating an addressing command and sending the addressing command to each of the slave devices, wherein the slave device is configured to read the address according to the addressing command;

[0032] determining whether each of the slave devices has been assigned an address based on the address reading result sent by each of the slave devices;

[0033] The slave device to which an address is not assigned is determined as the candidate slave device.

[0034] In a second aspect, an embodiment of the present application provides an address allocation device, which is applied to a bus system, wherein the bus system includes a master device and multiple slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices includes a detection resistor and a variable current source;

[0035] The device comprises:

[0036] an acquisition module, configured to acquire an initial detection current value of the detection resistor in each candidate slave device, the initial detection current value being a current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device being a slave device to which an address has not been assigned among all the slave devices, and the resistance of the detection resistor being less than or equal to 0.2Ω;

[0037] a determination module, configured to adjust the output current value of the variable current source in each candidate slave device and obtain the detection current value of the detection resistor in each candidate slave device, wherein the detection current value is the current value flowing through the detection resistor when the variable current source and the detection resistor are conductive, and the change in the output current value before and after each adjustment is the same; update the candidate slave device according to the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value; return at least twice to execute the adjustment of the output current value of the variable current source in each candidate slave device and obtain the detection current value of the detection resistor in each candidate slave device until the number of candidate slave devices reaches one, and determine that the candidate slave device is the candidate slave device farthest from the master device;

[0038] The allocation module is configured to allocate an address to each of the candidate slave devices based on the candidate slave device farthest from the master device.

[0039] In a third aspect, an embodiment of the present application provides a bus system, comprising: a master device and multiple slave devices, each of the slave devices being connected to the master device via a bus, and each of the slave devices comprising a detection resistor and a variable current source;

[0040] The main device is used to execute the steps of any method provided in the first aspect.

[0041] In a fourth aspect, an embodiment of the present application provides a main device, including a processor, the processor being configured to execute a computer program stored in a memory, and implementing any one of the methods provided in the first aspect when the processor executes the computer program.

[0042] In a fifth aspect, an embodiment of the present application provides a computer storage medium having a computer program stored thereon, which implements the steps of any method provided in the first aspect when the computer program is executed by a processor.

[0043] In the technical solution of the embodiment of the application, the initial detection current value of the detection resistor in each candidate slave device is obtained, the initial detection current value is the current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device is a slave device that has not been assigned an address among all slave devices, and the resistance value of the detection resistor is less than or equal to 0.2Ω; the output current value of the variable current source in each candidate slave device is adjusted, and the detection current value of the detection resistor in each candidate slave device is obtained, the detection current value is the current value flowing through the detection resistor when the variable current source is connected to the detection resistor, and the change of the output current value before and after each adjustment is the same; the candidate slave device is updated according to the difference between the detection current value and the initial detection current value of the detection resistor in each candidate slave device; the output current value of the variable current source in each candidate slave device is adjusted at least twice, and the detection current value of the detection resistor in each candidate slave device is obtained until the number of candidate slave devices is one, and the candidate slave device is determined to be the candidate slave device farthest from the master device; and addresses are assigned to each candidate slave device based on the candidate slave device farthest from the master device. In this way, the resistance value of the detection resistor can be reduced, the delay caused by the detection resistor to the slave device can be reduced, and the reliability of communication can be improved. In addition, because the change of the output current value before and after each adjustment is the same, the output current value of the variable current source can be raised in a step change manner, and the problem of unstable address assignment caused by the low resistance value of the detection resistor can be avoided, thereby improving the stability of address assignment.

[0044] The above description is only a summary of the technical solutions of the embodiments of the application, in order to more clearly understand the technical means of the embodiments of the application, the embodiments of the application can be implemented according to the content of the description, and in order to make the above and other purposes, characteristics and advantages of the embodiments of the application more obvious and easy to understand, the specific embodiments of the application are described below. BRIEF DESCRIPTION OF DRAWINGS

[0045] In order to more clearly illustrate the technical solutions of the embodiments of the application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creating labor.

[0046] Figure 1 It is a structural schematic diagram of a bus system in the prior art;

[0047] Figure 2 It is a structural schematic diagram of another bus system in the prior art;

[0048] Figure 3 It is a structural schematic diagram of a bus system provided by the embodiments of the application;

[0049] Figure 4 A flowchart of an address allocation method provided in an embodiment of the present application;

[0050] Figure 5 A flowchart of another address allocation method provided in an embodiment of the present application;

[0051] Figure 6 A flowchart of another address allocation method provided in an embodiment of the present application;

[0052] Figure 7 A flowchart of another address allocation method provided in an embodiment of the present application;

[0053] Figure 8 A timing diagram of address allocation provided in an embodiment of the present application;

[0054] Figure 9 A state diagram of address allocation provided in an embodiment of the present application;

[0055] Figure 10 A schematic diagram of the structure of an address allocation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0058] The terms "comprises", "comprising" and "having" and any variations thereof in the specification, claims and drawings of this application are intended to cover but not exclude other contents. The word "a" or "an" does not exclude the presence of a plurality.

[0059] References to "embodiments" herein mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase "embodiment" in various places in the specification does not necessarily refer to the same embodiment, nor does it necessarily refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0060] The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order, and may explicitly or implicitly include one or more such features.

[0061] In the description of this application, unless otherwise specified, "plurality" means more than two (including two), and similarly, "multiple groups" means more than two (including two).

[0062] In the description of this application, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood broadly. For example, "connected" or "connected" in a mechanical structure can refer to a physical connection. For example, a physical connection can be a fixed connection, such as a fixed connection via a fixing member, such as a screw, bolt, or other fixing member. A physical connection can also be a detachable connection, such as a mutual snap-fit ​​connection. A physical connection can also be an integral connection, such as a connection formed by welding, bonding, or integral molding. "Connected" or "connected" in a circuit structure can refer not only to a physical connection but also to an electrical connection or a signal connection. For example, it can be a direct connection, i.e., a physical connection, or an indirect connection through at least one intermediate element, as long as the circuit is interconnected. It can also refer to internal communication between two elements. A signal connection can refer to a signal connection through a circuit or a signal connection through a media medium, such as radio waves. Those skilled in the art will understand the specific meanings of the above terms in this application.

[0063] Figure 1 FIG. 1 is a structural diagram of a bus system in the prior art, such as Figure 1 As shown, the bus system includes a master device 10 and multiple slave devices 20. All slave devices 20 are connected to the master device 10 via a bus, and each slave device 20 is electrically connected to the bus in a daisy-chain manner. The number of slave devices 20 can be a positive integer greater than or equal to 2. For example, the number of slave devices 20 can be 15, and this embodiment of the application does not impose any specific limitation on this.

[0064] For example, Figure 2 FIG. 1 is a schematic diagram of another bus system in the prior art. Figure 2 for Figure 1 Based on the illustrated embodiment, the slave device 20 includes a first current source I and a second current source I'. The first current source I is electrically connected to the master device 10 via a first switch S', and the second current source I' is electrically connected to the master device 10 via a second switch S". Furthermore, both the first current source I and the second current source I' are electrically connected to the bus BUS via a diode. If the first switch S' is closed, the first current source I is connected to the slave device 20, i.e., the first current source I is connected to the bus system. If the second switch S' is closed, the second current source I' is connected to the slave device 20, i.e., the second current source I' is connected to the bus system. Furthermore, the first switch S' and the second switch S' are not closed at the same time.

[0065] The slave device 20 also includes a detection resistor R s , the bus BUS will sequentially connect all the detection resistors R s Each detection resistor R s The two ends of the differential amplifier AMP are electrically connected to the positive and negative input terminals of the differential amplifier AMP, and the output terminal of the differential amplifier AMP is electrically connected to the analog-to-digital converter ADC. In this way, the differential amplifier AMP can detect the current flowing through the detection resistor R s The voltage drop generated by the current is amplified and transmitted to the analog-to-digital converter ADC. The analog-to-digital converter ADC can obtain the current flowing through the detection resistor R based on the received amplified voltage drop. s When the current source is connected to the slave device 20, the current flowing through each detection resistor R s The magnitude of the current is related to the detection resistor R s The distance between the main device 10 is negatively correlated to the detection resistance R s The greater the distance between the slave device 20 and the master device 10, the greater the detection resistance R s The smaller the current value, the smaller the detection resistor R s The current value can be used to locate the slave device 20 farthest from the master device 10, and based on this, addresses are assigned to each slave device 20.

[0066] Figure 1 and Figure 2 In the bus system shown, the maximum external driving current of the master device 10 is 20mA, which limits the current flowing through the detection resistor R s The current is large, so a larger resistance detection resistor R is required. s However, in the bus system, the sense resistor R s When the resistance value is large, it may cause a delay in the farthest slave device 20. For example, the detection resistor R in each slave device 20 sThe resistance value of each is 1Ω. The bus system includes 15 slave devices 20. Thus, the farthest slave device 20 is subjected to a resistance of 15Ω, which causes serious waveform distortion and even bus system communication errors, thereby reducing communication reliability.

[0067] In order to solve the above problems, the present application provides an address allocation method, by obtaining the initial detection current value of the detection resistor in each candidate slave device, the initial detection current value is the current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device is a slave device that has not been assigned an address among all slave devices, and the resistance of the detection resistor is less than or equal to 0.2Ω; adjusting the output current value of the variable current source in each candidate slave device, and obtaining the detection current value of the detection resistor in each candidate slave device, the detection current value is the current value flowing through the detection resistor when the variable current source is connected to the detection resistor, and the output before and after each adjustment is adjusted. The changes in current values ​​are all the same; the candidate slave devices are updated based on the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value; the output current value of the variable current source in each candidate slave device is adjusted at least twice to obtain the detection current value of the detection resistor in each candidate slave device until the number of candidate slave devices is one, and the candidate slave device is determined to be the candidate slave device farthest from the master device; based on the candidate slave device farthest from the master device, an address is assigned to each candidate slave device, thereby reducing the resistance of the detection resistor and reducing the delay caused by the detection resistor to the slave device, thereby improving the reliability of communication. In addition, since the changes in the output current value before and after each adjustment are the same, the output current value of the variable current source can be raised in a step-by-step manner, which can avoid the problem of unstable address allocation caused by the low resistance of the detection resistor, thereby improving the stability of the address allocation.

[0068] Figure 3 A schematic diagram of the structure of a bus system is provided for an embodiment of the present application, such as Figure 3 As shown, the bus system 100 includes: a master device 10 and multiple slave devices 20, each slave device 20 is connected to the master device 10 via a bus BUS, and each slave device 20 includes a detection resistor R s and a variable current source I".

[0069] Exemplarily, the bus system 100 includes: a master device 10 and n slave devices 20, for example, n can be 15. The slave device 20 includes a detection resistor R s and a variable current source I", the output current value of the variable current source I" can change in steps. For example, the output current value of the variable current source I" ranges from 0mA to 20mA, and the change between two adjacent output current values ​​is 0.5mA. The main device 10 can execute the steps of any method embodiment provided in the present application.

[0070] The technical solutions of the method embodiments of this application are described in detail below with several specific implementation methods.

[0071] Figure 4 A flowchart of an address allocation method provided in an embodiment of the present application is provided. Figure 4 The method embodiment shown is applied to Figure 3 In the bus system 100 shown, the specific steps of the address allocation method include:

[0072] S101 , obtaining an initial detection current value of a detection resistor in each candidate slave device.

[0073] The initial detection current value is the current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor. The candidate slave device is a slave device that has not been assigned an address among all slave devices. The resistance of the detection resistor is less than or equal to 0.2Ω.

[0074] For example, the candidate slave devices may be some or all of the slave devices in the bus system, depending on whether each slave device has been assigned an address. If no slave devices in the bus system have been assigned an address, all of the slave devices are determined to be candidate slave devices. If some of the slave devices in the bus system have not been assigned an address, these slave devices are determined to be candidate slave devices. The resistance of the detection resistor can be set to be relatively small, for example, the resistance of the detection resistor can be less than or equal to 0.2Ω.

[0075] First, if Figure 3 As shown, the pull-up switch S in each candidate slave device is closed, and the voltage on the bus BUS is pulled up through the pull-up resistor R. At the same time, the first switch S' in each candidate slave device is opened. In this way, the variable current source I" is not connected to the bus system 100. At this time, the current on the bus BUS flows through the detection resistor R in each candidate slave device. s Through the differential amplifier AMP and analog-to-digital converter ADC in each candidate slave device, the current flowing through the detection resistor R s The current size of each candidate slave device can be collected to detect the resistance R s The initial detection current value of each candidate slave device can be obtained by s The initial detection current value.

[0076] S102 , adjusting the output current value of the variable current source in each candidate slave device, and obtaining the detection current value of the detection resistor in each candidate slave device.

[0077] The detection current value is the current value flowing through the detection resistor when the variable current source and the detection resistor are turned on. The change in the output current value before and after each adjustment is the same.

[0078] Secondly, when the pull-up switch in each candidate slave device is currently closed and the first switch is disconnected, closing the first switch in each candidate slave device and disconnecting the pull-up switch can turn on the variable current source and the detection resistor in each candidate slave device, that is, connecting the variable current source in each candidate slave device to the bus system, and the output current value of the variable current source is I1, that is, the change in the output current value before and after adjustment is I1. When the first switch in each candidate slave device is currently closed, if the output current value of the variable current source in each candidate slave device is I1, the output current value of the variable current source in each candidate slave device can be adjusted to I2, and the change in the output current value before and after the adjustment is I2-I1; if the output current value of the variable current source in each candidate slave device is I2, the output current value of the variable current source in each candidate slave device can be adjusted to I3, and the change in the output current value before and after the adjustment is I3-I2; if the output current value of the variable current source in each candidate slave device is Ia, the output current value of the variable current source in each candidate slave device can be adjusted to Ib, and the change in the output current value before and after the adjustment is Ib-Ia, and I1=I2-I1=I3-I2=Ib-Ia. In this way, the output current value of the variable current source can be increased in a step-by-step manner, which can avoid the problem of unstable address allocation when the resistance value of the detection resistor is low.

[0079] After adjusting the output current value of the variable current source in each candidate slave device, the magnitude of the current currently flowing through the detection resistor in each candidate slave device can be obtained, that is, the detection current value of the detection resistor in each candidate slave device can be obtained.

[0080] S103 , updating the candidate slave devices according to the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value.

[0081] Return and execute S102 twice.

[0082] Based on the above embodiment, if the initial detection current value of the detection resistor in any candidate slave device A is i0, and the output current value of the variable current source in candidate slave device A is i1, the detection current value of the detection resistor in candidate slave device A is i1. The difference between the initial detection current value i0 and the detection current value i1 of the detection resistor in candidate slave device A can be determined, i.e., i1-i0. Based on the difference i1-i0 corresponding to each candidate slave device, some or all of the candidate slave devices are determined as new candidate slave devices.

[0083] For the new candidate slave device, the output current value of the variable current source in each candidate slave device is adjusted to I2, the detection current value of the detection resistor in the candidate slave device is i2, and based on the difference i2-i0 between the initial detection current value i0 and the detection current value i2 of the detection resistor R in each candidate slave device, part or all of the candidate slave devices are determined as the new candidate slave device. In this way, the first return execution S102 is realized.

[0084] For the new candidate slave device, the output current value of the variable current source in each candidate slave device is adjusted to I3, the detection current value of the detection resistor in the candidate slave device is i3, and based on the difference i3-i0 between the initial detection current value i0 and the detection current value i3 of the detection resistor in each candidate slave device, part or all of the candidate slave devices are determined as the new candidate slave device. In this way, the second return execution S102 is realized.

[0085] In summary, three times of S102-S103 are equivalent to be executed, wherein the first time of executing S102, the variable current source in each candidate slave device is turned on, and when the output current value of the variable current source is I1, the first detection current value i1 is obtained, and the first time of updating the candidate slave device is performed. The second time of executing S102, the output current value of the variable current source in each candidate slave device is adjusted to I2, the second detection current value i2 is obtained, and the second time of updating the candidate slave device is performed. The third time of executing S102, the output current value of the variable current source in each candidate slave device is adjusted to I3, the second detection current value i3 is obtained, and the third time of updating the candidate slave device is performed.

[0086] S104, determining whether the number of candidate slave devices is one.

[0087] If yes, S105 is executed; if no, S102 is returned.

[0088] After the third time of updating the candidate slave device, it is determined whether the number of the updated candidate slave devices is one, if the number of the candidate slave devices is one, the updated candidate slave device is the candidate slave device farthest from the master device; if the number of the candidate slave devices is greater than one, it is needed to return to execute S102 again, to adjust the output current value of the variable current source in each candidate slave device again, to update the candidate slave device again, to determine whether the number of the candidate slave device is one again, until the number of the candidate slave device is one.

[0089] For example, if the third time the candidate slave devices are updated, the candidate slave devices are B, C and D, and the number of candidate slave devices is greater than one, the output current value of the variable current source of each of the candidate slave devices B, C and D is adjusted again, the detection current value of the detection resistor of each of the candidate slave devices B, C and D is obtained, and the candidate slave devices are updated for the fourth time. After the candidate slave devices are updated for the fourth time, the candidate slave devices are C and D, and the number of candidate slave devices is greater than one, the output current value of the variable current source of each of the candidate slave devices C and D is adjusted again, the detection current value of the detection resistor of each of the candidate slave devices C and D is obtained, and the candidate slave devices are updated for the fifth time. After the candidate slave devices are updated for the fifth time, the candidate slave devices are D.

[0090] It should be noted that the number of times of executing S102-S103 is only illustrated by taking five times as an example in the embodiment of the application. In actual application, the number of times of executing S102-S103 is not specifically limited, and the number of times of executing S102-S103 is greater than or equal to three.

[0091] S105, determining the candidate slave device farthest from the master device.

[0092] Based on the above embodiment, after the candidate slave devices are updated for the fifth time, the number of candidate slave devices is one, and the candidate slave device is D, it can be determined that the candidate slave device D is the candidate slave device farthest from the master device.

[0093] S106, assigning an address to each candidate slave device based on the candidate slave device farthest from the master device.

[0094] Based on the above embodiment, the candidate slave device farthest from the master device can be located, and then an address can be assigned to the farthest candidate slave device. Then, an address is assigned to the adjacent candidate slave device of the farthest candidate slave device, and so on, and an address can be assigned to each candidate slave device, so as to ensure that the master device and the slave device can normally communicate.

[0095] The present application provides an address allocation method, by obtaining the initial detection current value of the detection resistor in each candidate slave device, the initial detection current value is the current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device is a slave device that has not been assigned an address among all slave devices, and the resistance of the detection resistor is less than or equal to 0.2Ω; adjusting the output current value of the variable current source in each candidate slave device, and obtaining the detection current value of the detection resistor in each candidate slave device, the detection current value is the current value flowing through the detection resistor when the variable current source is connected to the detection resistor, and the output current value before and after each adjustment is adjusted. The changes are all the same; the candidate slave devices are updated based on the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value; the output current value of the variable current source in each candidate slave device is adjusted at least twice to obtain the detection current value of the detection resistor in each candidate slave device until the number of candidate slave devices is one, and the candidate slave device is determined to be the candidate slave device farthest from the master device; based on the candidate slave device farthest from the master device, an address is assigned to each candidate slave device, so that the resistance of the detection resistor can be reduced, and the delay caused by the detection resistor to the slave device can be reduced, thereby improving the reliability of communication. In addition, since the change in the output current value before and after each adjustment is the same, the output current value of the variable current source can be raised in a step-by-step manner, which can avoid the problem of unstable address allocation caused by the low resistance value of the detection resistor, thereby improving the stability of the address allocation.

[0096] Figure 5 A flowchart of another address allocation method provided in an embodiment of the present application is provided. Figure 5 for Figure 4 Based on the illustrated embodiment, a possible implementation method for executing S103 is described in detail as follows:

[0097] S201 , determining whether the difference value corresponding to each candidate slave device meets a preset condition based on the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value.

[0098] For example, the preset condition may be a preset current difference i th , for example, the preset current difference i th It can be 10mA. The preset condition can be greater than or equal to the preset current difference i th For example, based on the above embodiment, the preset condition may be greater than or equal to 10 mA.

[0099] Based on the initial detection current value i0 and the detection current value i of the detection resistor in each candidate slave device, the difference i-i0 between the initial detection current value i0 and the detection current value i of the detection resistor in each candidate slave device can be determined, that is, the difference i-i0 corresponding to each candidate slave device. The difference i-i0 corresponding to each candidate slave device is respectively compared with the preset current difference i th Compare, if i-i0≥i th , then it is determined that the preset conditions are met; if i-i0 th , it is determined that the preset conditions are not met.

[0100] S202 : Determine the candidate slave device corresponding to the difference that meets the preset condition as a new candidate slave device.

[0101] Based on the result of whether the difference value corresponding to each candidate slave device meets the preset condition, all difference values ​​that meet the preset condition can be screened out, and the candidate slave devices corresponding to each of these difference values ​​can be determined as new candidate slave devices. For example, if the difference value corresponding to candidate slave device A meets the preset condition, the difference value corresponding to candidate slave device B meets the preset condition, and the difference value corresponding to candidate slave device C does not meet the preset condition, then candidate slave devices A and B can be determined as new candidate slave devices.

[0102] The main purpose of the embodiments of this application is to locate the candidate slave device farthest from the master device. Since the difference value corresponding to the candidate slave device decreases as the distance between the candidate slave device and the master device increases, the present invention proposes selecting the candidate slave device corresponding to the difference value less than the preset current difference value as the new candidate slave device. This effectively narrows the selection range of the farthest candidate slave device, ultimately achieving the goal of locating the candidate slave device farthest from the master device.

[0103] Based on the above embodiment, before executing S102 for the second time, the following steps may be performed:

[0104] S301 : Determine candidate slave devices corresponding to differences that do not meet a preset condition as candidate slave devices to be disconnected.

[0105] Based on whether the difference value corresponding to each candidate slave device meets the preset condition, all difference values ​​that do not meet the preset condition can be screened out, and the candidate slave devices corresponding to these difference values ​​are determined as candidate slave devices to be disconnected. For example, based on the above embodiment, candidate slave device C can be determined as a candidate slave device to be disconnected.

[0106] S301 , controlling a variable current source in a candidate slave device to be disconnected to be disconnected from a detection resistor.

[0107] ​Exemplarily, the first switch in the to-be-disconnected candidate slave device can be disconnected, so that the variable current source in the to-be-disconnected candidate slave device is disconnected from the detection resistor. For example, based on the above embodiment, the first switch in the candidate slave device C is disconnected, so that the variable current source in the candidate slave device C is disconnected from the detection resistor.

[0108] The to-be-disconnected candidate slave device is the difference set of the set of candidate slave devices before the update and the set of candidate slave devices after the update. Since the output current value of the variable current source in the candidate slave device after the update is increased, disconnecting the variable current source in the to-be-disconnected candidate slave device from the detection resistor, that is, not connecting the variable current source in the to-be-disconnected candidate slave device to the bus system, can avoid the current provided by the variable current source in the bus system exceeding the driving capability current of the master device.

[0109] In the embodiment of the present application, the candidate slave device corresponding to the difference value that does not meet the preset condition is determined as the to-be-disconnected candidate slave device, and the variable current source in the to-be-disconnected candidate slave device is controlled to be disconnected from the detection resistor, which can avoid the current provided by the variable current source in the bus system exceeding the driving capability current of the master device, and can improve the stability of communication.

[0110] Figure 6 A flowchart of another address allocation method provided by the embodiment of the present application is shown in Figure 6 For Figure 5 On the basis of the embodiment shown in the figure, the address allocation method further includes the following steps before S101 is performed:

[0111] S401, determining the number of output current values according to the clock signals of the candidate slave devices and a preset allocation time threshold.

[0112] Exemplarily, due to the limitation of the slave device process, there is jitter between the clock signals of each slave device, that is, there is a difference between the clock signals of each candidate slave device. For example, the pulse width of the clock signal of the candidate slave device A is T1, the pulse width of the clock signal of the candidate slave device B is T2, and the pulse width of the clock signal of the candidate slave device C is T3, and T1≠T2≠T3.

[0113] As a possible implementation manner when S401 is performed, a specific description is as follows:

[0114] S4011, determining the minimum pulse width and the maximum pulse width in each clock signal according to the clock signals of each candidate slave device.

[0115] Exemplarily, if it can be determined that T1>T2>T3 on the basis of the above embodiment, the minimum pulse width of the clock signal of all candidate slave devices can be determined as T3, and the maximum pulse width can be determined as T1.

[0116] S4012: Determine the time for which the variable current source maintains the same output current value based on the minimum pulse width and the maximum pulse width.

[0117] For example, it can be determined that the time for the variable current source to maintain the same output current value is greater than the maximum pulse width, and at the same time, the time for the variable current source to maintain the same output current value needs to be less than twice the minimum pulse width. For example, based on the above embodiment, the time T for the variable current source to maintain the same output current value satisfies: T3 <T<2*T1。如此,在同一输出电流值的维持时间内,可以确保每个候选从设备中的可变电流源均可以向总线系统提供稳定的电流,从而能够获取到比较准确的检测电流值。

[0118] S4013 , determining the number of output current values ​​according to the time during which the variable current source maintains the same output current value and a preset allocation time threshold.

[0119] For example, the preset allocation time threshold is the time required to allocate an address under normal circumstances. The preset allocation time threshold can be an empirical value or a relatively reasonable time required for address allocation obtained based on experiments. Based on the preset allocation time threshold and the variable current source's continuous output current value, a ratio of the preset allocation time threshold to the variable current source's continuous output current value can be determined. The number of output current values ​​can be determined based on the ratio of the preset allocation time threshold to the variable current source's continuous output current value.

[0120] For example, the preset allocation time threshold is T th , the variable current source maintains the same output current value for a time T, if T th / T is an integer, which can determine T th / T is the number of output current values; if T th / T is a non-integer, it can be determined to be greater than T th The minimum integer of / T is the number of output current values.

[0121] In an embodiment of the present application, the minimum pulse width and the maximum pulse width in each clock signal are determined based on the clock signal of each candidate slave device; the time for which the variable current source maintains the same output current value is determined based on the minimum pulse width and the maximum pulse width; the number of output current values ​​is determined based on the time for which the variable current source maintains the same output current value and a preset allocation time threshold. This ensures that the variable current source in each candidate slave device can provide a stable current to the bus system within the maintenance time of the same output current value, thereby enabling a relatively accurate detection current value to be obtained.

[0122] S402 , determining each output current value of the variable current source according to the number of output current values.

[0123] As a possible implementation of S402 , each output current value of the variable current source may be determined according to a maximum current value that the master device can withstand and the number of output current values.

[0124] For example, the maximum current the master device can withstand is 20mA. Thus, the output current of the variable current source is less than 20mA. For example, the output current of the variable current source is less than or equal to 16mA. The range from 0mA to 16mA can be evenly divided into multiple steps, where the number of steps is the number of output current values, and the current value corresponding to each step is an output current value.

[0125] For example, based on the above embodiment, the number of output current values ​​is 32, and the output current value starts from 0.5 mA and increases by 0.5 mA at each step until it reaches 16 mA.

[0126] S403 , configuring a variable current source based on the order of output current values ​​from small to large.

[0127] Exemplarily, all output current values ​​determined in the above embodiments are arranged in order from small to large, and each variable current source is configured based on the order of output current values ​​from small to large, so that the first output current value of the variable current source during operation is 0.5mA, the second output current value is 1mA, and so on, so that the next output current value of the variable current source is 0.5mA higher than the previous output current value, until the last output current value of the variable current source is 16mA.

[0128] Figure 7 A flowchart of another address allocation method provided in an embodiment of the present application is shown below. Figure 7 for Figure 5 Based on the embodiment shown, before executing S101, the address allocation method further includes the following steps:

[0129] S501: Generate an addressing command and send it to each slave device.

[0130] The slave device is used to read the address according to the addressed command.

[0131] For example, if the master device needs to communicate with the slave device, it will generate an addressing command and send the addressing command to all slave devices electrically connected to the master device. After receiving the addressing command, the slave device can read the address of the slave device.

[0132] S502: Determine whether each slave device has been assigned an address based on the address reading result sent by each slave device.

[0133] Exemplarily, if the address is not read from the device, the address reading result is empty, and it can be determined that the slave device has not been assigned an address; if the address is read from the device, the address reading result is the address of the slave device, and it can be determined that the slave device has been assigned an address.

[0134] S503: Determine a slave device to which an address is not assigned as a candidate slave device.

[0135] Based on the above embodiment, there is no need to allocate addresses again for slave devices that have been allocated addresses. In this way, slave devices that have not been allocated addresses can be selected as candidate slave devices, and addresses are allocated only to these slave devices that have not been allocated addresses, thereby avoiding repeated address allocation and improving the efficiency of address allocation.

[0136] As a specific embodiment of the present application, the address allocation process can be used Figure 8 The timing diagram and Figure 9 The state diagram description can be divided into 5 processes:

[0137] (1) The master device sends an automatic addressing command, and the slave device receives the automatic addressing interrupt and starts addressing. For slave devices without automatic addressing function, the state remains unchanged. After starting automatic addressing, all slave devices turn off the pull-up resistor and variable current source, and the slave device determines whether the address has been assigned.

[0138] (2) If the address has been assigned, wait for the addressing command to end and restore to the default state. Otherwise, the voltage on the detection resistor is amplified by the differential amplifier AMP and sent to the ADC, which converts the offset current of the detection resistor and marks it as I0.

[0139] (3) Start the configuration by step-by-step adding the variable current source from the device. First, all the slave devices are configured with current source I1, and the measured current on the detection resistor is measured as I1, and IDIFF1 is calculated as I1-I0. If IDIFF1 is greater than the set threshold, the variable current source is turned off, and the addressing command is waited for to end before restoring the default state. If IDIFF1 is less than the set threshold, the variable current source is increased to I2, and the measured current on the detection resistor is measured as I2, and IDIFF2 is calculated as I2-I0. If IDIFF2 is greater than the set threshold, the variable current source is turned off, and the addressing command is waited for to end before restoring the default state. If IDIFF2 is less than the set threshold, the variable current source is continued to be increased step by step to I3, and so on until the maximum current In is reached, and IDIFFn is calculated as In-I0.

[0140] (4) After the variable current source increases to its maximum current, IDIFFn is greater than the set threshold, the variable current source is turned off, and the default state is restored after the addressing command is completed. If IDIFFn is less than the set threshold, the slave device is identified as the slave device farthest from the master device among all slave devices that have not been assigned an address. The judgment result is stored in its RAM, and the master device assigns an address to it. Finally, the default state is restored, all variable current sources are turned off, and the pull-up resistor of the slave device is turned on.

[0141] (5) Check whether all slave devices have been assigned addresses.

[0142] The LIN Bus Shunt Slave Node Position Detection Revision 1.0, released by the LIN Alliance, specifies a maximum current of 20mA for a master device to drive a slave device. The following example illustrates the above steps. For example, with a pull-up current source stepping by 0.5mA, a maximum current of 16mA, and a comparison threshold current set at 10mA, and 15 slave devices to be assigned addresses, the current flowing through the sense resistor for each slave device at different time points is given in Table 1.

[0143] Table 1 Current on the sense resistor

[0144]

[0145]

[0146] At time t0 above, the offset current I0 is measured. At t1, all slave devices add 0.5mA, and the current on all slave devices does not exceed 10mA. Therefore, at t2, the current sources of all slave devices are still on. At t2, the slave current source becomes 1mA, and the current of slaves 4 to 1 exceeds 10mA. At t3, the current source of slaves 4 to 1 is turned off. At t3, the current source becomes 1.5mA, and the current of slaves 8 to 1 exceeds 10mA. The current source is turned off at the next moment. At t4, the current source becomes 2mA, and the current of slaves 9 to 1 exceeds 10mA. The current source is turned off at the next moment, and the current source of the unselected slaves continues to increase. At tn, the current source becomes 16mA, and the current of slaves 14 to 1 exceeds 10mA. Finally, only slave 15 is not selected. It is identified as the slave farthest from the master device among the slaves without assigned addresses, and then an address is assigned to slave 15. This process repeats until all slave devices are assigned addresses and automatic addressing is completed.

[0147] In practical applications, this application needs to consider the clock errors between different slave devices. When calculating the time of different steps, a certain clock margin must be considered.

[0148] The embodiment of the present application also provides an address allocation device, Figure 10 A structure diagram of an address allocation device provided in an embodiment of the present application, Figure 10 The address allocation device shown is applied to a bus system as shown Figure 3 The address allocation device includes:

[0149] The acquisition module 110 is configured to acquire an initial detection current value of the detection resistor in each candidate slave device, the initial detection current value being a current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device being a slave device that has not been allocated an address among all the slave devices, and the detection resistor having a resistance value less than or equal to 0.2 Ω.

[0150] The determination module 120 is configured to adjust an output current value of the variable current source in each candidate slave device, and acquire a detection current value of the detection resistor in each candidate slave device, the detection current value being a current value flowing through the detection resistor when the variable current source is connected to the detection resistor, the output current value being changed by the same amount before and after each adjustment; update the candidate slave device according to a difference between the detection current value and the initial detection current value of the detection resistor in each candidate slave device; and return at least twice to perform the adjustment of the output current value of the variable current source in each candidate slave device, and the acquisition of the detection current value of the detection resistor in each candidate slave device, until the number of candidate slave devices is one, and the candidate slave device is determined to be the candidate slave device farthest from the master device.

[0151] The allocation module 130 is configured to allocate an address to each candidate slave device based on the candidate slave device farthest from the master device.

[0152] In some embodiments, the determination module 120 is further configured to determine, according to the difference between the detection current value and the initial detection current value of the detection resistor in each candidate slave device, whether the difference corresponding to each candidate slave device satisfies a preset condition; and determine the candidate slave device corresponding to the difference satisfying the preset condition as a new candidate slave device.

[0153] In some embodiments, the satisfaction of the preset condition includes that the difference is less than or equal to a preset current difference value.

[0154] In some embodiments, the determination module 120 is further configured to determine, as a candidate slave device to be disconnected, the candidate slave device corresponding to the difference not satisfying the preset condition; and control the variable current source in the candidate slave device to be disconnected to be disconnected from the detection resistor.

[0155] In some embodiments, the determination module 120 is further used to determine the number of the output current values ​​based on the clock signal of each candidate slave device and a preset allocation time threshold; and determine each output current value of the variable current source based on the number of the output current values.

[0156] The address allocating device further comprises:

[0157] A configuration module is used to configure the variable current source based on the order of the output current values ​​from small to large.

[0158] In some embodiments, the determination module 120 is further used to determine the minimum pulse width and the maximum pulse width in each of the clock signals based on the clock signals of each of the candidate slave devices; determine the time for which the variable current source maintains the same output current value based on the minimum pulse width and the maximum pulse width; and determine the number of the output current values ​​based on the time for which the variable current source maintains the same output current value and the preset allocation time threshold.

[0159] In some embodiments, the determination module 120 is further configured to determine each output current value of the variable current source according to a maximum current value that the master device can withstand and the number of the output current values.

[0160] In some embodiments, the address allocation device further comprises:

[0161] The generating module is used to generate an addressing command and send the addressing command to each of the slave devices, and the slave device is used to read the address according to the addressing command.

[0162] The determination module 120 is further configured to determine whether each of the slave devices has been assigned an address based on the address reading result sent by each of the slave devices; and determine the slave devices that have not been assigned an address as the candidate slave devices.

[0163] An embodiment of the present application further provides a main device, comprising: a processor, the processor being configured to execute a computer program stored in a memory, and implementing the steps of any method embodiment of the present application when the processor executes the computer program.

[0164] An embodiment of the present application further provides a computer storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of any of the above method embodiments are implemented.

[0165] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductors, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by an instruction execution system, device or device or used in combination with it.

[0166] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0167] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0168] The computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or wide area network (WAN) domain, or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0169] Those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments, combinations of features from different embodiments are intended to be within the scope of this application and to form different embodiments. For example, in the claims, any one of the claimed embodiments may be used in any combination.

[0170] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An address allocation method, characterized in that: Applicable to a bus system, the bus system includes a master device and multiple slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices includes a detection resistor and a variable current source; The method comprises: Obtaining an initial detection current value of the detection resistor in each candidate slave device, where the initial detection current value is a current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave devices being slave devices to which no address has been assigned among all the slave devices, and the resistance of the detection resistor being less than or equal to 0.2Ω; Adjusting the output current value of the variable current source in each candidate slave device, and obtaining the detection current value of the detection resistor in each candidate slave device, wherein the detection current value is the current value flowing through the detection resistor when the variable current source and the detection resistor are conductive, and the change in the output current value before and after each adjustment is the same; updating the candidate slave devices according to a difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value; Returning at least twice to perform the step of adjusting the output current value of the variable current source in each candidate slave device, obtaining the detection current value of the detection resistor in each candidate slave device, until the number of candidate slave devices reaches one, and determining that the candidate slave device is the candidate slave device farthest from the master device; assigning an address to each of the candidate slave devices based on the candidate slave device farthest from the master device; Before obtaining the initial detection current value of the detection resistor in each candidate slave device, it also includes: determining the minimum pulse width and the maximum pulse width in each clock signal according to the clock signal of each candidate slave device; determining the time for the variable current source to maintain the same output current value according to the minimum pulse width and the maximum pulse width; determining the number of output current values ​​according to the time for the variable current source to maintain the same output current value and a preset allocation time threshold; determining each output current value of the variable current source according to the number of output current values; and configuring the variable current source based on the order of the output current values ​​from small to large.

2. The method according to claim 1, characterized in that The updating of the candidate slave devices according to the difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value comprises: determining, according to a difference between the detection current value of the detection resistor in each candidate slave device and the initial detection current value, whether the difference corresponding to each candidate slave device meets a preset condition; The candidate slave device corresponding to the difference value that meets the preset condition is determined as the new candidate slave device.

3. The method according to claim 2, characterized in that The satisfying of the preset condition includes: the difference being less than or equal to a preset current difference.

4. The method according to claim 2, characterized in that Before adjusting the output current value of the variable current source in each candidate slave device, the method further includes: Determine the candidate slave device corresponding to the difference that does not meet the preset condition as a candidate slave device to be disconnected; The variable current source in the candidate slave device to be disconnected is controlled to be disconnected from the detection resistor.

5. The method according to claim 1, wherein Determining each output current value of the variable current source according to the number of the output current values ​​includes: Each output current value of the variable current source is determined according to a maximum current value that the master device can withstand and the number of the output current values.

6. The method according to any one of claims 1 to 4, characterized in that Before obtaining the initial detection current value of the detection resistor in each candidate slave device, the method further includes: generating an addressing command and sending the addressing command to each of the slave devices, wherein the slave device is configured to read the address according to the addressing command; determining whether each of the slave devices has been assigned an address based on the address reading result sent by each of the slave devices; The slave device to which an address is not assigned is determined as the candidate slave device.

7. An address allocation device, characterized in that: Applicable to a bus system, the bus system includes a master device and multiple slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices includes a detection resistor and a variable current source; The device comprises: an acquisition module, configured to acquire an initial detection current value of the detection resistor in each candidate slave device, the initial detection current value being a current value flowing through the detection resistor when the variable current source is disconnected from the detection resistor, the candidate slave device being a slave device to which an address has not been assigned among all the slave devices, and the resistance of the detection resistor being less than or equal to 0.2Ω; A determination module is configured to adjust the output current value of the variable current source in each of the candidate slave devices and obtain the detection current value of the detection resistor in each of the candidate slave devices, wherein the detection current value is the current value flowing through the detection resistor when the variable current source and the detection resistor are turned on, and the change in the output current value before and after each adjustment is the same; update the candidate slave device according to the difference between the detection current value of the detection resistor in each of the candidate slave devices and the initial detection current value; return at least twice to execute the adjustment of the output current value of the variable current source in each of the candidate slave devices and obtain the detection current value of the detection resistor in each of the candidate slave devices, until the number of candidate slave devices is The method further comprises: determining that the candidate slave device is the candidate slave device farthest from the master device; and before obtaining the initial detection current value of the detection resistor in each candidate slave device, further comprising: determining, based on the clock signal of each candidate slave device, a minimum pulse width and a maximum pulse width in each clock signal; determining, based on the minimum pulse width and the maximum pulse width, a time for which the variable current source maintains a constant output current value; determining the number of output current values ​​based on the time for which the variable current source maintains a constant output current value and a preset allocation time threshold; determining each output current value of the variable current source based on the number of output current values; and configuring the variable current source based on the order of the output current values ​​from small to large. The allocation module is configured to allocate an address to each of the candidate slave devices based on the candidate slave device farthest from the master device.

8. A bus system, characterized in that: include: A master device and multiple slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices includes a detection resistor and a variable current source; The master device is configured to execute the steps of the method according to any one of claims 1 to 6.

9. A master device, characterized in that: include: A processor, wherein the processor is configured to execute a computer program stored in a memory, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.

10. A computer storage medium, characterized in that The computer storage medium stores a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • LIN bus system and slave automatic addressing method thereof

    CN115086278A