Automatic addressing method and system
By introducing a current source into the slave machine and controlling the output of the current source according to the comparison between the actual current and the current threshold, the problems of limited number of slaves and high measurement accuracy in the prior art are solved, and the accurate addressing and efficiency improvement of multiple slaves are achieved.
Patent Information
- Application Number
- CN202411419522.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-10-12
AI Technical Summary
In the prior art, when addressing the LIN bus, if each slave is flooded with 1mA current, the number of slaves is limited, and the measurement circuit cannot accurately distinguish the voltages of different slaves, resulting in high accuracy requirements.
By introducing a current source into the slave and upon receiving the address command sent by the host, the slave that does not store the address information outputs the current at the initial current value. The slave compares the actual current with the current threshold. When the actual current is greater than the threshold, the current source is turned off. When the actual current is less than the threshold, the output current of the current source is increased until only one current source is turned on, and the address information is stored.
Accurate addressing of multiple slaves is achieved, the number of slaves that can be connected on the bus is increased, the requirement for measuring device accuracy is reduced, and the addressing efficiency and accuracy is improved.
Smart Images

Figure CN118964225B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic addressing technology, and in particular to an automatic addressing method and system. Background Art
[0002] LIN (Local Interconnect Network) bus is a bus architecture widely used in automotive systems. A daisy chain connection can be used to form a LIN communication network. In this communication system, the host and multiple slaves are connected through the LIN bus. The host needs to assign an address to each slave to selectively transmit commands.
[0003] When addressing the LIN bus, in the prior art, the slave uses a current source to feed current to the previous slave, and measures the current of the measuring resistor inside the slave. The farthest slave has the smallest current and is less than the set threshold. In this method, if each slave feeds 1mA, which does not exceed the maximum current on the LIN bus, the number of slaves that can be connected is limited, and when the resistance of the measuring resistor is small or the current fed to the slave is small, the measurement circuit cannot accurately distinguish the voltages of different slaves, and the accuracy requirements of the measurement device are high. Summary of the invention
[0004] The present invention provides an automatic addressing method and system to solve the problem that when a current source outputs current to a slave, the number of slaves that can be connected is limited and a measuring circuit cannot accurately distinguish different slaves.
[0005] According to one aspect of the present invention, there is provided an automatic addressing method, which is applied to an automatic addressing system, wherein the automatic addressing system comprises a host and a plurality of slaves, wherein the host and the plurality of slaves are connected via a bus; the slaves comprise a current source; and the method comprises:
[0006] After receiving the addressing command sent by the host, the slave without storing the address information controls the current source to output current at an initial current value;
[0007] The slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is greater than the output current of the corresponding current source controls its current source to turn off; the slave whose actual current is less than the current threshold and whose difference between the current threshold and the actual current is greater than the output current of the corresponding current source controls its current source to increase the output current step value;
[0008] The slave updates the step value, and returns to execute the step of controlling the current source of the slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is greater than the output current of the corresponding current source to turn off, until only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command, and returns to execute the step of controlling the current source to output current with the initial current value after receiving the addressing command sent by the host, and the slave that does not store the address information controls the current source to output current with the initial current value, until all slaves store the address information.
[0009] Optionally, when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to turn off; and when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls the output current of its current source to increase the step value, the method further includes:
[0010] If the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls the output current of its current source to decrease; if the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave controls the output current of its current source to increase.
[0011] Optionally, the slave whose actual current is greater than a current threshold and whose difference between the actual current and the current threshold is less than an output current of a corresponding current source controls the output current of its current source to decrease; the slave whose actual current is less than the current threshold and whose difference between the current threshold and the actual current is less than an output current of a corresponding current source controls the output current of its current source to increase, including:
[0012] If the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave machine controls its current source to update the output current to the difference between the previous output current of the current source and the actual current corresponding to the current source and the current threshold; if the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave machine controls its current source to increase the output current by the difference between the current threshold and the corresponding actual current.
[0013] Optionally, the slave further includes a current acquisition module, and the method further includes:
[0014] When the current acquired by the current acquisition module is less than a preset threshold, the slave determines that the bus node of the slave is reversely connected;
[0015] The reversely connected slave corrects the current acquired by the current acquisition module to obtain the actual current of the slave.
[0016] Optionally, the slave updates the step value, including:
[0017] The slave uses n times the step value as the updated step value; wherein n is an integer greater than 1 and less than or equal to 3.
[0018] Optionally, the initial step value is the same as the initial current value;
[0019] The product of the initial current value and the target value is less than or equal to the current threshold; wherein the target value is n raised to the power of a preset value, and the preset value is the number of times the output current of the current source increases by a step value.
[0020] Optionally, the product of the initial current value and the number of slaves is less than or equal to the product of the current limit of the bus and an error coefficient.
[0021] Optionally, the slave further includes a first switch, a second switch and a pull-up module; the first switch is connected between the power supply terminal of the host and the current source; the second switch is connected between the power supply terminal of the host and the pull-up module;
[0022] After receiving the addressing command sent by the host, before the slave without storing the address information controls the current source to output current at the initial current value, the method further includes:
[0023] The slave that does not store the address information controls the corresponding second switch to be turned off, and controls the corresponding first switch to be turned on; the slave that has stored the address information controls the corresponding first switch and second switch to be turned off.
[0024] According to another aspect of the present invention, an automatic addressing system is provided, the automatic addressing system is used to implement the automatic addressing method described in any embodiment of the present invention, the automatic addressing system comprises: a host and a plurality of slaves;
[0025] The host and the plurality of slaves are connected via a bus; the slave comprises a current source, a current acquisition module, a first switch, a second switch and a pull-up module; the first switch is connected between the power supply terminal of the host and the current source; the second switch is connected between the power supply terminal of the host and the pull-up module;
[0026] The current acquisition module is used to acquire the actual current of the corresponding slave.
[0027] Optionally, the current acquisition module includes a sampling resistor, an amplifier and an analog-to-digital converter;
[0028] The first end of the sampling resistor is connected to the pull-up module, and the second end of the sampling resistor is connected to the current source;
[0029] The first input end of the amplifier is connected to the first end of the sampling resistor, the second input end of the amplifier is connected to the second end of the sampling resistor, and the output end of the amplifier is connected to the analog-to-digital converter.
[0030] The technical solution of the embodiment of the present invention is that after receiving the addressing command sent by the host, the slave without storing the address information controls the current source to output the current at the initial current value, and the slave compares the actual current flowing inside with the current threshold. The slave whose actual current is greater than the current threshold and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source controls its current source to turn off, and the slave whose actual current is less than the current threshold and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source controls its current source to increase the output current step value and update the step value, and repeats this process until only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command to achieve addressing of a slave. The host continues to send the addressing command, repeats it continuously, and identifies a slave each time, so that each slave can be addressed in turn. In the addressing process, by shutting down the slave with a larger actual current, the total current on the bus can be avoided to be too large, and the number of slaves connected to the bus can be increased. By increasing the output current of the current source of the slave with a smaller actual current, the actual current will not be too small, and the actual currents of different slaves will differ greatly, which can avoid the problem that the measurement circuit cannot accurately distinguish different slaves, and there is no need to use a high-precision measurement device. In addition, during each addressing process, the step value gradually increases, so that the step value increases incrementally, thereby making the current increase faster, which is convenient for shortening the addressing time and improving the addressing efficiency.
[0031] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0033] Figure 1 It is a flow chart of an automatic addressing method provided by an embodiment of the present invention.
[0034] Figure 2This is a flow chart of another automatic addressing method provided by an embodiment of the present invention.
[0035] Figure 3 This is a flow chart of another automatic addressing method provided by an embodiment of the present invention.
[0036] Figure 4 This is a flow chart of another automatic addressing method provided by an embodiment of the present invention.
[0037] Figure 5 It is a schematic diagram of the circuit structure of an automatic addressing system provided by an embodiment of the present invention.
[0038] Figure 6 The present invention provides a circuit diagram of a reverse connection of a slave device. DETAILED DESCRIPTION
[0039] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0040] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] An embodiment of the present invention provides an automatic addressing method, for example, the automatic addressing method is an automatic addressing method for a LIN bus, and may also be an automatic addressing method for other types of buses. The automatic addressing method is applied to an automatic addressing system, that is, the automatic addressing method can be implemented by the automatic addressing system. The automatic addressing system includes a host and multiple slaves, and the host and the multiple slaves are connected through a bus; for example, through a LIN bus. The slave includes a current source, and the current source can output current to supply current to the slave in which it is located. The current source can be controlled by the corresponding slave, that is, by the slave in which it is located.
[0042] Figure 1 is a flowchart of an automatic addressing method provided by an embodiment of the present invention, refer to Figure 1 , automatic addressing methods include:
[0043] S110 , after receiving the addressing command sent by the host, the slave device that does not store the address information controls the current source to output current at the initial current value.
[0044] When automatic addressing is not required, the host and each slave communicate normally through the bus. When automatic addressing is required, the host sends an addressing command to all slaves through the bus, and the addressing command includes address information.
[0045] Specifically, after all slaves receive the addressing command sent by the host, if the slave has stored the address information, that is, the address of the slave has been determined, the slave will not act, that is, the slave that has been addressed can be eliminated. If the slave stores the address information, the slave controls its internal current source to output current at the initial current value. At this time, the output current of the current source in all slaves that do not store the address information is the same, which is the initial current value.
[0046] S120, when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to shut down; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls the output current of its current source to increase the step value.
[0047] The current threshold may be a preset value, and the current threshold is smaller than the current limit that the bus can withstand.
[0048] Among them, multiple slaves are connected to the host through a bus, and the power supply end of the host is also connected to multiple slaves. The current flows from the power supply end of the host through the power line to the slave at the end farthest from the host, and then flows from the slave at the end to the host through the bus, so that the actual current of the slave at the end of the bus is the smallest, and the actual current of the slave closest to the host is the largest. The actual current of the slave at the current stage is the sum of the current source output currents of all slaves at the previous stage. The previous stage is the stage farthest from the host.
[0049] When all the current sources that are turned on output current at the initial current value, for example, among two adjacent slaves, the slave close to the host is the i-th slave, and the slave far from the host is the i-1-th slave, and the output current of each current source is IPU, then the actual current of the i-1-th slave is IPU×(i-1), and the actual current of the i-th slave is IPU×i. Wherein, i is an integer greater than 1. Table 1 is a schematic table of the actual current of the slave when the current source outputs current at the initial current value. As shown in Table 1, the slave serial number starts from the slave farthest from the host, and starts from 1 in Table 1. In other implementations, it can also start from 0.
[0050] Table 1 Schematic diagram of the actual current of the slave when the current source outputs current at the initial current value
[0051]
[0052] As shown in Table 1, when the number of slaves turned on is N and the current sources of all slaves output current at the initial current value IPU, the output current of the first slave is IPU, the output current of the second slave is IPU×2, the output current of the third slave is IPU×3, and so on. The output current of the Nth slave is IPU×N.
[0053] Specifically, after the slave that does not store address information controls its current source to output current, the slave obtains the actual current flowing through it, that is, the actual current flowing through the internal sampling resistor of the slave, and compares the actual current with the current threshold. When the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, it indicates that the actual current of the slave exceeds the current threshold by a large amount. The slave will then control the internal current source to shut down and no longer output current, thereby shutting down part of the current source close to the host. When the output current is subsequently increased, the output current of the current source in the slave will no longer be increased, thereby avoiding the total current on the bus being too large and exceeding the maximum current that the bus can withstand.
[0054] When the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the corresponding current source, it indicates that the actual current of the slave is small and the output current of the current source can be increased. The slave will then control the output current of the internal current source to increase and increase it according to the step value, that is, the output current of the slave's current source is updated to the previous output current plus the current step value.
[0055] In this way, the actual current of the slave will not be too small, and the actual current of different slaves will differ greatly, which can avoid the problem that the measurement circuit cannot accurately distinguish different slaves. This is beneficial to improving the accuracy of addressing, reducing the accuracy requirements for measuring devices, reducing costs, and reducing the errors of measuring devices.
[0056] S130, the slave updates the step value and determines whether only one current source is turned on. If so, execute step S140; if not, return to execute step S120.
[0057] The slave updating step value may be that all slaves update the internally stored step value, or the slave corresponding to the turned-on current source may update the internally stored step value. The updating step value may be to increase the step value so that the step value increases progressively, thereby making the current increase faster, which is convenient for shortening the addressing time and improving the addressing efficiency.
[0058] Moreover, when the current grows faster, time is saved for addressing, and the time for the current source to adjust the output current can be increased. That is, after the current source outputs the current, it can be delayed for a period of time, and then the current source can be controlled to adjust the output current. After the output current of the current source is stable, the output current of the current source can be changed to eliminate the error caused by the rapid change of current, which can improve the anti-interference ability of the bus and improve the reliability and accuracy of automatic addressing.
[0059] S140, only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command.
[0060] Specifically, the actual current flowing through the slave farthest from the host is the smallest. If only one current source is turned on, it means that the current source corresponding to the end slave farthest from the host is turned on, and the slave of the turned-on current source will store the address information in the addressing command. In this way, the addressing of the end slave is realized, and after repeated repetitions, one slave is identified each time, so that each slave can be addressed in turn.
[0061] Exemplarily, Table 2 is a schematic table of actual current of the slaves when only one current source is turned on. The slave numbers in Table 2 are numbered in the same manner as the slave numbers in Table 1.
[0062] Table 2 Schematic diagram of actual current of slave device when only one current source is turned on
[0063]
[0064] As shown in Table 2, by continuously comparing the actual current of the slave with the current threshold, the current source corresponding to the slave with a larger actual current is turned off, and the output current of the current source corresponding to the slave with a smaller actual current is increased, until only one current source is turned on and the other current sources are turned off. The slave corresponding to the current source is the slave farthest from the host, that is, the first slave, and the actual current of the slave is Ith.
[0065] S150, the host determines whether all slaves have stored address information, if so, then the process ends; if not, then the process returns to step S110.
[0066] The host can determine whether all slaves have stored address information based on whether the number of times the addressing command is sent is equal to the number of slaves. The host can also read the address of the slave to determine whether all slaves have stored address information.
[0067] Specifically, if there is a slave that does not store address information, the host will continue to send addressing commands, and then return to execute step S110. All slaves that do not store address information continue to control the output current of the current source. By comparing the actual current with the current threshold, the current source of all slaves close to the host is turned off, and the output current of the current source of some slaves far away from the host is increased until only the current source of the last slave is turned on, thereby achieving addressing of the slave. This process is repeated, and one slave is identified each time, so that each slave can be addressed in turn.
[0068] The technical solution of this embodiment is that after receiving the addressing command sent by the host, the slave without storing the address information controls the current source to output the current at the initial current value, and the slave compares the actual current flowing inside with the current threshold. The slave whose actual current is greater than the current threshold and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source controls its current source to turn off, and the slave whose actual current is less than the current threshold and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source controls its current source to increase the output current step value and update the step value, and repeats this process until only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command to achieve addressing of a slave. The host continues to send the addressing command, repeating it continuously, identifying one slave each time, so that each slave can be addressed in turn. In the addressing process, by shutting down the slave with a larger actual current, the total current on the bus can be avoided to be too large, and the number of slaves connected to the bus can be increased. By increasing the output current of the current source of the slave with a smaller actual current, the actual current will not be too small, and the actual currents of different slaves will differ greatly, which can avoid the problem that the measurement circuit cannot accurately distinguish different slaves, and there is no need to use a high-precision measurement device. In addition, during each addressing process, the step value gradually increases, so that the step value increases incrementally, thereby making the current increase faster, which is convenient for shortening the addressing time and improving the addressing efficiency.
[0069] Based on the above technical solutions, Figure 2 is a flowchart of another automatic addressing method provided by an embodiment of the present invention. Optionally, refer to Figure 2 , automatic addressing methods include:
[0070] S210 , after receiving the addressing command sent by the host, the slave device that does not store the address information controls the current source to output current at an initial current value.
[0071] S220, when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to shut down; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls its current source to increase the output current step value; when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls its current source to decrease the output current; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave controls its current source to increase the output current.
[0072] Specifically, the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, indicating that the actual current of the slave is greater than the current threshold, but not too large, then the slave controls the output current of its current source to decrease, that is, does not turn off its current source, until the actual current of the corresponding slave is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, then it turns off its current source.
[0073] The actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, indicating that the actual current of the slave is less than the current threshold, but closer to the current threshold, then the slave controls the output current of its current source to increase, but does not increase the step value, for example, the increase value is small, which can avoid the actual current of the slave being too large. Until the actual current of the corresponding slave is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, its current source will be turned off.
[0074] S230, the slave updates the step value and determines whether only one current source is turned on. If so, execute step S240; if not, return to execute step S220.
[0075] S240, only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command.
[0076] S250, the host determines whether all slaves have stored address information, if so, then the process ends; if not, then the process returns to step S210.
[0077] On the basis of the above technical solution, optionally, the slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is less than the output current of the corresponding current source controls the output current of its current source to decrease; the slave whose actual current is less than the current threshold and whose difference between the current threshold and the actual current is less than the output current of the corresponding current source controls the output current of its current source to increase, including:
[0078] If the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls its current source to update the output current to the difference between the previous output current of the current source and the actual current corresponding to the current source and the current threshold; if the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave controls its current source to increase the output current by the difference between the current threshold and the corresponding actual current.
[0079] Specifically, if the actual current is greater than the current threshold and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls the output current of its current source to be updated to the difference between the previous output current of the current source and the actual current corresponding to the current source and the current threshold, that is, the slave controls the output current of its current source to subtract the part that exceeds the current threshold, so that the subsequent output current of the slave's current source is smaller, and the actual current of the slave increases less, thereby avoiding the actual current of the slave being too large.
[0080] The slave machine controls the output current of its current source to increase the difference between the current threshold and the actual current when the actual current is less than the current threshold and the difference between the current threshold and the actual current is less than the output current of the corresponding current source. That is, the output current of the current source of the slave machine only increases by the difference between the current threshold and the actual current, and the increase is small, which can avoid the actual current of the slave machine being too large.
[0081] Optionally, the slave further includes a current acquisition module, which includes a measuring device and can measure the actual current flowing through the slave.
[0082] On the basis of the above technical solutions, Figure 3 is a flowchart of another automatic addressing method provided by an embodiment of the present invention. Optionally, refer to Figure 3 , automatic addressing methods include:
[0083] S310: After receiving the addressing command sent by the host, the slave device that does not store the address information controls the current source to output current at an initial current value.
[0084] S320: When the current acquired by the current acquisition module is less than a preset threshold, the slave determines that the bus node of the slave is reversely connected.
[0085] For example, the current acquisition module can directly acquire current, or the current acquisition module can acquire the voltage corresponding to the current, and the slave converts the voltage acquired by the current acquisition module to obtain the corresponding current, which is the current acquired by the current acquisition module.
[0086] For example, if the preset threshold is a negative value, and the current acquired by the current acquisition module is less than the preset threshold, it indicates that the current acquired by the current acquisition module is a reverse current.
[0087] Specifically, each slave includes a first bus node and a second bus node, the first bus node of the slave is connected to the host or a slave close to the host, and the second bus node of the slave is connected to a slave far from the host, so that all slaves are connected to the host through the bus. The current source is connected to the first bus node or the second bus node of the slave. When the current acquired by the current acquisition module is less than the preset threshold, it indicates that the current acquired by the current acquisition module is a reverse current, that is, the output current of the current source in the slave does not flow through the slave, then the first bus node that should be connected to the current source becomes the second bus node; or the second bus node that should be connected to the current source becomes the first bus node. Then the slave determines that its bus node is connected in reverse.
[0088] S330: The reversely connected slave corrects the current acquired by the current acquisition module to obtain the actual current of the slave.
[0089] Specifically, the reverse-connected slave corrects the current acquired by the current acquisition module, that is, after the current acquired by the current acquisition module is reversed, the actual current of the slave (the slave adjacent to the slave and farther away from the host) is added to obtain the actual current of the slave. In this way, the slave can still be addressed normally after reverse connection, which can ensure that the slave uses the correct actual current and current threshold comparison, improve the fault tolerance of automatic addressing, realize reverse connection error correction, and improve the reliability and accuracy of the automatic addressing method.
[0090] S340, when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to shut down; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls its current source to increase the output current step value; when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls its current source to decrease the output current; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave controls its current source to increase the output current.
[0091] S350, the slave updates the step value and determines whether only one current source is turned on. If so, execute step S360; if not, return to execute step S340.
[0092] S360, only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command.
[0093] S370, the host determines whether all slaves have stored address information, if so, then end; if not, then return to execute step S310.
[0094] On the basis of the above technical solutions, optionally, the automatic addressing method further includes:
[0095] When the voltage acquired by the current acquisition module exceeds the maximum voltage, the corresponding slave determines that the slave is open-circuited.
[0096] Specifically, the maximum voltage is, for example, the maximum voltage that the current acquisition module can acquire. When the voltage acquired by the current acquisition module exceeds the maximum current, it indicates that the slave is open-circuited. The slave can then promptly discover the internal fault and process it in a timely manner.
[0097] Based on the above technical solutions, optionally, the slave updates the step value, including:
[0098] The slave uses n times the step value as the updated step value; wherein n is an integer greater than 1 and less than or equal to 3.
[0099] Specifically, n can be 2 or 3. When the initial current value is small, n can be 3, so that the step value increases faster, so that the output current of the current source increases faster, the addressing time can be shortened, and the actual current of the slave will not be too small, reducing the demand for the accuracy of the measuring device. When the initial current value is large, n can be 2, so that the step value of the current source increases faster, but the actual current will not increase too much, which can shorten the addressing time while avoiding excessive actual current and avoiding the current on the bus exceeding the maximum current that the bus can withstand. And it can make the number of connectable slaves larger, improving the applicability of the automatic addressing method.
[0100] Based on the above technical solutions, optionally, the initial step value is the same as the initial current value;
[0101] The product of the initial current value and the target value is less than or equal to the current threshold; wherein the target value is n raised to the power of a preset value, and the preset value is the number of times the output current of the current source increases by the step value.
[0102] Specifically, the initial step value is the step value that increases each time the current source increases from the initial current value. By setting the initial step value to be the same as the initial current value, the step value is larger, and the output current of the current source can be increased exponentially, which is convenient for shortening the addressing time.
[0103] For example, for the current source at the end, for example, starting from the initial current value output by the current source, the output current is controlled M times, that is, the initial current value output by the current source is the first output current control, then the number of times the output current of the current source increases by the step value is M-1, the current threshold is W, and the initial current value is Istep, then the initial current value satisfies In this way, after determining the number of current increases, the initial current value can be determined so that the initial current value is not too small. Alternatively, after determining the initial current value, the number of current increases can be determined so that the number of current increases is not too large, thereby shortening the addressing time. And the output current of the current source of the last slave can be made greater than or equal to the current threshold, which facilitates the identification of the last slave.
[0104] On the basis of the above technical solutions, optionally, the product of the initial current value and the number of slaves is less than or equal to the product of the current limit of the bus and the error coefficient.
[0105] Specifically, the initial current value is Istep, the number of slaves is N, the error coefficient is K, and the current limit of the bus is Imax, then Istep×N≤K×Imax. In this way, the initial current value will not be too large, and the current on the bus will not exceed the current limit. By setting the error coefficient, it can be ensured that the current on the bus does not exceed the current limit, ensuring the reliability of the initial current value determination and the reliability of the automatic addressing method.
[0106] For example, if 20 slaves are connected to the bus, Table 3 shows the actual current change table of each slave, and Table 4 shows the current source output current change table of each slave. As shown in Tables 3 and 4, the serial numbers of the slaves are numbered from the slave farthest from the host. The current threshold is, for example, 10 mA.
[0107] Table 3 Actual current change table of each slave
[0108]
[0109] Table 4 Output current change table of each slave current source
[0110]
[0111] As shown in Table 3 and Table 4, STEP1 is a step in which the current sources of all slaves output current at an initial current value, STEP2 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the current source output current once, STEP3 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the current source output current twice, and so on, STEP6 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the current source output current five times. As shown in Table 3 and Table 4, according to the automatic addressing method of this embodiment, the output current of the current source is continuously increased or decreased, and the current source of the slave whose actual current is greater than the current threshold and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source is turned off. Finally, only one current source outputs current, and the slave corresponding to the current source is the slave farthest from the host, thereby achieving addressing of the slave farthest from the host. This is repeated to address each slave.
[0112] For example, if 30 slaves are connected to the bus, Table 5 shows another actual current change table of each slave, and Table 6 shows another current source output current change table of each slave. As shown in Tables 5 and 6, the serial numbers of the slaves are numbered from the slave farthest from the host. The current threshold is, for example, 10 mA.
[0113] Table 5 Another actual current change table for each slave
[0114]
[0115] Table 6 Output current change table of another current source of each slave
[0116]
[0117] As shown in Table 5 and Table 6, STEP1 is a step in which the current sources of all slaves output current at an initial current value, STEP2 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the output current of the current source once, STEP3 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the output current of the current source twice, and so on, STEP7 is a step in which the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, and the slave increases the output current of the current source six times. As shown in Table 5 and Table 6, according to the automatic addressing method of this embodiment, the output current of the current source is continuously increased or decreased, and the current source of the slave whose actual current is greater than the current threshold and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source is turned off. Finally, only one current source outputs current, and the slave corresponding to the current source is the slave farthest from the host, thereby achieving addressing of the slave farthest from the host. This is repeated to address each slave.
[0118] It should be noted that the current values in Table 3, Table 4, Table 5 and Table 6 are in milliamperes.
[0119] Based on the above technical solutions, optionally, the slave also includes a first switch, a second switch and a pull-up module; the first switch is connected between the power supply end of the host and the current source; the second switch is connected between the power supply end of the host and the pull-up module.
[0120] On the basis of the above technical solutions, Figure 4 is a flowchart of another automatic addressing method provided by an embodiment of the present invention. Optionally, refer to Figure 4 , automatic addressing methods include:
[0121] S410, after receiving the addressing command sent by the host, the slave that has not stored the address information controls the corresponding second switch to be turned off, and controls the corresponding first switch to be turned on; the slave that has stored the address information controls the corresponding first switch and second switch to be turned off.
[0122] Specifically, when addressing is not required, the host and the slave communicate normally through the bus, the second switch is turned on, the first switch is turned off, the current source is not connected to the circuit, and the pull-up module is connected to the circuit, so that the host and the slave communicate normally. When addressing is required, the host sends an addressing command to all slaves through the bus, and the slaves that have stored the address information do not act. The slave that does not store the address information controls the second switch inside it to be turned off, and controls the first switch inside it to be turned on, disconnects the pull-up module, and the current source is connected to the circuit, so that the current source outputs current, so that the addressing of the slave can be realized according to the actual current of the slave. Among them, the pull-up module may include a pull-up resistor.
[0123] Furthermore, the slave device that has stored the address information controls the corresponding first switch and second switch to be turned off, thereby avoiding an increase in the total current on the bus.
[0124] S420 , the slave that does not store the address information controls the current source to output current at an initial current value.
[0125] S430, when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to shut down; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls its current source to increase the output current step value; when the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is less than the output current of the corresponding current source, the slave controls its current source to decrease the output current; when the actual current is less than the current threshold, and the difference between the current threshold and the actual current is less than the output current of the corresponding current source, the slave controls its current source to increase the output current.
[0126] S440, the slave updates the step value and determines whether only one current source is turned on. If so, execute step S450; if not, return to execute step S430.
[0127] S450, only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command.
[0128] S460, the host determines whether all slaves have stored address information, if so, then the process ends; if not, then the process returns to step S410.
[0129] An embodiment of the present invention further provides an automatic addressing system, which is used to implement the automatic addressing method provided by any embodiment of the present invention. Figure 5 is a schematic diagram of a circuit structure of an automatic addressing system provided by an embodiment of the present invention, with reference to Figure 5 , the automatic addressing system comprises: a host 101 and a plurality of slaves 102;
[0130] The host 101 and multiple slaves 102 are connected through a bus LIN; the slave 102 includes a current source 121, a current acquisition module 122, a first switch S1, a second switch S2 and a pull-up module 123; the first switch S1 is connected between the power supply terminal VBAT of the host 101 and the current source 121; the second switch S2 is connected between the power supply terminal VBAT of the host 101 and the pull-up module 123; the current acquisition module 122 is used to collect the actual current of the corresponding slave 102.
[0131] The automatic addressing system provided in this embodiment is used to implement the automatic addressing method provided in any implementation scheme of the present invention, and therefore has the same beneficial effects as the automatic addressing method provided in any implementation scheme of the present invention, which will not be described in detail here.
[0132] Optionally, continue to refer to Figure 5 , the current acquisition module 122 includes a sampling resistor R1, an amplifier U1 and an analog-to-digital converter U2;
[0133] A first end of the sampling resistor R1 is connected to the pull-up module 123 , and a second end of the sampling resistor R1 is connected to the current source 121 ;
[0134] The first input terminal of the amplifier U1 is connected to the first terminal of the sampling resistor R1, the second input terminal of the amplifier U1 is connected to the second terminal of the sampling resistor R1, and the output terminal of the amplifier U1 is connected to the analog-to-digital converter U2. The first input terminal of the amplifier U1 is an inverting input terminal, and the second input terminal of the amplifier U1 is a non-inverting input terminal.
[0135] Specifically, the amplifier U1 can collect the voltage across the sampling resistor R1, the analog-to-digital converter U2 can convert the voltage collected by the amplifier U1 into a digital value, and the slave 102 can convert the collected voltage into a corresponding current, so as to determine the current flowing through the sampling resistor R1, that is, the actual current of the slave 102. In this way, the slave 102 can compare the actual current with the current threshold, and adjust the output current of the current source 121 according to the comparison result, so as to realize automatic addressing.
[0136] According to the automatic addressing method of the embodiment of the present invention, the step value increases gradually, so that the actual current of the slave 102 increases faster, that is, the current flowing through the sampling resistor R1 is larger, so that the resistance value of the sampling resistor R1 can be smaller, which is conducive to reducing the transmission delay problem.
[0137] Optionally, refer to Figure 5 The slave 102 includes a first bus node L1 and a second bus node L2. The first bus node L1 of the slave 102 is connected to the host 101 or a slave close to the host 101, and the second bus node L2 of the slave 102 is connected to a slave far away from the host 101, so that all slaves are connected to the host through the bus.
[0138] Optionally, refer to Figure 5, the pull-up module 123 is electrically connected to the first bus node L1 of the slave 102, and the current source 121 is electrically connected to the second bus node L2 of the slave 102. The first input terminal of the amplifier U1 is the inverting input terminal, and the second input terminal of the amplifier U1 is the non-inverting input terminal. In this way, the voltage of the sampling resistor R1 obtained by the amplifier U1 and the analog-to-digital converter U2 is a positive voltage, that is, the current collected by the current acquisition module 122 obtained by the slave 102 is a positive current. When the slave 102 is reversely connected (the first bus node L1 and the second bus node L2 are reversely connected), the current obtained by the slave 102 is a negative current, so that the slave 102 can determine whether it is reversely connected according to the current obtained by the current acquisition module 122, and when reversely connected, the current obtained by the current acquisition module 122 can be corrected to obtain the actual current. In this way, the slave can still be addressed normally after reverse connection, which can ensure that the slave uses the correct actual current and current threshold comparison, improve the fault tolerance of automatic addressing, realize reverse connection error correction, and improve the reliability and accuracy of the automatic addressing method.
[0139] For example, Figure 6 is a schematic diagram of a circuit structure of a slave reverse connection provided by an embodiment of the present invention, such as Figure 6 As shown, the slave farthest from the host 101 is the first slave, then the second slave and the fourth slave are connected in reverse, the output current of the current source of the first slave is IPU1, and the resistance of the sampling resistor R1 is R1. For example, the voltage obtained by the analog-to-digital converter U2 of the second slave is -R1×I0, then the correct voltage should be R1×(I0+IPU1), so that the actual current can be obtained as I0+IPU1, and the current obtained by the current acquisition module 122 can be corrected. Among them, I0 is the output current of the current source of the second slave. The voltage obtained by the analog-to-digital converter U2 of the fourth slave is -R1×I', then the correct voltage should be R1×(I'+I3), so that the actual current can be determined to be I'+I3, I' is the output current of the current source of the fourth slave, and I3 is the actual current of the third slave. In this way, the current obtained by the current acquisition module 122 is corrected, reverse connection error correction is achieved, and the reliability and accuracy of the automatic addressing method are improved.
[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0141] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An automatic addressing method, characterized in that: Applied to an automatic addressing system, the automatic addressing system comprises a host and a plurality of slaves, the host and the plurality of slaves are connected via a bus; the slave comprises a current source; the method comprises: After receiving the addressing command sent by the host, the slave without storing the address information controls the current source to output current at an initial current value; The slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is greater than the output current of the corresponding current source controls its current source to turn off; the slave whose actual current is less than the current threshold and whose difference between the current threshold and the actual current is greater than the output current of the corresponding current source controls its current source to increase the output current step value; The slave updates the step value, and returns to execute the step of controlling the current source of the slave whose actual current is greater than the current threshold and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source to turn off, until only one current source is turned on, and the slave corresponding to the current source stores the address information in the addressing command, and returns to execute the step of controlling the current source to output current with the initial current value after receiving the addressing command sent by the host, and the slave that does not store the address information controls the current source to output current at the initial current value, until all slaves store the address information; The slave device further includes a current acquisition module, and the method further includes: When the current acquired by the current acquisition module is less than a preset threshold, the slave determines that the bus node of the slave is reversely connected; The reversely connected slave corrects the current acquired by the current acquisition module to obtain the actual current of the slave.
2. The method according to claim 1, characterized in that: When the actual current is greater than the current threshold, and the difference between the actual current and the current threshold is greater than the output current of the corresponding current source, the slave controls its current source to turn off; When the actual current is less than the current threshold and the difference between the current threshold and the actual current is greater than the output current of the corresponding current source, the slave controls the output current of its current source to increase the step value, the method further includes: The slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is less than the output current of the corresponding current source controls the output current of its current source to decrease; The slave device, in which the actual current is smaller than the current threshold and the difference between the current threshold and the actual current is smaller than the output current of the corresponding current source, controls the output current of its current source to increase.
3. The method according to claim 2, characterized in that The slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is less than the output current of the corresponding current source controls the output current of its current source to decrease; The slave device, in which the actual current is smaller than the current threshold and the difference between the current threshold and the actual current is smaller than the output current of the corresponding current source, controls the output current of its current source to increase, comprising: The slave whose actual current is greater than the current threshold and whose difference between the actual current and the current threshold is less than the output current of the corresponding current source controls the output current of its current source to be updated to the difference between the previous output current of the current source and the actual current corresponding to the current source and the current threshold; The slave machine controls the output current of its current source to increase the difference between the current threshold and the corresponding actual current when the actual current is less than the current threshold and the difference between the current threshold and the actual current is less than the output current of the corresponding current source.
4. The method according to claim 1, characterized in that The slave updates the step value, including: The slave uses n times the step value as the updated step value; wherein n is an integer greater than 1 and less than or equal to 3.
5. The method according to claim 4, characterized in that The initial step value is the same as the initial current value; The product of the initial current value and the target value is less than or equal to the current threshold; wherein the target value is n raised to the power of a preset value, and the preset value is the number of times the output current of the current source increases by a step value.
6. The method according to any one of claims 1 to 5, characterized in that The product of the initial current value and the number of slaves is less than or equal to the product of the current limit value of the bus and an error coefficient.
7. The method according to any one of claims 1 to 5, characterized in that The slave further includes a first switch, a second switch and a pull-up module; the first switch is connected between the power supply terminal of the host and the current source; the second switch is connected between the power supply terminal of the host and the pull-up module; After receiving the addressing command sent by the host, before the slave without storing the address information controls the current source to output current at the initial current value, the method further includes: The slave that does not store address information controls the corresponding second switch to be turned off, and controls the corresponding first switch to be turned on; The slave device that has stored the address information controls the corresponding first switch and second switch to be turned off.
8. An automatic addressing system, characterized in that: Used to implement the automatic addressing method according to any one of claims 1 to 7, the automatic addressing system comprises: a host and a plurality of slaves; The host and the plurality of slaves are connected via a bus; the slave comprises a current source, a current acquisition module, a first switch, a second switch and a pull-up module; the first switch is connected between the power supply terminal of the host and the current source; the second switch is connected between the power supply terminal of the host and the pull-up module; The current acquisition module is used to acquire the actual current of the corresponding slave.
9. The automatic addressing system according to claim 8, characterized in that: The current acquisition module includes a sampling resistor, an amplifier and an analog-to-digital converter; The first end of the sampling resistor is connected to the pull-up module, and the second end of the sampling resistor is connected to the current source; The first input end of the amplifier is connected to the first end of the sampling resistor, the second input end of the amplifier is connected to the second end of the sampling resistor, and the output end of the amplifier is connected to the analog-to-digital converter.
Citation Information
Patent Citations
LIN bus system and slave automatic addressing method thereof
CN115086278A