Address allocation method and apparatus, bus system, and master device
By adjusting the detection current value of the slave device in the automobile bus system, determining the slave device farthest from the master device and assigning an address, the delay and reliability problems caused by current limitation in the existing technology are solved, and the stability and reliability of communication are improved. reliability.
Patent Information
- Application Number
- PCT/CN2024/075891
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-27
- Filing Date
- 2024-02-05
- Publication Date
- 2024-10-03
AI Technical Summary
In the automotive bus system, in the existing technology, the maximum external driving current of the master device limits the current of the internal resistor, resulting in reduced delay and communication reliability of the slave device.
By obtaining the initial detection current value of the detection resistor of each candidate slave device, and adjusting the output current value of the variable current source until the number of candidate slave devices is one, determine the candidate slave device farthest from the master device, and assign an address based on this , reduce the resistance of the detection resistor to improve communication reliability.
It effectively reduces the delay of the detection resistor to the slave device, improves the reliability of communication, avoids the problem of unstable address allocation, and improves the stability of address allocation.
Smart Images

Figure CN2024075891_03102024_PF_FP_ABST
Abstract
Description
Address allocation method, device, bus system, and master device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 27, 2023, with application number 202310302407.9 and application name “A method, device, bus system, and master device for allocating addresses,” the entire contents of which are incorporated herein by reference. Technical Field
[0002] 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
[0003] 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.
[0004] 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.
[0005] 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.
[0006] Summary of the Invention
[0007] 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.
[0008] 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;
[0009] The method comprises:
[0010] 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Ω;
[0011] 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;
[0012] 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;
[0013] 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;
[0014] An address is assigned to each of the candidate slave devices based on the candidate slave device that is farthest from the master device.
[0015] 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:
[0016] 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;
[0017] The candidate slave device corresponding to the difference value that meets the preset condition is determined as the new candidate slave device.
[0018] In some embodiments, satisfying a preset condition includes: the difference being less than or equal to a preset current difference.
[0019] In some embodiments, before adjusting the output current value of the variable current source in each candidate slave device, the method further includes:
[0020] Determine the candidate slave device corresponding to the difference that does not meet the preset condition as a candidate slave device to be disconnected;
[0021] The variable current source in the candidate slave device to be disconnected is controlled to be disconnected from the detection resistor.
[0022] In some embodiments, before obtaining the initial detection current value of the detection resistor in each candidate slave device, the method further includes:
[0023] determining the number of the output current values according to the clock signal of each candidate slave device and a preset allocation time threshold;
[0024] determining each output current value of the variable current source according to the number of the output current values;
[0025] The variable current sources are configured based on the order of the output current values from small to large.
[0026] 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:
[0027] 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;
[0028] 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;
[0029] 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.
[0030] In some embodiments, determining each output current value of the variable current source according to the number of the output current values includes:
[0031] 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.
[0032] In some embodiments, before obtaining the initial detection current value of the detection resistor in each candidate slave device, the method further includes:
[0033] 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;
[0034] 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;
[0035] The slave device to which an address is not assigned is determined as the candidate slave device.
[0036] 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;
[0037] The device comprises:
[0038] 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Ω;
[0039] 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;
[0040] The allocation module is configured to allocate an address to each candidate slave device based on the candidate slave device farthest from the master device.
[0041] 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;
[0042] The main device is used to execute the steps of any method provided in the first aspect.
[0043] 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.
[0044] 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.
[0045] In the technical solution of the embodiment of the present application, 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 change of the output current value before and after each adjustment The master device is configured to be the same as the master device; the candidate slave device is 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 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. In this way, the resistance value 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.
[0046] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] FIG1 is a schematic structural diagram of a bus system in the prior art;
[0048] FIG2 is a schematic structural diagram of another bus system in the prior art;
[0049] FIG3 is a schematic diagram of the structure of a bus system provided in an embodiment of the present application;
[0050] FIG4 is a flow chart of an address allocation method provided in an embodiment of the present application;
[0051] FIG5 is a flow chart of another address allocation method provided in an embodiment of the present application;
[0052] FIG6 is a flow chart of another address allocation method provided in an embodiment of the present application;
[0053] FIG7 is a flow chart of another address allocation method provided in an embodiment of the present application;
[0054] FIG8 is a timing diagram of address allocation provided by an embodiment of the present application;
[0055] FIG9 is a state diagram of an address allocation according to an embodiment of the present application;
[0056] FIG10 is a schematic structural diagram of an address allocation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] 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.
[0058] 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.
[0059] 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.
[0060] 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.
[0061] 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.
[0062] 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).
[0063] 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.
[0064] FIG1 is a schematic diagram of the structure of a bus system in the prior art. As shown in FIG1 , 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 present application does not impose any specific limitation on this.
[0065] For example, FIG2 is a schematic diagram of the structure of another bus system in the prior art. FIG2 is based on the embodiment shown in FIG1 , and 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 through a first switch S', and the second current source I' is electrically connected to the master device 10 through a second switch S". In addition, the first current source I and the second current source I' are both electrically connected to the bus BUS through a diode. If the first switch S' is closed, the first current source I is connected to the slave device 20, that is, 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, that is, the second current source I' is connected to the bus system, and the first switch S' and the second switch S' will not be closed at the same time.
[0066] The slave device 20 also includes a detection resistor R s , the bus BUS will sequentially connect all the detection resistors Rs 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.
[0067] In the bus system shown in FIG1 and FIG2, 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 s The 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.
[0068] 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.
[0069] FIG3 is a schematic diagram of the structure of a bus system provided by an embodiment of the present application. As shown in FIG3 , the bus system 100 includes: a master device 10 and multiple slave devices 20, each of which is connected to the master device 10 via a bus BUS, and each of which includes a detection resistor R s and a variable current source I".
[0070] 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.
[0071] The technical solutions of the method embodiments of this application are described in detail below with several specific implementation methods.
[0072] FIG4 is a flow chart of an address allocation method provided in an embodiment of the present application. The method embodiment shown in FIG4 is applied to the bus system 100 shown in FIG3 . The specific steps of the address allocation method include:
[0073] S101 , obtaining an initial detection current value of a detection resistor in each candidate slave device.
[0074] 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Ω.
[0075] 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Ω.
[0076] First, as shown in FIG3 , 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.
[0077] 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.
[0078] 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.
[0079] 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.
[0080] 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.
[0081] 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.
[0082] Return and execute S102 twice.
[0083] 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.
[0084] For each new candidate slave device, the output current value of the variable current source in each candidate slave device is adjusted to I2, and the detection current value of the detection resistor in each candidate slave device is i2. 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, some or all of the candidate slave devices are determined to be new candidate slave devices. In this way, the first return to S102 is achieved.
[0085] 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 obtained as 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, some or all of the candidate slave devices are determined to be new candidate slave devices. In this way, the second return to S102 is achieved.
[0086] In summary, this is equivalent to executing S102-S103 three times. During the first execution of 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 update of the candidate slave device is performed. During the second execution of 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 update of the candidate slave device is performed. During the third execution of 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 update of the candidate slave device is performed.
[0087] S104: Determine whether the number of candidate slave devices is one.
[0088] If yes, execute S105; if no, return to S102.
[0089] After the candidate slave devices are updated for the third time, it is determined whether the number of updated candidate slave devices is one. If the number of candidate slave devices is one, the updated candidate slave device is the candidate slave device farthest from the master device. If the number of candidate slave devices is greater than one, it is necessary to return to execute S102, adjust the output current value of the variable current source in each candidate slave device again, update the candidate slave devices again, and determine again whether the number of candidate slave devices is one, until the number of candidate slave devices is one.
[0090] For example, if after the third candidate slave device update, the candidate slave devices are B, C, and D, it is clear that the number of candidate slave devices is greater than one. The output current values of the variable current sources of candidate slave devices B, C, and D are adjusted again, and the detection current values of the detection resistors of candidate slave devices B, C, and D are obtained. The candidate slave devices are then updated a fourth time. After the fourth candidate slave device update, the candidate slave devices are C and D, and it is clear that the number of candidate slave devices is greater than one. The output current values of the variable current sources of candidate slave devices C and D are adjusted again, and the detection current values of the detection resistors of candidate slave devices C and D are obtained. The candidate slave devices are then updated a fifth time. After the fifth candidate slave device update, the candidate slave device is D.
[0091] It should be noted that the embodiment of the present application uses only five times as an example to illustrate the number of times S102-S103 is executed when the number of candidate slave devices is determined to be one. In actual application, there is no specific limit on the number of times S102-S103 is executed, as long as the number of times S102-S103 is greater than or equal to three.
[0092] S105 , determining that the candidate slave device is the candidate slave device farthest from the master device.
[0093] 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 candidate slave device D is the candidate slave device farthest from the master device.
[0094] S106 , assigning an address to each candidate slave device based on the candidate slave device farthest from the master device.
[0095] Based on the above embodiment, the candidate slave device farthest from the master device can be located, and an address can be assigned to the farthest candidate slave device. Then, an address can be assigned to the adjacent candidate slave devices of the farthest candidate slave device, and so on. An address can be assigned to each candidate slave device to ensure normal communication between the master device and the slave devices.
[0096] The present application provides an address assignment method, which includes obtaining an initial detection current value of a detection resistor in each candidate slave device, where the initial detection current value is the current value flowing through the detection resistor when a 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, where 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 in the output current value before and after each adjustment is the same; updating 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; and returning at least twice 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. Until the number of candidate slave devices reaches one, the candidate slave device is determined to be the candidate slave device farthest from the master device; an address is assigned to each candidate slave device based on the candidate slave device farthest from the master device. This reduces the resistance of the sense resistor, thereby reducing the delay caused by the sense resistor to the slave device, thereby improving communication reliability. In addition, because 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 increased in a step-by-step manner, avoiding the problem of unstable address allocation caused by a low sense resistor value, thereby improving the stability of address allocation.
[0097] FIG5 is a flow chart of another address allocation method provided in an embodiment of the present application. FIG5 is a specific description of a possible implementation method when performing S103 based on the embodiment shown in FIG4 , as follows:
[0098] 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.
[0099] 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.
[0100] 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≥ith , then it is determined that the preset conditions are met; if i-i0 th , it is determined that the preset conditions are not met.
[0101] S202 : Determine the candidate slave device corresponding to the difference that meets the preset condition as a new candidate slave device.
[0102] 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.
[0103] 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.
[0104] Based on the above embodiment, before executing S102 for the second time, the following steps may be performed:
[0105] S301 : Determine candidate slave devices corresponding to differences that do not meet a preset condition as candidate slave devices to be disconnected.
[0106] 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.
[0107] S302 , controlling the variable current source in the candidate slave device to be disconnected to be disconnected to be disconnected from the detection resistor.
[0108] For example, the first switch in the candidate slave device to be disconnected may be disconnected, thereby disconnecting the variable current source in the candidate slave device to be disconnected from the sense resistor. For example, based on the above embodiment, the first switch in candidate slave device C may be disconnected, thereby disconnecting the variable current source in candidate slave device C from the sense resistor.
[0109] The candidate slave device to be disconnected is the difference between 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 updated candidate slave device will increase, the variable current source in the candidate slave device to be disconnected is disconnected from the detection resistor, that is, the variable current source in the candidate slave device to be disconnected is not connected to the bus system, which can avoid the current provided by the variable current source in the bus system exceeding the driving capability current of the master device.
[0110] In an embodiment of the present application, by determining the candidate slave device corresponding to the difference that does not meet the preset conditions as the candidate slave device to be disconnected; controlling the variable current source in the candidate slave device to be disconnected to disconnect from the detection resistor, it is possible to avoid the current provided by the variable current source in the bus system exceeding the driving capability current of the master device, thereby improving the stability of communication.
[0111] FIG6 is a flow chart of another address allocation method provided in an embodiment of the present application. FIG6 is based on the embodiment shown in FIG5 . Before executing S101 , the address allocation method further includes the following steps:
[0112] S401 : Determine the number of output current values according to the clock signal of each candidate slave device and a preset allocation time threshold.
[0113] For example, due to limitations in slave device technology, jitter exists between the clock signals of each slave device, that is, there are differences between the clock signals of the candidate slave devices. For example, the pulse width of the clock signal of candidate slave device A is T1, the pulse width of the clock signal of candidate slave device B is T2, and the pulse width of the clock signal of candidate slave device C is T3, and T1 ≠ T2 ≠ T3.
[0114] A specific description of a possible implementation method for executing S401 is as follows:
[0115] S4011 , determining the minimum pulse width and the maximum pulse width of each clock signal according to the clock signal of each candidate slave device.
[0116] For example, if it can be determined based on the above embodiment that T1>T2>T3, then it can be determined that the minimum pulse width of the clock signals of all candidate slave devices is T3, and the maximum pulse width is T1.
[0117] 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.
[0118] Exemplarily, 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 also 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. Thus, within the time of maintaining the same output current value, it can be ensured that the variable current sources in each candidate slave device can provide stable current to the bus system, so as to obtain a relatively accurate detected current value.
[0119] S4013. Determine the number of output current values according to the time for the variable current source to continuously maintain the same output current value and the preset allocation time threshold.
[0120] Exemplarily, the preset allocation time threshold is the time required to allocate an address under normal circumstances. The preset allocation time threshold here can be an empirical value or a relatively reasonable time required for address allocation obtained through experiments. The ratio of the preset allocation time threshold to the time for the variable current source to continuously maintain the same output current value can be determined according to the preset allocation time threshold and the time for the variable current source to continuously maintain the same output current value, and the number of output current values can be determined based on the ratio of the preset allocation time threshold to the time for the variable current source to continuously maintain the same output current value.
[0121] For example, the preset allocation time threshold is T th , and the time for the variable current source to continuously maintain the same output current value is T. If T th / T is an integer, it can be determined that T th / T is the number of output current values; if T th / T is a non-integer, it can be determined that the smallest integer greater than T th / T is the number of output current values.
[0122] In the embodiments of the present application, by determining the minimum pulse width and the maximum pulse width in each clock signal according to the clock signals of each candidate slave device; determining the time for the variable current source to continuously maintain the same output current value according to the minimum pulse width and the maximum pulse width; and determining the number of output current values according to the time for the variable current source to continuously maintain the same output current value and the preset allocation time threshold, it can be ensured that the variable current sources in each candidate slave device can provide stable current to the bus system within the time of maintaining the same output current value, so as to obtain a relatively accurate detected current value.
[0123] S402. Determine each output current value of the variable current source according to the number of output current values.
[0124] As a possible implementation manner when executing S402, each output current value of the variable current source can be determined according to the maximum current value that the master device can withstand and the number of output current values.
[0125] 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.
[0126] 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.
[0127] S403 , configuring a variable current source based on the order of output current values from small to large.
[0128] 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.
[0129] FIG7 is a flow chart of another address allocation method provided in an embodiment of the present application. FIG7 is based on the embodiment shown in FIG5 . Before executing S101 , the address allocation method further includes the following steps:
[0130] S501: Generate an addressing command and send it to each slave device.
[0131] The slave device is used to read the address according to the addressed command.
[0132] 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.
[0133] S502: Determine whether each slave device has been assigned an address based on the address reading result sent by each slave device.
[0134] 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.
[0135] S503: Determine a slave device to which an address is not assigned as a candidate slave device.
[0136] 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.
[0137] As a specific embodiment of the present application, the address allocation process can be described using the timing diagram of FIG8 and the state diagram of FIG9 , and can be divided into five processes:
[0138] (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.
[0139] (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.
[0140] (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.
[0141] (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.
[0142] (5) Check whether all slave devices have been assigned addresses.
[0143] 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.
[0144] Table 1 Current on the sense resistor
[0145] 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.
[0146] 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.
[0147] The present application also provides an address allocation device. FIG10 is a schematic structural diagram of an address allocation device provided in the present application. The address allocation device shown in FIG10 is applied to the bus system shown in FIG3 . The address allocation device includes:
[0148] An acquisition module 110 is configured to obtain 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 device is a slave device that has not been assigned an address among all the slave devices, and the resistance of the detection resistor is less than or equal to 0.2Ω.
[0149] The determination module 120 is used 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 the candidate slave devices is one, and determine that the candidate slave device is the candidate slave device farthest from the master device.
[0150] The allocating module 130 is configured to allocate an address to each candidate slave device based on the candidate slave device farthest from the master device.
[0151] In some embodiments, the determination module 120 is further used to determine whether the difference 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; and the candidate slave device corresponding to the difference that meets the preset condition is determined as the new candidate slave device.
[0152] In some embodiments, satisfying a preset condition includes: the difference being less than or equal to a preset current difference.
[0153] In some embodiments, the determination module 120 is further configured to determine the candidate slave device corresponding to the difference that does not meet the preset condition as a candidate slave device to be disconnected; and control the variable current source in the candidate slave device to be disconnected to disconnect from the detection resistor.
[0154] 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.
[0155] The address allocating device further comprises:
[0156] A configuration module is used to configure the variable current source based on the order of the output current values from small to large.
[0157] 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.
[0158] 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.
[0159] In some embodiments, the address allocation device further comprises:
[0160] 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.
[0161] 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.
[0162] 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.
[0163] 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.
[0164] 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.
[0165] 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.
[0166] 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.
[0167] 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).
[0168] 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.
[0169] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. An address allocation method, characterized in that: Applicable to a bus system, the bus system comprises a master device and a plurality of slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices comprises 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, wherein 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 device is a slave device to which an address is not assigned among all the slave devices, and the resistance value of the detection resistor is less than or equal to 0.2Ω; Adjusting the output current value of the variable current source in each of the candidate slave devices, and obtaining 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 is turned on by the detection resistor, and the change of the output current value before and after each adjustment is the same; updating 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; Returning at least twice to execute the step of adjusting the output current value of the variable current source in each of the candidate slave devices, obtaining the detection current value of the detection resistor in each of the candidate slave devices, until the number of the candidate slave devices is one, and determining that the candidate slave device is the candidate slave device farthest from the master device; An address is assigned to each of the candidate slave devices based on the candidate slave device farthest from the master device.
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 of the candidate slave devices and the initial detection current value comprises: Determining whether the difference corresponding to each of the candidate slave devices meets a preset condition 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; 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 is 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 of the candidate slave devices, the method further includes: Determine the candidate slave device corresponding to the difference value 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 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: Determining the number of output current values according to the clock signal of each candidate slave device and a preset allocation time threshold; Determining each output current value of the variable current source according to the number of the output current values; The variable current source is configured based on the order of the output current values from small to large.
6. The method according to claim 5, characterized in that The determining the number of the output current values according to the clock signal of each candidate slave device and the preset allocation time threshold comprises: Determine the minimum pulse width and the maximum pulse width of each of the clock signals according to the clock signals of each of the candidate slave devices; Determining the time for which the variable current source maintains the same output current value according to the minimum pulse width and the maximum pulse width; The number of the output current values is determined according to the time during which the variable current source continues to output the same current value and the preset allocation time threshold.
7. The method according to claim 5, characterized in that Determining each output current value of the variable current source according to the number of the output current values comprises: Each output current value of the variable current source is determined according to a maximum current value that the host device can withstand and the number of the output current values.
8. 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: Generate an addressing command and send it to each of the slave devices, wherein the slave device is used to read an address according to the addressing command; Determining whether each of the slave devices has been assigned an address according to 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.
9. An address allocation device, characterized in that: Applicable to a bus system, the bus system comprises a master device and a plurality of slave devices, each of the slave devices is connected to the master device via a bus, and each of the slave devices comprises 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, wherein 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 device is a slave device to which an address is not assigned among all the slave devices, and the resistance value of the detection resistor is less than or equal to 0.2Ω; A determination module, used 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, 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 of the output current value before and after each adjustment is the same; 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, update the candidate slave device; return at least twice to perform the adjustment of the output current value of the variable current source in each of the candidate slave devices, obtain the detection current value of the detection resistor in each of the candidate slave devices, until the number of the candidate slave devices is one, and determine that the candidate slave device is the candidate slave device farthest from the master device; The allocation module is used to allocate an address to each of the candidate slave devices based on the candidate slave device farthest from the master device.
10. A bus system, characterized in that: include: A master device and a plurality of 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 used to execute the steps of the method described in any one of claims 1-8.
11. A master device, characterized in that: include: A processor, wherein the processor is used to execute a computer program stored in a memory, and when the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
12. 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 8.
Citation Information
Patent Citations
LIN bus system and slave automatic addressing method thereof
CN115086278A
Method and system for automatically allocating node addresses to LIN bus and SOC
CN115150222A
Address allocation method and device, bus system, master device and medium
CN116346782A
Method for controlling electrical and / or electronic components of a vehicle module and such a vehicle module with automatic module addressing via powerline
DE102018104872A1
Data bus system and allocation of bus addresses in such a data bus system
WO2019166503A2
