Disclosure of Invention
The present invention provides a master-slave communication system, a slave position identification method, and a leasing apparatus for a portable power source, which are directed to overcome the above-mentioned drawbacks of the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows: the method comprises the steps that a master-slave communication system comprises a master machine and a plurality of slave machines, each slave machine comprises a unique coded address, the master machine and the slave machines are connected in parallel through a communication bus and are connected in series with the master machine as the head through a serial bus; the slave position identification method comprises the following steps:
the first slave computer receives the position identification information sent by the host computer through the serial bus, processes and acquires the position information of the first slave computer relative to the host computer;
the next slave computer processes and acquires the position information of the next slave computer relative to the host computer according to the position identification information processed by the previous slave computer received through the serial bus;
the host machine communicates with the slave machines at all positions through the communication bus to obtain the coding addresses of the slave machines at the corresponding positions.
Wherein, the preferred scheme is: the position information is the sequence of each slave relative to the master.
Preferably, the step of communicating the master with the slaves at each location via a communication bus to obtain the coded addresses of the slaves at the corresponding locations includes:
the master machine sends address pairing information containing position information through a communication bus, and the slave machine processes the address pairing information after receiving the address pairing information so as to extract the position information;
the slave machine processes the address matching information which is the same as the self position information to form matching success information with a coded address, and the matching success information is sent to the host machine through a communication bus;
and the host acquires the coding address of the slave at the corresponding position according to the pairing success information.
Preferably, the slave processing the address pairing information includes:
processing the slave after receiving the address pairing information to extract the position information;
the slave machine compares the position information extracted from the address matching information with the position information acquired from the position identification information, and processes the address matching information if the preset address matching condition is met;
and forming pairing success information with the coded address, and sending the pairing success information to the host through the communication bus.
Preferably, the method for identifying a slave location further includes:
the host computer sends notification information through the communication bus, and the slave computer waits for receiving the position identification information after receiving the notification information through the communication bus;
the master machine sends the position identification information through the serial bus, each slave machine processes the position identification information after receiving the position identification information, and the processed position identification information is sent to the next slave machine through the serial bus.
Preferably, the slave position identifying method further includes:
the host computer sends notification information through the communication bus, and the slave computer waits for receiving the position identification information within preset time after receiving the notification information through the communication bus;
if the slave does not receive the position identification information within the preset time, sending failure feedback information through a communication bus;
the master machine obtains the number of the slave machines or the slave machine coding addresses which do not receive the position identification information according to the failure feedback information, the master machine readjusts the position identification information to meet the requirement of the slave machines with the corresponding number, and the slave machine sends the position identification information through the serial bus.
Wherein, the preferred scheme is: the master-slave communication system also comprises a controllable switch which is connected with the transceiving end of the slave serial bus in parallel, the control end of the controllable switch is connected with the control pin of the corresponding slave, the controllable switch is normally open under the control of the slave, and when the slave can not work normally, the controllable switch is not controlled any more, and the controllable switch enters a normally closed state.
The technical scheme adopted by the invention for solving the technical problems is as follows: the master-slave communication system comprises a master machine and a plurality of slave machines, each slave machine comprises a unique coded address, the master machine and the slave machines are connected in parallel through communication buses and are connected in series with the master machine through serial buses, and the master-slave communication system can realize the slave machine position identification method.
Wherein, the preferred scheme is: the master-slave communication system also comprises a controllable switch connected with the transceiving end of the slave serial bus in parallel, the control end of the controllable switch is connected with the control pin of the corresponding slave, and the controllable switch is normally opened under the control of the slave; when the slave can not work normally, the controllable switch is not controlled any more, and the controllable switch enters a normally closed state.
The technical scheme adopted by the invention for solving the technical problems is as follows: the leasing device comprises the master-slave communication system and the mobile power supply placed on a slave.
Compared with the prior art, the invention has the advantages that the arrangement sequence of the slave machines relative to the host machine and the corresponding coded addresses are obtained on the premise that the host machine does not need to know the coded addresses of the slave machines in advance, so that the equipment can be managed and identified conveniently, the flexibility of the host machine and the slave machine structures is improved, in the repair, installation and replacement processes, workers do not need to specially input the coded addresses into the host machine or a main system, and the positions of the slave machines corresponding to the coded addresses can be obtained in time because the workers change the positions of the slave machines; furthermore, when the slave machine has a problem and can not work normally, the position identification information is ignored by the slave machine and directly enters the next slave machine, so that the breakpoint transmission of communication is realized, and the reliability of the system is improved.
Detailed Description
The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
As shown in fig. 1 to 4, the present invention provides a preferred embodiment of a slave position identification method.
A slave position identification method of a master-slave communication system comprises a master 110 and a plurality of slaves 120, each slave 120 comprises a unique coded address, and the master 110 and the slaves 120 are connected in parallel through a communication bus 220 and connected in series with the master 110 through a serial bus 210.
Specifically, the master 110 is provided with one and a plurality of slaves 120 matched with the master 110, the master 110 includes a first master pin 111 having a sending function and a second master pin 112 having an information communication function, the slaves 120 includes a first slave pin 121 having a receiving function, a second slave pin 122 having a sending function and a third slave pin 123 having an information communication function, wherein the master 110 is connected to the communication bus 220 through the second master pin 112, the slaves 120 is connected to the communication bus 220 through the third slave pin 123, the master 110 is connected to the first slave pin 121 of the slaves 120 through the first master pin 111 to realize serial communication, and the slaves 120 is connected to the first slave pin 121 of the next slave 120 through the second slave pin 122 to realize serial communication. The master 110 and the slaves 120 both realize the communication of 'one question and one answer' through the communication bus 220, the master 110 and the slaves 120 realize the serial communication in sequence with the master 110 as the head through the serial bus 210, and the output signals of the master 110 are transmitted to the slaves 120 in sequence.
In order to improve the simplicity of language, the related functional operations of the host 110 and the slave 120 provided in the specification are implemented by the internal processing module as default, and the related pins are also pins of the processing module.
In this embodiment, and referring to fig. 2, the slave position identification method includes the steps of:
step S10, the slave 120 sequentially receives and processes the position identification information sent from the master 110 through the serial bus 210, and obtains the position information of the slave relative to the master 110;
in step S20, the master 110 communicates with the slaves 120 at different positions via the communication bus 220 to obtain the coded addresses of the slaves 120 at the corresponding positions.
The position identification information of the master 110 is sequentially transmitted to the slaves 120 through the serial bus 210, and different position information is acquired according to the receiving sequence of the slaves 120, thereby acquiring the position information of the slave relative to the master 110. And then, on the basis of the position information of each slave machine 120, address identification communication is carried out through the communication bus 220, and the coded address corresponding to the slave machine 120 at each position is obtained, so that the coded address of the slave machine 120 at each position can be intelligently obtained on the basis of unknown information of the slave machine 120.
The position information is the sequencing sequence of each slave relative to the master.
Further, and referring to fig. 3, the specific steps of the slave location identification method include:
step S11, the master 110 sends the position identification information through the serial bus 210, each slave 120 processes the position identification information after receiving the position identification information, and sends the processed position identification information to the next slave 120 through the serial bus 210;
step S12, the slave 120 respectively acquires the position information of the slave relative to the master 110 from the position identification information;
step S21, the master 110 sends address pairing information including location information through the communication bus 220, and the slave 120 performs processing to extract the location information after receiving the address pairing information;
step S22, the slave machine 120 processes the address matching information which is the same as the self position information to form matching success information with a coded address, and sends the matching success information to the host machine 110 through the communication bus 220;
step S23, the master 110 obtains the coded address of the slave 120 at the corresponding position according to the pairing success information.
Specifically, through steps S11 and S12, depending on the characteristic that the serial bus 210 needs to pass through each slave 120 to reach the next slave 120, the slave 120 sends the position identification information through the serial bus 210, where the position identification information should include the corresponding position information, or after passing through the slave 120, provides new position information for the next slave 120. For example, the position identification information is a string of continuous numbers, such as a string of 1 to 9 ordered characters, after the slave 120 at the first position acquires the position identification information, the slave 120 at the first position extracts the first digit according to a preset algorithm, modifies the position identification information, such as deletes the first digit string to form new position identification information, and sends the new position identification information to the next slave 120, and each slave 120 acquires a corresponding position, i.e., position information relative to the position of the master 110. For another example, the position identification information is a code, the first slave 120 receives the code first, and extracts the position information through a preset algorithm or a database, that is, the position information of the current slave 120 is considered as "number 1" through the code, and then the code is modified into another new position identification information which can be identified by the slave 120 and represents "number 2" through the preset algorithm or the database, and each slave 120 can obtain a corresponding position, that is, the position information relative to the position of the master 110 through the above operations.
And, through steps S21 to S23, the communication between the master 110 and the plurality of slaves 120 is realized by the communication bus 220, for example, each slave 120 obtains its own position information relative to the master 110, and obtains an address corresponding to each position information through the address pairing information including specific position information, that is, the master 110 can obtain a coding address corresponding to the slave 120 at each position according to the mutual communication of the communication bus 220. Subsequently, the master 110 controls the slaves 120 corresponding to the code addresses according to the known code addresses and the intelligent control or the remote command control, and can intelligently acquire the code addresses of the slaves 120 on the premise that the master 110 does not need to know the code addresses of the slaves 120 in advance, so that the flexibility of the structures of the master 110 and the slaves 120 is improved, and in the repair, installation and replacement processes, a worker does not need to specially input the code addresses into the master 110 or a master system, and subsequently, the worker can acquire the positions of the slaves 120 corresponding to the code addresses in time because the worker exchanges the positions of the slaves 120.
The slave 120 processes the address pairing information that is the same as the self-location information, for example, adds the self-location to the address pairing information to form successful pairing information, where the address pairing information is (1) AAA, and the successful pairing information is (1) (XXX) AAA, where (1) belongs to the location information, (XXX) belongs to the coded address, and AAA belongs to the additional information. For another example, the self address is fused into the address pairing information to form pairing success information, for example, the address pairing information is (1) AAA, the pairing success information is (1 XXX) AAA or (1) AXAXAX, and the host 110 may extract the coded address XXX by using a specific algorithm, so as to prevent signal interference and improve security performance. Of course, the serial bus 210 and the communication bus 220 can be implemented by high and low levels, which are conventional technologies for information transmission and are not described one by one.
In this embodiment, and referring to fig. 4, the step of the slave device 120 processing the address pairing information includes:
step S221, after receiving the address pairing information, the slave 120 performs processing to extract the position information;
step S222, the slave 120 compares the position information extracted from the address matching information with the position information obtained from the position identification information, and processes the address matching information if the preset address matching condition is met;
in step S223, a pairing success message with the coded address is formed, and the pairing success message is sent to the host 110 through the communication bus 220.
Specifically, it is mainly emphasized how the slave 120 performs different processing according to the received address pairing information, if the address pairing information is intentionally sent to the slave 120 by the master 110, the slave 120 performs processing to form pairing success information and feeds back the pairing success information to the master 110, and if the address pairing information is intentionally sent to other slaves 120 by the master 110, the slave 120 does not perform processing. The general processing method is to extract the location information of the address matching information, compare the location information with the location information of the slave 120 itself, and perform the subsequent processing in the same way, or not perform the subsequent processing in the opposite way.
As shown in fig. 5 and 6, the present invention provides a preferred embodiment of a slave location identification method based on notification information.
The slave position identification method further comprises the steps of:
step S31, the master 110 first sends the notification information through the communication bus 220, and the slave 120 waits to receive the position identification information after receiving the notification information through the communication bus 220;
step S32, the master 110 sends the position identification information through the serial bus 210, and each slave 120 processes the position identification information after receiving the position identification information, and sends the processed position identification information to the next slave 120 through the serial bus 210.
Specifically, the main function of the notification information is to prevent the number of the slaves 120 from being too large, and the position identification information of the master 110 cannot enable all the slaves 120 to acquire their own position information, or the position identification information is not transmitted to the corresponding slaves 120 in time due to a midway error. The master 110 first sends a notification message through the communication bus 220 to notify all slaves 120 accessing the communication bus 220 that the master 110 will perform the step of determining the position information, and the slaves 120 enter the corresponding operating mode to wait for receiving the position identification information.
In this embodiment, and referring to fig. 6, the slave position identification method further includes the steps of:
step S311, the host 110 sends a notification message through the communication bus 220;
step S312, after receiving the notification message through the communication bus 220, the slave 120 waits for receiving the location identification message within a preset time;
step S33, if the slave 120 does not receive the position identification information within the preset time, sending failure feedback information through the communication bus 220;
step S34, the master 110 obtains the number of the slaves 120 that have not received the position identification information or the coded addresses of the slaves 120 according to the failure feedback information, and the master 110 readjusts the position identification information to satisfy the slaves 120 of the corresponding number, and then sends the position identification information through the serial bus 210.
Specifically, when a certain slave 120 does not receive the position identification information within a predetermined time, it may be considered that the slave 120 cannot acquire its own position information, the slave 120 feeds back the position information to the master 110, that is, the slave 120 transmits failure feedback information through the communication bus 220, the master 110 acquires the number of slaves 120 that do not receive the position identification information or the coded addresses of the slaves 120 according to the failure feedback information, the master 110 readjusts the position identification information to satisfy the number of slaves 120 corresponding to the number, and the slave transmits the position identification information through the serial bus 210. The content of the position identification information is intelligently adjusted to satisfy that different slaves 120 can obtain their own position information.
As shown in fig. 7, the present invention provides a preferred embodiment of the controllable switch.
The master-slave communication system further comprises a controllable switch 300 connected in parallel with the transceiving end of the serial bus 210 of the slave 120, the control end of the controllable switch 300 is connected with the control pin of the corresponding slave 120, the controllable switch 300 is normally open under the control of the slave 120, and when the slave 120 cannot normally work, the controllable switch 300 is not controlled any more, and the controllable switch 300 enters the normally closed state.
Specifically, the first slave pin 121 and the second slave pin 122 of each slave 120 are connected through a controllable switch 300, the controllable switch 300 includes a switch 310 disposed between the first slave pin 121 and the second slave pin 122, and a controller 320 for controlling the switch 310 to be turned on or off, the slave 120 further includes a fourth slave pin 124 for controlling the controller 320 to operate, and the slave 120 controls the controller 320 through the fourth slave pin 124 to control the switch 310 to be normally open. And when the master-slave communication system is powered on, the controllable switch 300 is normally opened under the control of the slave 120, and when the controllable switch 300 is disconnected from the control of the slave 120, the controllable switch enters normally closed, that is, when the slave 120 has a problem and cannot normally work, the first slave pin 121 and the second slave pin 122 can be directly short-circuited, so that the position identification information ignores the slave 120 and directly enters the next slave 120, the breakpoint transmission of communication is realized, and the reliability of the system is improved.
Further, the controller 320 is also connected to ground, so as to realize effective transmission of the control signal of the fourth slave pin 124.
In the present invention, the present invention provides a preferred embodiment of the lending apparatus.
A portable power source's lease device which characterized in that: the lending device includes a master-slave communication system, and a portable power source disposed on the slave 120. The master 110 implements normal operation of the slave 120 as a rental device according to intelligent control or remote command control.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the scope of the present invention, but rather as embodying the invention in a wide variety of equivalent variations and modifications within the scope of the appended claims.