CN114285824B - Master-slave equipment addressing method - Google Patents

Master-slave equipment addressing method Download PDF

Info

Publication number
CN114285824B
CN114285824B CN202111650793.8A CN202111650793A CN114285824B CN 114285824 B CN114285824 B CN 114285824B CN 202111650793 A CN202111650793 A CN 202111650793A CN 114285824 B CN114285824 B CN 114285824B
Authority
CN
China
Prior art keywords
command
slave device
slave
master device
master
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111650793.8A
Other languages
Chinese (zh)
Other versions
CN114285824A (en
Inventor
吴炜杰
夏晴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panshi Electric Changzhou Co ltd
Original Assignee
Panshi Electric Changzhou Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Panshi Electric Changzhou Co ltd filed Critical Panshi Electric Changzhou Co ltd
Priority to CN202111650793.8A priority Critical patent/CN114285824B/en
Publication of CN114285824A publication Critical patent/CN114285824A/en
Application granted granted Critical
Publication of CN114285824B publication Critical patent/CN114285824B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a master-slave device addressing method, which comprises the following steps: s1: the master device sends a report serial number command to the network; s2: the uninitialized slave device in the network receives the sequence number reporting command, responds and sends the sequence number of the slave device to the master device; s3: the master device receives the corresponding serial number and then sends an addressing command to the corresponding slave device; the addressing command comprises the serial number of the corresponding slave device and the allocated address; s4: the slave device of the corresponding serial number receives the addressing command containing the corresponding serial number and writes the assigned address. The method can quickly address multiple devices, is convenient to operate, saves time, and is not easy to cause the problems of address repetition, errors and the like.

Description

Master-slave equipment addressing method
Technical Field
The invention relates to a master-slave device addressing method.
Background
Currently, in a multi-device network, such as a multi-sensor and multi-electronic tag environment in an intelligent shelf, one device can only have one address and cannot be repeated, and the existing addressing scheme generally performs independent addressing on single device, which is time-consuming and labor-consuming. When the number is large, the operation is inconvenient, and the address is easy to be confused, so that the problems of address repetition, address errors and the like are solved.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, and provides a master-slave equipment addressing method which can quickly address multiple equipment, is convenient to operate, saves time, and is not easy to cause the problems of address repetition, error and the like.
In order to solve the technical problems, the technical scheme of the invention is as follows: a master-slave device addressing method comprises the following steps:
s1: the master device sends a report serial number command to the network;
s2: the uninitialized slave device in the network receives the sequence number reporting command, responds and sends the sequence number of the slave device to the master device;
s3: the master device receives the corresponding serial number and then sends an addressing command to the corresponding slave device; the addressing command comprises the serial number of the corresponding slave device and the allocated address;
s4: the slave device of the corresponding serial number receives the addressing command containing the corresponding serial number and writes the assigned address.
Further, the method comprises the following steps:
s5: and the slave device writes the allocated address and then sends an addressing completion command to the master device, and the master device sends an initialization command to the corresponding slave device to initialize the corresponding slave device after receiving the corresponding addressing completion command.
Further, in step S2, the initialized slave device in the network ignores the report serial number command after receiving the report serial number command.
Further, in order to avoid the phenomenon that a plurality of slave devices simultaneously respond to the master device after the master device sends out the report serial number command and cause network conflict, in step S2, the slave device which is not initialized in the network receives the report serial number command and responds after waiting for Q seconds and sends the serial number of the slave device to the master device; wherein the latency Q of each slave device is random.
Further, the master device is at P+Q max Receiving a response of the slave device in time; wherein, P is a set value, Q max Is the maximum value of the latency Q of the slave device.
Further, in step S1, the master device periodically sends a report sequence number command to the network at intervals; the master device is divided into a fast state and a slow state according to the time length of interval timing.
Further, the master device and all addressed slave devices in the network complete communication into one round, and when in a fast state, the master device sends a serial number reporting command to the network once every communication M rounds; in a slow state, the master device sends a sequence number reporting command to the network once every N times of communication; wherein N is more than M; m is more than or equal to 1.
Further, for convenience of operation, the fast state and the slow state are adapted to be switched automatically or manually; when the slave device is not allocated with an address and/or the master device receives a serial number reported by the slave device, the master device is switched to a fast state; and when the master equipment does not receive the sequence number reported by the slave equipment within a certain interval time, the master equipment is switched to a slow state.
Further, the master device is adapted to be set to an off state.
Further, in order to reasonably address the slave devices, the master device reorders addresses of the slave devices according to the power-on time of the slave devices after the slave devices are addressed.
Further, when the slave device accesses to the network to power on, the slave device accumulates the power-on time TRealtime of the slave device;
the master device sends a locking power-on time command to the slave device after the slave device is addressed;
after receiving the command for locking the power-on time, the slave device updates the accumulated power-on time TRealtime to be the locked power-on time TLooktime;
and the master device reorders the addresses of the slave devices according to the length of the TLooktime time.
After the technical scheme is adopted, the method can be used for rapidly addressing multiple devices, is convenient to operate, saves time, and is not easy to cause the problems of address repetition, error and the like.
Detailed Description
A master-slave device addressing method comprises the following steps:
s1: the master device sends a report serial number command to the network;
s2: the uninitialized slave device in the network receives the sequence number reporting command, responds and sends the sequence number of the slave device to the master device;
s3: after receiving the corresponding serial number, the master device automatically allocates an address and sends an addressing command to the corresponding slave device; the addressing command comprises the serial number of the corresponding slave device and the allocated address;
s4: the slave device with the corresponding serial number receives the addressing command containing the corresponding serial number and writes the address into the allocated address; specifically, after receiving an addressing command, the slave device writes the assigned address according to the comparison between the serial number in the addressing command and the self serial number;
s5: and the slave device writes the allocated address and then sends an addressing completion command to the master device, and the master device sends an initialization command to the corresponding slave device after receiving the corresponding addressing completion command so as to initialize the corresponding slave device.
In this embodiment, the address range of all the slave devices in the network may be 1-250, and the master device may send a report serial number command to the network by using a special address different from the address of the slave device, which may be set to 251, 252, etc.
Specifically, in step S2, the initialized slave device in the network ignores the report serial number command after receiving the report serial number command.
Specifically, because there may be multiple uninitialized slave devices in the network, the master device may send out a sequence number reporting command, and then the multiple slave devices respond to the master device at the same time, so as to cause a network collision. For example, when two slave devices a and B receive a command from the master device to report a serial number, a responds to the master device and B also responds to the master device. When the network conflicts, the data on the network can be wrong, and the data can be ignored after the master device receives the wrong data packet because the checksum does not pass, so that the influence on the device network can not be caused. However, the master device cannot obtain the serial numbers of a and B because it does not completely receive the response information of a and B. In order to avoid network collision, in step S2, the uninitialized slave device in the network receives the report sequence number command, waits for Q seconds, then responds and sends its own sequence number to the master device; wherein the latency Q of each slave device is random; in this embodiment, Q is a random value of 0-2 seconds;
the master device sends a report serial number command and waits for P+Qmax time, and receives the response of the slave device in the time (note: P is the fixed time of the slave device response+the allowance, so after the P+Qmax time, all the slave devices respond completely, and P is the set value). For example, when both slave devices a and B receive a command from the master device to report a serial number, a responds to the master device at 0.5s and B responds to the master device at 1 s. The master device acquires the SNs of A and B, and can sequentially perform addressing operation, and all slave devices respond in P+Qmax time.
In step S1, a master device periodically transmits a report sequence number command to a network at intervals; the master device is divided into a fast state and a slow state according to the time length of interval timing. Fast state: the master device periodically transmits a report sequence number command at short time intervals. Slow state: the master device periodically transmits a report sequence number command at a longer time interval.
Specifically, the master device and all addressed slave devices in the network complete communication into one round, and when in a fast state, the master device sends a serial number reporting command to the network once every communication M rounds; in a slow state, the master device sends a sequence number reporting command to the network once every N times of communication; wherein N is more than M; m is more than or equal to 1; for example: in a fast state, the master device sends a sequence number reporting command to the network once every communication round; in a slow state, the master device sends a sequence number reporting command to the network once every communication is carried out at least two times; specifically, in the slow state, the master device sends a report sequence number command to the network once every five rounds of communication.
In particular, the fast and slow states are adapted to be switched automatically or manually; when the slave device is not allocated with an address and the master device receives a serial number reported by the slave device, the master device is switched to a fast state; and when the master device does not receive the sequence number reported by the slave device within a certain interval time, the master device is switched to a slow state. And (3) manual switching: the fast state can be switched manually when fast addressing is required, for example when the host device is PC software, the state can be switched through the interface. The master device may also be informed of the switching state by commands, such as network commands, serial commands.
In particular, the master device is further adapted to be set to an off state. Because the network devices are limited, the addressing actions are all completed, no new uninitialized slave devices are added, and the master device does not need to send commands any more. At this point the master device may be turned off and no longer operate. The off state can be manually switched when addressing is not required. And further when the addressing number reaches a certain total number, the master device is automatically switched to the off state.
When there are more slaves in the network, although the slaves access the network in turn to power on, the actual addressing sequence and the sequence of the access network are different due to the reasons of shorter interval time of the access network, network collision, etc., for example, when the A, B and the C slaves receive the command of reporting the serial number by the master, the three slaves respond to the master at the same time, the interval time of the A and the B access networks is shorter, the A and the B respond to collision when the master sends the command of reporting the serial number, then the C responds slowly but responds successfully, because the C responds successfully first, the address of the C is 1, the original address sequence is 123, and the invention is 321. To circumvent this, therefore, a ranking algorithm is employed in the device network. In this embodiment, the master reorders the addresses of the slaves according to the power-up time of the slaves after the slave addressing is completed. The specific process is that when the slave device accesses the network to power on, the slave device accumulates the self power on time TRealtime; the master device sends a locking power-on time command to the slave device after the slave device finishes addressing; after receiving the locking power-on time command, the slave device updates the accumulated power-on time TRealtime to be the locking power-on time TLooktime; the master device reorders the addresses of the slave devices according to the length of the TLooktime time. In this embodiment, the larger the TLooktime time, the higher the priority of addressing. For example, ABC three slaves, A accesses the device network at 0.5s, B accesses the device network at 1s, and C accesses the device network at 1.5 s. At this time, the master device sends a lock power-on time command at 3s, at this time, a TLooktime value is obtained, the lock power-on times TLooktime of the three slave devices A, B, C are respectively 2.5s, 2s and 1.5s, the three slave devices are sorted according to the values, and the larger the values are, the higher the addressing priority is. Further sorting algorithms may also use bubbling sorting, fast sorting, selective sorting, etc.
The technical problems, technical solutions and advantageous effects solved by the present invention have been further described in detail in the above-described embodiments, and it should be understood that the above-described embodiments are only illustrative of the present invention and are not intended to limit the present invention, and any modifications, equivalent substitutions, improvements, etc. within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims (7)

1. A master-slave device addressing method, comprising the steps of:
s1: the master device sends a report serial number command to the network;
s2: the uninitialized slave device in the network receives the sequence number reporting command, responds and sends the sequence number of the slave device to the master device;
s3: the master device receives the corresponding serial number and then sends an addressing command to the corresponding slave device; the addressing command comprises the serial number of the corresponding slave device and the allocated address;
s4: the slave device with the corresponding serial number receives the addressing command containing the corresponding serial number and writes the address into the allocated address; wherein, the liquid crystal display device comprises a liquid crystal display device,
the master device reorders addresses of the slave devices according to the power-on time of the slave devices after the slave devices are addressed;
when the slave device accesses the network to power on, the slave device accumulates the power-on time T of the slave device Realtime
The master device sends a locking power-on time command to the slave device after the slave device is addressed;
the slave device receives the command of locking the power-on time and then accumulates the power-on time T at the moment Realtime Updated to lock up to power-on time T Looktime
The master device is according to T Looktime The addresses of the slave devices are reordered according to the length of time;
in step S2, the uninitialized slave device in the network receives the report sequence number command and responds after waiting for Q seconds and sends its own sequence number to the master device; wherein the latency Q of each slave device is random;
the master device is at P+Q max Receiving a response of the slave device in time; wherein, P is a set value, Q max Is the maximum value of the waiting time Q of the slave device; q is a random value of 0-2 seconds.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the method further comprises the following steps:
s5: and the slave device writes the allocated address and then sends an addressing completion command to the master device, and the master device sends an initialization command to the corresponding slave device to initialize the corresponding slave device after receiving the corresponding addressing completion command.
3. The method of claim 1, wherein the step of determining the position of the substrate comprises,
in step S2, the initialized slave device in the network ignores the report serial number command after receiving the report serial number command.
4. The method of claim 1, wherein the step of determining the position of the substrate comprises,
in step S1, the master device periodically sends a report sequence number command to a network at intervals; the master device is divided into a fast state and a slow state according to the time length of interval timing.
5. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
the master device and all addressed slave devices in the network complete communication into one round, and in a fast state, the master device sends a report sequence number command to the network once every communication M rounds; in a slow state, the master device sends a sequence number reporting command to the network once every N times of communication; wherein N is more than M; m is more than or equal to 1.
6. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
the fast state and the slow state are suitable for automatic switching or manual switching; when the slave device is not allocated with an address and/or the master device receives a serial number reported by the slave device, the master device is switched to a fast state; and when the master equipment does not receive the sequence number reported by the slave equipment within a certain interval time, the master equipment is switched to a slow state.
7. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
the master device is further adapted to be set to an off state.
CN202111650793.8A 2021-12-31 2021-12-31 Master-slave equipment addressing method Active CN114285824B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111650793.8A CN114285824B (en) 2021-12-31 2021-12-31 Master-slave equipment addressing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111650793.8A CN114285824B (en) 2021-12-31 2021-12-31 Master-slave equipment addressing method

Publications (2)

Publication Number Publication Date
CN114285824A CN114285824A (en) 2022-04-05
CN114285824B true CN114285824B (en) 2023-04-25

Family

ID=80878609

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111650793.8A Active CN114285824B (en) 2021-12-31 2021-12-31 Master-slave equipment addressing method

Country Status (1)

Country Link
CN (1) CN114285824B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105099562A (en) * 2015-07-15 2015-11-25 武汉虹信通信技术有限责任公司 Method and system for master device to automatically number slave devices
CN108737590A (en) * 2018-05-15 2018-11-02 浙江正泰电器股份有限公司 A kind of method that address is distributed automatically, system, Modbus main websites, Modbus slave stations

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103826252B (en) * 2014-01-16 2017-05-10 京信通信系统(中国)有限公司 Method of acquiring and sending sequence numbers among main and slave devices and system
CN110505319A (en) * 2019-08-07 2019-11-26 金陵科技学院 A kind of RS485 is from device address auto-allocation method and system
CN110830338A (en) * 2019-11-13 2020-02-21 广东美的暖通设备有限公司 Method and device for managing equipment addresses of multiple systems, air conditioner and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105099562A (en) * 2015-07-15 2015-11-25 武汉虹信通信技术有限责任公司 Method and system for master device to automatically number slave devices
CN108737590A (en) * 2018-05-15 2018-11-02 浙江正泰电器股份有限公司 A kind of method that address is distributed automatically, system, Modbus main websites, Modbus slave stations

Also Published As

Publication number Publication date
CN114285824A (en) 2022-04-05

Similar Documents

Publication Publication Date Title
CN101582824B (en) Node number automatic distribution method for controlling secondary node equipment of local area network bus
US20140173013A1 (en) Method for setting addresses of slave devices in communication network
US7433356B2 (en) Methods and apparatus for creating addresses
WO2020125524A1 (en) Distributed optical fiber access system and management method therefor
US11310196B2 (en) Manufacturing line computer system and network setup method of the same
US8725863B2 (en) Method for obtaining external IP address and its network protocol system
CN101951345A (en) Message transmitting method and equipment
CN113395198B (en) Networking method and device of equipment and data transmission system
EP3422655B1 (en) Method for managing address of meter device, and acquisition terminal and meter device
CN112953774A (en) Network topology generation method, system, equipment and computer storage medium
CN114285824B (en) Master-slave equipment addressing method
CN108491337B (en) Method for realizing group control
US7400615B2 (en) System and method for deterministic registration for communication networks
CN113055501B (en) Method and device for configuring IP addresses in series through internet access
JP4527650B2 (en) Physical wiring control device, physical wiring control method, and physical wiring control program
US7583690B2 (en) Allocation of station addresses to communication users in a bus system
US7783812B2 (en) Extended serial bus architecture and method
CN112565039B (en) Communication network architecture
CN104202443A (en) Method and device for disaster tolerance treatment of IP address conflict and corresponding equipment
US9893900B2 (en) Intelligent illumination system, network apparatus and operating method thereof
CN111400215A (en) Bus address distribution and communication method based on cascade father node gating
US11575539B2 (en) Identification number numbering method and multipoint communication system
KR20080110216A (en) Simultaneous distributed control and independent control system
CN103188352B (en) Obtain method and the procotol system thereof of far-end network address
CN109683960B (en) Register configuration method of electric port module and electric port module thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant